VHDL算术shift_left

时间:2017-10-10 12:22:49

标签: vhdl

使用shift_left ieee.numeric_std函数,我想将信号向左移,然后从右边插入10

signal qo: signed (3 downto 0) := (others=>'0');
qo <= shift_left(qo,1);

这只会从右边插入0。我想在某些条件下插入1

2 个答案:

答案 0 :(得分:3)

而不是使用$data = preg_replace('/(<([^>]*))(id=("[^"]*"|[^" >]*))/', '$1', $data); 函数,如何使用切片连接

shift_left

qo <= qo(2 downto 0) & '1';

就个人而言,我建议使用切片和连接进行移位和旋转。运算符(qo <= qo(2 downto 0) & '0'; 等)存在问题,正如您所看到的,使用切片和连接可以完全控制。

答案 1 :(得分:1)

table does not exist on this engine.类型的信号的最右侧位置插入'1'意味着将其值增加1.同样,插入signed意味着增加其值由0。

最好用'1'运算符表示overloaded by the numeric_std package

+

所以简单地使用:

-- Id: A.8
function "+" (L: SIGNED; R: INTEGER) return SIGNED;
-- Result subtype: SIGNED(L'LENGTH-1 downto 0).
-- Result: Adds a SIGNED vector, L, to an INTEGER, R.
分别

shift_left(qo, 1) + 1

无论shift_left(qo, 1) + 0 如何定义,这都有效,因此如果您稍后更改qo的长度,则无需调整任何切片操作。