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

Subversion Repositories raptor64

[/] [raptor64/] [trunk/] [rtl/] [verilog/] [Raptor64_EvaluateBranch.v] - Blame information for rev 42

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 42 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_EvaluateBranch.v
11
//  - Evaluate branch conditions.
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_EvaluateBranch(ir, a, b, imm, rsf, takb);
31
input [31:0] ir;
32
input [63:0] a;
33
input [63:0] b;
34
input [63:0] imm;
35
input rsf;                      // reservation flag
36
output takb;
37
reg takb;
38
 
39
wire [6:0] opcode = ir[31:25];
40
wire [4:0] func5 = ir[4:0];
41
wire [3:0] func4 = ir[3:0];
42
wire [3:0] cond4 = ir[18:15];
43
wire [3:0] cond4t = ir[14:11];
44
 
45
wire aeqz = a==64'd0;
46
wire beqz = b==64'd0;
47
wire immeqz = imm==64'd0;
48
 
49
wire eq = a==b;
50
wire eqi = a==imm;
51
wire lt = $signed(a) < $signed(b);
52
wire lti = $signed(a) < $signed(imm);
53
wire ltu = a < b;
54
wire ltui = a < imm;
55
 
56
always @(opcode or func5 or func4 or cond4 or cond4t or a or eq or eqi or lt or lti or ltu or ltui or aeqz or beqz or rsf)
57
case (opcode)
58
`BTRR:
59
        case(func5)
60
        `BRA:   takb = 1'b1;
61
        `BRN:   takb = 1'b0;
62
        `BEQ:   takb = eq;
63
        `BNE:   takb = !eq;
64
        `BLT:   takb = lt;
65
        `BLE:   takb = lt|eq;
66
        `BGT:   takb = !(lt|eq);
67
        `BGE:   takb = !lt;
68
        `BLTU:  takb = ltu;
69
        `BLEU:  takb = ltu|eq;
70
        `BGTU:  takb = !(ltu|eq);
71
        `BGEU:  takb = !ltu;
72
        `BOR:   takb = !aeqz || !beqz;
73
        `BAND:  takb = !aeqz && !beqz;
74
        `BNR:   takb = !rsf;
75
        `LOOP:  takb = !beqz;
76
        `BEQR:  takb = eq;
77
        `BNER:  takb = !eq;
78
        `BLTR:  takb = lt;
79
        `BLER:  takb = lt|eq;
80
        `BGTR:  takb = !(lt|eq);
81
        `BGER:  takb = !lt;
82
        `BLTUR: takb = ltu;
83
        `BLEUR: takb = ltu|eq;
84
        `BGTUR: takb = !(ltu|eq);
85
        `BGEUR: takb = !ltu;
86
        default:        takb = 1'b0;
87
        endcase
88
`BEQI:  takb = eqi;
89
`BNEI:  takb = !eqi;
90
`BLTI:  takb = lti;
91
`BLEI:  takb = lti|eqi;
92
`BGTI:  takb = !(lti|eqi);
93
`BGEI:  takb = !lti;
94
`BLTUI: takb = ltui;
95
`BLEUI: takb = ltui|eqi;
96
`BGTUI: takb = !(ltui|eqi);
97
`BGEUI: takb = !ltui;
98
`BTRI:
99
        case(cond4t)
100
        `BRA:   takb = 1'b1;
101
        `BRN:   takb = 1'b0;
102
        `BEQ:   takb = eqi;
103
        `BNE:   takb = !eqi;
104
        `BLT:   takb = lti;
105
        `BLE:   takb = lti|eqi;
106
        `BGT:   takb = !(lti|eqi);
107
        `BGE:   takb = !lti;
108
        `BLTU:  takb = ltui;
109
        `BLEU:  takb = ltui|eqi;
110
        `BGTU:  takb = !(ltui|eqi);
111
        `BGEU:  takb = !ltui;
112
        default:        takb = 1'b0;
113
        endcase
114
`TRAPcc:
115
        case(func4)
116
        `TEQ:   takb = eq;
117
        `TNE:   takb = !eq;
118
        `TLT:   takb = lt;
119
        `TLE:   takb = lt|eq;
120
        `TGT:   takb = !(lt|eq);
121
        `TGE:   takb = !lt;
122
        `TLTU:  takb = ltu;
123
        `TLEU:  takb = ltu|eq;
124
        `TGTU:  takb = !(ltu|eq);
125
        `TGEU:  takb = !ltu;
126
        default:        takb = 1'b0;
127
        endcase
128
`TRAPcci:
129
        case(cond4)
130
        `TEQI:  takb = eqi;
131
        `TNEI:  takb = !eqi;
132
        `TLTI:  takb = lti;
133
        `TLEI:  takb = lti|eqi;
134
        `TGTI:  takb = !(lti|eqi);
135
        `TGEI:  takb = !lti;
136
        `TLTUI: takb = ltui;
137
        `TLEUI: takb = ltui|eqi;
138
        `TGTUI: takb = !(ltui|eqi);
139
        `TGEUI: takb = !ltui;
140
        default:        takb = 1'b0;
141
        endcase
142
default:
143
        takb = 1'b0;
144
endcase
145
 
146
endmodule
147
 

powered by: WebSVN 2.1.0

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