【正文】
號,并且能實 現(xiàn)當(dāng)有一路搶答按鍵按下時,該路搶答信號將其余個綠搶答封鎖的功能。 數(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ù)碼管上顯示。 頂層文件: 在這個模塊中是對前七 個模塊的綜合編寫的頂層文件。整個系統(tǒng)的大致組成框圖如圖 所示。搶答鑒別模塊 use 。 states:buffer std_logic_vector(3 downto 0)。 begin p1:process(s0,rst,s1,s2,s3,clk2) begin if rst=39。st=0000。 then if (s0=39。)and not( st(1)=39。 or st(3)=39。 end if 。139。139。139。 or st(2)=39。 or st(1)=39。 ) then st(2)=39。139。139。139。 tmp=s0 or s1 or s2 or s3。 elsif (st=0001) then states=0001。 end if。其中有四個搶答信號 s0、 s s s3;搶答使能信號s;搶答狀態(tài)顯示信號 states;搶答與警報時鐘信號 clk2;系統(tǒng)復(fù)位信號 rst;警報信號 tmp。 entity js is port(clk,rst,s,stop:in std_logic。 architecture one of js is signal co:std_logic。139。139。139。 else ta=ta1。 end process p1。139。139。 else tb=tb1。 end process p2。 (三)數(shù)據(jù)選擇模塊 VHDL 源程序 library ieee。 entity sjxz is port (a,b,c: in std_logic_vector(3 downto 0)。 end sjxz。039。139。 end if。 when others=null。 仿真圖 11 數(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ù)碼管上顯示。 ENTITY ALARM IS PORT(CLK,I:IN STD_LOGIC。 SIGNAL N:INTEGER RANGE 0 TO 20。139。039。 N=N+1。 END IF。 (五)譯碼模塊 VHDL 源程序 LIBRARY IEEE。 DOUT7: OUT STD_LOGIC_VECTOR(6 DOWNTO 0))。 1 WHEN 0010=DOUT7=1101101。 5 14 WHEN 0110=DOUT7=1011111。 9 WHEN OTHERS=DOUT7=0000000。 仿真圖 譯碼模塊圖 在這個模塊中主要實現(xiàn)搶答過程中將 BCD 碼轉(zhuǎn)換成 7 段的功能。 USE 。 ARCHITECTURE rtl OF clkdiv IS SIGNAL count : STD_LOGIC_VECTOR(3 DOWNTO 0)。) THEN IF(count=1111) THEN Count =0000。 END PROCESS。) THEN IF(count=1111) THEN clk16 = 39。 END IF 。 仿真圖 分頻模塊圖 在這個模塊中主要實現(xiàn)搶答過程中實現(xiàn)輸出雙脈沖的功能。 use 。 a,b,c,d,e,f,g:out std_logic)。 17 tmp:out std_logic。 warn:out std_logic。 s:out std_logic_vector(1 downto 0)。 ponent ymq is port(ain4: in std_logic_vector (3 downto 0)。 q:out std_logic)。 signal w:std_logic。d=ledout(3)。 u1:qdjb port map(clk2,rst,s0,s1,s2,s3,tmp=k,states=states_out)。 u5:alarm port map(clk2,s,q_out)。 四 、性能測試與分析 按下 rst 鍵清零,按下 s 鍵,觀察數(shù)碼管是否開始倒計時,揚(yáng)聲器是否發(fā)出報警聲,按下 s0,觀察數(shù)碼管是否顯示 1 和搶答的時間,再按 s1, 均不改變顯示,按下 rst 鍵,觀察是否清零,再按 s 鍵,不按別的,直到計時時間到,觀察是否顯示 00,揚(yáng)聲器是否發(fā)出