【正文】
程中,編寫主程序的時(shí)候,也遇到調(diào)試不成功的問題,主要問題如下:①在編寫xianshi模塊時(shí),最后給輸出信號(hào)賦值時(shí),使用了進(jìn)程語句,但是由于敏感列表不全,導(dǎo)致在仿真時(shí)其輸出信號(hào)的值產(chǎn)生錯(cuò)誤。解決措施就是通過逐個(gè)查看內(nèi)部信號(hào),由于敏感列表不全,致使有些時(shí)刻,最后賦值的進(jìn)程語句沒有啟動(dòng),從而造成輸出結(jié)果不全。②在實(shí)現(xiàn)綠燈剩余時(shí)間小于三秒時(shí)開始閃爍功能時(shí),遇到問題。具體表現(xiàn)在yima模塊中。開始為了在綠燈狀態(tài),使綠燈在高、地電平間變換,所以就嘗試使用時(shí)鐘信號(hào)clk的上升沿和下降沿,其中上升沿時(shí),綠燈高電平即亮,下降沿時(shí)綠燈熄滅。雖然這種方案在modelsim中仿真成功,但是在quartus進(jìn)行綜合出現(xiàn)錯(cuò)誤,該綜合軟件綜合不出此寄存器。經(jīng)過多次試驗(yàn),使用了clk高低電平觸發(fā),不再使用其上升下降沿。③在整個(gè)程序中有時(shí)在使用IF語句時(shí),會(huì)因?yàn)榭紤]不完整造成實(shí)驗(yàn)結(jié)果出錯(cuò)。因?yàn)樵贗F語句中如果過沒有ELSE語句,那么輸出將默認(rèn)保持前一個(gè)狀態(tài),這樣很容易產(chǎn)生錯(cuò)誤??傊?jīng)過查閱各種資料,成功的把程序調(diào)試了出來。在查閱試驗(yàn)箱說明書的情況下,完成了引腳的選定,并把程序下載到了試驗(yàn)箱里面,完成了實(shí)物的演示。參考文獻(xiàn)[1]:.[2]潘松,(第二版).北京:.[3]:. [4]徐志軍,: .[5]楊旭,:.七、附錄附錄一:本系統(tǒng)采用用硬件描述語言VHDL描述。分為五個(gè)模塊,分別為控制模塊、計(jì)時(shí)模塊、顯示模塊、譯碼模塊和分頻模塊,下面針對(duì)每個(gè)模塊給出相應(yīng)的程序:模塊一:/*************************控制部分**********************//***********定義輸入輸出端口***********/library ieee。use 。use 。entity kongzhi is 實(shí)體部分; port ( clk,clr : in std_logic。 at,bt : in std_logic_vector(7 downto 0)。 s : out std_logic_vector(2 downto 0) )。end kongzhi。architecture rtl of kongzhi is 結(jié)構(gòu)體部分;signal q :std_logic_vector(2 downto 0)。begin main logicprocess (clk,clr,at,bt)beginif clr=39。139。 then q=011。 系統(tǒng)復(fù)位后,系統(tǒng)的狀態(tài)是A干道綠燈; B干道紅燈; elsif (clk39。event and clk =39。139。) then if (at=x01) or (bt=x01) then 倒計(jì)時(shí)結(jié)束時(shí),狀態(tài)發(fā)生改變;q=q+1。 else q=q。 end if。 end if。end process。s = q。end rtl。模塊二:/*************************計(jì)時(shí)部分**********************//***********為A,B方向設(shè)置初值 ***********/library ieee。use 。use 。entity jishi is 實(shí)體部分 port ( clk, clr : in std_logic。 s :in std_logic_vector(2 downto 0)。 at,bt :out std_logic_vector(7 downto 0) )。end jishi。architecture rtl of jishi is 結(jié)構(gòu)體signal ati,bti :std_logic_vector(7 downto 0)。中間信號(hào)signal art,agt,alt,abyt:std_logic_vector(7 downto 0)。signal brt,bgt,blt:std_logic_vector(7 downto 0)。begin main logic 每個(gè)狀態(tài)的總時(shí)間分別賦給相應(yīng)的信號(hào)。art=x33。 A方向直行紅燈總時(shí)間為33s;agt=x20。 A方向直行綠燈總時(shí)間為20s;alt=x10。 A方向左拐綠燈總時(shí)間為4s;abyt=x04。 黃燈總時(shí)間為4s;brt=x38。 B方向直行紅燈總時(shí)間為38s;bgt=x15。 B方向直行綠燈總時(shí)間為15s;blt=x04。 B方向左拐綠燈總時(shí)間為4s;process (clk,clr,s) begin if clr=39。139。 then ati=x33。bti=x24。系統(tǒng)復(fù)位后A方向直行綠燈剩余時(shí)間為33s,B方向直行紅燈剩余時(shí)間為24s; elsif (clk39。event and clk =39。139。) then if(ati=x01) or (bti=x01) then case s is 在每個(gè)狀態(tài),賦給相應(yīng)初始時(shí)間; when 000=ati=alt。bti=brt。 when 001=ati=abyt。 when 010=ati=agt。 when 011=ati=abyt。 when 100=ati=art。bti=blt。 when 101=bti=abyt。 when 110=bti=bgt。 when 111=bti=abyt。 when others=ati=