OpenCores
URL https://opencores.org/ocsvn/plasma/plasma/trunk

Subversion Repositories plasma

[/] [plasma/] [trunk/] [vhdl/] [shifter.vhd] - Blame information for rev 43

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 rhoads
---------------------------------------------------------------------
2
-- TITLE: Shifter Unit
3
-- AUTHOR: Steve Rhoads (rhoadss@yahoo.com)
4
-- DATE CREATED: 2/2/01
5
-- FILENAME: shifter.vhd
6 43 rhoads
-- PROJECT: Plasma CPU core
7 2 rhoads
-- COPYRIGHT: Software placed into the public domain by the author.
8
--    Software 'as is' without warranty.  Author liable for nothing.
9
-- DESCRIPTION:
10
--    Implements the 32-bit shifter unit.
11
---------------------------------------------------------------------
12
library ieee;
13
use ieee.std_logic_1164.all;
14 39 rhoads
use work.mlite_pack.all;
15 2 rhoads
 
16
entity shifter is
17
   port(value        : in  std_logic_vector(31 downto 0);
18
        shift_amount : in  std_logic_vector(4 downto 0);
19
        shift_func   : in  shift_function_type;
20
        c_shift      : out std_logic_vector(31 downto 0));
21
end; --entity shifter
22
 
23
architecture logic of shifter is
24
--   type shift_function_type is (
25
--      shift_nothing, shift_left_unsigned, 
26
--      shift_left_signed, shift_right_unsigned);
27
begin
28
 
29
shift_proc: process(value, shift_amount, shift_func)  --barrel shifter unit
30
   variable shift1, shift2, shift4,
31
            shift8, shift16 : std_logic_vector(31 downto 0);
32
   variable fills : std_logic_vector(31 downto 16);
33
variable go_right : std_logic;
34
begin
35
   if shift_func = shift_right_unsigned or shift_func = shift_right_signed then
36
      go_right := '1';
37
   else
38
      go_right := '0';
39
   end if;
40
   if shift_func = shift_right_signed and value(31) = '1' then
41
      fills := "1111111111111111";
42
   else
43
      fills := "0000000000000000";
44
   end if;
45
   if go_right = '0' then  --shift left
46
      if shift_amount(0) = '1' then
47
         shift1 := value(30 downto 0) & '0';
48
      else
49
         shift1 := value;
50
      end if;
51
      if shift_amount(1) = '1' then
52
         shift2 := shift1(29 downto 0) & "00";
53
      else
54
         shift2 := shift1;
55
      end if;
56
      if shift_amount(2) = '1' then
57
         shift4 := shift2(27 downto 0) & "0000";
58
      else
59
         shift4 := shift2;
60
      end if;
61
      if shift_amount(3) = '1' then
62
         shift8 := shift4(23 downto 0) & "00000000";
63
      else
64
         shift8 := shift4;
65
      end if;
66
      if shift_amount(4) = '1' then
67
         shift16 := shift8(15 downto 0) & ZERO(15 downto 0);
68
      else
69
         shift16 := shift8;
70
      end if;
71
   else  --shift right
72
      if shift_amount(0) = '1' then
73
         shift1 := fills(31) & value(31 downto 1);
74
      else
75
         shift1 := value;
76
      end if;
77
      if shift_amount(1) = '1' then
78
         shift2 := fills(31 downto 30) & shift1(31 downto 2);
79
      else
80
         shift2 := shift1;
81
      end if;
82
      if shift_amount(2) = '1' then
83
         shift4 := fills(31 downto 28) & shift2(31 downto 4);
84
      else
85
         shift4 := shift2;
86
      end if;
87
      if shift_amount(3) = '1' then
88
         shift8 := fills(31 downto 24) & shift4(31 downto 8);
89
      else
90
         shift8 := shift4;
91
      end if;
92
      if shift_amount(4) = '1' then
93
         shift16 := fills(31 downto 16) & shift8(31 downto 16);
94
      else
95
         shift16 := shift8;
96
      end if;
97
   end if;  --shift_dir
98
   if shift_func = shift_nothing then
99
      c_shift <= ZERO;
100
   else
101
      c_shift <= shift16;
102
   end if;
103
end process;
104
 
105
end; --architecture logic
106
 

powered by: WebSVN 2.1.0

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