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

Subversion Repositories or1200_hp

[/] [or1200_hp/] [trunk/] [rtl/] [rtl_cm3/] [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_cm3(
76
                clk_i_cml_1,
77
                clk_i_cml_2,
78
 
79
        // Clock and reset
80
        clk, rst,
81
 
82
        // Internal i/f
83
        id_freeze, ex_freeze, rf_dataa, rf_datab, ex_forw, wb_forw,
84
        simm, sel_a, sel_b, operand_a, operand_b, muxed_b
85
);
86
 
87
 
88
input clk_i_cml_1;
89
input clk_i_cml_2;
90
reg  ex_freeze_cml_2;
91
reg [ 32 - 1 : 0 ] ex_forw_cml_2;
92
reg [ 32 - 1 : 0 ] wb_forw_cml_2;
93
reg [ 32 - 1 : 0 ] wb_forw_cml_1;
94
reg [ 32 - 1 : 0 ] operand_a_cml_2;
95
reg [ 32 - 1 : 0 ] operand_a_cml_1;
96
reg [ 32 - 1 : 0 ] operand_b_cml_2;
97
reg [ 32 - 1 : 0 ] operand_b_cml_1;
98
reg  saved_a_cml_2;
99
reg  saved_a_cml_1;
100
reg  saved_b_cml_2;
101
reg  saved_b_cml_1;
102
 
103
 
104
 
105
parameter width = `OR1200_OPERAND_WIDTH;
106
 
107
//
108
// I/O
109
//
110
input                           clk;
111
input                           rst;
112
input                           id_freeze;
113
input                           ex_freeze;
114
input   [width-1:0]              rf_dataa;
115
input   [width-1:0]              rf_datab;
116
input   [width-1:0]              ex_forw;
117
input   [width-1:0]              wb_forw;
118
input   [width-1:0]              simm;
119
input   [`OR1200_SEL_WIDTH-1:0]  sel_a;
120
input   [`OR1200_SEL_WIDTH-1:0]  sel_b;
121
output  [width-1:0]              operand_a;
122
output  [width-1:0]              operand_b;
123
output  [width-1:0]              muxed_b;
124
 
125
//
126
// Internal wires and regs
127
//
128
reg     [width-1:0]              operand_a;
129
reg     [width-1:0]              operand_b;
130
reg     [width-1:0]              muxed_a;
131
reg     [width-1:0]              muxed_b;
132
reg                             saved_a;
133
reg                             saved_b;
134
 
135
//
136
// Operand A register
137
//
138
 
139
// SynEDA CoreMultiplier
140
// assignment(s): operand_a, saved_a
141
// replace(s): ex_freeze, operand_a, saved_a
142
always @(posedge clk or posedge rst) begin
143
        if (rst) begin
144
                operand_a <= #1 32'd0;
145
                saved_a <= #1 1'b0;
146
        end else begin  saved_a <= saved_a_cml_2; operand_a <= operand_a_cml_2; if (!ex_freeze_cml_2 && id_freeze && !saved_a_cml_2) begin
147
                operand_a <= #1 muxed_a;
148
                saved_a <= #1 1'b1;
149
        end else if (!ex_freeze_cml_2 && !saved_a_cml_2) begin
150
                operand_a <= #1 muxed_a;
151
        end else if (!ex_freeze_cml_2 && !id_freeze)
152
                saved_a <= #1 1'b0; end
153
end
154
 
155
//
156
// Operand B register
157
//
158
 
159
// SynEDA CoreMultiplier
160
// assignment(s): operand_b, saved_b
161
// replace(s): ex_freeze, operand_b, saved_b
162
always @(posedge clk or posedge rst) begin
163
        if (rst) begin
164
                operand_b <= #1 32'd0;
165
                saved_b <= #1 1'b0;
166
        end else begin  saved_b <= saved_b_cml_2; operand_b <= operand_b_cml_2; if (!ex_freeze_cml_2 && id_freeze && !saved_b_cml_2) begin
167
                operand_b <= #1 muxed_b;
168
                saved_b <= #1 1'b1;
169
        end else if (!ex_freeze_cml_2 && !saved_b_cml_2) begin
170
                operand_b <= #1 muxed_b;
171
        end else if (!ex_freeze_cml_2 && !id_freeze)
172
                saved_b <= #1 1'b0; end
173
end
174
 
175
//
176
// Forwarding logic for operand A register
177
//
178
 
179
// SynEDA CoreMultiplier
180
// assignment(s): muxed_a
181
// replace(s): ex_forw, wb_forw
182
always @(ex_forw_cml_2 or wb_forw_cml_2 or rf_dataa or sel_a) begin
183
`ifdef OR1200_ADDITIONAL_SYNOPSYS_DIRECTIVES
184
        casex (sel_a)   // synopsys parallel_case infer_mux
185
`else
186
        casex (sel_a)   // synopsys parallel_case
187
`endif
188
                `OR1200_SEL_EX_FORW:
189
                        muxed_a = ex_forw_cml_2;
190
                `OR1200_SEL_WB_FORW:
191
                        muxed_a = wb_forw_cml_2;
192
                default:
193
                        muxed_a = rf_dataa;
194
        endcase
195
end
196
 
197
//
198
// Forwarding logic for operand B register
199
//
200
 
201
// SynEDA CoreMultiplier
202
// assignment(s): muxed_b
203
// replace(s): ex_forw, wb_forw
204
always @(simm or ex_forw_cml_2 or wb_forw_cml_2 or rf_datab or sel_b) begin
205
`ifdef OR1200_ADDITIONAL_SYNOPSYS_DIRECTIVES
206
        casex (sel_b)   // synopsys parallel_case infer_mux
207
`else
208
        casex (sel_b)   // synopsys parallel_case
209
`endif
210
                `OR1200_SEL_IMM:
211
                        muxed_b = simm;
212
                `OR1200_SEL_EX_FORW:
213
                        muxed_b = ex_forw_cml_2;
214
                `OR1200_SEL_WB_FORW:
215
                        muxed_b = wb_forw_cml_2;
216
                default:
217
                        muxed_b = rf_datab;
218
        endcase
219
end
220
 
221
 
222
always @ (posedge clk_i_cml_1) begin
223
wb_forw_cml_1 <= wb_forw;
224
operand_a_cml_1 <= operand_a;
225
operand_b_cml_1 <= operand_b;
226
saved_a_cml_1 <= saved_a;
227
saved_b_cml_1 <= saved_b;
228
end
229
always @ (posedge clk_i_cml_2) begin
230
ex_freeze_cml_2 <= ex_freeze;
231
ex_forw_cml_2 <= ex_forw;
232
wb_forw_cml_2 <= wb_forw_cml_1;
233
operand_a_cml_2 <= operand_a_cml_1;
234
operand_b_cml_2 <= operand_b_cml_1;
235
saved_a_cml_2 <= saved_a_cml_1;
236
saved_b_cml_2 <= saved_b_cml_1;
237
end
238
endmodule
239
 

powered by: WebSVN 2.1.0

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