|
library IEEE;
use IEEE.Std_Logic_1164.all;
use IEEE.std_logic_unsigned.all;
use IEEE.Numeric_STD.all;
use IEEE.std_logic_arith.all;
entity shift is
port(
A : in std_logic_vector (7 downto 0);
Y1,Y2,Y3,Y4,Y5,Y6 : out std_logic_vector (7 downto 0)
);
end shift;
architecture logic of shift is
constant B: integer := 3;
begin
process (A, B) begin
Y1 <= A sll B; --Logical shift left
Y2 <= A srl B; --Logical shift right
Y3 <= A rol B; --Logical rotate left
Y4 <= A ror B; --Logical rotate right
Y5 <= A sla B; --Arithmetic shift left
Y6 <= A sra B; --Arithmetic shift right
end process
end logic;
----------------------------------------------------------------------
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.Numeric_STD.all;
--use IEEE.std_logic_arith.all;
--use IEEE.std_logic_unsigned.all;
entity shift_tb is
end shift_tb;
architecture logic of shift_tb is
component shift
port(
A: in unsigned(7 downto 0);
Y1,Y2,Y3,Y4,Y5,Y6: out unsigned(7 downto 0)
);
end component;
signal A: unsigned (7 downto 0);
signal Y1,Y2,Y3,Y4,Y5,Y6: unsigned (7 downto 0);
begin
UUT : shift port map (
A => A,
Y1 => Y1,
Y2 => Y2,
Y3 => Y3,
Y4 => Y4,
Y5 => Y5,
Y6 => Y6
);
process begin
A <= "00000000";
wait for 10 ns;
A <= "01110110";
wait for 10 ns;
A <= "00000000";
wait for 10 ns;
end process;
end t1; |
|