VHDL中的左位移位器
我需要使用if-then语句在VHDL中创建一个左位移位器。根据我已经写的,我不知道该怎么办。我在下面附上了照片和代码。非常感谢VHDL中的左位移位器,vhdl,quartus,Vhdl,Quartus,我需要使用if-then语句在VHDL中创建一个左位移位器。根据我已经写的,我不知道该怎么办。我在下面附上了照片和代码。非常感谢 ieee库; 使用IEEE.STD_LOGIC_1164.ALL; 使用IEEE.NUMERIC_STD.ALL; 实体移位器是 港口( 输入:无符号(7到0); shift_cntrl:IN UNSIGNED(1向下到0); shift_out:out未签名(从15降到0) ); 端部移位器; 换档机构的结构是 开始 过程(输入、移位) 开始 如果是(shift
ieee库;
使用IEEE.STD_LOGIC_1164.ALL;
使用IEEE.NUMERIC_STD.ALL;
实体移位器是
港口(
输入:无符号(7到0);
shift_cntrl:IN UNSIGNED(1向下到0);
shift_out:out未签名(从15降到0)
);
端部移位器;
换档机构的结构是
开始
过程(输入、移位)
开始
如果是(shift_cntrl=“00”),则shift_out该问题未指定,但我相信这就是您想要做的:
library ieee;
use ieee.std_logic_1164.all;
entity shifter is
port (
input: in std_ulogic_vector (7 downto 0);
shift_cntrl: in std_ulogic_vector (1 downto 0);
shift_out: out std_ulogic_vector (15 downto 0)
);
end shifter;
architecture arch of shifter is
begin
process (input, shift_cntrl)
begin
if shift_cntrl = "00" then shift_out <= x"00" & input;
elsif shift_cntrl = "11" then shift_out <= x"00" & input;
elsif shift_cntrl = "01" then shift_out <= x"0" & input & x"0";
elsif shift_cntrl = "10" then shift_out <= input & x"00";
end if;
end process;
end arch;
ieee库;
使用ieee.std_logic_1164.all;
实体移位器是
港口(
输入:标准逻辑向量(7到0);
移位:在标准逻辑向量中(1向下到0);
移位:输出标准逻辑向量(15向下至0)
);
端部移位器;
换档机构的结构是
开始
过程(输入、移位)
开始
如果使用VHDL-2008,则可以使用sll运算符执行移位,例如,移位一位:
shift_out <= input sll 1;
shift_out二次幂乘法的优点是将十进制整数文本设置为另一个操作数的长度,并生成一个长度为其两倍的结果。在合成中,这将转化为位移<代码>移出
shift_out <= input sll 1;
shift_out <= input & '0';
shift_out <= '0000000' & input & '0';