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

Subversion Repositories raptor64

[/] [raptor64/] [trunk/] [rtl/] [verilog/] [Raptor64_bitfield.v] - Blame information for rev 44

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

Line No. Rev Author Line
1 31 robfinch
`include "Raptor64_opcodes.v"
2
`timescale 1ns / 1ps
3
//=============================================================================
4
//        __
5
//   \\__/ o\    (C) 2012  Robert Finch
6
//    \  __ /    All rights reserved.
7
//     \/_//     robfinch<remove>@opencores.org
8
//       ||
9
//  
10
//      Raptor64_bitfield.v
11
//  - bitfield datapath operations
12
//
13
//  
14
// This source file is free software: you can redistribute it and/or modify 
15
// it under the terms of the GNU Lesser General Public License as published 
16
// by the Free Software Foundation, either version 3 of the License, or     
17
// (at your option) any later version.                                      
18
//                                                                          
19
// This source file is distributed in the hope that it will be useful,      
20
// but WITHOUT ANY WARRANTY; without even the implied warranty of           
21
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            
22
// GNU General Public License for more details.                             
23
//                                                                          
24
// You should have received a copy of the GNU General Public License        
25
// along with this program.  If not, see <http://www.gnu.org/licenses/>.    
26
//                                                                          
27
//
28
//=============================================================================
29
//
30 44 robfinch
module Raptor64_bitfield(xIR, a, b, o, masko);
31 41 robfinch
input [31:0] xIR;
32 44 robfinch
input [63:0] a;
33 31 robfinch
input [63:0] b;
34
output [63:0] o;
35
reg [63:0] o;
36
output [63:0] masko;
37
 
38
reg [63:0] o1;
39 44 robfinch
reg [63:0] o2;
40 41 robfinch
wire [6:0] xOpcode = xIR[31:25];
41 44 robfinch
wire [2:0] xFunc3 = xIR[2:0];
42 31 robfinch
 
43
// generate mask
44
reg [63:0] mask;
45
assign masko = mask;
46 44 robfinch
wire [5:0] mb = xIR[8:3];
47
wire [5:0] me = xIR[14:9];
48 31 robfinch
integer nn,n;
49
always @(mb or me or nn)
50
        for (nn = 0; nn < 64; nn = nn + 1)
51
                mask[nn] <= (nn >= mb) ^ (nn <= me) ^ (me >= mb);
52
 
53 44 robfinch
always @(xOpcode,xFunc3,mask,b,a,mb)
54 31 robfinch
case (xOpcode)
55 44 robfinch
`BITFIELD:
56
        case(xFunc3)
57
        `BFINS:         begin
58
                                        o2 = a << mb;
59
                                        for (n = 0; n < 64; n = n + 1) o[n] = mask[n] ? o2[n] : b[n];
60
                                end
61
        `BFSET:         begin for (n = 0; n < 64; n = n + 1) o[n] = mask[n] ? 1'b1 : a[n]; end
62
        `BFCLR:         begin for (n = 0; n < 64; n = n + 1) o[n] = mask[n] ? 1'b0 : a[n]; end
63
        `BFCHG:         begin for (n = 0; n < 64; n = n + 1) o[n] = mask[n] ? ~a[n] : a[n]; end
64 31 robfinch
        `BFEXT:         begin
65
                                        for (n = 0; n < 64; n = n + 1)
66 44 robfinch
                                                o1[n] = mask[n] ? a[n] : 1'b0;
67 31 robfinch
                                        o = o1 >> mb;
68
                                end
69
        default:        o = 64'd0;
70
        endcase
71
default:        o = 64'd0;
72
endcase
73
 
74
endmodule

powered by: WebSVN 2.1.0

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