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

Subversion Repositories or1200_hp

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 tobil
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  OR1200's Freeze logic                                       ////
4
////                                                              ////
5
////  This file is part of the OpenRISC 1200 project              ////
6
////  http://www.opencores.org/cores/or1k/                        ////
7
////                                                              ////
8
////  Description                                                 ////
9
////  Generates all freezes and stalls inside RISC                ////
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.7  2004/04/05 08:29:57  lampret
48
// Merged branch_qmem into main tree.
49
//
50
// Revision 1.6.4.2  2003/12/05 00:09:49  lampret
51
// No functional change.
52
//
53
// Revision 1.6.4.1  2003/07/08 15:36:37  lampret
54
// Added embedded memory QMEM.
55
//
56
// Revision 1.6  2002/07/31 02:04:35  lampret
57
// MAC now follows software convention (signed multiply instead of unsigned).
58
//
59
// Revision 1.5  2002/07/14 22:17:17  lampret
60
// Added simple trace buffer [only for Xilinx Virtex target]. Fixed instruction fetch abort when new exception is recognized.
61
//
62
// Revision 1.4  2002/03/29 15:16:55  lampret
63
// Some of the warnings fixed.
64
//
65
// Revision 1.3  2002/01/28 01:16:00  lampret
66
// Changed 'void' nop-ops instead of insn[0] to use insn[16]. Debug unit stalls the tick timer. Prepared new flag generation for add and and insns. Blocked DC/IC while they are turned off. Fixed I/D MMU SPRs layout except WAYs. TODO: smart IC invalidate, l.j 2 and TLB ways.
67
//
68
// Revision 1.2  2002/01/14 06:18:22  lampret
69
// Fixed mem2reg bug in FAST implementation. Updated debug unit to work with new genpc/if.
70
//
71
// Revision 1.1  2002/01/03 08:16:15  lampret
72
// New prefixes for RTL files, prefixed module names. Updated cache controllers and MMUs.
73
//
74
// Revision 1.10  2001/11/13 10:02:21  lampret
75
// Added 'setpc'. Renamed some signals (except_flushpipe into flushpipe etc)
76
//
77
// Revision 1.9  2001/10/21 17:57:16  lampret
78
// 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.
79
//
80
// Revision 1.8  2001/10/19 23:28:46  lampret
81
// Fixed some synthesis warnings. Configured with caches and MMUs.
82
//
83
// Revision 1.7  2001/10/14 13:12:09  lampret
84
// MP3 version.
85
//
86
// Revision 1.1.1.1  2001/10/06 10:18:36  igorm
87
// no message
88
//
89
// Revision 1.2  2001/08/09 13:39:33  lampret
90
// Major clean-up.
91
//
92
// Revision 1.1  2001/07/20 00:46:03  lampret
93
// Development version of RTL. Libraries are missing.
94
//
95
//
96
 
97
// synopsys translate_off
98
`include "timescale.v"
99
// synopsys translate_on
100
`include "or1200_defines.v"
101
 
