在 VHDL 中使用矢量
using a vector in VHDL
我正在尝试模拟一个简单的 Register 和 shift 功能。这里是我使用的代码:
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).
知道我做错了什么吗?
提前致谢 !
REG
的大小是 10 位 (9 downto 0
),而您正试图将 REG(9 downto 0) & WORD
放入其中。该表达式的总大小为 10 + 1 = 11 位。这不适合 REG
,它本身有 10 位长。
你可能想要REG <= REG(8 downto 0) & WORD;
我正在尝试模拟一个简单的 Register 和 shift 功能。这里是我使用的代码:
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).
知道我做错了什么吗? 提前致谢 !
REG
的大小是 10 位 (9 downto 0
),而您正试图将 REG(9 downto 0) & WORD
放入其中。该表达式的总大小为 10 + 1 = 11 位。这不适合 REG
,它本身有 10 位长。
你可能想要REG <= REG(8 downto 0) & WORD;