【问题标题】:using a vector in VHDL在 VHDL 中使用向量
【发布时间】:2026-01-25 03:30:01
【问题描述】:

我正在尝试模拟一个简单的寄存器和移位功能。这里是我使用的代码:

entity shift is port (
CLK : in bit );
end shift ; 

architecture BEHAV of shift is 
signal  REG: bit_vector(9 downto 0) ;
signal  WORD: bit:='1'; 
begin
SYS :process (CLK)
begin 
    if CLK'event and CLK='1' then
    REG <= REG(9 downto 0) & WORD;  -- line cause the error
    end if;
end process SYS;
end BEHAV ;

我使用了一个模拟时钟的 do 文件,但我得到一个错误,上面写着:

# ** Fatal: (vsim-3420) Array lengths do not match. Left is 10 (9 downto 0). Right is 11 (0 to 10).

并知道我在这里做错了什么? 提前致谢 !

【问题讨论】:

    标签: vhdl


    【解决方案1】:

    REG 的大小为 10 位 (9 downto 0),您尝试将REG(9 downto 0) &amp; WORD 放入其中。该表达式的总大小为 10 + 1 = 11 位。这不适合 REG,它本身就是 10 位长。

    你可能想要REG &lt;= REG(8 downto 0) &amp; WORD;

    【讨论】: