想实现30个周期的fa3信号循环,超过30个周期fa3恢复初始值0,程序不对,请高手指教,谢谢
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity a_team is
Port ( clk : in STD_LOGIC; --35M主时钟
rst_n : in STD_LOGIC;
fa3 : out STD_LOGIC);
end a_team;
architecture Behavioral of a_team is
signal cnt1:std_logic_vector(10 downto 0); --外层计数,想实现30个fa3信号周期循环
signal count1:std_logic_vector(4 downto 0);--内层计数,实现fa3,频率3.5M,占空比2:5
signal fa3_temp:std_logic;
begin
process(clk,rst_n)
begin
if rst_n = '0' then
cnt1 <= (others => '0');
count1 <= (others => '0');
fa3_temp <= '0';
elsif clk'event and clk = '1' then
cnt1 <=cnt1+1;
count1 <= count1 + 1;
if cnt1 = 30 then
cnt1 <= (others => '0');
elsif cnt1 < 30 then
if count1 =9 then
count1<= (others=>'0');
elsif(count1<4) then fa3_temp <= '1';
else fa3_temp <= '0';
end if;
end if;
end if;
end process;
fa3 <= fa3_temp;
end Behavioral;