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

Subversion Repositories thor

[/] [thor/] [trunk/] [FT64/] [rtl/] [common/] [FT64_EvalBranch.v] - Blame information for rev 43

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 43 robfinch
// ============================================================================
2
//        __
3
//   \\__/ o\    (C) 2017-2018  Robert Finch, Waterloo
4
//    \  __ /    All rights reserved.
5
//     \/_//     robfinch<remove>@finitron.ca
6
//       ||
7
//
8
// FT64_EvalBranch.v
9
// - FT64 branch evaluation
10
//
11
// This source file is free software: you can redistribute it and/or modify 
12
// it under the terms of the GNU Lesser General Public License as published 
13
// by the Free Software Foundation, either version 3 of the License, or     
14
// (at your option) any later version.                                      
15
//                                                                          
16
// This source file is distributed in the hope that it will be useful,      
17
// but WITHOUT ANY WARRANTY; without even the implied warranty of           
18
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            
19
// GNU General Public License for more details.                             
20
//                                                                          
21
// You should have received a copy of the GNU General Public License        
22
// along with this program.  If not, see <http://www.gnu.org/licenses/>.    
23
//
24
// ============================================================================
25
//
26
`define BccR    6'h03
27
`define BBc0    6'h26
28
`define BBc1    6'h27
29
`define Bcc0    6'h30
30
`define Bcc1    6'h31
31
`define BEQ0    6'h32
32
`define BEQ1    6'h33
33
`define CHK             6'h34
34
 
35
`define BEQ             4'h0
36
`define BNE             4'h1
37
`define BLT             4'h2
38
`define BGE             4'h3
39
`define BLTU    4'h4
40
`define BGEU    4'h5
41
`define FBEQ    4'h8
42
`define FBNE    4'h9
43
`define FBLT    4'hA
44
`define FBGE    4'hB
45
`define FBUN    4'hC
46
 
47
`define DBNZ    3'd7
48
 
49
module FT64_EvalBranch(instr, a, b, c, takb);
50
parameter WID=64;
51
input [31:0] instr;
52
input [WID-1:0] a;
53
input [WID-1:0] b;
54
input [WID-1:0] c;
55
output reg takb;
56
 
57
wire [5:0] opcode = instr[5:0];
58
wire [4:0] fcmpo;
59
wire fnanx;
60
fp_cmp_unit #(WID) ufcmp1 (a, b, fcmpo, fnanx);
61
 
62
//Evaluate branch condition
63
always @*
64
case(opcode)
65
`BccR:
66
        case(instr[24:21])
67
        `BEQ:   takb <= a==b;
68
        `BNE:   takb <= a!=b;
69
        `BLT:   takb <= $signed(a) < $signed(b);
70
        `BGE:   takb <= $signed(a) >= $signed(b);
71
        `BLTU:  takb <= a < b;
72
        `BGEU:  takb <= a >= b;
73
        `FBEQ:  takb <=  fcmpo[0];
74
        `FBNE:  takb <= ~fcmpo[0];
75
        `FBLT:  takb <=  fcmpo[1];
76
        `FBGE:  takb <= ~fcmpo[2];
77
        `FBUN:  takb <=  fcmpo[4];
78
        default:        takb <= `TRUE;
79
        endcase
80
`Bcc0,`Bcc1:
81
        case(instr[19:16])
82
        `BEQ:   takb <= a==b;
83
        `BNE:   takb <= a!=b;
84
        `BLT:   takb <= $signed(a) < $signed(b);
85
        `BGE:   takb <= $signed(a) >= $signed(b);
86
        `BLTU:  takb <= a < b;
87
        `BGEU:  takb <= a >= b;
88
        `FBEQ:  takb <=  fcmpo[0];
89
        `FBNE:  takb <= ~fcmpo[0];
90
        `FBLT:  takb <=  fcmpo[1];
91
        `FBGE:  takb <= ~fcmpo[2];
92
        `FBUN:  takb <=  fcmpo[4];
93
        default:        takb <= `TRUE;
94
        endcase
95
`BEQ0,`BEQ1:    takb <= a=={{55{instr[19]}},instr[19:11]};
96
`BBc0,`BBc1:
97
        case(instr[19:17])
98
        3'd0:   takb <=  a[instr[16:11]];       // BBS
99
        3'd1:   takb <= ~a[instr[16:11]];       // BBC
100
        `DBNZ:  takb <=  a=={58'h0,instr[16:11]};
101
        default:        takb <= `TRUE;
102
        endcase
103
`CHK:   takb <= a >= b && a < c;
104
default:        takb <= `TRUE;
105
endcase
106
 
107
endmodule

powered by: WebSVN 2.1.0

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