gpt4 book ai didi

VHDL 算术 shift_left

转载 作者:行者123 更新时间:2023-12-03 16:14:56 33 4
gpt4 key购买 nike

shift_left ieee.numeric_std 的功能, 我想将信号左移并插入 10从右边。

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

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

最佳答案

而不是使用 shift_left函数,如何使用切片和连接:

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

或者
qo <= qo(2 downto 0) & '0';

就个人而言,我建议使用切片和串联进行移位和旋转。运算符( sra 等)存在问题,正如您所见,使用切片和连接可以让您完全控制。

关于VHDL 算术 shift_left,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46666682/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com