【正文】
28分頻輸入信號(hào) clk_in2:in std_logic。 15分頻輸入信號(hào) clk_out:out std_logic)。 輸出信號(hào)end kongzhi。architecture rt4 of kongzhi isbeginprocess(ent0,ent1)begin if ent0=39。139。 then 實(shí)現(xiàn)二選一功能 clk_out=clk_in1。 elsif ent1=39。139。 then clk_out=clk_in2。 end if。 end process。end rt4。附錄六:計(jì)費(fèi)模塊VHDL語言程序:library ieee。use 。use 。use 。entity jifei isport(clk2:in std_logic。 計(jì)費(fèi)驅(qū)動(dòng)信號(hào) start: in std_logic。 計(jì)費(fèi)開始信號(hào) c0,c1,c2,c3: buffer std_logic_vector(3 downto 0))。end jifei。architecture rt3 of jifei isbeginprocess(clk2,start)begin if start=39。039。 then c3=0000。c2=0000。c1=1000。c0=0000。 起步價(jià)8元 elsif clk239。event and clk2=39。139。 then if c0=1001 then c0=0000。 if c1=1001 then c1=0000。 if c2=1001 then c2=0000。 if c3=1001 then c3=0000。 計(jì)價(jià)范圍0~ else c3=c3+1。 end if。 else c2=c2+1。 end if。 else c1=c1+1。 end if。 else c0=c0+1。 end if。 end if。end process。end rt3。附錄七:模8計(jì)數(shù)器VHDL語言程序:library ieee。use 。use 。entity tm8 isport( nreset:in std_logic。 clk: in std_logic。 qout: buffer std_logic_vector(3 downto 0) )。 end tm8。 architecture behave of tm8 is begin process(clk,nreset) begin if(nreset=39。039。) then qout=0000 。 elsif(clk39。event and clk=39。139。) then if(qout=7) then qout=0000。 else qout=qout+1。 end if。 end if。 end process。 end behave。附錄八:片選模塊VHDL語言程序: 【用模8控制片選,如果不放模8 直接放占內(nèi)純,仿真時(shí)間比較長】library ieee。use 。use 。use 。entity pianxuan is port( qo:in std_logic_vector(3 downto 0)。 t0,t1,mile0,mile1,fei0,fei1,fei2,fei3:in std_logic_vector(3 downto 0)。 seg:buffer std_logic_vector(3 downto 0) )。end pianxuan。architecture behave of pianxuan is begin process(qo) begin case qo is when 0000 = seg=fei0。 when 0001 = seg=fei1。 when 0010 = seg=fei2。 when 0011 = seg=fei3。 when 0100 = seg=t0。 when 0101 = seg=t1。 when 0110 = seg=mile0。 when others = seg=mile1。 end case。 end process。end behave。附錄九:數(shù)碼顯示VHDL語言程序:library ieee。use 。use 。entity decode isport(qt:in std_logic_vector(3 downto 0)。 adr:in std_logic_vector(3 downto 0)。 seg:out std_logic_vector(6 downto 0)。 scan:out std_logic_vector(7 downto 0) )。 end decode。 architecture behave of decode is begin process(qt,adr) begin case qt is when 0000 = scan=01111111。 when 0001 = scan=10111111。 when 0010 = scan=11011111。 when 0011 = scan=11101111。 when 0100 = scan=11110111。 when 0101 = scan=11111011。 when 0110 = scan=11111101。 when others = scan=11111110。 end case。 case adr is when 0000 = seg=1111110。 when 0001 = seg=0110000。 when 0010 = seg=1101101。 when 0011 = seg=1111001。 when 0100 = seg=0110011。 when 0101 = seg=1011011。 when 0110 = seg=1011111。 when 0111 = seg=1110000。 when 1000 = seg=1111111。 when others = seg=1111011。 end case。 end process。 end behave。附錄十:測試寫入固定值模塊VHDL語言程序:【測試寫入固定值模塊VHDL語言程序:測試各個(gè)硬件片子能不能正常顯示】library ieee。use 。use 。use 。entity fuzhi is port( t0,t1,mile0,mile1,fei0,fei1,fei2,fei3:buffer std_logic_vector(3 downto 0) )。end fuzhi。architecture behave of fuzhi is begin t0=0001。 t1=0000。 mile0=0011。 mile1=0010。 fei0=0111。 fei1=0110。 fei2=0101。 fei3=0100。 end behave。