假设我有 2 个 std_logic_vectors:
inputA : std_logic_vector(31 downto 0)
inputB: std_logic_vector(31 downto 0)
如何使用串联将 inputA
移动 inputB
?
我知道如何向左或向右移动 1 个位置,但不知道如何向右(或向左)移动 N 个位置。 注意:这是一个无时钟电路,不能使用标准的 vhdl 移位运算符。
除了连接之外的其他技术或想法也将受到赞赏。
最佳答案
最简单的方法是像这样:
library ieee;
use ieee.numeric_std.all;
...
output <= std_logic_vector(unsigned(inputA) srl to_integer(unsigned(inputB)));
(顺便说一句,作为一个无时钟电路与是否能够使用移位运算符无关。决定它的是数据类型。这种移位操作将由合成器转换为相同的逻辑,如果你用 case 语句写了一些更复杂的东西,都是手工展开的。)
关于concatenation - 如何使用串联通过 std_logic_vector 移动 std_logic_vector,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12447010/