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

Subversion Repositories mlite

[/] [mlite/] [tags/] [V3_0/] [vhdl/] [shifter.vhd] - Blame information for rev 87

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 87 rhoads
   variable shift1L, shift2L, shift4L, shift8L, shift16 :
31
      std_logic_vector(31 downto 0);
32
   variable shift1R, shift2R, shift4R, shift8R :
33
      std_logic_vector(31 downto 0);
34 2 rhoads
   variable fills : std_logic_vector(31 downto 16);
35
variable go_right : std_logic;
36
begin
37
   if shift_func = shift_right_unsigned or shift_func = shift_right_signed then
38
      go_right := '1';
39
   else
40
      go_right := '0';
41
   end if;
42
   if shift_func = shift_right_signed and value(31) = '1' then
43
      fills := "1111111111111111";
44
   else
45
      fills := "0000000000000000";
46
   end if;
47
   if go_right = '0' then  --shift left
48
      if shift_amount(0) = '1' then
49 87 rhoads
         shift1L := value(30 downto 0) & '0';
50 2 rhoads
      else
51 87 rhoads
         shift1L := value;
52 2 rhoads
      end if;
53
      if shift_amount(1) = '1' then
54 87 rhoads
         shift2L := shift1L(29 downto 0) & "00";
55 2 rhoads
      else
56 87 rhoads
         shift2L := shift1L;
57 2 rhoads
      end if;
58
      if shift_amount(2) = '1' then
59 87 rhoads
         shift4L := shift2L(27 downto 0) & "0000";
60 2 rhoads
      else
61 87 rhoads
         shift4L := shift2L;
62 2 rhoads
      end if;
63
      if shift_amount(3) = '1' then
64 87 rhoads
         shift8L := shift4L(23 downto 0) & "00000000";
65 2 rhoads
      else
66 87 rhoads
         shift8L := shift4L;
67 2 rhoads
      end if;
68
      if shift_amount(4) = '1' then
69 87 rhoads
         shift16 := shift8L(15 downto 0) & ZERO(15 downto 0);
70 2 rhoads
      else
71 87 rhoads
         shift16 := shift8L;
72 2 rhoads
      end if;
73
   else  --shift right
74
      if shift_amount(0) = '1' then
75 87 rhoads
         shift1R := fills(31) & value(31 downto 1);
76 2 rhoads
      else
77 87 rhoads
         shift1R := value;
78 2 rhoads
      end if;
79
      if shift_amount(1) = '1' then
80 87 rhoads
         shift2R := fills(31 downto 30) & shift1R(31 downto 2);
81 2 rhoads
      else
82 87 rhoads
         shift2R := shift1R;
83 2 rhoads
      end if;
84
      if shift_amount(2) = '1' then
85 87 rhoads
         shift4R := fills(31 downto 28) & shift2R(31 downto 4);
86 2 rhoads
      else
87 87 rhoads
         shift4R := shift2R;
88 2 rhoads
      end if;
89
      if shift_amount(3) = '1' then
90 87 rhoads
         shift8R := fills(31 downto 24) & shift4R(31 downto 8);
91 2 rhoads
      else
92 87 rhoads
         shift8R := shift4R;
93 2 rhoads
      end if;
94
      if shift_amount(4) = '1' then
95 87 rhoads
         shift16 := fills(31 downto 16) & shift8R(31 downto 16);
96 2 rhoads
      else
97 87 rhoads
         shift16 := shift8R;
98 2 rhoads
      end if;
99
   end if;  --shift_dir
100
   if shift_func = shift_nothing then
101
      c_shift <= ZERO;
102
   else
103
      c_shift <= shift16;
104
   end if;
105
end process;
106
 
107
end; --architecture logic
108
 

powered by: WebSVN 2.1.0

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