1
entity Adder4Bit is
Port ( A : in  STD_LOGIC_VECTOR (3 downto 0);
       B : in  STD_LOGIC_VECTOR (3 downto 0);
       S : out  STD_LOGIC_VECTOR (3 downto 0);
       COUT : out  STD_LOGIC);
end Adder4Bit;

architecture structure of Adder4Bit is

component FullAdder -- add the fulladder to this architecture
port (
        A       : in std_logic;
        B       : in std_logic;
        CIN : in std_logic;
        SUM : out std_logic;
        COUT    : out std_logic
        );
end component;

signal wires : std_logic_vector(3 downto 1) := "000";       -- Make a signal "wires" with initial value 000

begin

adder0 : FullAdder port map ( A=> A(0), B => B(0), CIN => '0', SUM => S(0), COUT => wires(1)        );
adder1 : FullAdder port map ( A=> A(1), B => B(1), CIN => wires(1), SUM => S(1), COUT => wires(2)   );
adder2 : FullAdder port map ( A=> A(2), B => B(2), CIN => wires(2), SUM => S(2), COUT => wires(3)   );
adder3 : FullAdder port map ( A=> A(3), B => B(3), CIN => wires(3), SUM => S(3), COUT => COUT       );


end structure;

在最底层的adder3中,程序怎么知道哪个cout属于实体Adder4Bit,哪个cout属于组件FullAdder呢?它与箭头的方向有什么关系吗?

非常感谢您提前

4

2 回答 2

4

当然左边是组件内部的名字,右边是你的vhdl信号的名字。

它知道左边的 B 是 std_logic 而右边的 B 是 std_logic_vector 的方式相同。

于 2012-04-18T09:50:50.363 回答
2

左侧是“引脚名称”,右侧是“电线名称” - 所以这两个:

adder2 : FullAdder port map ( A=> A(2), B => B(2), CIN => wires(2), SUM => S(2), COUT => wires(3)   );
adder3 : FullAdder port map ( A=> A(3), B => B(3), CIN => wires(3), SUM => S(3), COUT => COUT       );

adder2COUT引脚连接到被调用的信号wires(3),并且adder3COUT引脚连接到被调用的信号COUT

这是将引脚和信号命名为同一事物的问题之一 - 坚持下去,一周左右您甚至不会注意到考虑它!

于 2012-04-18T13:02:12.990 回答