今天装了QII6.0,弄了个10进制的加法器,没有想到佳果与理想严重不一样,请求高手帮忙看看。谢谢!
library ieee ; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity CNT10 is port (clk,rst,en : in std_logic; CQ : out std_logic_vector(3 downto 0); cout : out std_logic ); end CNT10; architecture behav of CNT10 is begin process (clk,rst,en) variable CQI : std_logic_vector(3 downto 0); begin if rst='1' then CQI := (others => '0'); -- 计数器异步复位 elsif clk 'event and clk ='1' then --检测时钟上升沿 if en = '1' then -- 检测是否允许计数(同步使能) if CQI < 9 then CQI := CQI + 1; --允许计数,检测是否小于9 else CQI := (others =>'0'); --大于9,计数器清零 end if ; end if; end if; if CQI = 9 then cout <= '1'; --计数大于9,输出进位信号 else cout <= '0'; end if; CQ <= CQI; --将计数值向端口输出 end process; end behav;

|