2

I'm facing some weird errors from quartus when I try this.

Here's the code (all the unsigned & other weird functions was my attempt at persuading Quartus to compile it.)

library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

...
variable data : std_logic_vector(17 downto 0) := "000000000000000011";

...

-- 00000000111111000 original
-- 00000000000011111 shifted
-- 00000000000011000 result (AND)

data := std_logic_vector(unsigned(data) & shift_right(unsigned(data), 4));


-- 00000000011111000 original
-- 00000000111110000 shifted
-- 00000000111111000 result (OR)

data := std_logic_vector(unsigned(data) or shift_left(unsigned(data), 1));

I've left out quite a lot of the code, but the broken parts are left the same.

I'm getting

Error (10344): VHDL expression error at snake_driver.vhd(66): expression has 36 elements, but must have 18 elements

How to do it right?

4

1 回答 1

6

&运算and符与 VHDL 中的运算符不同。您正在寻找and运算符来执行按位与运算。&是向量的连接运算符,在两个 18 位向量之间使用它会产生一个 36 位向量(同样是向量宽度不匹配),如您的错误消息所示。

于 2014-11-07T23:39:03.977 回答