2015-11-03 32 views
0

我试图模拟一个简单的寄存器和移位功能。这里的代码我使用:使用VHDL中的向量

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). 

和想法是什么,我做错了什么? 在此先感谢!

回答

2

REG的大小是10位(9 downto 0),并进入此设置,您试图把REG(9 downto 0) & WORD。这个表达式的总大小是10 + 1 = 11位。这不适合REG,它本身是10位长。

你可能想REG <= REG(8 downto 0) & WORD;

+0

感谢你快速回复! – Engine