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

Subversion Repositories raptor64

[/] [raptor64/] [trunk/] [rtl/] [verilog/] [lib/] [shiftAndMask.v] - Blame information for rev 45

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

Line No. Rev Author Line
1 3 robfinch
//=============================================================================
2
//      (C) 2005-2011  Robert Finch
3
//      All rights reserved.
4
//      robfinch@opencores.org
5
//
6
//      shiftAndMask.v
7
//
8
//
9
// This source file is free software: you can redistribute it and/or modify 
10
// it under the terms of the GNU Lesser General Public License as published 
11
// by the Free Software Foundation, either version 3 of the License, or     
12
// (at your option) any later version.                                      
13
//                                                                          
14
// This source file is distributed in the hope that it will be useful,      
15
// but WITHOUT ANY WARRANTY; without even the implied warranty of           
16
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            
17
// GNU General Public License for more details.                             
18
//                                                                          
19
// You should have received a copy of the GNU General Public License        
20
// along with this program.  If not, see <http://www.gnu.org/licenses/>.    
21
//                                                                          
22
//      Funnel rotater / shifter
23
//      Rotate, arithmetic shift left, or logical shift /
24
//      arithmetic shift right by 0 to 63 bits.
25
//      Parameterized with a default width of 32 bits.
26
//
27
//
28
//      Resource Usage Samples:
29
//      Ref. Spartan3
30
//      170 slices / 302 LUTs / 19.091ns
31
//      Webpack 9.2i Spartan3e  xc3s1200e 4fg320
32
//      170 slices / 302 LUTs / 14.450 ns (32 bits)
33
//      374 slices / 673 LUTs / 15.787 ns (64 bits)
34
//=============================================================================
35
 
36
module shiftAndMask(op, oz, a, b, mb, me, o, mo);
37
parameter WID = 64;
38
localparam DMSB = WID-1;
39
input [1:0] op;          // 0 = shl, 1 = rol, 2 = shr, 3 = asr
40
input oz;           // zero the output
41
input [DMSB:0] a;
42
input [5:0] b;
43
input [5:0] mb;
44
input [5:0] me;
45
output [DMSB:0] o;       // output
46
output [DMSB:0] mo;      // mask output
47
 
48
reg [DMSB:0] o;
49
reg [DMSB:0] mo;
50
 
51
integer nn;
52
wire [DMSB:0] rol_o;
53
wire fill_bit = a[DMSB] & op[0] & op[1];
54
 
55
rol #(WID) rol0(.op(op!=2'b00), .a(a), .b(b), .o(rol_o) );
56
 
57
// generate mask
58
always @(mb or me)
59
        for (nn = 0; nn < WID; nn = nn + 1)
60
                mo[nn] <= (nn >= mb) ^ (nn <= me) ^ (me >= mb);
61
 
62
always @(op or mo or rol_o or fill_bit or nn)
63
        for (nn = 0; nn < WID; nn = nn + 1)
64
                o[nn] <= oz ? 1'b0 : mo[nn] ? rol_o[nn] : fill_bit;
65
 
66
endmodule

powered by: WebSVN 2.1.0

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