介绍
从矢量移位器的名字就可以看出来,这是实现移位功能的。输出矢量是输入矢量移位后的结果,输出矢量的位宽是输入矢量的两倍,移位操作的次数是通过一个选择信号来实现的。
示例
在这里我举个例子吧。这里我设置输入信号是0110。通过改变sel信号,就可以实现不同的移位操作了。
设计文件
library ieee;
use ieee.std_logic_1164.all;
entity shifter is
port(input : in std_logic_vector(3 downto 0);
sel : in integer range 0 to 4;
output : out std_logic_vector(7 downto 0));
end shifter;
architecture shifter of shifter is
subtype vector is std_logic_vector(7 downto 0);
type matrix is array (4 downto 0) of vector;
signal row : matrix;
begin
row(0) <= "0000"&input;
G1 : for i in 1 to 4 generate
row(i) <= row(i-1)(6 downto 0) & '0';
end g