【正文】
示超時并報警。其中有搶答時鐘信號 clk2;系統(tǒng)復位信號 rst;搶答使能信號 s;搶答狀態(tài)顯示信號 states;無人搶答警報信號 warn;計時中止信號 stop;計時十位 和 個位信號 tb, ta。 數(shù)據(jù)選擇模塊: 在這個模塊中主要實現(xiàn)搶答過程中的數(shù)據(jù)輸入功能, 輸入信號 a[3..0]、 b[3..0]、c[3..0];計數(shù)輸出信號 s;數(shù)據(jù)輸出信號 y; 計數(shù)脈沖 clk2,實現(xiàn) a、 b、 c 按脈沖輪流選通,在數(shù)碼管上顯示。 報警模塊: 在這個模塊中主要實現(xiàn)搶答過程中的報警功能,當主持人按下 控制鍵 ,有限時間 5 內(nèi) 人搶答或是計數(shù)到時蜂鳴器開始報警,有效電平輸入信號 i;狀態(tài)輸出信號 q;計數(shù)脈沖 clk2。 譯碼模塊: 在這個模塊中主要實現(xiàn)搶答過程中將 BCD 碼轉(zhuǎn)換成 7 段的 功能 。 分頻模塊: 在這個模塊中主要實現(xiàn)搶答過程中實現(xiàn)輸出雙脈沖的功能。 頂層文件: 在這個模塊中是對前七 個模塊的綜合編寫的頂層文件。 三、 單元電路設計 (一)搶答鑒別模塊 VHDL 源程序 library ieee。搶答鑒別模塊 use 。 use 。 entity qdjb is port(rst,clk2:in std_logic。 s0,s1,s2,s3:in std_logic。 states:buffer std_logic_vector(3 downto 0)。 tmp:out std_logic)。 end qdjb。 architecture one of qdjb is signal st:std_logic_vector(3 downto 0)。 begin p1:process(s0,rst,s1,s2,s3,clk2) begin if rst=39。039。 then tmp=39。039。st=0000。 elsif clk239。event and clk2=39。139。 then if (s0=39。139。 or st(0)=39。139。)and not( st(1)=39。139。 or st(2)=39。139。 or st(3)=39。139。 ) 6 then st(0)=39。139。 end if 。 if (s1=39。139。 or st(1)=39。139。)and not( st(0)=39。139。 or st(2)=39。139。 or st(3)=39。139。 ) then st(1)=39。139。 end if 。 if (s2=39。139。 or st(2)=39。139。)and not( st(0)=39。139。 or st(1)=39。139。 or st(3)=39。139。 ) then st(2)=39。139。 end if 。 if (s3=39。139。 or st(3)=39。139。)and not( st(0)=39。139。 or st(1)=39。139。 or st(2)=39。139。 ) then st(3)=39。139。 end if 。 tmp=s0 or s1 or s2 or s3。 end if 。 end process p1。 p2:process(states(0),states(1),states(2),states(3)) begin if (st=0000) then states=0000。 elsif (st=0001) then states=0001。 elsif (st=0010) then states=0010。 elsif (st=0100) then states=0011。 elsif (st=1000) then states=0100。 end if。 end process p2。 end one。 仿真圖 : 7 (二)計時模塊 VHDL 源程序 library ieee。 use 。 use 。 entity js is port(clk,rst,s,stop:in std_logic。 warn:out std_logic。 ta,tb:buffer std_logic_vector(3 downto 0))。 end js。 architecture one of js is signal co:std_logic。 begin p1:process(clk,rst,s,stop,ta) begin if rst=39。039。 or stop=39。139。 then ta=0000。