0

我是 VHDL 的新手。我有这个实体(缩短):

entity foo is
  port (CLK   : in  std_logic;
        out_A : out std_logic;
        );
end foo;

architecture Structure of foo is

  component D_Flipflop
    port (
      D     : in  std_logic;
      CLK   : in  std_logic;
      Q     : out std_logic;
      not_Q : out std_logic);
  end component;

  signal D_A, qA, not_qA : std_logic;

begin
  my_Flipflop : D_Flipflop
    port map(
      not_qA,
      CLK,
      qA,
      not_qA
      );
end Structure;

如您所见,我想使用D_Flipflop类似 Toggle-Flipflop 的东西,所以我通过信号将输出重定向到输入not_qA(这可能吗?)。问题在于,从外部看,只有 的端口CLK作为foo输入可见,并且 - 至少在 Vivado 模拟器中 - 信号qA从未not_qA被评估过。

这是的架构D_Flipflop

architecture Behavioral of D_Flipflop is

begin

  set_state : process(CLK, D)
    variable state : std_logic := '0';
  begin
    if falling_edge(CLK) then
      state := D;
      Q     <= state;
      not_Q <= not state;
    end if;
  end process set_state;

end Behavioral;

我为此搜索了很多。没有机会。有什么解决办法吗?

4

1 回答 1

1

并不是您在标题中指出组件的内部信号my_Flipflop没有触发,而是没有方法可以提供已知的非元值状态 - 'U' 的不是'U'。

这是运营商造成的not。参考包std_logic_1164主体中的not_table:

    -- truth table for "not" function
    CONSTANT not_table: stdlogic_1d :=
    --  -------------------------------------------------
    --  |   U    X    0    1    Z    W    L    H    -   |
    --  -------------------------------------------------
         ( 'U', 'X', '1', '0', 'X', 'X', '1', '0', 'X' );

查看更改和添加的测试平台:

library ieee;                   -- Added Context clause (MCVe)
use ieee.std_logic_1164.all;

entity D_Flipflop is
    port (
        D:      in  std_logic;
        CLK:    in  std_logic;
        Q:      out std_logic; 
        not_Q:  out std_logic := '0'
);
end entity;

architecture behavioral of D_Flipflop is  
begin
set_state:  
    process (CLK)                -- removed D from sensitivity list
        variable state:  std_logic := '0';  
    begin
        if falling_edge(CLK) then
            state := D;
            Q <= state;
            not_Q <= not state;
        end if;
    end process;  
end architecture;

library ieee;                    -- added context clause
use ieee.std_logic_1164.all;

entity foo is
    port (
        CLK:    in  std_logic;
        out_A:  out std_logic     -- removed extra ';'
    );
end entity;

architecture Structure of foo is

    component D_Flipflop is
        port (
            D:      in  std_logic;
            CLK:    in  std_logic;
            Q:      out std_logic;
            not_Q:  out std_logic
      );
  end component;

    -- signal D_A:     std_logic;  -- not used
    signal qA:      std_logic;       
    signal not_qA:  std_logic := '1';  -- notice this didn't matter

begin
my_Flipflop:  
    D_Flipflop
        port map (
            not_qA,
            CLK,
            qA,
            not_qA
        );

    out_A <= qA;                -- Added

end architecture;

library ieee;
use ieee.std_logic_1164.all;

entity foo_tb is
end entity;

architecture fum of foo_tb is
    signal CLK:     std_logic := '0';
    signal out_A:   std_logic;
begin

DUT:
    entity work.foo 
        port map (
            CLK => CLK,
            out_A => out_A
        );
CLOCK:
    process
    begin
        wait for 10 ns;
        CLK <= not CLK;
        if Now > 200 ns then
            wait;
        end if;
    end process;
end architecture;

D_Flipflop的not_Q输出已初始化为“0”(它可以很容易地初始化为“1”)。这相当于上电时触发器的收集器组。

现在触发器可以切换 - 它在D输入上有一个已知的非元值。

这给出了:

在此处输入图像描述 (可点击)

于 2015-06-10T17:05:00.700 回答