| 1 |
350 |
julius |
//////////////////////////////////////////////////////////////////////
|
| 2 |
|
|
//// ////
|
| 3 |
|
|
//// OR1200's register file read operands mux ////
|
| 4 |
|
|
//// ////
|
| 5 |
|
|
//// This file is part of the OpenRISC 1200 project ////
|
| 6 |
|
|
//// http://www.opencores.org/project,or1k ////
|
| 7 |
|
|
//// ////
|
| 8 |
|
|
//// Description ////
|
| 9 |
|
|
//// Mux for two register file read operands. ////
|
| 10 |
|
|
//// ////
|
| 11 |
|
|
//// To Do: ////
|
| 12 |
|
|
//// - make it smaller and faster ////
|
| 13 |
|
|
//// ////
|
| 14 |
|
|
//// Author(s): ////
|
| 15 |
|
|
//// - Damjan Lampret, lampret@opencores.org ////
|
| 16 |
|
|
//// ////
|
| 17 |
|
|
//////////////////////////////////////////////////////////////////////
|
| 18 |
|
|
//// ////
|
| 19 |
|
|
//// Copyright (C) 2000 Authors and OPENCORES.ORG ////
|
| 20 |
|
|
//// ////
|
| 21 |
|
|
//// This source file may be used and distributed without ////
|
| 22 |
|
|
//// restriction provided that this copyright statement is not ////
|
| 23 |
|
|
//// removed from the file and that any derivative work contains ////
|
| 24 |
|
|
//// the original copyright notice and the associated disclaimer. ////
|
| 25 |
|
|
//// ////
|
| 26 |
|
|
//// This source file is free software; you can redistribute it ////
|
| 27 |
|
|
//// and/or modify it under the terms of the GNU Lesser General ////
|
| 28 |
|
|
//// Public License as published by the Free Software Foundation; ////
|
| 29 |
|
|
//// either version 2.1 of the License, or (at your option) any ////
|
| 30 |
|
|
//// later version. ////
|
| 31 |
|
|
//// ////
|
| 32 |
|
|
//// This source is distributed in the hope that it will be ////
|
| 33 |
|
|
//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
|
| 34 |
|
|
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
|
| 35 |
|
|
//// PURPOSE. See the GNU Lesser General Public License for more ////
|
| 36 |
|
|
//// details. ////
|
| 37 |
|
|
//// ////
|
| 38 |
|
|
//// You should have received a copy of the GNU Lesser General ////
|
| 39 |
|
|
//// Public License along with this source; if not, download it ////
|
| 40 |
|
|
//// from http://www.opencores.org/lgpl.shtml ////
|
| 41 |
|
|
//// ////
|
| 42 |
|
|
//////////////////////////////////////////////////////////////////////
|
| 43 |
|
|
//
|
| 44 |
|
|
// $Log: or1200_operandmuxes.v,v $
|
| 45 |
|
|
// Revision 2.0 2010/06/30 11:00:00 ORSoC
|
| 46 |
|
|
// Minor update:
|
| 47 |
|
|
// Bugs fixed.
|
| 48 |
|
|
|
| 49 |
|
|
// synopsys translate_off
|
| 50 |
|
|
`include "timescale.v"
|
| 51 |
|
|
// synopsys translate_on
|
| 52 |
|
|
`include "or1200_defines.v"
|
| 53 |
|
|
|
| 54 |
|
|
module or1200_operandmuxes(
|
| 55 |
|
|
// Clock and reset
|
| 56 |
|
|
clk, rst,
|
| 57 |
|
|
|
| 58 |
|
|
// Internal i/f
|
| 59 |
|
|
id_freeze, ex_freeze, rf_dataa, rf_datab, ex_forw, wb_forw,
|
| 60 |
|
|
simm, sel_a, sel_b, operand_a, operand_b, muxed_a, muxed_b
|
| 61 |
|
|
);
|
| 62 |
|
|
|
| 63 |
|
|
parameter width = `OR1200_OPERAND_WIDTH;
|
| 64 |
|
|
|
| 65 |
|
|
//
|
| 66 |
|
|
// I/O
|
| 67 |
|
|
//
|
| 68 |
|
|
input clk;
|
| 69 |
|
|
input rst;
|
| 70 |
|
|
input id_freeze;
|
| 71 |
|
|
input ex_freeze;
|
| 72 |
|
|
input [width-1:0] rf_dataa;
|
| 73 |
|
|
input [width-1:0] rf_datab;
|
| 74 |
|
|
input [width-1:0] ex_forw;
|
| 75 |
|
|
input [width-1:0] wb_forw;
|
| 76 |
|
|
input [width-1:0] simm;
|
| 77 |
|
|
input [`OR1200_SEL_WIDTH-1:0] sel_a;
|
| 78 |
|
|
input [`OR1200_SEL_WIDTH-1:0] sel_b;
|
| 79 |
|
|
output [width-1:0] operand_a;
|
| 80 |
|
|
output [width-1:0] operand_b;
|
| 81 |
|
|
output [width-1:0] muxed_a;
|
| 82 |
|
|
output [width-1:0] muxed_b;
|
| 83 |
|
|
|
| 84 |
|
|
//
|
| 85 |
|
|
// Internal wires and regs
|
| 86 |
|
|
//
|
| 87 |
|
|
reg [width-1:0] operand_a;
|
| 88 |
|
|
reg [width-1:0] operand_b;
|
| 89 |
|
|
reg [width-1:0] muxed_a;
|
| 90 |
|
|
reg [width-1:0] muxed_b;
|
| 91 |
|
|
reg saved_a;
|
| 92 |
|
|
reg saved_b;
|
| 93 |
|
|
|
| 94 |
|
|
//
|
| 95 |
|
|
// Operand A register
|
| 96 |
|
|
//
|
| 97 |
358 |
julius |
always @(posedge clk or `OR1200_RST_EVENT rst) begin
|
| 98 |
|
|
if (rst == `OR1200_RST_VALUE) begin
|
| 99 |
350 |
julius |
operand_a <= 32'd0;
|
| 100 |
|
|
saved_a <= 1'b0;
|
| 101 |
|
|
end else if (!ex_freeze && id_freeze && !saved_a) begin
|
| 102 |
|
|
operand_a <= muxed_a;
|
| 103 |
|
|
saved_a <= 1'b1;
|
| 104 |
|
|
end else if (!ex_freeze && !saved_a) begin
|
| 105 |
|
|
operand_a <= muxed_a;
|
| 106 |
|
|
end else if (!ex_freeze && !id_freeze)
|
| 107 |
|
|
saved_a <= 1'b0;
|
| 108 |
|
|
end
|
| 109 |
|
|
|
| 110 |
|
|
//
|
| 111 |
|
|
// Operand B register
|
| 112 |
|
|
//
|
| 113 |
358 |
julius |
always @(posedge clk or `OR1200_RST_EVENT rst) begin
|
| 114 |
|
|
if (rst == `OR1200_RST_VALUE) begin
|
| 115 |
350 |
julius |
operand_b <= 32'd0;
|
| 116 |
|
|
saved_b <= 1'b0;
|
| 117 |
|
|
end else if (!ex_freeze && id_freeze && !saved_b) begin
|
| 118 |
|
|
operand_b <= muxed_b;
|
| 119 |
|
|
saved_b <= 1'b1;
|
| 120 |
|
|
end else if (!ex_freeze && !saved_b) begin
|
| 121 |
|
|
operand_b <= muxed_b;
|
| 122 |
|
|
end else if (!ex_freeze && !id_freeze)
|
| 123 |
|
|
saved_b <= 1'b0;
|
| 124 |
|
|
end
|
| 125 |
|
|
|
| 126 |
|
|
//
|
| 127 |
|
|
// Forwarding logic for operand A register
|
| 128 |
|
|
//
|
| 129 |
|
|
always @(ex_forw or wb_forw or rf_dataa or sel_a) begin
|
| 130 |
|
|
`ifdef OR1200_ADDITIONAL_SYNOPSYS_DIRECTIVES
|
| 131 |
363 |
julius |
casez (sel_a) // synopsys parallel_case infer_mux
|
| 132 |
350 |
julius |
`else
|
| 133 |
363 |
julius |
casez (sel_a) // synopsys parallel_case
|
| 134 |
350 |
julius |
`endif
|
| 135 |
|
|
`OR1200_SEL_EX_FORW:
|
| 136 |
|
|
muxed_a = ex_forw;
|
| 137 |
|
|
`OR1200_SEL_WB_FORW:
|
| 138 |
|
|
muxed_a = wb_forw;
|
| 139 |
|
|
default:
|
| 140 |
|
|
muxed_a = rf_dataa;
|
| 141 |
|
|
endcase
|
| 142 |
|
|
end
|
| 143 |
|
|
|
| 144 |
|
|
//
|
| 145 |
|
|
// Forwarding logic for operand B register
|
| 146 |
|
|
//
|
| 147 |
|
|
always @(simm or ex_forw or wb_forw or rf_datab or sel_b) begin
|
| 148 |
|
|
`ifdef OR1200_ADDITIONAL_SYNOPSYS_DIRECTIVES
|
| 149 |
363 |
julius |
casez (sel_b) // synopsys parallel_case infer_mux
|
| 150 |
350 |
julius |
`else
|
| 151 |
363 |
julius |
casez (sel_b) // synopsys parallel_case
|
| 152 |
350 |
julius |
`endif
|
| 153 |
|
|
`OR1200_SEL_IMM:
|
| 154 |
|
|
muxed_b = simm;
|
| 155 |
|
|
`OR1200_SEL_EX_FORW:
|
| 156 |
|
|
muxed_b = ex_forw;
|
| 157 |
|
|
`OR1200_SEL_WB_FORW:
|
| 158 |
|
|
muxed_b = wb_forw;
|
| 159 |
|
|
default:
|
| 160 |
|
|
muxed_b = rf_datab;
|
| 161 |
|
|
endcase
|
| 162 |
|
|
end
|
| 163 |
|
|
|
| 164 |
|
|
endmodule
|