【正文】
l,sub_gh,sub_gl,sub_lh,sub_ll, chief_rh,chief_rl,sub_rh,sub_rl, counter_play1h,counter_play1l,counter_play2h,counter_play2l )。input[3:0]sub_gh,sub_gl,sub_lh,sub_ll。output flash,select,g_l。reg Initial。reg[3:0]sub_ghtemp,sub_gltemp,sub_lhtemp,sub_lltemp。 chief_gltemp=chief_gl。 sub_rhtemp=sub_rh。 sub_lltemp=sub_ll。 end else if(Initial==1) begin if(select==1)//主干道紅燈 begin counter_play1h=chief_rhtemp。(chief_rhtemp=1)) begin chief_rhtemp=chief_rhtemp1。(chief_rltemp=9)) begin chief_rltemp=chief_rltemp1。 chief_rltemp=chief_rl。amp。amp。(sub_rltemp==0)) begin sub_rhtemp=sub_rh。g_l==0)//主干道綠燈 begin counter_play1h=chief_ghtemp。(chief_ghtemp=1)) begin chief_ghtemp=chief_ghtemp1。(chief_gltemp=9)) begin if((chief_ghtemp==0)amp。 end else chief_gltemp=chief_gltemp1。 g_l=1。 end end if(select==0amp。 if((chief_lltemp==0)amp。 end if((chief_lltemp=1)amp。(chief_lltemp==5)) begin flash=1。amp。 chief_lhtemp=chief_lh。g_l==0)//支干道綠燈 begin counter_play2h=sub_ghtemp。(sub_ghtemp=1)) begin sub_ghtemp=sub_ghtemp1。(sub_gltemp=9)) begin if((sub_ghtemp==0)amp。 end else sub_gltemp=sub_gltemp1。 g_l=1。 end end if(select==1amp。 if((sub_lltemp==0)amp。 end if((sub_lltemp=1)amp。(sub_lltemp==5)) begin flash=1。amp。 sub_lltemp=sub_ll。 chief_rhtemp=0。 sub_lhtemp=0。 sub_rhtemp=0。output[3:0]OutH,OutL。b1010)beginoutl1=In1L+1439。endelsebeginoutl1=In1L+1。b1010。OutH=outh1+In2H。((outh1+In2H)==439。OutH=439。output[3:0]OutH,OutL。b1010)beginoutl1=In1L+1439。endelsebeginoutl1=In1L+1。b1010。OutH=outh1+In2H。((outh1+In2H)==439。OutH=439。output chief_green,chief_left,chief_red,sub_green,sub_left,sub_red。clk))。clk))。(~(flashamp。(~(flashamp。input [31:0] iDIG。always(posedge iCLK or negedge iRST_N)begin if(!iRST_N) rDIG = 0。SEG7_LUT u2 ( oSEG2,rDIG[11:8] )。SEG7_LUT u6 ( oSEG6,rDIG[27:24] )。output clk1。counter=0。endelsecounter=counter+139。endendmodule輾轉(zhuǎn)異地一衫淚,曾記當(dāng)年一傘輕。d25000000)beginclk1=~clk1。reg [24:0] counter。Endmodulemodule freq_div(clk,clk1)。SEG7_LUT u4 ( oSEG4,rDIG[19:16] )。 endendSEG7_LUT u0 ( oSEG0,rDIG[3:0] )。output [6:0] oSEG0,oSEG1,oSEG2,oSEG3,oSEG4,oSEG5,oSEG6,oSEG7。assign sub_red=~select。assign sub_left=selectamp。assign sub_green=selectamp。g_lamp。~g_lamp。endendendmodulemodule view(clk,flash,select,g_l, chief_green,chief_left,chief_red,sub_green,sub_left,sub_red )。b1001)))beginOutL=439。b1010)amp。b1。endif((outl1+In2L)=439。outh1=In1H+139。reg[3:0]outh1,outl1。endendendmodulemodule plus4(OutH,OutL,In1H,In1L,In2H,In2L)。b1001)))beginOutL=439。b1010)amp。b1。endif((outl1+In2L)=439。outh1=In1H+139。reg[3:0]outh1,outl1。 endend//always結(jié)束endmodulemodule plus2(OutH,OutL,In1H,In1L,In2H,In2L)。 sub_ghtemp=0。 chief_lhtemp=0。 end end end//initial=1結(jié)束 end //start=1結(jié)束 else if(start==0)//開(kāi)始信號(hào)無(wú)效時(shí),計(jì)數(shù)中間變量清零 begin chief_ghtemp=0。 g_l=0。 end else sub_lltemp=sub_lltemp1。(sub_lltemp=9)) begin if((sub_lhtemp==0)amp。(sub_lhtemp=1)) begin sub_lhtemp=sub_lhtemp1。g_l==1)//支干道左轉(zhuǎn)燈 begin counter_play2h=sub_lhtemp。 sub_ghtemp=sub_gh。amp。(sub_gltemp==5)) begin flash=1。 end if((sub_gltemp=1)amp。 if((sub_gltemp==0)amp。 end end if(select==1amp。 g_l=0。 end else