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

Subversion Repositories raptor64

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

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

Line No. Rev Author Line
1 33 robfinch
`include "Raptor64_opcodes.v"
2
`timescale 1ns / 1ps
3
//=============================================================================
4
//        __
5
//   \\__/ o\    (C) 2011,2012  Robert Finch
6
//    \  __ /    All rights reserved.
7
//     \/_//     robfinch<remove>@opencores.org
8
//       ||
9
//  
10
//      Raptor64_SetOperandRegs.v
11
//  
12
// This source file is free software: you can redistribute it and/or modify 
13
// it under the terms of the GNU Lesser General Public License as published 
14
// by the Free Software Foundation, either version 3 of the License, or     
15
// (at your option) any later version.                                      
16
//                                                                          
17
// This source file is distributed in the hope that it will be useful,      
18
// but WITHOUT ANY WARRANTY; without even the implied warranty of           
19
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            
20
// GNU General Public License for more details.                             
21
//                                                                          
22
// You should have received a copy of the GNU General Public License        
23
// along with this program.  If not, see <http://www.gnu.org/licenses/>.    
24
//                                                                          
25
//
26 41 robfinch
// If a register field is not used by an instruction, then the register
27
// selected is forced to r0 for that field. This causes load stalls to be
28
// avoided, which would otherwise occur.
29 33 robfinch
//=============================================================================
30
 
31
module Raptor64_SetOperandRegs(rst, clk, advanceI, advanceR, advanceX, b, AXC, insn, xIR, dRa, dRb, dRc);
32
input rst;
33
input clk;
34
input advanceI;
35
input advanceR;
36
input advanceX;
37
input [63:0] b;
38
input [3:0] AXC;
39 41 robfinch
input [31:0] insn;
40
input [31:0] xIR;
41 33 robfinch
output [8:0] dRa;
42
reg [8:0] dRa;
43
output [8:0] dRb;
44
reg [8:0] dRb;
45
output [8:0] dRc;
46
reg [8:0] dRc;
47
 
48 41 robfinch
wire [6:0] iOpcode = insn[31:25];
49
wire [6:0] xOpcode = xIR[31:25];
50
wire [5:0] xFunc = xIR[5:0];
51
wire [6:0] iFunc7 = insn[6:0];
52 33 robfinch
 
53
always @(posedge clk)
54
if (rst) begin
55
        dRa <= 9'd0;
56
        dRb <= 9'd0;
57
        dRc <= 9'd0;
58
end
59
else begin
60
        if (advanceI) begin
61
                // Default settings, to be overridden
62 41 robfinch
                dRa <= {AXC,insn[24:20]};
63
                dRb <= {AXC,insn[19:15]};
64
                dRc <= {AXC,insn[14:10]};
65 33 robfinch
                casex(iOpcode)
66 41 robfinch
                `MISC:
67
                        case(iFunc7)
68
                        `IRET:  begin
69
                                        dRa <= {AXC,5'd25};
70
                                        dRb <= 9'd0;
71
                                        dRc <= 9'd0;
72
                                        end
73
                        `ERET:  begin
74
                                        dRa <= {AXC,5'd24};
75
                                        dRb <= 9'd0;
76
                                        dRc <= 9'd0;
77
                                        end
78
                        default:
79
                                        begin
80
                                        dRa <= 9'd0;
81
                                        dRb <= 9'd0;
82
                                        dRc <= 9'd0;
83
                                        end
84
                        endcase
85
                `CALL,`JMP,`NOPI:
86
                                        begin
87
                                        dRa <= 9'd0;
88
                                        dRb <= 9'd0;
89
                                        dRc <= 9'd0;
90
                                        end
91 33 robfinch
                `RET:           begin
92
                                        dRa <= {AXC,5'd30};
93
                                        dRb <= {AXC,5'd31};
94 41 robfinch
                                        dRc <= 9'd0;
95 33 robfinch
                                        end
96 41 robfinch
                `BLTI,`BLEI,`BGTI,`BGEI,
97
                `BLTUI,`BLEUI,`BGTUI,`BGEUI,
98
                `BEQI,`BNEI:
99
                                        begin
100
                                        dRb <= 9'd0;
101
                                        dRc <= 9'd0;
102
                                        end
103
                `SLTI,`SLEI,`SGTI,`SGEI,
104
                `SLTUI,`SLEUI,`SGTUI,`SGEUI,
105
                `SEQI,`SNEI:
106
                                        begin
107
                                        dRb <= 9'd0;
108
                                        dRc <= 9'd0;
109
                                        end
110
                `SETLO:         dRa <= {AXC,insn[26:22]};
111
                `SETMID:        dRa <= {AXC,insn[26:22]};
112
                `SETHI:         dRa <= {AXC,insn[26:22]};
113
                default:        dRa <= {AXC,insn[24:20]};
114 33 robfinch
                endcase
115
        end
116
        else if (advanceR) begin
117
                dRa <= 9'd0;
118
                dRb <= 9'd0;
119
                dRc <= 9'd0;
120
        end
121
        // no else here
122
        if (advanceX) begin
123
                if (xOpcode==`R) begin
124
                        if (xFunc==`EXEC) begin
125 41 robfinch
                                dRa <= b[24:20];
126
                                dRb <= b[19:15];
127
                                dRc <= b[14:10];
128 33 robfinch
                        end
129
                end
130
        end
131
end
132
 
133
endmodule

powered by: WebSVN 2.1.0

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