Newer
Older
-------------------------------------------------------------------------------
-- Project ELE8304 : Circuits intégrés à très grande échelle
-------------------------------------------------------------------------------
-- File shifter.vhd
-- Authors Titouan Luard <luardtitouan@gmail.com>
-- Yann Roberge <yann.roberge@polymtl.ca>
-- Lab GRM - Polytechnique Montreal
-- Date 2021-10-29
-------------------------------------------------------------------------------
-- Brief Single-bit half-adder with carry out
------------------------------------------------------------------------
-------
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use ieee.math_real.all;
library work;
use work.riscv_pkg.all;
entity shifter is
port (
i_shamt : in std_logic_vector(4 downto 0); -- nombre de bits décalés
i_src1 : in std_logic_vector(XLEN-1 downto 0); -- nombre décalé
i_arith : in std_logic; -- 0: décalage logique (bourre des 0) ; 1
o_sh : out std_logic_vector(XLEN-1 downto 0) );
signal temp : std_logic_vector(XLEN-1 downto 0);
when "000" =>
if i_arith='0' then
--decalage a droite logique
o_sh <= i_src1 srl to_integer(unsigned(i_shamt));
else
if i_src1(XLEN-1)='0' then
temp <= i_src1 srl to_integer(unsigned(i_shamt));
o_sh <= not temp(temp'length - 1 downto temp'length - to_integer(unsigned(i_shamt))) & i_src1(temp'length - 1 - to_integer(unsigned(i_shamt)) downto 0);
when "001" =>
--decalage a droite arithmetique
o_sh <= i_src1 sll to_integer(unsigned(i_shamt));