2015-11-03 39 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