【问题标题】:Can't have a simulation for my VHDL code无法模拟我的 VHDL 代码
【发布时间】:2014-02-14 19:36:53
【问题描述】:

我正在寻找我的问题的原因或答案: 我的 VHDL 代码正在运行,我正在尝试创建一个 10 分频器。 问题是模拟报告一直给我一个未定义的输出(没有值)。

这是我的 VHDL 代码,如果有任何帮助,我将不胜感激!谢谢你!

Library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;

entity Frequency_divider is 
port(clk: in std_logic;
     Q:out std_logic);
end Frequency_divider;

architecture desc_freq_divider_10 of Frequency_divider is 


signal S: std_logic:='0';
begin

process(clk,S)
    variable cpt: integer:=0;
    begin

        if (rising_edge(clk)) then 
            cpt:=cpt+1;
        end if;

        if (cpt=5) then 
            S<=not(S);
            cpt:=0;
        end if;

    end process;    
    Q<=S;
end desc_freq_divider_10;       

【问题讨论】:

    标签: vhdl simulation


    【解决方案1】:

    我去掉了多余的 use 子句:

    --use ieee.std_logic_arith.all;
    --use ieee.std_logic_unsigned.all;
    

    添加了一个测试台:

    library ieee;
    use ieee.std_logic_1164.all;
    
    entity freq_test is
    end entity;
    
    architecture tb of freq_test is
        signal CLK:     std_logic :='0';
        signal Q:       std_logic;
    begin
    
    CLOCK:
        process
        begin
            if Now < 300 ns then
                wait for 10 ns;
                clk <= not clk;
            else
                wait;
            end if;
        end process;
    DUT:
        entity work.frequency_divider
            port map (clk,q);
    end architecture;
    

    对所有内容进行分析、详细说明和模拟,然后让它发挥作用。

    它表示您的代码可以正常工作,并且您很可能存在工具链使用错误。

    【讨论】:

      【解决方案2】:

      模拟应该没问题,正如 David Koontz 所描述的那样,但对于可综合的设计,该过程应该只有 clk 在敏感性列表中,并且应该在 if 语句中包含所有更新,例如:

      process(clk)
        variable cpt : integer range 0 to 5 := 0;  -- Must be constrained for synthesis
      begin
        if (rising_edge(clk)) then
          cpt := cpt+1;
          if (cpt = 5) then
            S   <= not(S);
            cpt := 0;
          end if;
        end if;
      end process;
      

      其他设计可能会推断出闩锁和类似问题。

      2014-02-17 编辑:在cpt 整数上添加了约束,因为综合无法计算出最小尺寸,因此会产生太多触发器。

      【讨论】:

        猜你喜欢
        • 2014-01-24
        • 2019-09-26
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-06-30
        • 2020-11-27
        • 2019-08-07
        • 1970-01-01
        相关资源
        最近更新 更多