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

Subversion Repositories raptor64

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

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
module Raptor64_bitfield(xIR, rolo, b, o, masko);
31 41 robfinch
input [31:0] xIR;
32 31 robfinch
input [63:0] rolo;
33
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 41 robfinch
wire [6:0] xOpcode = xIR[31:25];
40 31 robfinch
wire [4:0] xFunc5 = xIR[4:0];
41
 
42
// generate mask
43
reg [63:0] mask;
44
assign masko = mask;
45 41 robfinch
wire [5:0] mb = xIR[10:5];
46
wire [5:0] me = xIR[16:11];
47 31 robfinch
integer nn,n;
48
always @(mb or me or nn)
49
        for (nn = 0; nn < 64; nn = nn + 1)
50
                mask[nn] <= (nn >= mb) ^ (nn <= me) ^ (me >= mb);
51
 
52
always @(xOpcode,xFunc5,mask,b,rolo,mb)
53
case (xOpcode)
54
`SHFTI:
55
        case(xFunc5)
56
        `BFINS:         begin for (n = 0; n < 64; n = n + 1) o[n] = mask[n] ? rolo[n] : b[n]; end
57
        `BFSET:         begin for (n = 0; n < 64; n = n + 1) o[n] = mask[n] ? 1'b1 : b[n]; end
58
        `BFCLR:         begin for (n = 0; n < 64; n = n + 1) o[n] = mask[n] ? 1'b0 : b[n]; end
59
        `BFCHG:         begin for (n = 0; n < 64; n = n + 1) o[n] = mask[n] ? ~b[n] : b[n]; end
60
        `BFEXT:         begin
61
                                        for (n = 0; n < 64; n = n + 1)
62
                                                o1[n] = mask[n] ? b[n] : 1'b0;
63
                                        o = o1 >> mb;
64
                                end
65
        default:        o = 64'd0;
66
        endcase
67
default:        o = 64'd0;
68
endcase
69
 
70
endmodule

powered by: WebSVN 2.1.0

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