0

VHDL を試しているところ、取り除けない遅延に遭遇しました。

AND3 とその後の出力の可能性のあるすべての入力を循環するテストベンチで、非常に単純な 3 入力 AND ゲートをプログラムしようとしています。シミュレーションでの評価を簡単にするために、1 つの入力を High に接続しました。

3 つの入力の 8 つの値の間を循環するシミュレーションを実行しましたが (3 番目の入力は無視されます)、数値の反復とその入力への割り当ての間には、これらのステートメントが直後に続くという事実にもかかわらず、100ns があります。遅れる - なぜ?反復間の 100 ns の遅延は意図的なものであるため理解できますが、以下に示す 2 つの行が順次実行されたときに 100 ns の遅延が発生する理由がわかりません。

ここに画像の説明を入力

定義、テストベンチを下に置きました。

どうもありがとう!

--ENTITY AND3 (3 input AND gate) --
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity and3 is
    port(
        a, b, c : in  std_logic;
        o       : out std_logic
    );
end entity and3;
architecture RTL of and3 is
begin
    o <= (a and b and c) after 5 ns;
end architecture RTL;

--TESTBENCH FOR AND3 with 3rd input left open (tied high)
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

entity testAnd3 is
end entity testAnd3;                    -- no ports for a test bench

architecture io of testAnd3 is
    component And3 is
        port(x, y, z : in  std_logic:= '1'; --Sets default value if left open; 
             o       : out std_logic
        );
    end component And3;
    signal a, b, c   : std_logic:='0';
   signal iteration : unsigned(2 downto 0):= (others => '0');

begin
    g1 : And3 port map(x => a, y => b, z => open, o => c); --map signals to And ports 
    stim_process : process 
    begin
        iteration <= iteration + 1;     --//100 ns delay between here and next line!?
        a <= iteration(0);
        b <= iteration(1);
        wait for 100 ns;
    end process;

end architecture io;
4

1 に答える 1

3

問題は<=割り当てです:

iteration <= iteration + 1;

これは、デルタ遅延の後まで<=の読み取り値を更新しないため、は直後にインクリメントされた値を確認しませんが、次の反復で最初に確認します。iterationa <= iteration(0);wait for 100 ns;

これは、次のいずれかで修正できます。

  • 割り当てをプロセスの内外に移動するa(b合成可能なコードのコーディング スタイルと一致するため、推奨される解決策)
  • iteration <= iteration + 1;の直前に移動しますwait for 100 ns;。これにより、値waitの更新の遅延が「隠され」iterationます (波形は同じになります。以下のコメントを参照してください)。
  • 変数の割り当てを使用してすぐiterationに行われるため、 のローカル変数に変更します。process:=

で割り当てられたシグナルの更新の遅延は<=、VHDL の重要な機能であることに注意してください。これは、評価順序に関係なく、すべてのクロックされたプロセスが同じ値を確認できるようにするためです。この関連する優れた回答を読むことを検討してください: Is process in VHDL reentrant? .

于 2015-10-25T16:25:33.573 に答える