0

プログラムで紛らわしい問題に直面しています。プログラムでコンポーネントをポート マップ (呼び出し) する必要があります。また、コンポーネント内で別のポート マッピング (呼び出し) を行う必要がありますが、これは VHDL では違法です。この問題に対する別の解決策はありますか。これが私が意味したことの例です。

ここでプログラムを開始します。

library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

entity binary1 is
port( N: in std_logic;
  d: out integer);
end binary1 ;  


Architecture Behavior1 of binary1 is

たとえば、次のコンポーネントがあります。

component binary_integer_1 is
port ( b1: in std_logic;
   int1: out integer);
end component;

コンポーネントを呼び出すコマンド: begin s0: binary_integer_1 port map(n,d); Behavior1 を終了します。

また、メインプログラムは次のとおりです。

library ieee;
use ieee.std_logic_1164.all;
entity binary_integer_1 is
port ( b1: in std_logic;
int1: out integer);
end binary_integer_1;
architecture Behavior4 of binary_integer_1 is 
begin
process(b1)
begin
if b1 = '1' then
   int1 <= 1; 
   else
   int1 <= 0;
 end if;
 end process;
 end Behavior4;

たとえば、上位エンティティ内でポート マップを実行したい場合。私は違法な声明を持っています。別の方法を教えてください。

4

1 に答える 1

1

3 レベルの設計階層の小さな例を示しました。エンティティとアーキテクチャのペアは、下から上にリストされています。

entity comp1 is
    port (
        x:      in      integer;
        y:      out     integer 
    );
end entity;

architecture foo of comp1 is
begin
    y <= x after 2 ns;
end architecture;

entity comp2 is 
    port (
        a:      in  integer;
        b:      out integer
    );
end entity;

architecture fum of comp2 is
    component comp1 is
        port (
            x:      in      integer;
            y:      out     integer 
        );
    end component;

begin
INST_COMP1:
    comp1 port map (X => A, Y => B);
end architecture;

entity top is
end entity;

architecture fum of top is
     component comp2 is 
        port (
            a:      in  integer;
            b:      out integer
        );
    end component;

    signal a:   integer := 0;
    signal b:   integer;

begin
INST_COMP2:
    comp2 port map (a => a, b => b);

TEST:
    process 
    begin
        wait for 5 ns;
        a <= 1;
        wait for 5 ns;
        a <= 2;
        wait for 5 ns;
        a <= 3;
        wait for 5 ns;
        wait;
    end process;

end architecture;

ghdl -コンポーネント.vhdl

ghdl -e トップ

ghdl -r トップ --wave=top.ghw

(top.ghw を gtkwave で開き、波形表示を設定)、および:

ここに画像の説明を入力

したがって、たまたまテスト ベンチ (ポートなし) であるトップ レベル エンティティ top があり、インスタンス化されたコンポーネント comp1 を含むコンポーネント comp2 をインスタンス化し、入力からの出力に割り当てられた 2 ns の遅延を提供します。

整数 b の負の最大値は、整数範囲の左の値であり、これがデフォルトです。std_logic の場合と同様に、左の値は 'U' です。シミュレーション時間が、comp1 で x が y に割り当てられるまで (2 ns 後)、出力はデフォルト値を示します。0 への移行は、上部の x のデフォルト値が原因で発生しました。

コンテキスト節 (ライブラリー節と使用節) を避けるために整数を使用しました。エンティティの直接インスタンス化を使用することもできましたが、コンポーネント宣言を示しました。

于 2014-02-19T22:31:58.423 に答える