102
`define OR1200_NO_FREEZE        3'd0
103
`define OR1200_FREEZE_BYDC      3'd1
104
`define OR1200_FREEZE_BYMULTICYCLE      3'd2
105
`define OR1200_WAIT_LSU_TO_FINISH       3'd3
106
`define OR1200_WAIT_IC                  3'd4
107
 
108
//
109
// Freeze logic (stalls CPU pipeline, ifetcher etc.)
110
//
111
module or1200_freeze_cm4(
112
                clk_i_cml_1,
113
                clk_i_cml_2,
114
                clk_i_cml_3,
115
 
116
        // Clock and reset
117
        clk, rst,
118
 
119
        // Internal i/f
120
        multicycle, flushpipe, extend_flush, lsu_stall, if_stall,
121
        lsu_unstall, du_stall, mac_stall,
122
        force_dslot_fetch, abort_ex,
123
        genpc_freeze, if_freeze, id_freeze, ex_freeze, wb_freeze,
124
        icpu_ack_i, icpu_err_i
125
);
126
 
127
 
128
input clk_i_cml_1;
129
input clk_i_cml_2;
130
input clk_i_cml_3;
131
reg  extend_flush_cml_3;
132
reg  extend_flush_cml_2;
133
reg  extend_flush_cml_1;
134
reg  lsu_stall_cml_3;
135
reg  lsu_stall_cml_2;
136
reg  if_stall_cml_3;
137
reg  lsu_unstall_cml_3;
138
reg  lsu_unstall_cml_2;
139
reg  lsu_unstall_cml_1;
140
reg  abort_ex_cml_2;
141
reg  du_stall_cml_3;
142
reg  du_stall_cml_2;
143
reg  du_stall_cml_1;
144
reg  mac_stall_cml_3;
145
reg  mac_stall_cml_2;
146
reg  mac_stall_cml_1;
147
reg  ex_freeze_cml_3;
148
reg  icpu_ack_i_cml_3;
149
reg  icpu_ack_i_cml_2;
150
reg  icpu_err_i_cml_3;
151
reg  multicycle_freeze_cml_3;
152
reg  multicycle_freeze_cml_2;
153
reg [ 2 - 1 : 0 ] multicycle_cnt_cml_3;
154
reg [ 2 - 1 : 0 ] multicycle_cnt_cml_2;
155
reg [ 2 - 1 : 0 ] multicycle_cnt_cml_1;
156
reg  flushpipe_r_cml_3;
157
reg  flushpipe_r_cml_2;
158
reg  flushpipe_r_cml_1;
159
 
160
 
161
 
162
//
163
// I/O
164
//
165
input                           clk;
166
input                           rst;
167
input   [`OR1200_MULTICYCLE_WIDTH-1:0]   multicycle;
168
input                           flushpipe;
169
input                           extend_flush;
170
input                           lsu_stall;
171
input                           if_stall;
172
input                           lsu_unstall;
173
input                           force_dslot_fetch;
174
input                           abort_ex;
175
input                           du_stall;
176
input                           mac_stall;
177
output                          genpc_freeze;
178
output                          if_freeze;
179
output                          id_freeze;
180
output                          ex_freeze;
181
output                          wb_freeze;
182
input                           icpu_ack_i;
183
input                           icpu_err_i;
184
 
