【正文】
eee。 warn:buffer std_logic。beginp1:process(clk,rst,en,stop,ta) 個位計時信號進(jìn)行0到9循環(huán)計數(shù) begin if rst=39。 then ta=0000。 then co=39。 then if ta=0000 then ta=1001。 end if。p2:process(co,rst,en,stop,tb) 十位計時信號0到3變化 begin if rst=39。 then tb=0011。 then if en=39。 end if。p3:process(rst,ta,tb) 計時時間到達(dá),報警 begin if rst=39。 elsif ta=0000 and tb=0000 then warn=39。 end if。 use 。 a_out,b_out,c_out,d_out:buffer std_logic_vector(3 downto 0))。) then a_out=0101。 初始化置5分 elsif en=39。139。 else a_out=a_out+1。 then add信號為0,減1分 if a_out=0000 then a_out=0000。 when 0010= if add=39。 end if。 else b_out=b_out1。139。 elsif add=39。 end if。 then if d_out=1111 then d_out=0000。039。 end if。d_out=d_out。end process p1。use 。 states:buffer std_logic_vector(3 downto 0)。architecture bhv of qiangda isponent qdjb is port(clk2,en,rst:in std_logic。end ponent。end ponent。end ponent。ponent divf is port(clk: IN STD_LOGIC。signal t:std_logic_vector(3 downto 0)。u2:js port map(clk,rst,en,stop,alarm,ta,tb)。end bhv。 數(shù)據(jù)輸入 q : OUT STD_LOGIC_VECTOR(0 TO 6) )。 when 0010 = q=1101101。 when 0110 = q=1011111。 when others = q=0000000。一千分頻器模塊程序:LIBRARY IEEE。 q : OUT STD_LOGIC。 signal qn1:std_logic_vector(9 downto 0)。 elsif clk39。 end if。 when qn1=1000 else 39。 分頻輸出,1000分頻END behav。 計時模塊:仿真結(jié)果:本模塊主要實現(xiàn)計時功能。圖示,開始后a臺連續(xù)搶答5題,且都答對,a_out變成10了,之后c臺連續(xù)搶答成功,且都答對加分,最高記到了15分?jǐn)?shù)碼管顯示位F,此時獲勝并把分?jǐn)?shù)重新置為0。另外還可以取其中的其他位,實現(xiàn)其他分頻。四、 心得體會這次實驗,首先最難的就是模塊的劃分,必須先有一個總體的規(guī)劃,然后細(xì)化去寫每個模塊的程序,我在寫程序的過程中,參考了課程使用的課件,參考了網(wǎng)上資料,覺得vhdl程序結(jié)構(gòu)特別嚴(yán)密,并且quartus ii軟件能為我找出程序語法上的低級失誤,低級錯誤,使我對于vhdl語法規(guī)則有了更加深刻