OpenCores
URL https://opencores.org/ocsvn/hf-risc/hf-risc/trunk

Subversion Repositories hf-risc

[/] [hf-risc/] [trunk/] [hf-risc/] [ucore/] [bshifter.vhd] - Blame information for rev 13

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 13 serginhofr
library ieee;
2
use ieee.std_logic_1164.all;
3
 
4
entity bshift is
5
        port (  left:           in std_logic;                           -- '1' for left, '0' for right
6
                logical:        in std_logic;                           -- '1' for logical, '0' for arithmetic
7
                shift:          in std_logic_vector(4 downto 0); -- shift count
8
                input:          in std_logic_vector (31 downto 0);
9
                output:         out std_logic_vector (31 downto 0)
10
        );
11
end entity bshift;
12
 
13
architecture logic of bshift is
14
        signal shift1l, shift2l, shift4l, shift8l, shift16l : std_logic_vector(31 downto 0);
15
        signal shift1r, shift2r, shift4r, shift8r, shift16r : std_logic_vector(31 downto 0);
16
        signal fill : std_logic_vector(31 downto 16);
17
begin
18
        fill <= (others => input(31)) when logical = '0' else x"0000";
19
 
20
        shift1l  <= input(30 downto 0) & '0' when shift(0) = '1' else input;
21
        shift2l  <= shift1l(29 downto 0) & "00" when shift(1) = '1' else shift1l;
22
        shift4l  <= shift2l(27 downto 0) & x"0" when shift(2) = '1' else shift2l;
23
        shift8l  <= shift4l(23 downto 0) & x"00" when shift(3) = '1' else shift4l;
24
        shift16l <= shift8l(15 downto 0) & x"0000" when shift(4) = '1' else shift8l;
25
 
26
        shift1r  <= fill(31) & input(31 downto 1) when shift(0) = '1' else input;
27
        shift2r  <= fill(31 downto 30) & shift1r(31 downto 2) when shift(1) = '1' else shift1r;
28
        shift4r  <= fill(31 downto 28) & shift2r(31 downto 4) when shift(2) = '1' else shift2r;
29
        shift8r  <= fill(31 downto 24) & shift4r(31 downto 8)  when shift(3) = '1' else shift4r;
30
        shift16r <= fill(31 downto 16) & shift8r(31 downto 16) when shift(4) = '1' else shift8r;
31
 
32
        output <= shift16r when left = '0' else shift16l;
33
end;
34
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.