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

Subversion Repositories or1200_hp

[/] [or1200_hp/] [trunk/] [rtl/] [rtl_cm4/] [verilog/] [or1200_operandmuxes.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 tobil
//////////////////////////////////////////////////////////////////////
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/cores/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
// CVS Revision History
45
//
46
// $Log: not supported by cvs2svn $
47
// Revision 1.1  2002/01/03 08:16:15  lampret
48
// New prefixes for RTL files, prefixed module names. Updated cache controllers and MMUs.
49
//
50
// Revision 1.9  2001/11/12 01:45:40  lampret
51
// Moved flag bit into SR. Changed RF enable from constant enable to dynamic enable for read ports.
52
//
53
// Revision 1.8  2001/10/21 17:57:16  lampret
54
// Removed params from generic_XX.v. Added translate_off/on in sprs.v and id.v. Removed spr_addr from dc.v and ic.v. Fixed CR+LF.
55
//
56
// Revision 1.7  2001/10/14 13:12:09  lampret
57
// MP3 version.
58
//
59
// Revision 1.1.1.1  2001/10/06 10:18:36  igorm
60
// no message
61
//
62
// Revision 1.2  2001/08/09 13:39:33  lampret
63
// Major clean-up.
64
//
65
// Revision 1.1  2001/07/20 00:46:05  lampret
66
// Development version of RTL. Libraries are missing.
67
//
68
//
69
 
70
// synopsys translate_off
71
`include "timescale.v"
72
// synopsys translate_on
73
`include "or1200_defines.v"
74
 
75
module or1200_operandmuxes_cm4(
76
                clk_i_cml_1,
77
                clk_i_cml_2,
78
                clk_i_cml_3,
79
 
80
        // Clock and reset
81
        clk, rst,
82
 
83
        // Internal i/f
84
        id_freeze, ex_freeze, rf_dataa, rf_datab, ex_forw, wb_forw,
85
        simm, sel_a, sel_b, operand_a, operand_b, muxed_b
86
);
87
 
88
 
89
input clk_i_cml_1;
90
input clk_i_cml_2;
91
input clk_i_cml_3;
92
reg  ex_freeze_cml_3;
93
reg [ 32 - 1 : 0 ] ex_forw_cml_3;
94
reg [ 32 - 1 : 0 ] wb_forw_cml_3;
95
reg [ 32 - 1 : 0 ] wb_forw_cml_2;
96
reg [ 32 - 1 : 0 ] wb_forw_cml_1;
97
reg [ 32 - 1 : 0 ] operand_a_cml_3;
98
reg [ 32 - 1 : 0 ] operand_a_cml_2;
99
reg [ 32 - 1 : 0 ] operand_a_cml_1;
100
reg [ 32 - 1 : 0 ] operand_b_cml_3;
101
reg [ 32 - 1 : 0 ] operand_b_cml_2;
102
reg [ 32 - 1 : 0 ] operand_b_cml_1;
103
reg  saved_a_cml_3;
104
reg  saved_a_cml_2;
105
reg  saved_a_cml_1;
106
reg  saved_b_cml_3;
107
reg  saved_b_cml_2;
108
reg  saved_b_cml_1;
109
 
110
 
111
 
112
parameter width = `OR1200_OPERAND_WIDTH;
113
 
114
//
115
// I/O
116
//
117
input                           clk;
118
input                           rst;
119
input                           id_freeze;
120
input                           ex_freeze;
121
input   [width-1:0]              rf_dataa;
122
input   [width-1:0]              rf_datab;
123
input   [width-1:0]              ex_forw;
124
input   [width-1:0]              wb_forw;
125
input   [width-1:0]              simm;
126
input   [`OR1200_SEL_WIDTH-1:0]  sel_a;
127
input   [`OR1200_SEL_WIDTH-1:0]  sel_b;
128
output  [width-1:0]              operand_a;
129
output  [width-1:0]              operand_b;
130
output  [width-1:0]              muxed_b;
131
 
132
//
133
// Internal wires and regs
134
//
135
reg     [width-1:0]              operand_a;
136
reg     [width-1:0]              operand_b;
137
reg     [width-1:0]              muxed_a;
138
reg     [width-1:0]              muxed_b;
139
reg                             saved_a;
140
reg                             saved_b;
141
 
142
//
143
// Operand A register
144
//
145
 
146
// SynEDA CoreMultiplier
147
// assignment(s): operand_a, saved_a
148
// replace(s): ex_freeze, operand_a, saved_a
149
always @(posedge clk or posedge rst) begin
150
        if (rst) begin
151
                operand_a <= #1 32'd0;
152
                saved_a <= #1 1'b0;
153
        end else begin  saved_a <= saved_a_cml_3; operand_a <= operand_a_cml_3; if (!ex_freeze_cml_3 && id_freeze && !saved_a_cml_3) begin
154
                operand_a <= #1 muxed_a;
155
                saved_a <= #1 1'b1;
156
        end else if (!ex_freeze_cml_3 && !saved_a_cml_3) begin
157
                operand_a <= #1 muxed_a;
158
        end else if (!ex_freeze_cml_3 && !id_freeze)
159
                saved_a <= #1 1'b0; end
160
end
161
 
162
//
163
// Operand B register
164
//
165
 
166
// SynEDA CoreMultiplier
167
// assignment(s): operand_b, saved_b
168
// replace(s): ex_freeze, operand_b, saved_b
169
always @(posedge clk or posedge rst) begin
170
        if (rst) begin
171
                operand_b <= #1 32'd0;
172
                saved_b <= #1 1'b0;
173
        end else begin  saved_b <= saved_b_cml_3; operand_b <= operand_b_cml_3; if (!ex_freeze_cml_3 && id_freeze && !saved_b_cml_3) begin
174
                operand_b <= #1 muxed_b;
175
                saved_b <= #1 1'b1;
176
        end else if (!ex_freeze_cml_3 && !saved_b_cml_3) begin
177
                operand_b <= #1 muxed_b;
178
        end else if (!ex_freeze_cml_3 && !id_freeze)
179
                saved_b <= #1 1'b0; end
180
end
181
 
182
//
183
// Forwarding logic for operand A register
184
//
185
 
186
// SynEDA CoreMultiplier
187
// assignment(s): muxed_a
188
// replace(s): ex_forw, wb_forw
189
always @(ex_forw_cml_3 or wb_forw_cml_3 or rf_dataa or sel_a) begin
190
`ifdef OR1200_ADDITIONAL_SYNOPSYS_DIRECTIVES
191
        casex (sel_a)   // synopsys parallel_case infer_mux
192
`else
193
        casex (sel_a)   // synopsys parallel_case
194
`endif
195
                `OR1200_SEL_EX_FORW:
196
                        muxed_a = ex_forw_cml_3;
197
                `OR1200_SEL_WB_FORW:
198
                        muxed_a = wb_forw_cml_3;
199
                default:
200
                        muxed_a = rf_dataa;
201
        endcase
202
end
203
 
204
//
205
// Forwarding logic for operand B register
206
//
207
 
208
// SynEDA CoreMultiplier
209
// assignment(s): muxed_b
210
// replace(s): ex_forw, wb_forw
211
always @(simm or ex_forw_cml_3 or wb_forw_cml_3 or rf_datab or sel_b) begin
212
`ifdef OR1200_ADDITIONAL_SYNOPSYS_DIRECTIVES
213
        casex (sel_b)   // synopsys parallel_case infer_mux
214
`else
215
        casex (sel_b)   // synopsys parallel_case
216
`endif
217
                `OR1200_SEL_IMM:
218
                        muxed_b = simm;
219
                `OR1200_SEL_EX_FORW:
220
                        muxed_b = ex_forw_cml_3;
221
                `OR1200_SEL_WB_FORW:
222
                        muxed_b = wb_forw_cml_3;
223
                default:
224
                        muxed_b = rf_datab;
225
        endcase
226
end
227
 
228
 
229
always @ (posedge clk_i_cml_1) begin
230
wb_forw_cml_1 <= wb_forw;
231
operand_a_cml_1 <= operand_a;
232
operand_b_cml_1 <= operand_b;
233
saved_a_cml_1 <= saved_a;
234
saved_b_cml_1 <= saved_b;
235
end
236
always @ (posedge clk_i_cml_2) begin
237
wb_forw_cml_2 <= wb_forw_cml_1;
238
operand_a_cml_2 <= operand_a_cml_1;
239
operand_b_cml_2 <= operand_b_cml_1;
240
saved_a_cml_2 <= saved_a_cml_1;
241
saved_b_cml_2 <= saved_b_cml_1;
242
end
243
always @ (posedge clk_i_cml_3) begin
244
ex_freeze_cml_3 <= ex_freeze;
245
ex_forw_cml_3 <= ex_forw;
246
wb_forw_cml_3 <= wb_forw_cml_2;
247
operand_a_cml_3 <= operand_a_cml_2;
248
operand_b_cml_3 <= operand_b_cml_2;
249
saved_a_cml_3 <= saved_a_cml_2;
250
saved_b_cml_3 <= saved_b_cml_2;
251
end
252
endmodule
253
 

powered by: WebSVN 2.1.0

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