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

Subversion Repositories amber

[/] [amber/] [trunk/] [hw/] [vlog/] [amber25/] [a25_barrel_shift.v] - Blame information for rev 60

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

Line No. Rev Author Line
1 16 csantifort
//////////////////////////////////////////////////////////////////
2
//                                                              //
3
//  Barrel Shifter for Amber 25 Core                            //
4
//                                                              //
5
//  This file is part of the Amber project                      //
6
//  http://www.opencores.org/project,amber                      //
7
//                                                              //
8
//  Description                                                 //
9
//  Provides 32-bit shifts LSL, LSR, ASR and ROR                //
10
//                                                              //
11
//  Author(s):                                                  //
12
//      - Conor Santifort, csantifort.amber@gmail.com           //
13
//                                                              //
14
//////////////////////////////////////////////////////////////////
15
//                                                              //
16
// Copyright (C) 2011 Authors and OPENCORES.ORG                 //
17
//                                                              //
18
// This source file may be used and distributed without         //
19
// restriction provided that this copyright statement is not    //
20
// removed from the file and that any derivative work contains  //
21
// the original copyright notice and the associated disclaimer. //
22
//                                                              //
23
// This source file is free software; you can redistribute it   //
24
// and/or modify it under the terms of the GNU Lesser General   //
25
// Public License as published by the Free Software Foundation; //
26
// either version 2.1 of the License, or (at your option) any   //
27
// later version.                                               //
28
//                                                              //
29
// This source is distributed in the hope that it will be       //
30
// useful, but WITHOUT ANY WARRANTY; without even the implied   //
31
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      //
32
// PURPOSE.  See the GNU Lesser General Public License for more //
33
// details.                                                     //
34
//                                                              //
35
// You should have received a copy of the GNU Lesser General    //
36
// Public License along with this source; if not, download it   //
37
// from http://www.opencores.org/lgpl.shtml                     //
38
//                                                              //
39
//////////////////////////////////////////////////////////////////
40
 
41
 
42
module a25_barrel_shift (
43
 
44 35 csantifort
input                       i_clk,
45 16 csantifort
input       [31:0]          i_in,
46
input                       i_carry_in,
47
input       [7:0]           i_shift_amount,     // uses 8 LSBs of Rs, or a 5 bit immediate constant
48
input                       i_shift_imm_zero,   // high when immediate shift value of zero selected
49
input       [1:0]           i_function,
50
 
51
output      [31:0]          o_out,
52 35 csantifort
output                      o_carry_out,
53
output                      o_stall
54 16 csantifort
 
55
);
56
 
57
 
58 35 csantifort
wire [31:0] quick_out;
59
wire        quick_carry_out;
60
wire [31:0] full_out;
61
wire        full_carry_out;
62
reg  [31:0] full_out_r       = 'd0;
63
reg         full_carry_out_r = 'd0;
64
reg         use_quick_r      = 1'd1;
65 16 csantifort
 
66
 
67 35 csantifort
assign o_stall      = (|i_shift_amount[7:2]) & use_quick_r;
68
assign o_out        = use_quick_r ? quick_out : full_out_r;
69
assign o_carry_out  = use_quick_r ? quick_carry_out : full_carry_out_r;
70 16 csantifort
 
71
 
72 35 csantifort
// Capture the result from the full barrel shifter in case the
73
// quick shifter gives the wrong value
74
always @(posedge i_clk)
75
    begin
76
    full_out_r       <= full_out;
77
    full_carry_out_r <= full_carry_out;
78
    use_quick_r      <= !o_stall;
79
    end
80 16 csantifort
 
81
 
82 35 csantifort
// Full barrel shifter
83
a25_shifter #(
84
    .FULL_BARREL (1)
85
    )
86
u_a25_shifter_full (
87
    .i_in               ( i_in             ),
88
    .i_carry_in         ( i_carry_in       ),
89
    .i_shift_amount     ( i_shift_amount   ),
90
    .i_shift_imm_zero   ( i_shift_imm_zero ),
91
    .i_function         ( i_function       ),
92
    .o_out              ( full_out         ),
93
    .o_carry_out        ( full_carry_out   )
94
);
95 16 csantifort
 
96
 
97
 
98 35 csantifort
// Quick barrel shifter
99
a25_shifter #(
100
    .FULL_BARREL        ( 0                )
101
    )
102
u_a25_shifter_quick (
103
    .i_in               ( i_in             ),
104
    .i_carry_in         ( i_carry_in       ),
105
    .i_shift_amount     ( i_shift_amount   ),
106
    .i_shift_imm_zero   ( i_shift_imm_zero ),
107
    .i_function         ( i_function       ),
108
    .o_out              ( quick_out        ),
109
    .o_carry_out        ( quick_carry_out  )
110
);
111 16 csantifort
 
112
endmodule
113
 
114
 

powered by: WebSVN 2.1.0

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