试了试,改成下面这样,还有毛刺!<br>
library ieee;<br>
use ieee.std_logic_1164.all;<br>
use ieee.std_logic_unsigned.all;<br>
<br>
entity count8 is<br>
port( clk_Mfo : in std_logic;<br>
rst : in std_logic;<br>
clk_out_2Nfo : out std_logic);<br>
end entity;<br>
<br>
architecture behave of count8 is<br>
signal cq : std_logic_vector(2 downto 0);<br>
signal temp,tempa : std_logic;<br>
begin<br>
<br>
P1:process(clk_Mfo,rst,cq)<br>
begin<br>
if rst = '0' then cq <= "000";<br>
elsif clk_Mfo'event and clk_Mfo = '1' then<br>
cq <= cq + 1;<br>
if cq = "111" then <br>
cq <= "000";<br>
<br>
end if;<br>
end if;<br>
end process P1;<br>
<br>
P4:process(clk_Mfo,cq)<br>
begin<br>
if rst = '0' then <br>
tempa <= '0';<br>
elsif clk_Mfo'event and clk_Mfo = '1' then<br>
case cq is<br>
when "000" => tempa <= '0'; <br>
when "001" => tempa <= '0'; <br>
when "010" => tempa <= '0'; <br>
when "011" => tempa <= '0'; <br>
when "100" => tempa <= '0'; <br>
when "101" => tempa <= '0'; <br>
when "110" => tempa <= '0'; <br>
when others => null; <br>
end case; <br>
<br>
end if;<br>
end process P4;<br>
<br>
temp <= clk_Mfo when cq="111" else tempa; <br>
<br>
clk_out_2Nfo <= temp;<br>
end behave; |