【文章內(nèi)容簡(jiǎn)介】
wnto 4) is when 0000 =dout1=1111110。 when 0001 =dout1=0110000。 when 0010 =dout1=1101101。 when 0011 =dout1=1111001。 when 0100 =dout1=0110011。 when 0101 =dout1=1011011。 when 0110 =dout1=1011111。 when 0111 =dout1=1110000。 when 1000 =dout1=1111111。 when 1001 =dout1=1111011。 when others =dout1=0000000。 end case。 case din(3 downto 0) is when 0000 =dout0=1111110。 when 0001 =dout0=0110000。 when 0010 =dout0=1101101。 when 0011 =dout0=1111001。 when 0100 =dout0=0110011。 when 0101 =dout0=1011011。 when 0110 =dout0=1011111。 when 0111 =dout0=1110000。 when 1000 =dout0=1111111。 when 1001 =dout0=1111011。 when others =dout0=0000000。 end case。 end process。 end one。 : 控制模塊: 控制模塊的框圖: 控制模塊用于 對(duì)數(shù)碼管里程、時(shí)間、費(fèi)用顯示的選擇,起到位選的作用,實(shí)現(xiàn)了 數(shù)碼管動(dòng)態(tài)顯示 ,節(jié)省了芯片的資源。 VHDL程序: (1)sel1模塊 library ieee。 use 。 use 。 entity sel1 is port(clk1:in std_logic。 s1:out std_logic_vector(1 downto 0))。 end sel1。 architecture sel_arc of sel1 is begin process(clk1) variable t:std_logic_vector(1 downto 0)。 begin if clk139。event and clk1=39。139。 then IF t=10 then t:=00。 else t:=t+1。 end if。 end if。 s1=t。 end process。 end sel_arc。 (2)sel2模塊 library ieee。 use 。 entity sel2 is port(sel2:in std_logic_vector(1 downto 0)。 s2:out std_logic_vector(2 downto 0))。 end sel2。 architecture bbb_arc of sel2 is begin process(sel2) begin case sel2 is when 00=s2=110。 when 01=s2=101。 when 10=s2=011。 when others=s2=ZZZ。 end case。 end process。 end bbb_arc。 : (1)sel1模塊 (2)sel2模塊 從波形圖可以看出 當(dāng)片選信號(hào)是 00時(shí),輸出選擇記程輸出。 當(dāng)片選信號(hào)是 01時(shí),輸出選擇記費(fèi)輸出。 當(dāng)片選信號(hào)是 10時(shí),輸出選擇等到時(shí)間輸出。 ,仿真結(jié)果及分析 各模塊設(shè)計(jì)仿真實(shí)現(xiàn)后,可分別創(chuàng) 建成元件符號(hào)。頂層就是將各分模塊用 VHDL語言或者是圖形方法連接起來,便可實(shí)現(xiàn)系統(tǒng)電路。 VHDL程序 : library ieee。 use 。 use 。 use 。 entity czc is port(clk,wr,ss,dn:in std_logic。 dnpd:out std_logic。 shuc1,shuc0:out std_logic_vector(6 downto 0)。 weix:out std_logic_vector(2 downto 0))。 end entity czc。 architecture one of czc is ponent bz PORT(AJ:IN STD_LOGIC。 BZ:OUT STD_LOGIC)。 end ponent。 ponent pulse PORT(CLK0:IN STD_LOGIC。 FOUT:OUT STD_LOGIC)。 end ponent。 ponent ddzt PORT(CLK,SS:IN STD_LOGIC。 DDBZ:IN STD_LOGIC。 DDJFBZ:OUT STD_LOGIC。 DDSJ:OUT STD_LOGIC_VECTOR(7 DOWNTO 0))。 end ponent。 ponent jc port(clks,SS,WR:in std_logic。 LC:BUFFER std_logic_vector(7 downto 0))。 end ponent。 ponent lcjfbz port(SS:in std_logic。 LC:IN STD_LOGIC_VECTOR(7 DOWNTO 0)。 LCJFBZ:OUT std_logic)。 end ponent。 ponent jf PORT( SS:IN STD_LOGIC。 DN:IN STD_LOGIC。 LC:IN std_logic_vector(7 downto 0)。 DDSJ:IN STD_LOGIC_VECTOR(7 DOWNTO 0)。 LCJFBZ:IN STD_LOGIC。 DDJFBZ:IN STD_LOGIC。 FY:OUT STD_LOGIC_VECTOR(7 DOWNTO 0))。 end ponent。 ponent ymq port(din:in std_logic_vector(7 downto 0)。 dout1:out std_logic_vector(6 downto 0)。 dout0:out std_logic_vector(6 downto 0))。 end ponent。 ponent xzsc port(jc,jf,wt:in std_logic_vector(7 downto 0)。 sel:in std_logic_vector(1 downto 0)。 q:out std_logic_vector(7 downto 0))。 end ponent。 ponent sel1 port(clk1:in std_logic。 s1:out std_logic_vector(1 downto 0))。 end ponent。 ponent sel2 port(sel2:in std_logic_vector(1 downto 0)。 s2:out std_logic_vector(2 downto 0))。 end ponent。 signal a,b,c,d,e,f,i,j,m,n:std_logic。 signal x,y,z,W:std_logic_vector(7 downto 0)。 signal k:std_logic_vector(1 downto 0)。 begin dnpd=a。 u1:bz port map(aj=dn,bz=a)。 u2:bz port map(aj=ss,bz=b)。 u3:bz port map(aj=wr,bz=c)。 u4:pulse port map(clk0=clk,fout=d)。 u5:pulse port map(clk0=d,fout=i)。 u6:pulse port map(clk0=i,fout=j)。 u7:pulse port map(clk0=j,fout=m)。 u8:pulse port map(clk0=m,fout=n)。 u9:jc port map(clks=n,ss=b,wr=c,lc=z)。 u10:ddzt port map(clk=n,ss=b,ddbz=c,ddjfbz=f,ddsj=y)。 u11:lcjfbz port map(ss=b,lc=z,lcjfbz=e)。 u12:jf port map(ss=b,dn=a,lc=z,ddsj=y,lcjfbz=e,ddjfbz=f,fy=x)。 u13:xzsc port map(jf=x,jc=z,wt=y,sel=k,q=W)。 u14:sel1 port map(clk1=j,s1=K)。 u15:sel2 port map(sel2=K,s2=weix)。 u16:ymq port map(din=W,dout1=shuc1,dout0=shuc0)。 end architecture one。 輸入、輸出信號(hào)說明 輸入: DN:day OR night 控制; SS:Start OR stop 控制; WR:wait OR run 控制; CLK:輸入時(shí)鐘信號(hào),模擬時(shí)間和路程。 輸出: DNPB:用于判別白天還是黑夜的輸出信號(hào),接至發(fā)光二極管,白天不發(fā)光,黑夜的時(shí)候發(fā)光。 FY1:費(fèi)用的十位 FY0:費(fèi)用的個(gè)位 DDSJ1:等待時(shí)間的十位 DDSJ0:等待時(shí)間的個(gè)位 LC1:路程的十位 LC0:路程的個(gè)位 各個(gè)模塊的 軟件 連線圖 (見附錄 二 ) 6.硬件電路設(shè)計(jì)與安裝圖 硬件 電路設(shè)計(jì)圖 (見附錄 三 ) 硬件電路的元器件清單: 器件名稱及個(gè)數(shù) 杜邦線 若干根 電阻 200 歐姆 21個(gè) 1K 3個(gè) 20 腳底座 3個(gè) 插針 若干個(gè) 9012 3個(gè) 發(fā)光二極管 1個(gè) 數(shù)碼管 6個(gè)