【正文】
1 library ieee。 use 。 use 。 entity count2 is port(clk:in std_logic。 output:out std_logic_vector(2 downto 0))。 end。 architecture shi of count2 is signal A :std_logic_vector(2 downto 0)。 begin process(clk) begin if clk39。event and clk=39。139。 then if A=111 then A=000。 else A=A+1。 end if。 end if。 end process。 output=A。 end。 library ieee。 use 。 use 。 entity fenping is port(clock:in std_logic。 Q:out std_logic)。 end。 architecture fenpin of fenping is signal full:std_logic。 begin process( clock ) variable count: integer range 0 to 200。 begin if clock39。event and clock=39。139。 then if count=200 then count:=1。full=not full。 else 2 count:=count+1。 end if。 end if。 end process。 Q=full。 end 。 library ieee。 use 。 use 。 entity maichong is port(clock:in std_logic。 Q:out std_logic)。 end。 architecture fenpin of maichong is signal full:std_logic。 begin process( clock ) variable count: integer range 0 to 500000。 begin if clock39。event and clock=39。139。 then if count=500000 then count:=1。full=not full。 else count:=count+1。 end if。 end if。 end process。 Q=full。 end 。 library ieee。 use 。 use 。 entity miaojishu is 3 port(clock:in std_logic。 Q:out std_logic)。 end。 architecture fenping of miaojishu is signal full:std_logic。 begin process( clock ) variable count: integer range 0 to 1000000。 begin if clock39。event and clock=39。139。 then if count=1000000 then count:=1。full=not full。 else count:=count+1。 end if。 end if。 end process。 Q=full。 end 。 library ieee。 use 。 use 。 entity saomiao is port(bcdin1 :in std_logic_vector(3 downto 0)。 bcdin2 :in std_logic_vector(3 downto 0)。 bcdin3 :in std_logic_vector(3 downto 0)。 bcdin4 :in std_logic_vector(3 downto 0)。 bcdin5 :in std_logic_vector(3 downto 0)。 bcdin6 :in std_logic_vector(3 downto 0)。 q:out std_logic_vector(1 downto 0)。 clk:in std_logic。 segout:out std_logic_vector(6 downto 0))。 end。 architecture one of saomiao is signal bcdin : std_logic_vector(3 downto 0)。 begin process(clk,bcdin1,bcdin2,bcdin3,bcdin4) 4 begin if bcdin3=1001and bcdin4=0101and bcdin2=0101 then case bcdin1 is when 0000 = q =01。 when 0010 = q =01。 when 0100 = q =01。 when 0110 = q =01。 when 1000 = q =01。 when others=null。 end case。 elsif (bcdin3=0000and bcdin4=0000and bcdin2=0000and bcdin1=0000) then q=10。 else q=00。 end if。 end process。 process(clk) variable full:std_logic_vector(2 downto 0):=000。 begin if full=101 then full:=000。 if clk39。event and clk=39。139。 then if full111 then full:=full+1。 else full:=000。end if。 case full is when 000= bcdin =bcdin1。 when 001= bcdin =bcdin2。 when 010= bcdin =1100。 when 011= bcdin =bcdin3。 when 100= bcdin =bcdin4。 when 101= bcdin =1100。 when 110= bcdin =bcdin5。 when 111= bcdin =bcdin6。 when others=null。 end case。 end if。 end process。 process( bcdin ) begin case bcdin is when 0000 = segout =0111111。 when 0001 = segout =0000110。 when 0010 = segout =1011011。 when 0011 = segout =1001111。 when 0100 = segout =1100110。 5 when 0101 = segout =1101101。 when 0110 = segout =1111101。 when 0111 = segout =0000111。 when 1000 = segout =1111111。 when 1001 = segout =1101111。 when 1100 = segout =1000000。 when others=null。 end case。 end process。 end。 library ieee。 use 。 use 。 entity voice is port(clock:in std_logic。 input:in std_logic_vector(1 downto 0)。 Q:out std_logic)。 end。 architecture fenpin of voice is signal full:std_logic。 signal full2:std_logic。 begin process( clock ) variable count: integer range 0 to 100000。 variable co : integer range 0 to 3。 begin 6 if clock39。event and clock=39。139。 then if count=50000 then count:=0。 full2=not full2。 if co=1 then full=not full。 co:=0。 else co:=co+1。 elsif count400 then count:=count+1。 if count=200 then full=not full。 end if。 else count:=count+1。 end if。 end if。 end process。 process( input ) begin if input=01 then Q=full。 elsif input=10 then Q=full2。 else Q=39。039。 end if。 end process。 end 。 library ieee。 use 。 use 。 entity xianshi is port(clk:in std_logic。 clk1:in std_logic。 miaol:out std_logic_vector(3 downto 0)。 miaoh:out std_logic_vector(3 downto 0)。 rst1:in std_logic。 rst2:in std_logic。 rst3:in std_logic。 q1:out std_logic。 7 q2:out std_logic。 q3:out std_logic)。 end。 architecture one of xianshi is signal miao:std_logic_vector(7 downto 0)。 signal full: std_logic。 signal h: std_logic。 begin process(rst1,rst2,rst3,clk1) variable count: integer range 0 to 10000000。 begin if rst1=39。139。 then if clk139。event and clk1=39。139。 then if rst1=39。139。 then q1=39。139。 end if。 end if。 else q1=39。039。 end if。 if rst2=39。139。 then if clk139。event and clk1=39。139。 then if rst2=39。139。 then q2=39。139。 end if。 end if。 else q2=39。039。 end if。 if rst3=39。139。 then if clk139。event and clk1=39。139。 then if rst3=39。139。 then q3=39。139。 end if。 end if。 else q3=39。039。 end if。 end process。 end。 8 library ieee。 use 。 use 。 entity zong is port(clk:in std_logic。 rst1:in std_logic。 rst2:in std_