1 |
2 |
alfik |
/*
|
2 |
|
|
* Copyright (c) 2014, Aleksander Osman
|
3 |
|
|
* All rights reserved.
|
4 |
|
|
*
|
5 |
|
|
* Redistribution and use in source and binary forms, with or without
|
6 |
|
|
* modification, are permitted provided that the following conditions are met:
|
7 |
|
|
*
|
8 |
|
|
* * Redistributions of source code must retain the above copyright notice, this
|
9 |
|
|
* list of conditions and the following disclaimer.
|
10 |
|
|
*
|
11 |
|
|
* * Redistributions in binary form must reproduce the above copyright notice,
|
12 |
|
|
* this list of conditions and the following disclaimer in the documentation
|
13 |
|
|
* and/or other materials provided with the distribution.
|
14 |
|
|
*
|
15 |
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
16 |
|
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
17 |
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
18 |
|
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
19 |
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
20 |
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
21 |
|
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
22 |
|
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
23 |
|
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
24 |
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
25 |
|
|
*/
|
26 |
|
|
|
27 |
|
|
`include "defines.v"
|
28 |
|
|
|
29 |
|
|
module ao486 (
|
30 |
|
|
input clk,
|
31 |
|
|
input rst_n,
|
32 |
|
|
|
33 |
|
|
input rst_internal_n,
|
34 |
|
|
|
35 |
|
|
//--------------------------------------------------------------------------
|
36 |
|
|
input interrupt_do,
|
37 |
|
|
input [7:0] interrupt_vector,
|
38 |
|
|
output interrupt_done,
|
39 |
|
|
|
40 |
|
|
//-------------------------------------------------------------------------- Altera Avalon memory bus
|
41 |
|
|
output [31:0] avm_address,
|
42 |
|
|
output [31:0] avm_writedata,
|
43 |
|
|
output [3:0] avm_byteenable,
|
44 |
|
|
output [2:0] avm_burstcount,
|
45 |
|
|
output avm_write,
|
46 |
|
|
output avm_read,
|
47 |
|
|
|
48 |
|
|
input avm_waitrequest,
|
49 |
|
|
input avm_readdatavalid,
|
50 |
|
|
input [31:0] avm_readdata,
|
51 |
|
|
|
52 |
|
|
//-------------------------------------------------------------------------- Altera Avalon io bus
|
53 |
|
|
output [15:0] avalon_io_address,
|
54 |
|
|
output [3:0] avalon_io_byteenable,
|
55 |
|
|
|
56 |
|
|
output avalon_io_read,
|
57 |
|
|
input avalon_io_readdatavalid,
|
58 |
|
|
input [31:0] avalon_io_readdata,
|
59 |
|
|
|
60 |
|
|
output avalon_io_write,
|
61 |
|
|
output [31:0] avalon_io_writedata,
|
62 |
|
|
|
63 |
|
|
input avalon_io_waitrequest
|
64 |
|
|
);
|
65 |
|
|
|
66 |
|
|
//------------------------------------------------------------------------------
|
67 |
|
|
|
68 |
|
|
wire dec_gp_fault;
|
69 |
|
|
wire dec_ud_fault;
|
70 |
|
|
wire dec_pf_fault;
|
71 |
|
|
wire rd_seg_gp_fault;
|
72 |
|
|
wire rd_descriptor_gp_fault;
|
73 |
|
|
wire rd_seg_ss_fault;
|
74 |
|
|
wire rd_io_allow_fault;
|
75 |
|
|
wire rd_ss_esp_from_tss_fault;
|
76 |
|
|
wire exe_div_exception;
|
77 |
|
|
wire exe_trigger_gp_fault;
|
78 |
|
|
wire exe_trigger_ts_fault;
|
79 |
|
|
wire exe_trigger_ss_fault;
|
80 |
|
|
wire exe_trigger_np_fault;
|
81 |
|
|
wire exe_trigger_nm_fault;
|
82 |
|
|
wire exe_trigger_db_fault;
|
83 |
|
|
wire exe_trigger_pf_fault;
|
84 |
|
|
wire exe_bound_fault;
|
85 |
|
|
wire exe_load_seg_gp_fault;
|
86 |
|
|
wire exe_load_seg_ss_fault;
|
87 |
|
|
wire exe_load_seg_np_fault;
|
88 |
|
|
wire wr_debug_init;
|
89 |
|
|
wire wr_new_push_ss_fault;
|
90 |
|
|
wire wr_string_es_fault;
|
91 |
|
|
wire wr_push_ss_fault;
|
92 |
|
|
|
93 |
|
|
wire read_ac_fault;
|
94 |
|
|
wire read_page_fault;
|
95 |
|
|
wire write_ac_fault;
|
96 |
|
|
wire write_page_fault;
|
97 |
|
|
wire [15:0] tlb_code_pf_error_code;
|
98 |
|
|
wire [15:0] tlb_check_pf_error_code;
|
99 |
|
|
wire [15:0] tlb_write_pf_error_code;
|
100 |
|
|
wire [15:0] tlb_read_pf_error_code;
|
101 |
|
|
|
102 |
|
|
wire wr_int;
|
103 |
|
|
wire wr_int_soft_int;
|
104 |
|
|
wire wr_int_soft_int_ib;
|
105 |
|
|
wire [7:0] wr_int_vector;
|
106 |
|
|
wire wr_exception_external_set;
|
107 |
|
|
wire wr_exception_finished;
|
108 |
|
|
|
109 |
|
|
wire [31:0] eip;
|
110 |
|
|
wire [31:0] dec_eip;
|
111 |
|
|
wire [31:0] rd_eip;
|
112 |
|
|
wire [31:0] exe_eip;
|
113 |
|
|
wire [31:0] wr_eip;
|
114 |
|
|
wire [3:0] rd_consumed;
|
115 |
|
|
wire [3:0] exe_consumed;
|
116 |
|
|
wire [3:0] wr_consumed;
|
117 |
|
|
|
118 |
|
|
wire rd_dec_is_front;
|
119 |
|
|
wire rd_is_front;
|
120 |
|
|
wire exe_is_front;
|
121 |
|
|
wire wr_is_front;
|
122 |
|
|
|
123 |
|
|
wire wr_interrupt_possible;
|
124 |
|
|
wire wr_string_in_progress_final;
|
125 |
|
|
wire wr_is_esp_speculative;
|
126 |
|
|
|
127 |
|
|
wire real_mode;
|
128 |
|
|
|
129 |
|
|
wire [15:0] rd_error_code;
|
130 |
|
|
wire [15:0] exe_error_code;
|
131 |
|
|
wire [15:0] wr_error_code;
|
132 |
|
|
|
133 |
|
|
wire exc_dec_reset;
|
134 |
|
|
wire exc_micro_reset;
|
135 |
|
|
wire exc_rd_reset;
|
136 |
|
|
wire exc_exe_reset;
|
137 |
|
|
wire exc_wr_reset;
|
138 |
|
|
|
139 |
|
|
wire exc_restore_esp;
|
140 |
|
|
wire exc_set_rflag;
|
141 |
|
|
wire exc_debug_start;
|
142 |
|
|
wire exc_init;
|
143 |
|
|
wire exc_load;
|
144 |
|
|
wire [31:0] exc_eip;
|
145 |
|
|
wire [7:0] exc_vector;
|
146 |
|
|
wire [15:0] exc_error_code;
|
147 |
|
|
wire exc_push_error;
|
148 |
|
|
wire exc_soft_int;
|
149 |
|
|
wire exc_soft_int_ib;
|
150 |
|
|
wire exc_pf_read;
|
151 |
|
|
wire exc_pf_write;
|
152 |
|
|
wire exc_pf_code;
|
153 |
|
|
wire exc_pf_check;
|
154 |
|
|
|
155 |
|
|
exception exception_inst(
|
156 |
|
|
.clk (clk),
|
157 |
|
|
.rst_n (rst_internal_n),
|
158 |
|
|
|
159 |
|
|
//exception indicators
|
160 |
|
|
.dec_gp_fault (dec_gp_fault), //input
|
161 |
|
|
.dec_ud_fault (dec_ud_fault), //input
|
162 |
|
|
.dec_pf_fault (dec_pf_fault), //input
|
163 |
|
|
|
164 |
|
|
.rd_seg_gp_fault (rd_seg_gp_fault), //input
|
165 |
|
|
.rd_descriptor_gp_fault (rd_descriptor_gp_fault), //input
|
166 |
|
|
.rd_seg_ss_fault (rd_seg_ss_fault), //input
|
167 |
|
|
.rd_io_allow_fault (rd_io_allow_fault), //input
|
168 |
|
|
.rd_ss_esp_from_tss_fault (rd_ss_esp_from_tss_fault), //input
|
169 |
|
|
|
170 |
|
|
.exe_div_exception (exe_div_exception), //input
|
171 |
|
|
.exe_trigger_gp_fault (exe_trigger_gp_fault), //input
|
172 |
|
|
.exe_trigger_ts_fault (exe_trigger_ts_fault), //input
|
173 |
|
|
.exe_trigger_ss_fault (exe_trigger_ss_fault), //input
|
174 |
|
|
.exe_trigger_np_fault (exe_trigger_np_fault), //input
|
175 |
|
|
.exe_trigger_nm_fault (exe_trigger_nm_fault), //input
|
176 |
|
|
.exe_trigger_db_fault (exe_trigger_db_fault), //input
|
177 |
|
|
.exe_trigger_pf_fault (exe_trigger_pf_fault), //input
|
178 |
|
|
.exe_bound_fault (exe_bound_fault), //input
|
179 |
|
|
.exe_load_seg_gp_fault (exe_load_seg_gp_fault), //input
|
180 |
|
|
.exe_load_seg_ss_fault (exe_load_seg_ss_fault), //input
|
181 |
|
|
.exe_load_seg_np_fault (exe_load_seg_np_fault), //input
|
182 |
|
|
|
183 |
|
|
.wr_debug_init (wr_debug_init), //input
|
184 |
|
|
.wr_new_push_ss_fault (wr_new_push_ss_fault), //input
|
185 |
|
|
.wr_string_es_fault (wr_string_es_fault), //input
|
186 |
|
|
.wr_push_ss_fault (wr_push_ss_fault), //input
|
187 |
|
|
|
188 |
|
|
//from memory
|
189 |
|
|
.read_ac_fault (read_ac_fault), //input
|
190 |
|
|
.read_page_fault (read_page_fault), //input
|
191 |
|
|
|
192 |
|
|
.write_ac_fault (write_ac_fault), //input
|
193 |
|
|
.write_page_fault (write_page_fault), //input
|
194 |
|
|
|
195 |
|
|
.tlb_code_pf_error_code (tlb_code_pf_error_code), //input [15:0]
|
196 |
|
|
.tlb_check_pf_error_code (tlb_check_pf_error_code), //input [15:0]
|
197 |
|
|
.tlb_write_pf_error_code (tlb_write_pf_error_code), //input [15:0]
|
198 |
|
|
.tlb_read_pf_error_code (tlb_read_pf_error_code), //input [15:0]
|
199 |
|
|
|
200 |
|
|
//wr_int
|
201 |
|
|
.wr_int (wr_int), //input
|
202 |
|
|
.wr_int_soft_int (wr_int_soft_int), //input
|
203 |
|
|
.wr_int_soft_int_ib (wr_int_soft_int_ib), //input
|
204 |
|
|
.wr_int_vector (wr_int_vector), //input [7:0]
|
205 |
|
|
|
206 |
|
|
.wr_exception_external_set (wr_exception_external_set), //input
|
207 |
|
|
.wr_exception_finished (wr_exception_finished), //input
|
208 |
|
|
|
209 |
|
|
//eip
|
210 |
|
|
.eip (eip), //input [31:0]
|
211 |
|
|
.dec_eip (dec_eip), //input [31:0]
|
212 |
|
|
.rd_eip (rd_eip), //input [31:0]
|
213 |
|
|
.exe_eip (exe_eip), //input [31:0]
|
214 |
|
|
.wr_eip (wr_eip), //input [31:0]
|
215 |
|
|
|
216 |
|
|
.rd_consumed (rd_consumed), //input [3:0]
|
217 |
|
|
.exe_consumed (exe_consumed), //input [3:0]
|
218 |
|
|
.wr_consumed (wr_consumed), //input [3:0]
|
219 |
|
|
|
220 |
|
|
//pipeline
|
221 |
|
|
.rd_dec_is_front (rd_dec_is_front), //input
|
222 |
|
|
.rd_is_front (rd_is_front), //input
|
223 |
|
|
.exe_is_front (exe_is_front), //input
|
224 |
|
|
.wr_is_front (wr_is_front), //input
|
225 |
|
|
|
226 |
|
|
//interrupt
|
227 |
|
|
.interrupt_vector (interrupt_vector), //input [7:0]
|
228 |
|
|
.interrupt_done (interrupt_done), //output
|
229 |
|
|
|
230 |
|
|
//input
|
231 |
|
|
.wr_interrupt_possible (wr_interrupt_possible), //input
|
232 |
|
|
.wr_string_in_progress_final (wr_string_in_progress_final), //input
|
233 |
|
|
.wr_is_esp_speculative (wr_is_esp_speculative), //input
|
234 |
|
|
|
235 |
|
|
.real_mode (real_mode), //input
|
236 |
|
|
|
237 |
|
|
.rd_error_code (rd_error_code), //input [15:0]
|
238 |
|
|
.exe_error_code (exe_error_code), //input [15:0]
|
239 |
|
|
.wr_error_code (wr_error_code), //input [15:0]
|
240 |
|
|
|
241 |
|
|
//output
|
242 |
|
|
.exc_dec_reset (exc_dec_reset), //output
|
243 |
|
|
.exc_micro_reset (exc_micro_reset), //output
|
244 |
|
|
.exc_rd_reset (exc_rd_reset), //output
|
245 |
|
|
.exc_exe_reset (exc_exe_reset), //output
|
246 |
|
|
.exc_wr_reset (exc_wr_reset), //output
|
247 |
|
|
|
248 |
|
|
//exception output
|
249 |
|
|
.exc_restore_esp (exc_restore_esp), //output
|
250 |
|
|
.exc_set_rflag (exc_set_rflag), //output
|
251 |
|
|
.exc_debug_start (exc_debug_start), //output
|
252 |
|
|
|
253 |
|
|
.exc_init (exc_init), //output
|
254 |
|
|
.exc_load (exc_load), //output
|
255 |
|
|
.exc_eip (exc_eip), //output [31:0]
|
256 |
|
|
|
257 |
|
|
.exc_vector (exc_vector), //output [7:0]
|
258 |
|
|
.exc_error_code (exc_error_code), //output [15:0]
|
259 |
|
|
.exc_push_error (exc_push_error), //output
|
260 |
|
|
.exc_soft_int (exc_soft_int), //output
|
261 |
|
|
.exc_soft_int_ib (exc_soft_int_ib), //output
|
262 |
|
|
|
263 |
|
|
.exc_pf_read (exc_pf_read), //output
|
264 |
|
|
.exc_pf_write (exc_pf_write), //output
|
265 |
|
|
.exc_pf_code (exc_pf_code), //output
|
266 |
|
|
.exc_pf_check (exc_pf_check) //output
|
267 |
|
|
);
|
268 |
|
|
|
269 |
|
|
//------------------------------------------------------------------------------
|
270 |
|
|
|
271 |
|
|
wire io_read_do;
|
272 |
|
|
wire [15:0] io_read_address;
|
273 |
|
|
wire [2:0] io_read_length;
|
274 |
|
|
wire [31:0] io_read_data;
|
275 |
|
|
wire io_read_done;
|
276 |
|
|
|
277 |
|
|
wire io_write_do;
|
278 |
|
|
wire [15:0] io_write_address;
|
279 |
|
|
wire [2:0] io_write_length;
|
280 |
|
|
wire [31:0] io_write_data;
|
281 |
|
|
wire io_write_done;
|
282 |
|
|
|
283 |
|
|
avalon_io avalon_io_inst(
|
284 |
|
|
.clk (clk),
|
285 |
|
|
.rst_n (rst_n),
|
286 |
|
|
|
287 |
|
|
//io_read
|
288 |
|
|
.io_read_do (io_read_do), //input
|
289 |
|
|
.io_read_address (io_read_address), //input [15:0]
|
290 |
|
|
.io_read_length (io_read_length), //input [2:0]
|
291 |
|
|
.io_read_data (io_read_data), //output [31:0]
|
292 |
|
|
.io_read_done (io_read_done), //output
|
293 |
|
|
|
294 |
|
|
//io_write
|
295 |
|
|
.io_write_do (io_write_do), //input
|
296 |
|
|
.io_write_address (io_write_address), //input [15:0]
|
297 |
|
|
.io_write_length (io_write_length), //input [2:0]
|
298 |
|
|
.io_write_data (io_write_data), //input [31:0]
|
299 |
|
|
.io_write_done (io_write_done), //output
|
300 |
|
|
|
301 |
|
|
.dcache_busy (dcache_busy), //input
|
302 |
|
|
|
303 |
|
|
//Avalon
|
304 |
|
|
.avalon_io_address (avalon_io_address), //output [15:0]
|
305 |
|
|
.avalon_io_byteenable (avalon_io_byteenable), //output [3:0]
|
306 |
|
|
|
307 |
|
|
.avalon_io_read (avalon_io_read), //output
|
308 |
|
|
.avalon_io_readdatavalid (avalon_io_readdatavalid), //input
|
309 |
|
|
.avalon_io_readdata (avalon_io_readdata), //input [31:0]
|
310 |
|
|
|
311 |
|
|
.avalon_io_write (avalon_io_write), //output
|
312 |
|
|
.avalon_io_writedata (avalon_io_writedata), //output [31:0]
|
313 |
|
|
.avalon_io_waitrequest (avalon_io_waitrequest) //input
|
314 |
|
|
);
|
315 |
|
|
|
316 |
|
|
//------------------------------------------------------------------------------
|
317 |
|
|
|
318 |
|
|
wire glob_param_1_set;
|
319 |
|
|
wire [31:0] glob_param_1_value;
|
320 |
|
|
wire glob_param_2_set;
|
321 |
|
|
wire [31:0] glob_param_2_value;
|
322 |
|
|
wire glob_param_3_set;
|
323 |
|
|
wire [31:0] glob_param_3_value;
|
324 |
|
|
wire glob_param_4_set;
|
325 |
|
|
wire [31:0] glob_param_4_value;
|
326 |
|
|
wire glob_param_5_set;
|
327 |
|
|
wire [31:0] glob_param_5_value;
|
328 |
|
|
wire glob_descriptor_set;
|
329 |
|
|
wire [63:0] glob_descriptor_value;
|
330 |
|
|
wire glob_descriptor_2_set;
|
331 |
|
|
wire [63:0] glob_descriptor_2_value;
|
332 |
|
|
wire [31:0] glob_param_1;
|
333 |
|
|
wire [31:0] glob_param_2;
|
334 |
|
|
wire [31:0] glob_param_3;
|
335 |
|
|
wire [31:0] glob_param_4;
|
336 |
|
|
wire [31:0] glob_param_5;
|
337 |
|
|
wire [63:0] glob_descriptor;
|
338 |
|
|
wire [63:0] glob_descriptor_2;
|
339 |
|
|
wire [31:0] glob_desc_base;
|
340 |
|
|
wire [31:0] glob_desc_limit;
|
341 |
|
|
wire [31:0] glob_desc_2_limit;
|
342 |
|
|
|
343 |
|
|
global_regs global_regs_inst(
|
344 |
|
|
.clk (clk),
|
345 |
|
|
.rst_n (rst_internal_n),
|
346 |
|
|
|
347 |
|
|
//input
|
348 |
|
|
.glob_param_1_set (glob_param_1_set), //input
|
349 |
|
|
.glob_param_1_value (glob_param_1_value), //input [31:0]
|
350 |
|
|
.glob_param_2_set (glob_param_2_set), //input
|
351 |
|
|
.glob_param_2_value (glob_param_2_value), //input [31:0]
|
352 |
|
|
.glob_param_3_set (glob_param_3_set), //input
|
353 |
|
|
.glob_param_3_value (glob_param_3_value), //input [31:0]
|
354 |
|
|
.glob_param_4_set (glob_param_4_set), //input
|
355 |
|
|
.glob_param_4_value (glob_param_4_value), //input [31:0]
|
356 |
|
|
.glob_param_5_set (glob_param_5_set), //input
|
357 |
|
|
.glob_param_5_value (glob_param_5_value), //input [31:0]
|
358 |
|
|
.glob_descriptor_set (glob_descriptor_set), //input
|
359 |
|
|
.glob_descriptor_value (glob_descriptor_value), //input [63:0]
|
360 |
|
|
.glob_descriptor_2_set (glob_descriptor_2_set), //input
|
361 |
|
|
.glob_descriptor_2_value (glob_descriptor_2_value), //input [63:0]
|
362 |
|
|
|
363 |
|
|
//output
|
364 |
|
|
.glob_param_1 (glob_param_1), //output [31:0]
|
365 |
|
|
.glob_param_2 (glob_param_2), //output [31:0]
|
366 |
|
|
.glob_param_3 (glob_param_3), //output [31:0]
|
367 |
|
|
.glob_param_4 (glob_param_4), //output [31:0]
|
368 |
|
|
.glob_param_5 (glob_param_5), //output [31:0]
|
369 |
|
|
.glob_descriptor (glob_descriptor), //output [63:0]
|
370 |
|
|
.glob_descriptor_2 (glob_descriptor_2), //output [63:0]
|
371 |
|
|
.glob_desc_base (glob_desc_base), //output [31:0]
|
372 |
|
|
.glob_desc_limit (glob_desc_limit), //output [31:0]
|
373 |
|
|
.glob_desc_2_limit (glob_desc_2_limit) //output [31:0]
|
374 |
|
|
);
|
375 |
|
|
|
376 |
|
|
//------------------------------------------------------------------------------
|
377 |
|
|
|
378 |
|
|
wire read_do;
|
379 |
|
|
wire read_done;
|
380 |
|
|
|
381 |
|
|
wire [1:0] read_cpl;
|
382 |
|
|
wire [31:0] read_address;
|
383 |
|
|
wire [3:0] read_length;
|
384 |
|
|
wire read_lock;
|
385 |
|
|
wire read_rmw;
|
386 |
|
|
wire [63:0] read_data;
|
387 |
|
|
|
388 |
|
|
wire write_do;
|
389 |
|
|
wire write_done;
|
390 |
|
|
|
391 |
|
|
wire [1:0] write_cpl;
|
392 |
|
|
wire [31:0] write_address;
|
393 |
|
|
wire [2:0] write_length;
|
394 |
|
|
wire write_lock;
|
395 |
|
|
wire write_rmw;
|
396 |
|
|
wire [31:0] write_data;
|
397 |
|
|
|
398 |
|
|
wire tlbcheck_do;
|
399 |
|
|
wire tlbcheck_done;
|
400 |
|
|
wire tlbcheck_page_fault;
|
401 |
|
|
wire [31:0] tlbcheck_address;
|
402 |
|
|
wire tlbcheck_rw;
|
403 |
|
|
|
404 |
|
|
wire dcache_busy;
|
405 |
|
|
|
406 |
|
|
wire tlbflushsingle_do;
|
407 |
|
|
wire tlbflushsingle_done;
|
408 |
|
|
wire [31:0] tlbflushsingle_address;
|
409 |
|
|
|
410 |
|
|
wire tlbflushall_do;
|
411 |
|
|
wire invdcode_do;
|
412 |
|
|
wire invdcode_done;
|
413 |
|
|
wire invddata_do;
|
414 |
|
|
wire invddata_done;
|
415 |
|
|
wire wbinvddata_do;
|
416 |
|
|
wire wbinvddata_done;
|
417 |
|
|
|
418 |
|
|
wire [1:0] prefetch_cpl;
|
419 |
|
|
wire [31:0] prefetch_eip;
|
420 |
|
|
wire [63:0] cs_cache;
|
421 |
|
|
|
422 |
|
|
wire cr0_pg;
|
423 |
|
|
wire cr0_wp;
|
424 |
|
|
wire cr0_am;
|
425 |
|
|
wire cr0_cd;
|
426 |
|
|
wire cr0_nw;
|
427 |
|
|
|
428 |
|
|
wire acflag;
|
429 |
|
|
|
430 |
|
|
wire [31:0] cr3;
|
431 |
|
|
|
432 |
|
|
wire prefetchfifo_accept_do;
|
433 |
|
|
wire [67:0] prefetchfifo_accept_data;
|
434 |
|
|
wire prefetchfifo_accept_empty;
|
435 |
|
|
|
436 |
|
|
wire pipeline_after_read_empty;
|
437 |
|
|
wire pipeline_after_prefetch_empty;
|
438 |
|
|
|
439 |
|
|
wire [31:0] tlb_code_pf_cr2;
|
440 |
|
|
wire [31:0] tlb_check_pf_cr2;
|
441 |
|
|
wire [31:0] tlb_write_pf_cr2;
|
442 |
|
|
wire [31:0] tlb_read_pf_cr2;
|
443 |
|
|
|
444 |
|
|
wire pr_reset;
|
445 |
|
|
wire rd_reset;
|
446 |
|
|
wire exe_reset;
|
447 |
|
|
wire wr_reset;
|
448 |
|
|
|
449 |
|
|
|
450 |
|
|
memory memory_inst(
|
451 |
|
|
.clk (clk),
|
452 |
|
|
.rst_n (rst_n),
|
453 |
|
|
.rst_internal_n (rst_internal_n),
|
454 |
|
|
|
455 |
|
|
//REQ:
|
456 |
|
|
.read_do (read_do), //input
|
457 |
|
|
.read_done (read_done), //output
|
458 |
|
|
.read_page_fault (read_page_fault), //output
|
459 |
|
|
.read_ac_fault (read_ac_fault), //output
|
460 |
|
|
|
461 |
|
|
.read_cpl (read_cpl), //input [1:0]
|
462 |
|
|
.read_address (read_address), //input [31:0]
|
463 |
|
|
.read_length (read_length), //input [3:0]
|
464 |
|
|
.read_lock (read_lock), //input
|
465 |
|
|
.read_rmw (read_rmw), //input
|
466 |
|
|
.read_data (read_data), //output [63:0]
|
467 |
|
|
//END
|
468 |
|
|
|
469 |
|
|
//REQ:
|
470 |
|
|
.write_do (write_do), //input
|
471 |
|
|
.write_done (write_done), //output
|
472 |
|
|
.write_page_fault (write_page_fault), //output
|
473 |
|
|
.write_ac_fault (write_ac_fault), //output
|
474 |
|
|
|
475 |
|
|
.write_cpl (write_cpl), //input [1:0]
|
476 |
|
|
.write_address (write_address), //input [31:0]
|
477 |
|
|
.write_length (write_length), //input [2:0]
|
478 |
|
|
.write_lock (write_lock), //input
|
479 |
|
|
.write_rmw (write_rmw), //input
|
480 |
|
|
.write_data (write_data), //input [31:0]
|
481 |
|
|
//END
|
482 |
|
|
|
483 |
|
|
//REQ:
|
484 |
|
|
.tlbcheck_do (tlbcheck_do), //input
|
485 |
|
|
.tlbcheck_done (tlbcheck_done), //output
|
486 |
|
|
.tlbcheck_page_fault (tlbcheck_page_fault), //output
|
487 |
|
|
|
488 |
|
|
.tlbcheck_address (tlbcheck_address), //input [31:0]
|
489 |
|
|
.tlbcheck_rw (tlbcheck_rw), //input
|
490 |
|
|
//END
|
491 |
|
|
|
492 |
|
|
.dcache_busy (dcache_busy), //output
|
493 |
|
|
|
494 |
|
|
//RESP:
|
495 |
|
|
.tlbflushsingle_do (tlbflushsingle_do), //input
|
496 |
|
|
.tlbflushsingle_done (tlbflushsingle_done), //output
|
497 |
|
|
.tlbflushsingle_address (tlbflushsingle_address), //input [31:0]
|
498 |
|
|
//END
|
499 |
|
|
|
500 |
|
|
.tlbflushall_do (tlbflushall_do), //input
|
501 |
|
|
|
502 |
|
|
.invdcode_do (invdcode_do), //input
|
503 |
|
|
.invdcode_done (invdcode_done), //output
|
504 |
|
|
|
505 |
|
|
.invddata_do (invddata_do), //input
|
506 |
|
|
.invddata_done (invddata_done), //output
|
507 |
|
|
|
508 |
|
|
.wbinvddata_do (wbinvddata_do), //input
|
509 |
|
|
.wbinvddata_done (wbinvddata_done), //output
|
510 |
|
|
|
511 |
|
|
// prefetch exported
|
512 |
|
|
.prefetch_cpl (prefetch_cpl), //input [1:0]
|
513 |
|
|
.prefetch_eip (prefetch_eip), //input [31:0]
|
514 |
|
|
.cs_cache (cs_cache), //input [63:0]
|
515 |
|
|
|
516 |
|
|
.cr0_pg (cr0_pg), //input
|
517 |
|
|
.cr0_wp (cr0_wp), //input
|
518 |
|
|
.cr0_am (cr0_am), //input
|
519 |
|
|
.cr0_cd (cr0_cd), //input
|
520 |
|
|
.cr0_nw (cr0_nw), //input
|
521 |
|
|
|
522 |
|
|
.acflag (acflag), //input
|
523 |
|
|
|
524 |
|
|
.cr3 (cr3), //input [31:0]
|
525 |
|
|
|
526 |
|
|
// prefetch_fifo exported
|
527 |
|
|
.prefetchfifo_accept_do (prefetchfifo_accept_do), //input
|
528 |
|
|
.prefetchfifo_accept_data (prefetchfifo_accept_data), //output [67:0]
|
529 |
|
|
.prefetchfifo_accept_empty (prefetchfifo_accept_empty), //output
|
530 |
|
|
|
531 |
|
|
// pipeline state
|
532 |
|
|
.pipeline_after_read_empty (pipeline_after_read_empty), //input
|
533 |
|
|
.pipeline_after_prefetch_empty (pipeline_after_prefetch_empty), //input
|
534 |
|
|
|
535 |
|
|
.tlb_code_pf_error_code (tlb_code_pf_error_code), //output [15:0]
|
536 |
|
|
.tlb_check_pf_error_code (tlb_check_pf_error_code), //output [15:0]
|
537 |
|
|
.tlb_write_pf_error_code (tlb_write_pf_error_code), //output [15:0]
|
538 |
|
|
.tlb_read_pf_error_code (tlb_read_pf_error_code), //output [15:0]
|
539 |
|
|
|
540 |
|
|
.tlb_code_pf_cr2 (tlb_code_pf_cr2), //output [31:0]
|
541 |
|
|
.tlb_check_pf_cr2 (tlb_check_pf_cr2), //output [31:0]
|
542 |
|
|
.tlb_write_pf_cr2 (tlb_write_pf_cr2), //output [31:0]
|
543 |
|
|
.tlb_read_pf_cr2 (tlb_read_pf_cr2), //output [31:0]
|
544 |
|
|
|
545 |
|
|
// reset exported
|
546 |
|
|
.pr_reset (pr_reset), //input
|
547 |
|
|
.rd_reset (rd_reset), //input
|
548 |
|
|
.exe_reset (exe_reset), //input
|
549 |
|
|
.wr_reset (wr_reset), //input
|
550 |
|
|
|
551 |
|
|
// avalon master
|
552 |
|
|
.avm_address (avm_address), //output [31:0]
|
553 |
|
|
.avm_writedata (avm_writedata), //output [31:0]
|
554 |
|
|
.avm_byteenable (avm_byteenable), //output [3:0]
|
555 |
|
|
.avm_burstcount (avm_burstcount), //output [2:0]
|
556 |
|
|
.avm_write (avm_write), //output
|
557 |
|
|
.avm_read (avm_read), //output
|
558 |
|
|
.avm_waitrequest (avm_waitrequest), //input
|
559 |
|
|
.avm_readdatavalid (avm_readdatavalid), //input
|
560 |
|
|
.avm_readdata (avm_readdata) //input [31:0]
|
561 |
|
|
);
|
562 |
|
|
|
563 |
|
|
//------------------------------------------------------------------------------
|
564 |
|
|
|
565 |
|
|
pipeline pipeline_inst(
|
566 |
|
|
.clk (clk),
|
567 |
|
|
.rst_n (rst_internal_n),
|
568 |
|
|
|
569 |
|
|
//to memory
|
570 |
|
|
.pr_reset (pr_reset), //output
|
571 |
|
|
.rd_reset (rd_reset), //output
|
572 |
|
|
.exe_reset (exe_reset), //output
|
573 |
|
|
.wr_reset (wr_reset), //output
|
574 |
|
|
|
575 |
|
|
.real_mode (real_mode), //output
|
576 |
|
|
|
577 |
|
|
//exception
|
578 |
|
|
.exc_restore_esp (exc_restore_esp), //input
|
579 |
|
|
.exc_set_rflag (exc_set_rflag), //input
|
580 |
|
|
.exc_debug_start (exc_debug_start), //input
|
581 |
|
|
|
582 |
|
|
.exc_init (exc_init), //input
|
583 |
|
|
.exc_load (exc_load), //input
|
584 |
|
|
.exc_eip (exc_eip), //input [31:0]
|
585 |
|
|
|
586 |
|
|
.exc_vector (exc_vector), //input [7:0]
|
587 |
|
|
.exc_error_code (exc_error_code), //input [15:0]
|
588 |
|
|
.exc_push_error (exc_push_error), //input
|
589 |
|
|
.exc_soft_int (exc_soft_int), //input
|
590 |
|
|
.exc_soft_int_ib (exc_soft_int_ib), //input
|
591 |
|
|
|
592 |
|
|
.exc_pf_read (exc_pf_read), //input
|
593 |
|
|
.exc_pf_write (exc_pf_write), //input
|
594 |
|
|
.exc_pf_code (exc_pf_code), //input
|
595 |
|
|
.exc_pf_check (exc_pf_check), //input
|
596 |
|
|
|
597 |
|
|
//pipeline eip
|
598 |
|
|
.eip (eip), //output [31:0]
|
599 |
|
|
.dec_eip (dec_eip), //output [31:0]
|
600 |
|
|
.rd_eip (rd_eip), //output [31:0]
|
601 |
|
|
.exe_eip (exe_eip), //output [31:0]
|
602 |
|
|
.wr_eip (wr_eip), //output [31:0]
|
603 |
|
|
|
604 |
|
|
.rd_consumed (rd_consumed), //output [3:0]
|
605 |
|
|
.exe_consumed (exe_consumed), //output [3:0]
|
606 |
|
|
.wr_consumed (wr_consumed), //output [3:0]
|
607 |
|
|
|
608 |
|
|
//exception reset
|
609 |
|
|
.exc_dec_reset (exc_dec_reset), //input
|
610 |
|
|
.exc_micro_reset (exc_micro_reset), //input
|
611 |
|
|
.exc_rd_reset (exc_rd_reset), //input
|
612 |
|
|
.exc_exe_reset (exc_exe_reset), //input
|
613 |
|
|
.exc_wr_reset (exc_wr_reset), //input
|
614 |
|
|
|
615 |
|
|
//global
|
616 |
|
|
.glob_param_1 (glob_param_1), //input [31:0]
|
617 |
|
|
.glob_param_2 (glob_param_2), //input [31:0]
|
618 |
|
|
.glob_param_3 (glob_param_3), //input [31:0]
|
619 |
|
|
.glob_param_4 (glob_param_4), //input [31:0]
|
620 |
|
|
.glob_param_5 (glob_param_5), //input [31:0]
|
621 |
|
|
|
622 |
|
|
.glob_descriptor (glob_descriptor), //input [63:0]
|
623 |
|
|
.glob_descriptor_2 (glob_descriptor_2), //input [63:0]
|
624 |
|
|
|
625 |
|
|
.glob_desc_base (glob_desc_base), //input [31:0]
|
626 |
|
|
|
627 |
|
|
.glob_desc_limit (glob_desc_limit), //input [31:0]
|
628 |
|
|
.glob_desc_2_limit (glob_desc_2_limit), //input [31:0]
|
629 |
|
|
|
630 |
|
|
//pipeline state
|
631 |
|
|
.rd_dec_is_front (rd_dec_is_front), //output
|
632 |
|
|
.rd_is_front (rd_is_front), //output
|
633 |
|
|
.exe_is_front (exe_is_front), //output
|
634 |
|
|
.wr_is_front (wr_is_front), //output
|
635 |
|
|
|
636 |
|
|
.pipeline_after_read_empty (pipeline_after_read_empty), //output
|
637 |
|
|
.pipeline_after_prefetch_empty (pipeline_after_prefetch_empty), //output
|
638 |
|
|
|
639 |
|
|
//dec exceptions
|
640 |
|
|
.dec_gp_fault (dec_gp_fault), //output
|
641 |
|
|
.dec_ud_fault (dec_ud_fault), //output
|
642 |
|
|
.dec_pf_fault (dec_pf_fault), //output
|
643 |
|
|
|
644 |
|
|
//rd exception
|
645 |
|
|
.rd_io_allow_fault (rd_io_allow_fault), //output
|
646 |
|
|
.rd_descriptor_gp_fault (rd_descriptor_gp_fault), //output
|
647 |
|
|
.rd_seg_gp_fault (rd_seg_gp_fault), //output
|
648 |
|
|
.rd_seg_ss_fault (rd_seg_ss_fault), //output
|
649 |
|
|
.rd_ss_esp_from_tss_fault (rd_ss_esp_from_tss_fault), //output
|
650 |
|
|
|
651 |
|
|
//exe exception
|
652 |
|
|
.exe_bound_fault (exe_bound_fault), //output
|
653 |
|
|
.exe_trigger_gp_fault (exe_trigger_gp_fault), //output
|
654 |
|
|
.exe_trigger_ts_fault (exe_trigger_ts_fault), //output
|
655 |
|
|
.exe_trigger_ss_fault (exe_trigger_ss_fault), //output
|
656 |
|
|
.exe_trigger_np_fault (exe_trigger_np_fault), //output
|
657 |
|
|
.exe_trigger_pf_fault (exe_trigger_pf_fault), //output
|
658 |
|
|
.exe_trigger_db_fault (exe_trigger_db_fault), //output
|
659 |
|
|
.exe_trigger_nm_fault (exe_trigger_nm_fault), //output
|
660 |
|
|
.exe_load_seg_gp_fault (exe_load_seg_gp_fault), //output
|
661 |
|
|
.exe_load_seg_ss_fault (exe_load_seg_ss_fault), //output
|
662 |
|
|
.exe_load_seg_np_fault (exe_load_seg_np_fault), //output
|
663 |
|
|
.exe_div_exception (exe_div_exception), //output
|
664 |
|
|
|
665 |
|
|
//wr exception
|
666 |
|
|
.wr_debug_init (wr_debug_init), //output
|
667 |
|
|
.wr_new_push_ss_fault (wr_new_push_ss_fault), //output
|
668 |
|
|
.wr_string_es_fault (wr_string_es_fault), //output
|
669 |
|
|
.wr_push_ss_fault (wr_push_ss_fault), //output
|
670 |
|
|
|
671 |
|
|
//error code
|
672 |
|
|
.rd_error_code (rd_error_code), //output [15:0]
|
673 |
|
|
.exe_error_code (exe_error_code), //output [15:0]
|
674 |
|
|
.wr_error_code (wr_error_code), //output [15:0]
|
675 |
|
|
|
676 |
|
|
//glob output
|
677 |
|
|
.glob_descriptor_set (glob_descriptor_set), //output
|
678 |
|
|
.glob_descriptor_value (glob_descriptor_value), //output [63:0]
|
679 |
|
|
.glob_descriptor_2_set (glob_descriptor_2_set), //output
|
680 |
|
|
.glob_descriptor_2_value (glob_descriptor_2_value), //output [63:0]
|
681 |
|
|
|
682 |
|
|
.glob_param_1_set (glob_param_1_set), //output
|
683 |
|
|
.glob_param_1_value (glob_param_1_value), //output [31:0]
|
684 |
|
|
.glob_param_2_set (glob_param_2_set), //output
|
685 |
|
|
.glob_param_2_value (glob_param_2_value), //output [31:0]
|
686 |
|
|
.glob_param_3_set (glob_param_3_set), //output
|
687 |
|
|
.glob_param_3_value (glob_param_3_value), //output [31:0]
|
688 |
|
|
.glob_param_4_set (glob_param_4_set), //output
|
689 |
|
|
.glob_param_4_value (glob_param_4_value), //output [31:0]
|
690 |
|
|
.glob_param_5_set (glob_param_5_set), //output
|
691 |
|
|
.glob_param_5_value (glob_param_5_value), //output [31:0]
|
692 |
|
|
|
693 |
|
|
// prefetch
|
694 |
|
|
.prefetch_cpl (prefetch_cpl), //output [1:0]
|
695 |
|
|
.prefetch_eip (prefetch_eip), //output [31:0]
|
696 |
|
|
|
697 |
|
|
.cs_cache (cs_cache), //output [63:0]
|
698 |
|
|
|
699 |
|
|
.cr0_pg (cr0_pg), //output
|
700 |
|
|
.cr0_wp (cr0_wp), //output
|
701 |
|
|
.cr0_am (cr0_am), //output
|
702 |
|
|
.cr0_cd (cr0_cd), //output
|
703 |
|
|
.cr0_nw (cr0_nw), //output
|
704 |
|
|
|
705 |
|
|
.acflag (acflag), //output
|
706 |
|
|
|
707 |
|
|
.cr3 (cr3), //output [31:0]
|
708 |
|
|
|
709 |
|
|
// prefetch_fifo
|
710 |
|
|
.prefetchfifo_accept_do (prefetchfifo_accept_do), //output
|
711 |
|
|
.prefetchfifo_accept_data (prefetchfifo_accept_data), //input [67:0]
|
712 |
|
|
.prefetchfifo_accept_empty (prefetchfifo_accept_empty), //input
|
713 |
|
|
|
714 |
|
|
//io_read
|
715 |
|
|
.io_read_do (io_read_do), //output
|
716 |
|
|
.io_read_address (io_read_address), //output [15:0]
|
717 |
|
|
.io_read_length (io_read_length), //output [2:0]
|
718 |
|
|
.io_read_data (io_read_data), //input [31:0]
|
719 |
|
|
.io_read_done (io_read_done), //input
|
720 |
|
|
|
721 |
|
|
//read memory
|
722 |
|
|
.read_do (read_do), //output
|
723 |
|
|
.read_done (read_done), //input
|
724 |
|
|
.read_page_fault (read_page_fault), //input
|
725 |
|
|
.read_ac_fault (read_ac_fault), //input
|
726 |
|
|
|
727 |
|
|
.read_cpl (read_cpl), //output [1:0]
|
728 |
|
|
.read_address (read_address), //output [31:0]
|
729 |
|
|
.read_length (read_length), //output [3:0]
|
730 |
|
|
.read_lock (read_lock), //output
|
731 |
|
|
.read_rmw (read_rmw), //output
|
732 |
|
|
.read_data (read_data), //input [63:0]
|
733 |
|
|
|
734 |
|
|
//tlbcheck
|
735 |
|
|
.tlbcheck_do (tlbcheck_do), //output
|
736 |
|
|
.tlbcheck_done (tlbcheck_done), //input
|
737 |
|
|
.tlbcheck_page_fault (tlbcheck_page_fault), //input
|
738 |
|
|
|
739 |
|
|
.tlbcheck_address (tlbcheck_address), //output [31:0]
|
740 |
|
|
.tlbcheck_rw (tlbcheck_rw), //output
|
741 |
|
|
|
742 |
|
|
//tlbflushsingle
|
743 |
|
|
.tlbflushsingle_do (tlbflushsingle_do), //output
|
744 |
|
|
.tlbflushsingle_done (tlbflushsingle_done), //input
|
745 |
|
|
|
746 |
|
|
.tlbflushsingle_address (tlbflushsingle_address), //output [31:0]
|
747 |
|
|
|
748 |
|
|
//flush tlb
|
749 |
|
|
.tlbflushall_do (tlbflushall_do), //output
|
750 |
|
|
|
751 |
|
|
.invdcode_do (invdcode_do), //output
|
752 |
|
|
.invdcode_done (invdcode_done), //input
|
753 |
|
|
|
754 |
|
|
.invddata_do (invddata_do), //output
|
755 |
|
|
.invddata_done (invddata_done), //input
|
756 |
|
|
|
757 |
|
|
.wbinvddata_do (wbinvddata_do), //output
|
758 |
|
|
.wbinvddata_done (wbinvddata_done), //input
|
759 |
|
|
|
760 |
|
|
//interrupt
|
761 |
|
|
.interrupt_do (interrupt_do), //input
|
762 |
|
|
|
763 |
|
|
.wr_interrupt_possible (wr_interrupt_possible), //output
|
764 |
|
|
.wr_string_in_progress_final (wr_string_in_progress_final), //output
|
765 |
|
|
.wr_is_esp_speculative (wr_is_esp_speculative), //output
|
766 |
|
|
|
767 |
|
|
//software interrupt
|
768 |
|
|
.wr_int (wr_int), //output
|
769 |
|
|
.wr_int_soft_int (wr_int_soft_int), //output
|
770 |
|
|
.wr_int_soft_int_ib (wr_int_soft_int_ib), //output
|
771 |
|
|
.wr_int_vector (wr_int_vector), //output [7:0]
|
772 |
|
|
|
773 |
|
|
.wr_exception_external_set (wr_exception_external_set), //output
|
774 |
|
|
.wr_exception_finished (wr_exception_finished), //output
|
775 |
|
|
|
776 |
|
|
//memory page fault
|
777 |
|
|
.tlb_code_pf_cr2 (tlb_code_pf_cr2), //input [31:0]
|
778 |
|
|
.tlb_write_pf_cr2 (tlb_write_pf_cr2), //input [31:0]
|
779 |
|
|
.tlb_read_pf_cr2 (tlb_read_pf_cr2), //input [31:0]
|
780 |
|
|
.tlb_check_pf_cr2 (tlb_check_pf_cr2), //input [31:0]
|
781 |
|
|
|
782 |
|
|
//memory write
|
783 |
|
|
.write_do (write_do), //output
|
784 |
|
|
.write_done (write_done), //input
|
785 |
|
|
.write_page_fault (write_page_fault), //input
|
786 |
|
|
.write_ac_fault (write_ac_fault), //input
|
787 |
|
|
|
788 |
|
|
.write_cpl (write_cpl), //output [1:0]
|
789 |
|
|
.write_address (write_address), //output [31:0]
|
790 |
|
|
.write_length (write_length), //output [2:0]
|
791 |
|
|
.write_lock (write_lock), //output
|
792 |
|
|
.write_rmw (write_rmw), //output
|
793 |
|
|
.write_data (write_data), //output [31:0]
|
794 |
|
|
|
795 |
|
|
//io write
|
796 |
|
|
.io_write_do (io_write_do), //output
|
797 |
|
|
.io_write_address (io_write_address), //output [15:0]
|
798 |
|
|
.io_write_length (io_write_length), //output [2:0]
|
799 |
|
|
.io_write_data (io_write_data), //output [31:0]
|
800 |
|
|
.io_write_done (io_write_done) //input
|
801 |
|
|
);
|
802 |
|
|
|
803 |
|
|
//------------------------------------------------------------------------------
|
804 |
|
|
|
805 |
|
|
endmodule
|