可逆特殊12进制计数器(20分)。 library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity cnt is Port ( clk : in std_logic; CL : in std_logic; co : out std_logic; output_l: out std_logic_vector(3 downto 0); output_h : out std_logic_vector(3 downto 0); add_dec: in std_logic); end cnt; architecture beh of cnt is signal count : std_logic_vector(7 downto 0); begin process(clk,CL) begin if CL= '1' then count <= \ co<='0'; elsif rising_edge(clk) then if count(3 downto 0)=\ count(3 downto 0)<=\ count(7 downto 4)<=count(7 downto 4) +1; else count(3 downto 0)<=count(3 downto 0)+1; end if; co<='0'; if count=\ co<='1'; elsif count=\ count<=\ co<='0'; else null ; end if; else if count(3 downto 0)=\ count(3 downto 0)<=\ count(7 downto 4)<=count(7 downto 4) -1; else count(3 downto 0)<=count(3 downto 0)-1;
第1页 共4页
end if; co<='0'; if count=\ co<='1'; count<=\ else co<='0'; end if; end if; else null ; end if; end process; output_l <= count(3 downto 0); output_h <= count(7 downto 4); end beh;
第2页 共4页