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

Subversion Repositories thor

[/] [thor/] [trunk/] [FT64v5/] [rtl/] [common/] [FT64_EvalBranch.v] - Blame information for rev 48

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 48 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 TRUE    1'b1
27
`define BBc             6'h26
28
`define Bcc             6'h30
29
`define BEQI    6'h32
30
`define BCHK    6'h33
31
`define CHK             6'h34
32
 
33
`define BEQ             3'h0
34
`define BNE             3'h1
35
`define BLT             3'h2
36
`define BGE             3'h3
37
`define BLTU    3'h6
38
`define BGEU    3'h7
39
 
40
`define IBNE    2'd2
41
`define DBNZ    2'd3
42
 
43
module FT64_EvalBranch(instr, a, b, c, takb);
44
parameter WID=64;
45
input [47:0] instr;
46
input [WID-1:0] a;
47
input [WID-1:0] b;
48
input [WID-1:0] c;
49
output reg takb;
50
 
51
wire [5:0] opcode = instr[5:0];
52
 
53
//Evaluate branch condition
54
always @*
55
case(opcode)
56
`Bcc:
57
        case(instr[20:18])
58
        `BEQ:   takb <= a==b;
59
        `BNE:   takb <= a!=b;
60
        `BLT:   takb <= $signed(a) < $signed(b);
61
        `BGE:   takb <= $signed(a) >= $signed(b);
62
        `BLTU:  takb <= a < b;
63
        `BGEU:  takb <= a >= b;
64
        default:        takb <= `TRUE;
65
        endcase
66
`BEQI:  takb <= a=={{56{instr[20]}},instr[20:13]};
67
`BBc:
68
        case(instr[20:19])
69
        2'd0:   takb <=  a[instr[18:13]];       // BBS
70
        2'd1:   takb <= ~a[instr[18:13]];       // BBC
71
        `IBNE:  takb <=  (a + 64'd1) !=b;
72
        `DBNZ:  takb <=  (a - 64'd1) !=b;
73
        default:        takb <= `TRUE;
74
        endcase
75
`CHK,`BCHK:     takb <= a >= b && a < c;
76
default:        takb <= `TRUE;
77
endcase
78
 
79
endmodule

powered by: WebSVN 2.1.0

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