OpenCores
URL https://opencores.org/ocsvn/an-fpga-implementation-of-low-latency-noc-based-mpsoc/an-fpga-implementation-of-low-latency-noc-based-mpsoc/trunk

Subversion Repositories an-fpga-implementation-of-low-latency-noc-based-mpsoc

[/] [an-fpga-implementation-of-low-latency-noc-based-mpsoc/] [trunk/] [mpsoc/] [src_processor/] [mor1kx-5.0/] [rtl/] [verilog/] [mor1kx_branch_prediction.v] - Blame information for rev 48

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 48 alirezamon
/******************************************************************************
2
 This Source Code Form is subject to the terms of the
3
 Open Hardware Description License, v. 1.0. If a copy
4
 of the OHDL was not distributed with this file, You
5
 can obtain one at http://juliusbaxter.net/ohdl/ohdl.txt
6
 
7
 Description: Branch prediction module
8
 Generates a predicted flag output and compares that to the real flag
9
 when it comes back in the following pipeline stage.
10
 Signals are deliberately not named after the pipeline stage they belong to,
11
 in order to keep this module generic.
12
 
13
 Copyright (C) 2013 Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>
14
 Copyright (C) 2016 Alexey Baturo <baturo.alexey@gmail.com>
15
 
16
 ******************************************************************************/
17
 
18
`include "mor1kx-defines.v"
19
 
20
module mor1kx_branch_prediction
21
  #(
22
    parameter [95:0] FEATURE_BRANCH_PREDICTOR = "SIMPLE",
23
    parameter OPTION_OPERAND_WIDTH = 32
24
    )
25
   (
26
   input clk,
27
   input rst,
28
 
29
   // Signals belonging to the stage where the branch is predicted.
30
   input op_bf_i,               // from decode stage, brn is bf
31
   input op_bnf_i,              // from decode stage, brn is bnf
32
   input [9:0] immjbr_upper_i,  // from decode stage, imm
33
   input [OPTION_OPERAND_WIDTH - 1:0] brn_pc_i, // pc of brn being predicted
34
   output predicted_flag_o,     // to decode-execute stage, flag we predict to be
35
 
36
   // Signals belonging to the stage where the branch is resolved.
37
   input prev_op_brcond_i,      // from decode-execute stage, prev brn was cond
38
   input prev_predicted_flag_i, // from decode-execute, prev predicted flag
39
   input flag_i,                // from execute-ctrl stage, real flag we got
40
 
41
   input padv_decode_i,         // is decode stage stalled
42
   input execute_bf_i,          // prev insn was bf
43
   input execute_bnf_i,         // prev insn was bnf
44
 
45
   // Branch misprediction indicator
46
   output       branch_mispredict_o // to decode-execute stage, was brn mispredicted or not
47
   );
48
 
49
   // Compare the real flag with the previously predicted flag and signal a
50
   // misprediction in case of a mismatch.
51
   assign branch_mispredict_o = prev_op_brcond_i & (flag_i != prev_predicted_flag_i);
52
 
53
generate
54
if (FEATURE_BRANCH_PREDICTOR=="SAT_COUNTER") begin : branch_predictor_saturation_counter
55
   mor1kx_branch_predictor_saturation_counter
56
      mor1kx_branch_predictor_saturation_counter
57
      (
58
         // Outputs
59
         .predicted_flag_o                 (predicted_flag_o),
60
         // Inputs
61
         .clk                              (clk),
62
         .rst                              (rst),
63
         .flag_i                           (flag_i),
64
         .execute_op_bf_i                  (execute_bf_i),
65
         .execute_op_bnf_i                 (execute_bnf_i),
66
         .op_bf_i                          (op_bf_i),
67
         .op_bnf_i                         (op_bnf_i),
68
         .prev_op_brcond_i                 (prev_op_brcond_i),
69
         .padv_decode_i                    (padv_decode_i),
70
         .branch_mispredict_i              (branch_mispredict_o));
71
 
72
end else if (FEATURE_BRANCH_PREDICTOR=="GSHARE") begin : branch_predictor_gshare
73
   mor1kx_branch_predictor_gshare
74
     #(
75
       .OPTION_OPERAND_WIDTH(OPTION_OPERAND_WIDTH)
76
       )
77
      mor1kx_branch_predictor_gshare
78
      (
79
         // Outputs
80
         .predicted_flag_o                 (predicted_flag_o),
81
         // Inputs
82
         .clk                              (clk),
83
         .rst                              (rst),
84
         .flag_i                           (flag_i),
85
         .execute_op_bf_i                  (execute_bf_i),
86
         .execute_op_bnf_i                 (execute_bnf_i),
87
         .op_bf_i                          (op_bf_i),
88
         .brn_pc_i                         (brn_pc_i),
89
         .op_bnf_i                         (op_bnf_i),
90
         .prev_op_brcond_i                 (prev_op_brcond_i),
91
         .padv_decode_i                    (padv_decode_i),
92
         .branch_mispredict_i              (branch_mispredict_o));
93
 
94
end else if (FEATURE_BRANCH_PREDICTOR=="SIMPLE") begin : branch_predictor_simple
95
   mor1kx_branch_predictor_simple
96
      mor1kx_branch_predictor_simple
97
      (
98
         // Outputs
99
         .predicted_flag_o                 (predicted_flag_o),
100
         // Inputs
101
         .op_bf_i                          (op_bf_i),
102
         .op_bnf_i                         (op_bnf_i),
103
         .immjbr_upper_i                   (immjbr_upper_i));
104
 
105
end else begin
106
   initial begin
107
      $display("Error: FEATURE_PREDICTOR_TYPE, %s, not valid", FEATURE_BRANCH_PREDICTOR);
108
      $finish();
109
   end
110
end
111
endgenerate
112
 
113
endmodule

powered by: WebSVN 2.1.0

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