VHDL 向量传递

VHDL Vector passing

我想将一个值从一个向量传递到另一个向量。 我可以简单地这样做吗?

vector_one : out STD_LOGIC_VECTOR (3 downto 0);
vector_two : out STD_LOGIC_VECTOR (3 downto 0);

vector_one <= vector_two;

vector_one是一个输出端口(模式out),在VHDL-2008中允许读取这个,所以你可以这样做:

vector_one <= vector_two;

但是,在 VHDL-2002 中不允许读取输出端口,因此您必须从源驱动两个 outputz,比如 vector_source,例如:

vector_one <= vector_source;
vector_two <= vector_source;

一般来说,应该避免重复这样的输出信号,因为从该模块的使用来看,某些输出是由相同的值驱动的并不明显,这使得理解模块的使用变得更加困难。

你可以,但你需要注意,如果你需要在你的模块中使用 vector_one 之前它被外部使用意味着该模块将需要保存关于它的信息。然后您需要声明一个内部信号才能对其进行处理。

示例:

entity exampleModule is 
port( iClk : in STD_LOGIC;
      iTrigger    : in STD_LOGIC;
      iVector_one : out STD_LOGIC_VECTOR (3 downto 0);
      oVector_two : out STD_LOGIC_VECTOR (3 downto 0));
end exampleModule ;

Architecture RTL of exampleModule is
    signal mVectorBuff : std_logic_vector (3 downto 0);
begin 
    process (iClk) begin
       if rising_edge (iClk) then
           if iTrigger then mVectorBuff <= iVector_one;
           end if;
       end if; 
    end process;

    oVector_two <= mVector_one;
end Architecture RTL;