微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 嵌入式设计讨论 > FPGA,CPLD和ASIC > 求助:VHDL实现30个周期的循环,如何实现

求助:VHDL实现30个周期的循环,如何实现

时间:10-02 整理:3721RD 点击:
想实现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;

小编你能把你想要的输出波形画一个波形图么?我理解你的意思是不是只希望fa输出30个时钟周期以后就输出为零,以后这个状态就不变了,除非被复位?

搞个计数器 就行了吧

建议你分成两个process来写,第一个生成fa3;第二个监视fa3的次数,每跳一次cnt1++,到30次后反馈信号给第一个process,归零。反馈信号和归零的时序要安排好,防止fa3出现短脉冲。

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top