【正文】
【Programming】library ieee。 use 。 use 。 entity bc3 is port(CLK:in std_logic。 D:IN std_logic_vector(7 downto 0)。 Q:buffer std_logic_vector(7 downto 0)。 Cd:out std_logic。EN:in std_logic)。 end。 architecture ONE of bc3 is begin process(CLK) begin if CLK39。event and CLK=39。139。and EN=39。039。then Q=D。 if QD1 then Q=Q+1。 else Q=00000000。 end if。 end if。 end process。 process(Q) begin if Q=D1 then Cd=39。139。 else Cd=39。039。 end if。 end process。 end。【Simulation waveform】assume EN is HIGH for 3 clock pulse .D is settle as 16.We can get the simulate wave form as below So the counter’s function has been realized.Counter for the sum of tablets【Function introduction】 I use four Asynchronous decimal counter construct a big counter which count range from 0 to moment a pulse which represent a tablets drop down reach, the lease significant counter add one. And when the counter drop from 9 to 0, the output of RCO is set one that be the next counter’s clock. Meanwhile, the current value of count transfer to correspondence 7447 and display it. 【Programming】LIBRARY IEEE。 USE 。USE 。ENTITY COUNTER IS PORT( CLK0: IN STD_LOGIC。 RST: IN STD_LOGIC。 //清零信號(hào) BCD: OUT STD_LOGIC_VECTOR(3 DOWNTO 0)。 RCO: OUT STD_LOGIC)。 //END COUNTER。ARCHITECTURE BEHAVE OF COUNTER IS BEGIN PROCESS(CLK0,RST)VARIABLE N: STD_LOGIC_VECTOR(3 DOWNTO 0)。 BEGIN IF RST=39。039。 THEN N:=(OTHERS=39。039。)。 ELSIF CLK039。EVENT AND CLK0=39。139。 THEN IF N9 THEN N:=N+1。RCO=39。039。 ELSE N:=0000。RCO=39。139。 END IF。 END IF。 BCD=N。 END PROCESS。END BEHAVE?!維imulation waveform】【cascaded decimal counter figure】【Simulation waveform】【System framework and simulation】