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

Subversion Repositories thor

[/] [thor/] [trunk/] [FT64v7/] [rtl/] [common/] [FT64_EvalBranch.v] - Blame information for rev 61

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 60 robfinch
// ============================================================================
2
//        __
3 61 robfinch
//   \\__/ o\    (C) 2017-2019  Robert Finch, Waterloo
4 60 robfinch
//    \  __ /    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 TRUE    1'b1
27 61 robfinch
`define BNEI    6'h12
28 60 robfinch
`define BBc             6'h26
29
`define Bcc             6'h30
30
`define BEQI    6'h32
31
`define BCHK    6'h33
32
`define CHK             6'h34
33
 
34
`define BEQ             3'h0
35
`define BNE             3'h1
36
`define BLT             3'h2
37
`define BGE             3'h3
38
`define BLTU    3'h6
39
`define BGEU    3'h7
40 61 robfinch
`define BAND    3'h0
41
`define BOR             3'h1
42
`define BXOR    3'd2
43
`define BNAND   3'h4
44
`define BNOR    3'h5
45
`define BXNOR   3'd6
46 60 robfinch
 
47
`define IBNE    2'd2
48
`define DBNZ    2'd3
49
 
50
module FT64_EvalBranch(instr, a, b, c, takb);
51
parameter WID=64;
52
input [47:0] instr;
53
input [WID-1:0] a;
54
input [WID-1:0] b;
55
input [WID-1:0] c;
56
output reg takb;
57
 
58
wire [5:0] opcode = instr[5:0];
59
 
60
//Evaluate branch condition
61
always @*
62
case(opcode)
63
`Bcc:
64
        case(instr[15:13])
65
        `BEQ:   takb <= a==b;
66
        `BNE:   takb <= a!=b;
67
        `BLT:   takb <= $signed(a) < $signed(b);
68
        `BGE:   takb <= $signed(a) >= $signed(b);
69
        `BLTU:  takb <= a < b;
70
        `BGEU:  takb <= a >= b;
71
        default:        takb <= `TRUE;
72
        endcase
73 61 robfinch
`BLcc:
74
        case(instr[15:13])
75
        `BAND:  takb <= a != 0 && b != 0;
76
        `BOR:           takb <= a != 0 || b != 0;
77
        `BXOR:  takb <= (a != 0) ^ (b != 0);
78
        `BNAND: takb <= !(a != 0 && b != 0);
79
        `BNOR:  takb <= !(a != 0 || b != 0);
80
        `BXNOR: takb <= !((a != 0) ^ (b != 0));
81
        default:        takb <= `TRUE;
82
        endcase
83 60 robfinch
`BEQI:  takb <= a=={{56{instr[22]}},instr[22:18],instr[15:13]};
84 61 robfinch
`BNEI:  takb <= a!={{56{instr[22]}},instr[22:18],instr[15:13]};
85 60 robfinch
`BBc:
86
        case(instr[14:13])
87
        2'd0:   takb <=  a[{instr[22:18],instr[15]}];   // BBS
88
        2'd1:   takb <= ~a[{instr[22:18],instr[15]}];   // BBC
89
        `IBNE:  takb <=  (a + 64'd1) !=b;
90
        `DBNZ:  takb <=  (a - 64'd1) !=b;
91
        default:        takb <= `TRUE;
92
        endcase
93
`CHK,`BCHK:     takb <= a >= b && a < c;
94
default:        takb <= `TRUE;
95
endcase
96
 
97
endmodule

powered by: WebSVN 2.1.0

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