185
//
186
// Internal wires and regs
187
//
188
wire                            multicycle_freeze;
189
reg     [`OR1200_MULTICYCLE_WIDTH-1:0]   multicycle_cnt;
190
reg                             flushpipe_r;
191
 
192
//
193
// Pipeline freeze
194
//
195
// Rules how to create freeze signals:
196
// 1. Not overwriting pipeline stages:
197
// Freze signals at the beginning of pipeline (such as if_freeze) can be asserted more
198
// often than freeze signals at the of pipeline (such as wb_freeze). In other words, wb_freeze must never
199
// be asserted when ex_freeze is not. ex_freeze must never be asserted when id_freeze is not etc.
200
//
201
// 2. Inserting NOPs in the middle of pipeline only if supported:
202
// At this time, only ex_freeze (and wb_freeze) can be deassrted when id_freeze (and if_freeze) are asserted.
203
// This way NOP is asserted from stage ID into EX stage.
204
//
205
//assign genpc_freeze = du_stall | flushpipe_r | lsu_stall;
206
 
207
// SynEDA CoreMultiplier
208
// assignment(s): genpc_freeze
209
// replace(s): du_stall, flushpipe_r
210
assign genpc_freeze = du_stall_cml_3 | flushpipe_r_cml_3;
211
 
212
// SynEDA CoreMultiplier
213
// assignment(s): if_freeze
214
// replace(s): extend_flush
215
assign if_freeze = id_freeze | extend_flush_cml_3;
216
//assign id_freeze = (lsu_stall | (~lsu_unstall & if_stall) | multicycle_freeze | force_dslot_fetch) & ~flushpipe | du_stall;
217
 
218
// SynEDA CoreMultiplier
219
// assignment(s): id_freeze
220
// replace(s): lsu_stall, if_stall, lsu_unstall, du_stall, mac_stall, multicycle_freeze
221
assign id_freeze = (lsu_stall_cml_3 | (~lsu_unstall_cml_3 & if_stall_cml_3) | multicycle_freeze_cml_3 | force_dslot_fetch) | du_stall_cml_3 | mac_stall_cml_3;
222
assign ex_freeze = wb_freeze;
223
//assign wb_freeze = (lsu_stall | (~lsu_unstall & if_stall) | multicycle_freeze) & ~flushpipe | du_stall | mac_stall;
224
 
225
// SynEDA CoreMultiplier
226
// assignment(s): wb_freeze
227
// replace(s): lsu_stall, lsu_unstall, abort_ex, du_stall, mac_stall, multicycle_freeze
228
assign wb_freeze = (lsu_stall_cml_2 | (~lsu_unstall_cml_2 & if_stall) | multicycle_freeze_cml_2) | du_stall_cml_2 | mac_stall_cml_2 | abort_ex_cml_2;
229
 
230
//
231
// registered flushpipe
232
//
233
 
234
// SynEDA CoreMultiplier
235
// assignment(s): flushpipe_r
236
// replace(s): icpu_ack_i, icpu_err_i, flushpipe_r
237
always @(posedge clk or posedge rst)
238
        if (rst)
239
                flushpipe_r <= #1 1'b0;
240
        else begin  flushpipe_r <= flushpipe_r_cml_3; if (icpu_ack_i_cml_3 | icpu_err_i_cml_3)
241
//      else if (!if_stall)
242
                flushpipe_r <= #1 flushpipe;
243
        else if (!flushpipe)
244
                flushpipe_r <= #1 1'b0; end
245
 
246
//
247
// Multicycle freeze
248
//
249
 
250
// SynEDA CoreMultiplier
251
// assignment(s): multicycle_freeze
252
// replace(s): multicycle_cnt
253
assign multicycle_freeze = |multicycle_cnt_cml_1;
254
 
255
//
256
// Multicycle counter
257
//
258
 
259
// SynEDA CoreMultiplier
260
// assignment(s): multicycle_cnt
261
// replace(s): ex_freeze, multicycle_cnt
262
always @(posedge clk or posedge rst)
263
        if (rst)
264
                multicycle_cnt <= #1 2'b00;
265
        else begin  multicycle_cnt <= multicycle_cnt_cml_3; if (|multicycle_cnt_cml_3)
266
                multicycle_cnt <= #1 multicycle_cnt_cml_3 - 2'd1;
267
        else if (|multicycle & !ex_freeze_cml_3)
268
                multicycle_cnt <= #1 multicycle; end
269
 
270
 
271
always @ (posedge clk_i_cml_1) begin
272
extend_flush_cml_1 <= extend_flush;
273
lsu_unstall_cml_1 <= lsu_unstall;
274
du_stall_cml_1 <= du_stall;
275
mac_stall_cml_1 <= mac_stall;
276
multicycle_cnt_cml_1 <= multicycle_cnt;
277
flushpipe_r_cml_1 <= flushpipe_r;
278
end
279
always @ (posedge clk_i_cml_2) begin
280
extend_flush_cml_2 <= extend_flush_cml_1;
281
lsu_stall_cml_2 <= lsu_stall;
282
lsu_unstall_cml_2 <= lsu_unstall_cml_1;
283
abort_ex_cml_2 <= abort_ex;
284
du_stall_cml_2 <= du_stall_cml_1;
285
mac_stall_cml_2 <= mac_stall_cml_1;
286
icpu_ack_i_cml_2 <= icpu_ack_i;
287
multicycle_freeze_cml_2 <= multicycle_freeze;
288
multicycle_cnt_cml_2 <= multicycle_cnt_cml_1;
289
flushpipe_r_cml_2 <= flushpipe_r_cml_1;
290
end
291
always @ (posedge clk_i_cml_3) begin
292
extend_flush_cml_3 <= extend_flush_cml_2;
293
lsu_stall_cml_3 <= lsu_stall_cml_2;
294
if_stall_cml_3 <= if_stall;
295
lsu_unstall_cml_3 <= lsu_unstall_cml_2;
296
du_stall_cml_3 <= du_stall_cml_2;
297
mac_stall_cml_3 <= mac_stall_cml_2;
298
ex_freeze_cml_3 <= ex_freeze;
299
icpu_ack_i_cml_3 <= icpu_ack_i_cml_2;
300
icpu_err_i_cml_3 <= icpu_err_i;
301
multicycle_freeze_cml_3 <= multicycle_freeze_cml_2;
302
multicycle_cnt_cml_3 <= multicycle_cnt_cml_2;
303
flushpipe_r_cml_3 <= flushpipe_r_cml_2;
304
end
305
endmodule
306
 

powered by: WebSVN 2.1.0

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