FEN1000libraryieee;useieee.std_logic_1164.all;useieee.std_logic_arith.all;useieee.std_logic_unsigned.all;entityfen1000isport(clk:instd_logic;q:outstd_logic);endfen1000;architectureaoffen1000issignalfm:std_logic;beginprocess(clk)variablenum:integerrange0to1000;beginifclk'eventandclk='1'thenifnum500thennum:=num+1;elsenum:=1;fm=notfm;endif;endif;q=fm;endprocess;enda;CNT60LIBRARYIEEE;USEIEEE.STD_LOGIC_1164.ALL;USEIEEE.STD_LOGIC_UNSIGNED.ALL;ENTITYCNT60ISPORT(RST,EN,CLK:INSTD_LOGIC;QB1,QA1:OUTSTD_LOGIC_VECTOR(3DOWNTO0));END;ARCHITECTUREBEHAVOFCNT60ISBEGINPROCESS(CLK)VARIABLEQA:STD_LOGIC_VECTOR(3DOWNTO0):=1001;VARIABLEQB:STD_LOGIC_VECTOR(3DOWNTO0):=0101;BEGINIFRST='1'THENQA:=0000;QB:=0000;ELSIFCLK'EVENTANDCLK='1'THENIFEN='1'THENIF(QA=0ANDQB/=0)THENQA:=1001;QB:=QB-1;ELSIFQA0THENQA:=QA-1;QB:=QB;ELSIF(QB=0ANDQA=0)THENQA:=1001;QB:=0101;ENDIF;ENDIF;ENDIF;QB1=QB;QA1=QA;ENDPROCESS;END;CNT3LIBRARYIEEE;USEIEEE.STD_LOGIC_1164.ALL;USEIEEE.STD_LOGIC_UNSIGNED.ALL;ENTITYCNT3ISPORT(RST,EN,CLK:INSTD_LOGIC;Q1:OUTSTD_LOGIC_VECTOR(3DOWNTO0));END;ARCHITECTUREBEHAVOFCNT3ISBEGINPROCESS(CLK)VARIABLEQ:STD_LOGIC_VECTOR(3DOWNTO0):=0010;BEGINIFRST='1'THENQ:=0000;ELSIFCLK'EVENTANDCLK='1'THENIFEN='1'THENIF(Q=0)THENQ:=0010;ELSIFQ0THENQ:=Q-1;ENDIF;ENDIF;ENDIF;Q1=Q;ENDPROCESS;END;CNT48LIBRARYIEEE;USEIEEE.STD_LOGIC_1164.ALL;USEIEEE.STD_LOGIC_UNSIGNED.ALL;ENTITYCNT48ISPORT(RST,EN,CLK:INSTD_LOGIC;QB1,QA1:OUTSTD_LOGIC_VECTOR(3DOWNTO0));END;ARCHITECTUREBEHAVOFCNT48ISBEGINPROCESS(CLK)VARIABLEQA:STD_LOGIC_VECTOR(3DOWNTO0):=0111;VARIABLEQB:STD_LOGIC_VECTOR(3DOWNTO0):=0100;BEGINIFRST='1'THENQA:=0000;QB:=0000;ELSIFCLK'EVENTANDCLK='1'THENIFEN='1'THENIF(QA=0ANDQB/=0)THENQA:=1001;QB:=QB-1;ELSIFQA0THENQA:=QA-1;QB:=QB;ELSIF(QB=0ANDQA=0)THENQA:=0111;QB:=0100;ENDIF;ENDIF;ENDIF;QB1=QB;QA1=QA;ENDPROCESS;END;CNT63LIBRARYIEEE;USEIEEE.STD_LOGIC_1164.ALL;USEIEEE.STD_LOGIC_UNSIGNED.ALL;ENTITYCNT63ISPORT(RST,EN,CLK:INSTD_LOGIC;QB1,QA1:OUTSTD_LOGIC_VECTOR(3DOWNTO0));END;ARCHITECTUREBEHAVOFCNT63ISBEGINPROCESS(CLK)VARIABLEQA:STD_LOGIC_VECTOR(3DOWNTO0):=0010;VARIABLEQB:STD_LOGIC_VECTOR(3DOWNTO0):=0110;BEGINIFRST='1'THENQA:=0000;QB:=0000;ELSIFCLK'EVENTANDCLK='1'THENIFEN='1'THENIF(QA=0ANDQB/=0)THENQA:=1001;QB:=QB-1;ELSIFQA0THENQA:=QA-1;QB:=QB;ELSIF(QB=0ANDQA=0)THENQA:=0010;QB:=0110;ENDIF;ENDIF;ENDIF;QB1=QB;QA1=QA;ENDPROCESS;END;CNT45LIBRARYIEEE;USEIEEE.STD_LOGIC_1164.ALL;USEIEEE.STD_LOGIC_UNSIGNED.ALL;ENTITYCNT45ISPORT(RST,EN,CLK:INSTD_LOGIC;QB1,QA1:OUTSTD_LOGIC_VECTOR(3DOWNTO0));END;ARCHITECTUREBEHAVOFCNT45ISBEGINPROCESS(CLK)VARIABLEQA:STD_LOGIC_VECTOR(3DOWNTO0):=0100;VARIABLEQB:STD_LOGIC_VECTOR(3DOWNTO0):=0100;BEGINIFRST='1'THENQA:=0000;QB:=0000;ELSIFCLK'EVENTANDCLK='1'THENIFEN='1'THENIF(QA=0ANDQB/=0)THENQA:=1001;QB:=QB-1;ELSIFQA0THENQA:=QA-1;QB:=QB;ELSIF(QB=0ANDQA=0)THENQA:=0100;QB:=0100;ENDIF;ENDIF;ENDIF;QB1=QB;QA1=QA;ENDPROCESS;END;CNT6libraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;useieee.std_logic_arith.all;entitycnt6isport(clk:instd_logic;q:outstd_logic_vector(2downto0));endcnt6;architecturertlofcnt6issignalcnt:std_logic_vector(2downto0);beginprocess(clk)beginif(clk'eventandclk='1')thenifcnt=101thencnt=000;elsecnt=cnt+1;endif;endif;endprocess;q=cnt;endrtl;主干道libraryieee;useieee.std_logic_1164.all;useieee.std_logic_arith.all;useieee.std_logic_unsigned.all;entitytralightmisport(rst,clk:instd_logic;mgl,mgh,myl,mrl,mrh:instd_logic_vector(3downto0);mg,my,mr:outstd_logic;mh,ml:outstd_logic_vector(3downto0);pout:outstd_logic_vector(6downto1));endtralightm;architecturebhvoftralightmistypestis(green,yellow,red,em);signalstate:st;signaler,eg,ey,wr,wg,wy:std_logic;signaley1,wy1:std_logic;beginprocess(clk)beginifrst='1'thenstate=em;mh=0000;ml=0000;er='1';eg='0';ey='0';wr='1';wg='0';wy='0';elsifclk'eventandclk='1'thencasestateiswhengreen=mg='1';my='0';mr='0';ml=mgl;mh=mgh;er='0';eg='1';ey='0';wr='0';wg='1';wy='0';ifmgl=1andmgh=0thenstate=yellow;endif;whenyellow=mg='0';my='1';mr='0';ml=myl;mh=0000;er='0';eg='0';ey='1';wr='0';wg='0';wy='1';ifmyl=1thenstate=red;endif;whenred=mg='0';my='0';mr='1';ml=mrl;mh=mrh;er='1';eg='0';ey='0';wr='1';wg='0';wy='0';ifmrl=1andmrh=0thenstate=green;endif;whenem=mg='0';my='0';mr='0';mh=0000;ml=0000;ifrst='0'thenstate=green;endif;endcase;endif;endprocess;ey1=eyandclk;wy1=wyandclk;pout=wy1&wg&wr&ey1&eg&er;endbhv;次干道libraryieee;useieee.std_logic_1164.all;useieee.std_logic_arith.all;useieee.std_logic_unsigned.all;entitytralightbisport(rst,clk:instd_logic;bgl,bgh,byl,brl,brh:instd_logic_vector(3downto0);bg,by,br:outstd_logic;bh,bl:outstd_logic_vector(3downto0);pout:outstd_logic_vector(6downto1));endtralightb;architecturebhvoftralightbistypestis(red,green,yellow,em);signalstate:st;signalsr,sg,sy,nr,ng,ny:std_logic;signalsy1,ny1:std_logic;beginprocess(clk)beginifrst='1'thenstate=em;bh=0000;bl=0000;sr='1';sg='0';sy='0';nr='1';ng='0';ny='0';elsifclk'eventandclk='1'thencasestateiswhenred=bg='0';by='0';br='1';bl=brl;bh=brh;sr='1';sg='0';sy='0';n