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

Subversion Repositories or1200_hp

[/] [or1200_hp/] [trunk/] [rtl/] [rtl_cm3/] [verilog/] [or1200_if.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 tobil
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  OR1200's instruction fetch                                  ////
4
////                                                              ////
5
////  This file is part of the OpenRISC 1200 project              ////
6
////  http://www.opencores.org/cores/or1k/                        ////
7
////                                                              ////
8
////  Description                                                 ////
9
////  PC, instruction fetch, interface to IC.                     ////
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.3  2002/03/29 15:16:56  lampret
48
// Some of the warnings fixed.
49
//
50
// Revision 1.2  2002/01/28 01:16:00  lampret
51
// 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.
52
//
53
// Revision 1.1  2002/01/03 08:16:15  lampret
54
// New prefixes for RTL files, prefixed module names. Updated cache controllers and MMUs.
55
//
56
// Revision 1.10  2001/11/20 18:46:15  simons
57
// Break point bug fixed
58
//
59
// Revision 1.9  2001/11/18 09:58:28  lampret
60
// Fixed some l.trap typos.
61
//
62
// Revision 1.8  2001/11/18 08:36:28  lampret
63
// For GDB changed single stepping and disabled trap exception.
64
//
65
// Revision 1.7  2001/10/21 17:57:16  lampret
66
// 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.
67
//
68
// Revision 1.6  2001/10/14 13:12:09  lampret
69
// MP3 version.
70
//
71
// Revision 1.1.1.1  2001/10/06 10:18:36  igorm
72
// no message
73
//
74
// Revision 1.1  2001/08/09 13:39:33  lampret
75
// Major clean-up.
76
//
77
//
78
 
79
// synopsys translate_off
80
`include "timescale.v"
81
// synopsys translate_on
82
`include "or1200_defines.v"
83
 
84
module or1200_if_cm3(
85
                clk_i_cml_1,
86
                clk_i_cml_2,
87
 
88
        // Clock and reset
89
        clk, rst,
90
 
91
        // External i/f to IC
92
        icpu_dat_i, icpu_ack_i, icpu_err_i, icpu_adr_i, icpu_tag_i,
93
 
94
        // Internal i/f
95
        if_freeze, if_insn, if_pc, flushpipe,
96
        if_stall, no_more_dslot, genpc_refetch, rfe,
97
        except_itlbmiss, except_immufault, except_ibuserr
98
);
99
 
100
 
101
input clk_i_cml_1;
102
input clk_i_cml_2;
103
reg  icpu_ack_i_cml_2;
104
reg  icpu_ack_i_cml_1;
105
reg  icpu_err_i_cml_2;
106
reg [ 31 : 0 ] icpu_adr_i_cml_2;
107
reg [ 31 : 0 ] icpu_adr_i_cml_1;
108
reg  no_more_dslot_cml_2;
109
reg  no_more_dslot_cml_1;
110
reg [ 31 : 0 ] insn_saved_cml_2;
111
reg [ 31 : 0 ] insn_saved_cml_1;
112
reg [ 31 : 0 ] addr_saved_cml_2;
113
reg [ 31 : 0 ] addr_saved_cml_1;
114
reg  saved_cml_2;
115
reg  saved_cml_1;
116
 
117
 
118
 
119
//
120
// I/O
121
//
122
 
123
//
124
// Clock and reset
125
//
126
input                           clk;
127
input                           rst;
128
 
129
//
130
// External i/f to IC
131
//
132
input   [31:0]                   icpu_dat_i;
133
input                           icpu_ack_i;
134
input                           icpu_err_i;
135
input   [31:0]                   icpu_adr_i;
136
input   [3:0]                    icpu_tag_i;
137
 
138
//
139
// Internal i/f
140
//
141
input                           if_freeze;
142
output  [31:0]                   if_insn;
143
output  [31:0]                   if_pc;
144
input                           flushpipe;
145
output                          if_stall;
146
input                           no_more_dslot;
147
output                          genpc_refetch;
148
input                           rfe;
149
output                          except_itlbmiss;
150
output                          except_immufault;
151
output                          except_ibuserr;
152
 
153
//
154
// Internal wires and regs
155
//
156
reg     [31:0]                   insn_saved;
157
reg     [31:0]                   addr_saved;
158
reg                             saved;
159
 
160
//
161
// IF stage insn
162
//
163
 
164
// SynEDA CoreMultiplier
165
// assignment(s): if_insn
166
// replace(s): icpu_ack_i, icpu_err_i, no_more_dslot, insn_saved, saved
167
assign if_insn = icpu_err_i_cml_2 | no_more_dslot_cml_2 | rfe ? {`OR1200_OR32_NOP, 26'h041_0000} : saved_cml_2 ? insn_saved_cml_2 : icpu_ack_i_cml_2 ? icpu_dat_i : {`OR1200_OR32_NOP, 26'h061_0000};
168
 
169
// SynEDA CoreMultiplier
170
// assignment(s): if_pc
171
// replace(s): icpu_adr_i, addr_saved, saved
172
assign if_pc = saved_cml_2 ? addr_saved_cml_2 : icpu_adr_i_cml_2;
173
// assign if_stall = !icpu_err_i & !icpu_ack_i & !saved & !no_more_dslot;
174
 
175
// SynEDA CoreMultiplier
176
// assignment(s): if_stall
177
// replace(s): icpu_ack_i, saved
178
assign if_stall = !icpu_err_i & !icpu_ack_i_cml_1 & !saved_cml_1;
179
 
180
// SynEDA CoreMultiplier
181
// assignment(s): genpc_refetch
182
// replace(s): icpu_ack_i, saved
183
assign genpc_refetch = saved_cml_1 & icpu_ack_i_cml_1;
184
 
185
// SynEDA CoreMultiplier
186
// assignment(s): except_itlbmiss
187
// replace(s): icpu_err_i, no_more_dslot
188
assign except_itlbmiss = icpu_err_i_cml_2 & (icpu_tag_i == `OR1200_ITAG_TE) & !no_more_dslot_cml_2;
189
 
190
// SynEDA CoreMultiplier
191
// assignment(s): except_immufault
192
// replace(s): icpu_err_i, no_more_dslot
193
assign except_immufault = icpu_err_i_cml_2 & (icpu_tag_i == `OR1200_ITAG_PE) & !no_more_dslot_cml_2;
194
 
195
// SynEDA CoreMultiplier
196
// assignment(s): except_ibuserr
197
// replace(s): icpu_err_i, no_more_dslot
198
assign except_ibuserr = icpu_err_i_cml_2 & (icpu_tag_i == `OR1200_ITAG_BE) & !no_more_dslot_cml_2;
199
 
200
//
201
// Flag for saved insn/address
202
//
203
 
204
// SynEDA CoreMultiplier
205
// assignment(s): saved
206
// replace(s): icpu_ack_i, saved
207
always @(posedge clk or posedge rst)
208
        if (rst)
209
                saved <= #1 1'b0;
210
        else begin  saved <= saved_cml_2; if (flushpipe)
211
                saved <= #1 1'b0;
212
        else if (icpu_ack_i_cml_2 & if_freeze & !saved_cml_2)
213
                saved <= #1 1'b1;
214
        else if (!if_freeze)
215
                saved <= #1 1'b0; end
216
 
217
//
218
// Store fetched instruction
219
//
220
 
221
// SynEDA CoreMultiplier
222
// assignment(s): insn_saved
223
// replace(s): icpu_ack_i, insn_saved, saved
224
always @(posedge clk or posedge rst)
225
        if (rst)
226
                insn_saved <= #1 {`OR1200_OR32_NOP, 26'h041_0000};
227
        else begin  insn_saved <= insn_saved_cml_2; if (flushpipe)
228
                insn_saved <= #1 {`OR1200_OR32_NOP, 26'h041_0000};
229
        else if (icpu_ack_i_cml_2 & if_freeze & !saved_cml_2)
230
                insn_saved <= #1 icpu_dat_i;
231
        else if (!if_freeze)
232
                insn_saved <= #1 {`OR1200_OR32_NOP, 26'h041_0000}; end
233
 
234
//
235
// Store fetched instruction's address
236
//
237
 
238
// SynEDA CoreMultiplier
239
// assignment(s): addr_saved
240
// replace(s): icpu_ack_i, icpu_adr_i, addr_saved, saved
241
always @(posedge clk or posedge rst)
242
        if (rst)
243
                addr_saved <= #1 32'h00000000;
244
        else begin  addr_saved <= addr_saved_cml_2; if (flushpipe)
245
                addr_saved <= #1 32'h00000000;
246
        else if (icpu_ack_i_cml_2 & if_freeze & !saved_cml_2)
247
                addr_saved <= #1 icpu_adr_i_cml_2;
248
        else if (!if_freeze)
249
                addr_saved <= #1 icpu_adr_i_cml_2; end
250
 
251
 
252
always @ (posedge clk_i_cml_1) begin
253
icpu_ack_i_cml_1 <= icpu_ack_i;
254
icpu_adr_i_cml_1 <= icpu_adr_i;
255
no_more_dslot_cml_1 <= no_more_dslot;
256
insn_saved_cml_1 <= insn_saved;
257
addr_saved_cml_1 <= addr_saved;
258
saved_cml_1 <= saved;
259
end
260
always @ (posedge clk_i_cml_2) begin
261
icpu_ack_i_cml_2 <= icpu_ack_i_cml_1;
262
icpu_err_i_cml_2 <= icpu_err_i;
263
icpu_adr_i_cml_2 <= icpu_adr_i_cml_1;
264
no_more_dslot_cml_2 <= no_more_dslot_cml_1;
265
insn_saved_cml_2 <= insn_saved_cml_1;
266
addr_saved_cml_2 <= addr_saved_cml_1;
267
saved_cml_2 <= saved_cml_1;
268
end
269
endmodule
270
 

powered by: WebSVN 2.1.0

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