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

Subversion Repositories rise

[/] [rise/] [trunk/] [vhdl/] [barrel.vhd] - Blame information for rev 148

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 75 cwalter
-------------------------------------------------------------------------------
2
-- File: ex_stage.vhd
3
-- Author: Jakob Lechner, Urban Stadler, Harald Trinkl, Christian Walter
4
-- Created: 2006-11-29
5
-- Last updated: 2006-11-29
6
 
7
-- Description:
8
-- Barrel shifter
9
-------------------------------------------------------------------------------
10
 
11
library IEEE;
12
use IEEE.STD_LOGIC_1164.all;
13
use IEEE.NUMERIC_STD.all;
14
use IEEE.STD_LOGIC_ARITH.all;
15
use ieee.STD_LOGIC_UNSIGNED.all;
16
use WORK.RISE_PACK.all;
17
use WORK.RISE_PACK_SPECIFIC.all;
18
 
19
library UNISIM;
20
use UNISIM.VComponents.all;
21
 
22
 
23
use WORK.RISE_PACK.all;
24
use work.RISE_PACK_SPECIFIC.all;
25
 
26
entity barrel_shifter is
27
  port (reg_a      : in  std_logic_vector(15 downto 0);
28
        reg_b      : in  REGISTER_T;
29
        left       : in  std_logic;
30
        arithmetic : in  std_logic;
31
        reg_q      : out REGISTER_T);
32
end barrel_shifter;
33
 
34
 
35
architecture barrel_shifter_rtl of barrel_shifter is
36
  signal shifter_value : REGISTER_T;
37
  signal mult_b_in     : std_logic_vector(17 downto 0);
38
  signal mult_a_in     : std_logic_vector(17 downto 0);
39
  signal mult_p_out    : std_logic_vector(35 downto 0);
40
 
41
  component MULT18X18
42
    port (A : in  std_logic_vector(17 downto 0);
43
          B : in  std_logic_vector(17 downto 0);
44
          P : out std_logic_vector(35 downto 0)
45
          );
46
  end component;
47
 
48
  function reverse_register (reg_in : REGISTER_T) return REGISTER_T is
49
    variable reversed : REGISTER_T;
50
  begin
51
    for i in 0 to (ARCHITECTURE_WIDTH - 1) loop
52
      reversed(i) := reg_in (ARCHITECTURE_WIDTH - 1 - i);
53
    end loop;
54
    return reversed;
55
  end reverse_register;
56
 
57
begin
58
  MULT18X18_inst : MULT18X18
59
    port map (
60
      P => mult_p_out,                  -- 36-bit multiplier output
61
      A => mult_b_in,                   -- 18-bit multiplier input
62
      B => mult_a_in                    -- 18-bit multiplier input
63
      );
64
 
65
  process(reg_b)
66
    variable index : integer range 0 to 15;
67
  begin
68
    shifter_value        <= x"0000";
69
    index                := to_integer(ieee.numeric_std.unsigned(reg_b(3 downto 0)));
70
    shifter_value(index) <= '1';
71
  end process;
72
 
73
  process(shifter_value, reg_a, left)
74
  begin
75
    mult_b_in <= "00" & shifter_value;
76
    if left = '1' then
77
      mult_a_in <= "00" & reg_a;
78
    else
79
      mult_a_in <= "00" & reverse_register(reg_a);
80
    end if;
81
  end process;
82
 
83
  process(mult_p_out, left, arithmetic, reg_a, reg_b)
84
  begin
85
    if left = '1' then
86
      reg_q <= mult_p_out(ARCHITECTURE_WIDTH - 1 downto 0);
87
    else
88
      reg_q <= reverse_register(mult_p_out(ARCHITECTURE_WIDTH - 1 downto 0));
89
      if arithmetic = '1' and reg_a(ARCHITECTURE_WIDTH - 1) = '1' then
90
        for index in 0 to ARCHITECTURE_WIDTH - 1 loop
91
          if index < reg_b then
92
            reg_q(ARCHITECTURE_WIDTH - 1 - index) <= '1';
93
          end if;
94
        end loop;
95
      end if;
96
    end if;
97
  end process;
98
 
99
end architecture;

powered by: WebSVN 2.1.0

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