0

以下のシミュレーションでクロック遅延が 1 つある理由と、それを修正する方法を教えてください。

entity outBit is
port(   clk1 : in STD_LOGIC; 
        clk2 : in STD_LOGIC;
      -- reset  : in STD_LOGIC;
        int_in : in INTEGER;
        bit_out : out STD_LOGIC); --_VECTOR of 32
end outBit ;

私のエンティティであり、clk 1のすべての立ち上がりエッジは整数を取ります。整数 (1、2、3、4...) に従って、配列の対応する行を選択します。その行は 32 ビットです。32 個のclk2のうち 1 ビットを出力したいと考えています。たとえば、clk1 = 100 の場合、clk2 = 100/32です。

architecture Behavioral of outBit is
signal temp : array; --the array is fixed
signal output_bits : std_logic_vector(31 downto 0);
signal bit_i : integer := 31; --outputting a single bit out of 32 each time
begin

    temp(0) <= "11111111111111111111111111111111";
    temp(1) <= "11111111111111111111111111111110";
    temp(2) <= "11111111111111111111111111111100";
    -- etc 

output_bits <= temp(int_in);

    process(clk2)
      --outputting a single bit out of 32 each time
      --variable bit_i : integer := 31; 
      begin
        if rising_edge(clk2) then
          bit_out <= output_bits(bit_i);
          if bit_i = 0 then
            bit_i <= 31;
          else
            bit_i <= bit_i - 1;
          end if;
        end if;
      end process;
end Behavioral;

不要な遅延を以下に示します。32サイクルごとに(入力整数に応じて)新しい行を読みたいと思います....

ここに画像の説明を入力

ちなみに、最初のクロック(コード内)、(写真内の2番目のクロック)は、整数がいつ来るかを理解するためだけに質問に関連しているわけではありません

4

1 に答える 1

1

bit_out 遅延を取り除きたい場合は、フリップフロップにしないでください。

library ieee;                      -- add missing context clause
use ieee.std_logic_1164.all;

entity outbit is
    port (
    --    clk1:       in  std_logic;  -- not relevant
        clk2:       in  std_logic;
     -- reset:      in  std_logic;
        int_in:     in  integer;
        bit_out:    out std_logic  --_vector of 32
    );
end entity outbit;

architecture behavioral of outbit is
    type bit_array is array (0 to 3) of std_logic_vector(0 to 31); -- added
    signal temp : bit_array; --the array is fixed -- non_reserved word name
    signal output_bits : std_logic_vector(31 downto 0);
    subtype index_int is  integer range 0 to 31;  -- changed bit_i type 
    signal bit_i: index_int := 31; --outputting a single bit out of 32 each time

begin

    temp(0) <= "11111111111111111111111111111111";
    temp(1) <= "11111111111111111111111111111110";
    temp(2) <= "11111111111111111111111111111100";
    temp(3) <= "11011001110000110101001000101110"; -- added
    -- etc 

    output_bits <= temp(int_in);

    process(clk2)
      --outputting a single bit out of 32 each time
      --variable bit_i : integer := 31; 
      begin
        if rising_edge(clk2) then
         --  bit_out <= output_bits(bit_i);   -- moved
          if bit_i = 0 then
            bit_i <= 31;
          else
            bit_i <= bit_i - 1;
          end if;
        end if;
      end process;

      bit_out <= output_bits(bit_i);           -- moved to here

end architecture behavioral;

bit_out 割り当てをクロック条件付き if ステートメントの外に移動します。(これは同時信号割り当てであり、32:1 マルチプレクサーを表します)。

テスト ベンチを追加して、Minimal, Complete, and Verifiable exampleを完成させます。

library ieee;
use ieee.std_logic_1164.all;

entity outbit_tb is
end entity;

architecture foo of outbit_tb is
    signal clk2:    std_logic := '1';
    subtype temp_index is integer  range 0 to 3;
    signal int_in:  temp_index := 3;
    signal bit_out: std_logic;
begin
CLOCK:
    process
    begin
        wait for 5 ns;  -- so can multiply clocks in my head to get stop time
        clk2 <= not clk2;
        if now > 360 ns then
            wait;
        end if;
    end process;
DUT:
    entity work.outbit
        port map (
            clk2 => clk2,
            int_in => int_in,
            bit_out => bit_out
        );
end architecture;

そして、遅延はなくなりました:

ここに画像の説明を入力

于 2015-11-30T19:21:14.980 に答える