首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >VHDL脉冲发生器似乎卡住了

VHDL脉冲发生器似乎卡住了
EN

Stack Overflow用户
提问于 2015-07-08 16:57:29
回答 1查看 720关注 0票数 0

我试图建立一个脉冲发生器,由两个脉冲发生器驱动,由一个mod计数器。计数器在一定的时间内通过一个周期,每当它到达指定的时间时,脉冲发生器就会在这些时间产生短的方波脉冲。

这在仿真中是可行的,但是当我在我的FPGA板上实现这一点时,它将成功地运行在方波脉冲的一个周期中,但当计数器永久卡在0(输出myag_qbyag_q卡在0,byag_lmyag_l被卡在1)时,它就会被卡住。我自己模拟了计数器,知道它继续在0到M之间循环。

下面列出了顶层模块、mod计数器和一个脉冲发生器的代码。另一个脉冲发生器非常类似于第一个脉冲发生器。不需要检查我的用户约束文件,因为我确信我得到的引脚分配是正确的。我需要一个总体的想法,我是否犯了任何重大错误组合这些模块/是否最后的程序(脉冲发生器)是正确的。最重要的是,我需要知道我使用计数器触发脉冲的方式是否正确。

顶层模块

代码语言:javascript
复制
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
entity trigger is
    Port ( clk, rst : in  STD_LOGIC;
              d: in STD_LOGIC_VECTOR(25 downto 0);
           myag_l, myag_q, byag_l, byag_q : out  STD_LOGIC);
end trigger;

architecture struc_arch of trigger is
signal counter: STD_LOGIC_VECTOR (25 downto 0);
begin

mini_yag: entity work.mini_yag(Behavioral)
port map(clk=>clk,rst=>rst,count=>counter,myag_l=>myag_l,myag_q=>myag_q);
big_yag: entity work.big_yag(Behavioral)
port map(clk=>clk,rst=>rst,d=>d,count=>counter,byag_l=>byag_l,byag_q=>byag_q);
baud: entity work.mod_m_counter(arch)
generic map(N=>26,M=>6434344)
port map(clk=>clk,reset=>rst,max_tick=>open,q=>counter);

end struc_arch;

Mod-M计数器

代码语言:javascript
复制
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;

entity mod_m_counter is
     generic (
        N: integer := 4; -- number of bits
        M: integer := 10 -- mod-M
     );
    Port ( clk, reset : in  STD_LOGIC;
           max_tick : out  STD_LOGIC;
           q : out  STD_LOGIC_VECTOR (N-1 downto 0));
end mod_m_counter;

architecture arch of mod_m_counter is
    signal r_reg: unsigned (N-1 downto 0);
    signal r_next: unsigned (N-1 downto 0);
begin
    --register
    process(clk,reset)
    begin
        if (reset='1') then
            r_reg <= (others=>'0');
        elsif (clk'event and clk='1') then
            r_reg <= r_next;
        end if;
    end process;
    --next-state logic
    r_next <= (others=>'0') when r_reg=(M-1) else
                 r_reg + 1;
    --output logic
    q <= std_logic_vector(r_reg);
    max_tick <= '1' when r_reg=(M-1) else '0';
end arch;

脉冲发生器

代码语言:javascript
复制
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;

entity big_yag is
generic(
T1: unsigned :=to_unsigned(0,26); --Lamp On
T2: unsigned :=to_unsigned(138889,26); --Lamp Off
T3: unsigned :=to_unsigned(4305555,26); --Q-switch On
T4: unsigned :=to_unsigned(4343434,26); --Q-switch Off
T5: unsigned :=to_unsigned(6434343,26)  --Reset Sequence
);
Port( 
clk,rst : in STD_LOGIC;
d,count: in STD_LOGIC_VECTOR(25 downto 0);
byag_l,byag_q : out STD_LOGIC
);
end big_yag;

architecture Behavioral of big_yag is
signal delay,counter: unsigned (25 downto 0);
signal byag_l_reg,byag_l_next,byag_q_reg,byag_q_next: std_logic;
begin
delay <= unsigned(d);
counter <= unsigned(count);

--register
process(rst,clk)
begin
if rst='1' then
    byag_l_reg <= '0';
    byag_q_reg <= '0';
elsif (clk='1' and clk'event) then
    byag_l_reg <= byag_l_next;
    byag_q_reg <= byag_q_next;
end if;
end process;

--next state logic
byag_l_next <= '1' when counter = T1+delay else
               '0' when counter = T2+delay else
               byag_l_reg;
byag_q_next <= '0' when counter = T1+delay else
               '1' when counter = T3+delay else
               '0' when counter = T4+delay else
               byag_q_reg;

--output logic
byag_l <= byag_l_reg;
byag_q <= byag_q_reg;

end Behavioral;
EN

回答 1

Stack Overflow用户

发布于 2015-07-10 12:48:36

模拟和现实之间的不匹配通常归结为以下一个或多个问题:

  • 测试台不提供与实际电路相同的刺激。
    • 例如: Test将按钮按下模拟为一个简单的1 > 0 > 1序列,但是一个真正的按钮不会有这样“干净”的行为。

  • 设计没有通过时间限制,或者设计没有适当的约束。
  • 在设计中存在竞争条件或危险,这是由未锁定/异步路径设计中的问题引起的。
    • 示例:当max_tick发生变化时,您的reg_M信号可能会出现故障。

  • 任何时钟域交叉点的设计都存在问题。
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31299008

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档