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 read(
|
30 |
|
|
input clk,
|
31 |
|
|
input rst_n,
|
32 |
|
|
|
33 |
|
|
input rd_reset,
|
34 |
|
|
|
35 |
|
|
//debug input
|
36 |
|
|
input [31:0] dr0,
|
37 |
|
|
input [31:0] dr1,
|
38 |
|
|
input [31:0] dr2,
|
39 |
|
|
input [31:0] dr3,
|
40 |
|
|
input [31:0] dr7,
|
41 |
|
|
|
42 |
|
|
input [2:0] debug_len0,
|
43 |
|
|
input [2:0] debug_len1,
|
44 |
|
|
input [2:0] debug_len2,
|
45 |
|
|
input [2:0] debug_len3,
|
46 |
|
|
|
47 |
|
|
//global input
|
48 |
|
|
input [63:0] glob_descriptor,
|
49 |
|
|
|
50 |
|
|
input [31:0] glob_param_1,
|
51 |
|
|
input [31:0] glob_param_2,
|
52 |
|
|
input [31:0] glob_param_3,
|
53 |
|
|
|
54 |
|
|
input [31:0] glob_desc_limit,
|
55 |
|
|
input [31:0] glob_desc_base,
|
56 |
|
|
|
57 |
|
|
//general input
|
58 |
|
|
input [15:0] gdtr_limit,
|
59 |
|
|
|
60 |
|
|
input [31:0] gdtr_base,
|
61 |
|
|
input [31:0] idtr_base,
|
62 |
|
|
|
63 |
|
|
input es_cache_valid,
|
64 |
|
|
input [63:0] es_cache,
|
65 |
|
|
|
66 |
|
|
input cs_cache_valid,
|
67 |
|
|
input [63:0] cs_cache,
|
68 |
|
|
|
69 |
|
|
input ss_cache_valid,
|
70 |
|
|
input [63:0] ss_cache,
|
71 |
|
|
|
72 |
|
|
input ds_cache_valid,
|
73 |
|
|
input [63:0] ds_cache,
|
74 |
|
|
|
75 |
|
|
input fs_cache_valid,
|
76 |
|
|
input [63:0] fs_cache,
|
77 |
|
|
|
78 |
|
|
input gs_cache_valid,
|
79 |
|
|
input [63:0] gs_cache,
|
80 |
|
|
|
81 |
|
|
input tr_cache_valid,
|
82 |
|
|
input [63:0] tr_cache,
|
83 |
|
|
input [15:0] tr,
|
84 |
|
|
|
85 |
|
|
input ldtr_cache_valid,
|
86 |
|
|
input [63:0] ldtr_cache,
|
87 |
|
|
|
88 |
|
|
input [1:0] cpl,
|
89 |
|
|
|
90 |
|
|
input [1:0] iopl,
|
91 |
|
|
|
92 |
|
|
input cr0_pg,
|
93 |
|
|
|
94 |
|
|
input real_mode,
|
95 |
|
|
input v8086_mode,
|
96 |
|
|
input protected_mode,
|
97 |
|
|
|
98 |
|
|
input io_allow_check_needed,
|
99 |
|
|
|
100 |
|
|
input [31:0] eax,
|
101 |
|
|
input [31:0] ebx,
|
102 |
|
|
input [31:0] ecx,
|
103 |
|
|
input [31:0] edx,
|
104 |
|
|
input [31:0] esp,
|
105 |
|
|
input [31:0] ebp,
|
106 |
|
|
input [31:0] esi,
|
107 |
|
|
input [31:0] edi,
|
108 |
|
|
|
109 |
|
|
//pipeline input
|
110 |
|
|
input exe_trigger_gp_fault,
|
111 |
|
|
|
112 |
|
|
input [10:0] exe_mutex,
|
113 |
|
|
input [10:0] wr_mutex,
|
114 |
|
|
|
115 |
|
|
input [31:0] wr_esp_prev,
|
116 |
|
|
|
117 |
|
|
input [7:0] exc_vector,
|
118 |
|
|
|
119 |
|
|
//rd exception
|
120 |
|
|
output rd_io_allow_fault,
|
121 |
|
|
output [15:0] rd_error_code,
|
122 |
|
|
output rd_descriptor_gp_fault,
|
123 |
|
|
output reg rd_seg_gp_fault,
|
124 |
|
|
output reg rd_seg_ss_fault,
|
125 |
|
|
output rd_ss_esp_from_tss_fault,
|
126 |
|
|
|
127 |
|
|
//pipeline state
|
128 |
|
|
output rd_dec_is_front,
|
129 |
|
|
output rd_is_front,
|
130 |
|
|
|
131 |
|
|
//glob output
|
132 |
|
|
output rd_glob_descriptor_set,
|
133 |
|
|
output [63:0] rd_glob_descriptor_value,
|
134 |
|
|
|
135 |
|
|
output rd_glob_descriptor_2_set,
|
136 |
|
|
output [63:0] rd_glob_descriptor_2_value,
|
137 |
|
|
|
138 |
|
|
output rd_glob_param_1_set,
|
139 |
|
|
output [31:0] rd_glob_param_1_value,
|
140 |
|
|
output rd_glob_param_2_set,
|
141 |
|
|
output [31:0] rd_glob_param_2_value,
|
142 |
|
|
output rd_glob_param_3_set,
|
143 |
|
|
output [31:0] rd_glob_param_3_value,
|
144 |
|
|
output rd_glob_param_4_set,
|
145 |
|
|
output [31:0] rd_glob_param_4_value,
|
146 |
|
|
output rd_glob_param_5_set,
|
147 |
|
|
output [31:0] rd_glob_param_5_value,
|
148 |
|
|
|
149 |
|
|
//io_read
|
150 |
|
|
output io_read_do,
|
151 |
|
|
output [15:0] io_read_address,
|
152 |
|
|
output [2:0] io_read_length,
|
153 |
|
|
input [31:0] io_read_data,
|
154 |
|
|
input io_read_done,
|
155 |
|
|
|
156 |
|
|
//read
|
157 |
|
|
output read_do,
|
158 |
|
|
input read_done,
|
159 |
|
|
input read_page_fault,
|
160 |
|
|
input read_ac_fault,
|
161 |
|
|
|
162 |
|
|
output [1:0] read_cpl,
|
163 |
|
|
output [31:0] read_address,
|
164 |
|
|
output [3:0] read_length,
|
165 |
|
|
output read_lock,
|
166 |
|
|
output read_rmw,
|
167 |
|
|
input [63:0] read_data,
|
168 |
|
|
|
169 |
|
|
//micro pipeline
|
170 |
|
|
output rd_busy,
|
171 |
|
|
input micro_ready,
|
172 |
|
|
|
173 |
|
|
input [87:0] micro_decoder,
|
174 |
|
|
input [31:0] micro_eip,
|
175 |
|
|
input micro_operand_32bit,
|
176 |
|
|
input micro_address_32bit,
|
177 |
|
|
input [1:0] micro_prefix_group_1_rep,
|
178 |
|
|
input micro_prefix_group_1_lock,
|
179 |
|
|
input [2:0] micro_prefix_group_2_seg,
|
180 |
|
|
input micro_prefix_2byte,
|
181 |
|
|
input [3:0] micro_consumed,
|
182 |
|
|
input [2:0] micro_modregrm_len,
|
183 |
|
|
input micro_is_8bit,
|
184 |
|
|
input [6:0] micro_cmd,
|
185 |
|
|
input [3:0] micro_cmdex,
|
186 |
|
|
|
187 |
|
|
//rd pipeline
|
188 |
|
|
input exe_busy,
|
189 |
|
|
output rd_ready,
|
190 |
|
|
|
191 |
|
|
output reg [87:0] rd_decoder,
|
192 |
|
|
output reg [31:0] rd_eip,
|
193 |
|
|
output reg rd_operand_32bit,
|
194 |
|
|
output reg rd_address_32bit,
|
195 |
|
|
output reg [1:0] rd_prefix_group_1_rep,
|
196 |
|
|
output reg rd_prefix_group_1_lock,
|
197 |
|
|
output reg rd_prefix_2byte,
|
198 |
|
|
output reg [3:0] rd_consumed,
|
199 |
|
|
output reg rd_is_8bit,
|
200 |
|
|
output reg [6:0] rd_cmd,
|
201 |
|
|
output reg [3:0] rd_cmdex,
|
202 |
|
|
output [31:0] rd_modregrm_imm,
|
203 |
|
|
output [10:0] rd_mutex_next,
|
204 |
|
|
output rd_dst_is_reg,
|
205 |
|
|
output rd_dst_is_rm,
|
206 |
|
|
output rd_dst_is_memory,
|
207 |
|
|
output rd_dst_is_eax,
|
208 |
|
|
output rd_dst_is_edx_eax,
|
209 |
|
|
output rd_dst_is_implicit_reg,
|
210 |
|
|
output [31:0] rd_extra_wire,
|
211 |
|
|
output [31:0] rd_linear,
|
212 |
|
|
output [3:0] rd_debug_read,
|
213 |
|
|
output [31:0] src_wire,
|
214 |
|
|
output [31:0] dst_wire,
|
215 |
|
|
output [31:0] rd_address_effective
|
216 |
|
|
);
|
217 |
|
|
|
218 |
|
|
//------------------------------------------------------------------------------
|
219 |
|
|
|
220 |
|
|
wire r_load;
|
221 |
|
|
|
222 |
|
|
wire [1:0] rd_modregrm_mod;
|
223 |
|
|
wire [2:0] rd_modregrm_reg;
|
224 |
|
|
wire [2:0] rd_modregrm_rm;
|
225 |
|
|
wire [7:0] rd_sib;
|
226 |
|
|
|
227 |
|
|
wire rd_operand_16bit;
|
228 |
|
|
wire rd_address_16bit;
|
229 |
|
|
|
230 |
|
|
//------------------------------------------------------------------------------
|
231 |
|
|
|
232 |
|
|
assign rd_ready = ~(rd_reset) && ~(rd_waiting) && rd_cmd != `CMD_NULL && ~(exe_busy);
|
233 |
|
|
|
234 |
|
|
assign rd_busy = rd_waiting || (rd_ready == `FALSE && rd_cmd != `CMD_NULL);
|
235 |
|
|
|
236 |
|
|
assign r_load = micro_ready;
|
237 |
|
|
|
238 |
|
|
//------------------------------------------------------------------------------
|
239 |
|
|
|
240 |
|
|
reg [2:0] rd_modregrm_len;
|
241 |
|
|
reg [2:0] rd_prefix_group_2_seg;
|
242 |
|
|
|
243 |
|
|
always @(posedge clk or negedge rst_n) begin if(rst_n == 1'b0) rd_decoder <= 88'd0; else if(r_load) rd_decoder <= micro_decoder; end
|
244 |
|
|
always @(posedge clk or negedge rst_n) begin if(rst_n == 1'b0) rd_eip <= 32'd0; else if(r_load) rd_eip <= micro_eip; end
|
245 |
|
|
always @(posedge clk or negedge rst_n) begin if(rst_n == 1'b0) rd_operand_32bit <= `FALSE; else if(r_load) rd_operand_32bit <= micro_operand_32bit; end
|
246 |
|
|
always @(posedge clk or negedge rst_n) begin if(rst_n == 1'b0) rd_address_32bit <= `FALSE; else if(r_load) rd_address_32bit <= micro_address_32bit; end
|
247 |
|
|
always @(posedge clk or negedge rst_n) begin if(rst_n == 1'b0) rd_prefix_group_1_rep <= 2'd0; else if(r_load) rd_prefix_group_1_rep <= micro_prefix_group_1_rep; end
|
248 |
|
|
always @(posedge clk or negedge rst_n) begin if(rst_n == 1'b0) rd_prefix_group_1_lock <= `FALSE; else if(r_load) rd_prefix_group_1_lock <= micro_prefix_group_1_lock; end
|
249 |
|
|
always @(posedge clk or negedge rst_n) begin if(rst_n == 1'b0) rd_prefix_group_2_seg <= 3'd3; else if(r_load) rd_prefix_group_2_seg <= micro_prefix_group_2_seg; end
|
250 |
|
|
always @(posedge clk or negedge rst_n) begin if(rst_n == 1'b0) rd_prefix_2byte <= `FALSE; else if(r_load) rd_prefix_2byte <= micro_prefix_2byte; end
|
251 |
|
|
always @(posedge clk or negedge rst_n) begin if(rst_n == 1'b0) rd_consumed <= 4'd0; else if(r_load) rd_consumed <= micro_consumed; end
|
252 |
|
|
always @(posedge clk or negedge rst_n) begin if(rst_n == 1'b0) rd_modregrm_len <= 3'd0; else if(r_load) rd_modregrm_len <= micro_modregrm_len; end
|
253 |
|
|
always @(posedge clk or negedge rst_n) begin if(rst_n == 1'b0) rd_is_8bit <= `FALSE; else if(r_load) rd_is_8bit <= micro_is_8bit; end
|
254 |
|
|
always @(posedge clk or negedge rst_n) begin if(rst_n == 1'b0) rd_cmdex <= 4'd0; else if(r_load) rd_cmdex <= micro_cmdex; end
|
255 |
|
|
|
256 |
|
|
always @(posedge clk or negedge rst_n) begin
|
257 |
|
|
if(rst_n == 1'b0) rd_cmd <= `CMD_NULL;
|
258 |
|
|
else if(rd_reset) rd_cmd <= `CMD_NULL;
|
259 |
|
|
else if(r_load) rd_cmd <= micro_cmd;
|
260 |
|
|
else if(rd_ready) rd_cmd <= `CMD_NULL;
|
261 |
|
|
end
|
262 |
|
|
|
263 |
|
|
//------------------------------------------------------------------------------
|
264 |
|
|
|
265 |
|
|
assign rd_modregrm_mod = rd_decoder[15:14];
|
266 |
|
|
assign rd_modregrm_reg = rd_decoder[13:11];
|
267 |
|
|
assign rd_modregrm_rm = rd_decoder[10:8];
|
268 |
|
|
assign rd_sib = rd_decoder[23:16];
|
269 |
|
|
|
270 |
|
|
assign rd_operand_16bit = ~(rd_operand_32bit);
|
271 |
|
|
assign rd_address_16bit = ~(rd_address_32bit);
|
272 |
|
|
|
273 |
|
|
//------------------------------------------------------------------------------
|
274 |
|
|
|
275 |
|
|
wire rd_descriptor_not_in_limits;
|
276 |
|
|
wire [31:0] rd_descriptor_offset;
|
277 |
|
|
|
278 |
|
|
reg rd_address_effective_ready_delayed;
|
279 |
|
|
wire write_virtual_check_ready;
|
280 |
|
|
|
281 |
|
|
//------------------------------------------------------------------------------
|
282 |
|
|
|
283 |
|
|
wire memory_read_system;
|
284 |
|
|
reg rd_one_mem_read;
|
285 |
|
|
wire read_for_rd_ready;
|
286 |
|
|
|
287 |
|
|
wire [31:0] read_4;
|
288 |
|
|
wire [63:0] read_8;
|
289 |
|
|
|
290 |
|
|
//------------------------------------------------------------------------------
|
291 |
|
|
|
292 |
|
|
wire rd_io_ready;
|
293 |
|
|
reg rd_one_io_read;
|
294 |
|
|
|
295 |
|
|
|
296 |
|
|
//------------------------------------------------------------------------------
|
297 |
|
|
|
298 |
|
|
wire [2:0] src_reg_index;
|
299 |
|
|
wire [2:0] dst_reg_index;
|
300 |
|
|
|
301 |
|
|
//------------------------------------------------------------------------------
|
302 |
|
|
|
303 |
|
|
reg [31:0] rd_memory_last;
|
304 |
|
|
|
305 |
|
|
//------------------------------------------------------------------------------
|
306 |
|
|
|
307 |
|
|
wire [31:0] rd_seg_linear;
|
308 |
|
|
|
309 |
|
|
wire [31:0] tr_base;
|
310 |
|
|
wire [31:0] ldtr_base;
|
311 |
|
|
|
312 |
|
|
wire [31:0] tr_limit;
|
313 |
|
|
wire [31:0] ldtr_limit;
|
314 |
|
|
|
315 |
|
|
//------------------------------------------------------------------------------
|
316 |
|
|
|
317 |
|
|
wire rd_address_effective_ready;
|
318 |
|
|
|
319 |
|
|
wire rd_address_effective_do;
|
320 |
|
|
|
321 |
|
|
//------------------------------------------------------------------------------
|
322 |
|
|
|
323 |
|
|
wire rd_mutex_busy_active;
|
324 |
|
|
wire rd_mutex_busy_memory;
|
325 |
|
|
wire rd_mutex_busy_eflags;
|
326 |
|
|
wire rd_mutex_busy_ebp;
|
327 |
|
|
wire rd_mutex_busy_esp;
|
328 |
|
|
wire rd_mutex_busy_edx;
|
329 |
|
|
wire rd_mutex_busy_ecx;
|
330 |
|
|
wire rd_mutex_busy_eax;
|
331 |
|
|
wire rd_mutex_busy_modregrm_reg;
|
332 |
|
|
wire rd_mutex_busy_modregrm_rm;
|
333 |
|
|
wire rd_mutex_busy_implicit_reg;
|
334 |
|
|
|
335 |
|
|
wire rd_address_waiting;
|
336 |
|
|
|
337 |
|
|
//------------------------------------------------------------------------------
|
338 |
|
|
|
339 |
|
|
wire [31:0] rd_system_linear;
|
340 |
|
|
wire rd_waiting;
|
341 |
|
|
|
342 |
|
|
wire rd_req_memory;
|
343 |
|
|
wire rd_req_eflags;
|
344 |
|
|
wire rd_req_all;
|
345 |
|
|
wire rd_req_reg;
|
346 |
|
|
wire rd_req_rm;
|
347 |
|
|
wire rd_req_implicit_reg;
|
348 |
|
|
wire rd_req_reg_not_8bit;
|
349 |
|
|
wire rd_req_edi;
|
350 |
|
|
wire rd_req_esi;
|
351 |
|
|
wire rd_req_ebp;
|
352 |
|
|
wire rd_req_esp;
|
353 |
|
|
wire rd_req_ebx;
|
354 |
|
|
wire rd_req_edx_eax;
|
355 |
|
|
wire rd_req_edx;
|
356 |
|
|
wire rd_req_ecx;
|
357 |
|
|
wire rd_req_eax;
|
358 |
|
|
|
359 |
|
|
wire address_enter_init;
|
360 |
|
|
wire address_enter;
|
361 |
|
|
wire address_enter_last;
|
362 |
|
|
wire address_leave;
|
363 |
|
|
wire address_esi;
|
364 |
|
|
wire address_edi;
|
365 |
|
|
wire address_xlat_transform;
|
366 |
|
|
wire address_bits_transform;
|
367 |
|
|
wire address_stack_pop;
|
368 |
|
|
wire address_stack_pop_speedup;
|
369 |
|
|
wire address_stack_pop_next;
|
370 |
|
|
wire address_stack_pop_esp_prev;
|
371 |
|
|
wire address_stack_pop_for_call;
|
372 |
|
|
wire address_stack_save;
|
373 |
|
|
wire address_stack_add_4_to_saved;
|
374 |
|
|
wire address_stack_for_ret_first;
|
375 |
|
|
wire address_stack_for_ret_second;
|
376 |
|
|
wire address_stack_for_iret_first;
|
377 |
|
|
wire address_stack_for_iret_second;
|
378 |
|
|
wire address_stack_for_iret_third;
|
379 |
|
|
wire address_stack_for_iret_last;
|
380 |
|
|
wire address_stack_for_iret_to_v86;
|
381 |
|
|
wire address_stack_for_call_param_first;
|
382 |
|
|
wire address_ea_buffer;
|
383 |
|
|
wire address_ea_buffer_plus_2;
|
384 |
|
|
wire address_memoffset;
|
385 |
|
|
|
386 |
|
|
wire read_virtual;
|
387 |
|
|
wire read_rmw_virtual;
|
388 |
|
|
wire write_virtual_check;
|
389 |
|
|
|
390 |
|
|
wire read_system_descriptor;
|
391 |
|
|
wire read_system_word;
|
392 |
|
|
wire read_system_dword;
|
393 |
|
|
wire read_system_qword;
|
394 |
|
|
wire read_rmw_system_dword;
|
395 |
|
|
|
396 |
|
|
wire read_length_word;
|
397 |
|
|
wire read_length_dword;
|
398 |
|
|
|
399 |
|
|
wire rd_src_is_memory;
|
400 |
|
|
wire rd_src_is_io;
|
401 |
|
|
wire rd_src_is_modregrm_imm;
|
402 |
|
|
wire rd_src_is_modregrm_imm_se;
|
403 |
|
|
wire rd_src_is_imm;
|
404 |
|
|
wire rd_src_is_imm_se;
|
405 |
|
|
wire rd_src_is_1;
|
406 |
|
|
wire rd_src_is_eax;
|
407 |
|
|
wire rd_src_is_ecx;
|
408 |
|
|
wire rd_src_is_cmdex;
|
409 |
|
|
wire rd_src_is_implicit_reg;
|
410 |
|
|
wire rd_src_is_rm;
|
411 |
|
|
wire rd_src_is_reg; //not used
|
412 |
|
|
|
413 |
|
|
wire rd_dst_is_0;
|
414 |
|
|
wire rd_dst_is_modregrm_imm_se;
|
415 |
|
|
wire rd_dst_is_modregrm_imm;
|
416 |
|
|
wire rd_dst_is_memory_last;
|
417 |
|
|
wire rd_dst_is_eip;
|
418 |
|
|
|
419 |
|
|
//------------------------------------------------------------------------------
|
420 |
|
|
|
421 |
|
|
// synthesis translate_off
|
422 |
|
|
wire _unused_ok = &{ 1'b0, rd_src_is_reg, 1'b0 };
|
423 |
|
|
// synthesis translate_on
|
424 |
|
|
|
425 |
|
|
//------------------------------------------------------------------------------
|
426 |
|
|
|
427 |
|
|
always @(posedge clk or negedge rst_n) begin
|
428 |
|
|
if(rst_n == 1'b0) rd_memory_last <= 32'd0;
|
429 |
|
|
else if(read_for_rd_ready && rd_ready) rd_memory_last <= read_4;
|
430 |
|
|
end
|
431 |
|
|
|
432 |
|
|
//------------------------------------------------------------------------------
|
433 |
|
|
|
434 |
|
|
assign rd_modregrm_imm =
|
435 |
|
|
(rd_modregrm_len == 3'd2)? rd_decoder[47:16] :
|
436 |
|
|
(rd_modregrm_len == 3'd3)? rd_decoder[55:24] :
|
437 |
|
|
(rd_modregrm_len == 3'd4)? rd_decoder[63:32] :
|
438 |
|
|
(rd_modregrm_len == 3'd6)? rd_decoder[79:48] :
|
439 |
|
|
rd_decoder[87:56]; //rd_modregrm_len == 3'd7
|
440 |
|
|
|
441 |
|
|
assign src_reg_index =
|
442 |
|
|
(rd_src_is_cmdex)? rd_cmdex[2:0] :
|
443 |
|
|
(rd_src_is_implicit_reg)? rd_decoder[2:0] :
|
444 |
|
|
(rd_src_is_rm)? rd_modregrm_rm :
|
445 |
|
|
rd_modregrm_reg;
|
446 |
|
|
|
447 |
|
|
assign dst_reg_index =
|
448 |
|
|
(rd_dst_is_implicit_reg)? rd_decoder[2:0] :
|
449 |
|
|
(rd_dst_is_rm)? rd_modregrm_rm :
|
450 |
|
|
rd_modregrm_reg;
|
451 |
|
|
|
452 |
|
|
//------------------------------------------------------------------------------
|
453 |
|
|
|
454 |
|
|
assign src_wire =
|
455 |
|
|
(rd_src_is_memory)? read_4 :
|
456 |
|
|
(rd_src_is_io)? io_read_data :
|
457 |
|
|
(rd_src_is_modregrm_imm)? rd_modregrm_imm :
|
458 |
|
|
(rd_src_is_modregrm_imm_se)? { {24{rd_modregrm_imm[7]}}, rd_modregrm_imm[7:0] } :
|
459 |
|
|
(rd_src_is_imm || (rd_src_is_imm_se && ~(rd_is_8bit)))? rd_decoder[39:8] :
|
460 |
|
|
(rd_src_is_imm_se)? { {24{rd_decoder[15]}}, rd_decoder[15:8] } :
|
461 |
|
|
(rd_src_is_1)? 32'd1 :
|
462 |
|
|
(rd_src_is_eax)? eax :
|
463 |
|
|
(rd_src_is_ecx)? ecx :
|
464 |
|
|
(src_reg_index == 3'd0)? eax :
|
465 |
|
|
(src_reg_index == 3'd1)? ecx :
|
466 |
|
|
(src_reg_index == 3'd2)? edx :
|
467 |
|
|
(src_reg_index == 3'd3)? ebx :
|
468 |
|
|
(src_reg_index == 3'd4 && rd_is_8bit)? { 24'd0, eax[15:8] } :
|
469 |
|
|
(src_reg_index == 3'd4)? esp :
|
470 |
|
|
(src_reg_index == 3'd5 && rd_is_8bit)? { 24'd0, ecx[15:8] } :
|
471 |
|
|
(src_reg_index == 3'd5)? ebp :
|
472 |
|
|
(src_reg_index == 3'd6 && rd_is_8bit)? { 24'd0, edx[15:8] } :
|
473 |
|
|
(src_reg_index == 3'd6)? esi :
|
474 |
|
|
(src_reg_index == 3'd7 && rd_is_8bit)? { 24'd0, ebx[15:8] } :
|
475 |
|
|
edi;
|
476 |
|
|
|
477 |
|
|
|
478 |
|
|
assign dst_wire =
|
479 |
|
|
(rd_dst_is_0)? 32'd0 :
|
480 |
|
|
(rd_dst_is_modregrm_imm_se)? { {24{rd_modregrm_imm[7]}}, rd_modregrm_imm[7:0] } :
|
481 |
|
|
(rd_dst_is_modregrm_imm)? rd_modregrm_imm : //must be before reg
|
482 |
|
|
(rd_dst_is_memory)? read_4 :
|
483 |
|
|
(rd_dst_is_memory_last)? rd_memory_last :
|
484 |
|
|
(rd_dst_is_eip)? rd_eip :
|
485 |
|
|
(rd_dst_is_eax || rd_dst_is_edx_eax)? eax :
|
486 |
|
|
(dst_reg_index == 3'd0)? eax :
|
487 |
|
|
(dst_reg_index == 3'd1)? ecx :
|
488 |
|
|
(dst_reg_index == 3'd2)? edx :
|
489 |
|
|
(dst_reg_index == 3'd3)? ebx :
|
490 |
|
|
(dst_reg_index == 3'd4 && rd_is_8bit)? { 24'd0, eax[15:8] } :
|
491 |
|
|
(dst_reg_index == 3'd4)? esp :
|
492 |
|
|
(dst_reg_index == 3'd5 && rd_is_8bit)? { 24'd0, ecx[15:8] } :
|
493 |
|
|
(dst_reg_index == 3'd5)? ebp :
|
494 |
|
|
(dst_reg_index == 3'd6 && rd_is_8bit)? { 24'd0, edx[15:8] } :
|
495 |
|
|
(dst_reg_index == 3'd6)? esi :
|
496 |
|
|
(dst_reg_index == 3'd7 && rd_is_8bit)? { 24'd0, ebx[15:8] } :
|
497 |
|
|
edi;
|
498 |
|
|
|
499 |
|
|
//------------------------------------------------------------------------------ io_read
|
500 |
|
|
|
501 |
|
|
always @(posedge clk or negedge rst_n) begin
|
502 |
|
|
if(rst_n == 1'b0) rd_one_io_read <= `FALSE;
|
503 |
|
|
else if(rd_ready || rd_reset) rd_one_io_read <= `FALSE;
|
504 |
|
|
else if(io_read_done) rd_one_io_read <= `TRUE;
|
505 |
|
|
end
|
506 |
|
|
|
507 |
|
|
assign io_read_length =
|
508 |
|
|
(rd_is_8bit)? 3'd1 :
|
509 |
|
|
(rd_operand_16bit)? 3'd2 :
|
510 |
|
|
3'd4;
|
511 |
|
|
|
512 |
|
|
wire io_read;
|
513 |
|
|
|
514 |
|
|
//NOTE: gp fault from CMDEX_io_allow_2
|
515 |
|
|
assign io_read_do = io_read && ~(io_read_done) && ~(rd_one_io_read) && ~(rd_reset) && ~(exe_trigger_gp_fault);
|
516 |
|
|
|
517 |
|
|
assign rd_io_ready = rd_one_io_read || io_read_done;
|
518 |
|
|
|
519 |
|
|
//------------------------------------------------------------------------------
|
520 |
|
|
|
521 |
|
|
wire rd_seg_gp_fault_init;
|
522 |
|
|
wire rd_seg_ss_fault_init;
|
523 |
|
|
|
524 |
|
|
always @(posedge clk or negedge rst_n) begin
|
525 |
|
|
if(rst_n == 1'b0) rd_seg_gp_fault <= `FALSE;
|
526 |
|
|
else if(rd_ready || rd_reset) rd_seg_gp_fault <= `FALSE;
|
527 |
|
|
else rd_seg_gp_fault <= rd_seg_gp_fault_init;
|
528 |
|
|
end
|
529 |
|
|
|
530 |
|
|
always @(posedge clk or negedge rst_n) begin
|
531 |
|
|
if(rst_n == 1'b0) rd_seg_ss_fault <= `FALSE;
|
532 |
|
|
else if(rd_ready || rd_reset) rd_seg_ss_fault <= `FALSE;
|
533 |
|
|
else rd_seg_ss_fault <= rd_seg_ss_fault_init;
|
534 |
|
|
end
|
535 |
|
|
|
536 |
|
|
|
537 |
|
|
//------------------------------------------------------------------------------ read memory
|
538 |
|
|
|
539 |
|
|
assign memory_read_system = read_system_descriptor || read_system_word || read_system_dword || read_system_qword || read_rmw_system_dword;
|
540 |
|
|
|
541 |
|
|
assign read_cpl = (memory_read_system)? 2'd0 : cpl;
|
542 |
|
|
assign read_rmw = read_rmw_virtual || read_rmw_system_dword;
|
543 |
|
|
assign read_lock = rd_prefix_group_1_lock;
|
544 |
|
|
|
545 |
|
|
|
546 |
|
|
assign read_address =
|
547 |
|
|
(read_rmw_virtual || read_virtual)? rd_seg_linear :
|
548 |
|
|
(read_system_descriptor)? rd_descriptor_offset :
|
549 |
|
|
rd_system_linear; //used by read_rmw_system_dword, read_system_dword,read_system_word,read_system_qword
|
550 |
|
|
|
551 |
|
|
assign read_length =
|
552 |
|
|
read_system_word? 4'd2 :
|
553 |
|
|
read_system_dword? 4'd4 :
|
554 |
|
|
read_system_qword? 4'd8 :
|
555 |
|
|
read_rmw_system_dword? 4'd4 :
|
556 |
|
|
read_system_descriptor? 4'd8 :
|
557 |
|
|
rd_is_8bit? 4'd1 :
|
558 |
|
|
read_length_word? 4'd2 :
|
559 |
|
|
read_length_dword? 4'd4 :
|
560 |
|
|
rd_operand_16bit? 4'd2 :
|
561 |
|
|
4'd4;
|
562 |
|
|
|
563 |
|
|
always @(posedge clk or negedge rst_n) begin
|
564 |
|
|
if(rst_n == 1'b0) rd_one_mem_read <= `FALSE;
|
565 |
|
|
else if(rd_ready || rd_reset) rd_one_mem_read <= `FALSE;
|
566 |
|
|
else if(read_done && ~(read_page_fault) && ~(read_ac_fault)) rd_one_mem_read <= `TRUE;
|
567 |
|
|
end
|
568 |
|
|
|
569 |
|
|
assign read_do =
|
570 |
|
|
~(rd_reset) &&
|
571 |
|
|
((rd_address_effective_ready && (read_rmw_virtual || read_virtual)) || memory_read_system) &&
|
572 |
|
|
~(rd_one_mem_read) && ~(read_done) && ~(read_page_fault) && ~(read_ac_fault) &&
|
573 |
|
|
~(rd_seg_gp_fault_init) && ~(rd_seg_gp_fault) && ~(rd_descriptor_gp_fault) && ~(rd_seg_ss_fault_init) && ~(rd_seg_ss_fault) && ~(rd_io_allow_fault) && ~(rd_ss_esp_from_tss_fault);
|
574 |
|
|
|
575 |
|
|
assign read_for_rd_ready = rd_one_mem_read || (read_done && ~(read_page_fault) && ~(read_ac_fault));
|
576 |
|
|
|
577 |
|
|
assign read_4 = read_data[31:0];
|
578 |
|
|
assign read_8 = read_data;
|
579 |
|
|
|
580 |
|
|
//------------------------------------------------------------------------------ write check
|
581 |
|
|
|
582 |
|
|
always @(posedge clk or negedge rst_n) begin
|
583 |
|
|
if(rst_n == 1'b0) rd_address_effective_ready_delayed <= `FALSE;
|
584 |
|
|
else if(rd_ready || rd_reset || ~(write_virtual_check)) rd_address_effective_ready_delayed <= `FALSE;
|
585 |
|
|
else rd_address_effective_ready_delayed <= rd_address_effective_ready;
|
586 |
|
|
end
|
587 |
|
|
|
588 |
|
|
assign write_virtual_check_ready =
|
589 |
|
|
~(rd_reset) &&
|
590 |
|
|
rd_address_effective_ready_delayed &&
|
591 |
|
|
~(rd_seg_gp_fault) && ~(rd_descriptor_gp_fault) && ~(rd_seg_ss_fault) && ~(rd_io_allow_fault) && ~(rd_ss_esp_from_tss_fault);
|
592 |
|
|
|
593 |
|
|
//------------------------------------------------------------------------------ misc
|
594 |
|
|
|
595 |
|
|
assign rd_address_effective_do = ~(rd_address_waiting) && rd_cmd != `CMD_NULL;
|
596 |
|
|
|
597 |
|
|
assign rd_linear = (read_rmw_system_dword)? rd_system_linear : rd_seg_linear;
|
598 |
|
|
|
599 |
|
|
assign rd_dec_is_front = rd_cmd == `CMD_NULL && ~(rd_mutex_busy_active);
|
600 |
|
|
|
601 |
|
|
assign rd_is_front = rd_cmd != `CMD_NULL && ~(rd_mutex_busy_active);
|
602 |
|
|
|
603 |
|
|
//------------------------------------------------------------------------------ load descriptor
|
604 |
|
|
|
605 |
|
|
assign rd_descriptor_offset =
|
606 |
|
|
(glob_param_1[2] == 1'b0)? gdtr_base + { 16'd0, glob_param_1[15:3], 3'd0 } :
|
607 |
|
|
ldtr_base + { 16'd0, glob_param_1[15:3], 3'd0 };
|
608 |
|
|
|
609 |
|
|
assign rd_descriptor_gp_fault = read_system_descriptor && rd_descriptor_not_in_limits;
|
610 |
|
|
|
611 |
|
|
assign rd_descriptor_not_in_limits =
|
612 |
|
|
(glob_param_1[2] == 1'b0 && { glob_param_1[15:3], 3'd7 } > gdtr_limit) ||
|
613 |
|
|
(glob_param_1[2] == 1'b1 && ({ 16'd0, glob_param_1[15:3], 3'd7 } > ldtr_limit || ~(ldtr_cache_valid)));
|
614 |
|
|
|
615 |
|
|
|
616 |
|
|
//------------------------------------------------------------------------------
|
617 |
|
|
|
618 |
|
|
read_segment read_segment_inst(
|
619 |
|
|
|
620 |
|
|
//general input
|
621 |
|
|
.es_cache (es_cache), //input [63:0]
|
622 |
|
|
.cs_cache (cs_cache), //input [63:0]
|
623 |
|
|
.ss_cache (ss_cache), //input [63:0]
|
624 |
|
|
.ds_cache (ds_cache), //input [63:0]
|
625 |
|
|
.fs_cache (fs_cache), //input [63:0]
|
626 |
|
|
.gs_cache (gs_cache), //input [63:0]
|
627 |
|
|
.tr_cache (tr_cache), //input [63:0]
|
628 |
|
|
.ldtr_cache (ldtr_cache), //input [63:0]
|
629 |
|
|
|
630 |
|
|
.es_cache_valid (es_cache_valid), //input
|
631 |
|
|
.cs_cache_valid (cs_cache_valid), //input
|
632 |
|
|
.ss_cache_valid (ss_cache_valid), //input
|
633 |
|
|
.ds_cache_valid (ds_cache_valid), //input
|
634 |
|
|
.fs_cache_valid (fs_cache_valid), //input
|
635 |
|
|
.gs_cache_valid (gs_cache_valid), //input
|
636 |
|
|
|
637 |
|
|
//address control
|
638 |
|
|
.address_stack_pop (address_stack_pop), //input
|
639 |
|
|
.address_stack_pop_next (address_stack_pop_next), //input
|
640 |
|
|
.address_enter_last (address_enter_last), //input
|
641 |
|
|
.address_enter (address_enter), //input
|
642 |
|
|
.address_leave (address_leave), //input
|
643 |
|
|
|
644 |
|
|
.address_edi (address_edi), //input
|
645 |
|
|
|
646 |
|
|
//read control
|
647 |
|
|
.read_virtual (read_virtual), //input
|
648 |
|
|
.read_rmw_virtual (read_rmw_virtual), //input
|
649 |
|
|
.write_virtual_check (write_virtual_check), //input
|
650 |
|
|
|
651 |
|
|
.rd_address_effective (rd_address_effective), //input [31:0]
|
652 |
|
|
.rd_address_effective_ready (rd_address_effective_ready), //input
|
653 |
|
|
.read_length (read_length), //input [3:0]
|
654 |
|
|
|
655 |
|
|
.rd_prefix_group_2_seg (rd_prefix_group_2_seg), //input [2:0]
|
656 |
|
|
|
657 |
|
|
//output
|
658 |
|
|
.tr_base (tr_base), //output [31:0]
|
659 |
|
|
.ldtr_base (ldtr_base), //output [31:0]
|
660 |
|
|
.tr_limit (tr_limit), //output [31:0]
|
661 |
|
|
.ldtr_limit (ldtr_limit), //output [31:0]
|
662 |
|
|
|
663 |
|
|
.rd_seg_gp_fault_init (rd_seg_gp_fault_init), //output
|
664 |
|
|
.rd_seg_ss_fault_init (rd_seg_ss_fault_init), //output
|
665 |
|
|
|
666 |
|
|
.rd_seg_linear (rd_seg_linear) //output [31:0]
|
667 |
|
|
);
|
668 |
|
|
|
669 |
|
|
//------------------------------------------------------------------------------
|
670 |
|
|
|
671 |
|
|
//------------------------------------------------------------------------------
|
672 |
|
|
|
673 |
|
|
read_effective_address read_effective_address_inst(
|
674 |
|
|
.clk (clk),
|
675 |
|
|
.rst_n (rst_n),
|
676 |
|
|
|
677 |
|
|
.rd_reset (rd_reset), //input
|
678 |
|
|
|
679 |
|
|
.rd_address_effective_do (rd_address_effective_do), //input
|
680 |
|
|
.rd_ready (rd_ready), //input
|
681 |
|
|
|
682 |
|
|
//general input
|
683 |
|
|
.eax (eax), //input [31:0]
|
684 |
|
|
.ebx (ebx), //input [31:0]
|
685 |
|
|
.ecx (ecx), //input [31:0]
|
686 |
|
|
.edx (edx), //input [31:0]
|
687 |
|
|
.esp (esp), //input [31:0]
|
688 |
|
|
.ebp (ebp), //input [31:0]
|
689 |
|
|
.esi (esi), //input [31:0]
|
690 |
|
|
.edi (edi), //input [31:0]
|
691 |
|
|
|
692 |
|
|
.ss_cache (ss_cache), //input [63:0]
|
693 |
|
|
.glob_param_3 (glob_param_3), //input [31:0]
|
694 |
|
|
|
695 |
|
|
.wr_esp_prev (wr_esp_prev), //input [31:0]
|
696 |
|
|
|
697 |
|
|
//rd input
|
698 |
|
|
.rd_address_16bit (rd_address_16bit), //input
|
699 |
|
|
.rd_address_32bit (rd_address_32bit), //input
|
700 |
|
|
.rd_operand_16bit (rd_operand_16bit), //input
|
701 |
|
|
.rd_operand_32bit (rd_operand_32bit), //input
|
702 |
|
|
.rd_decoder (rd_decoder), //input [87:0]
|
703 |
|
|
.rd_modregrm_rm (rd_modregrm_rm), //input [2:0]
|
704 |
|
|
.rd_modregrm_reg (rd_modregrm_reg), //input [2:0]
|
705 |
|
|
.rd_modregrm_mod (rd_modregrm_mod), //input [1:0]
|
706 |
|
|
.rd_sib (rd_sib), //input [7:0]
|
707 |
|
|
|
708 |
|
|
//address control
|
709 |
|
|
.address_enter_init (address_enter_init), //input
|
710 |
|
|
.address_enter (address_enter), //input
|
711 |
|
|
.address_enter_last (address_enter_last), //input
|
712 |
|
|
.address_leave (address_leave), //input
|
713 |
|
|
.address_esi (address_esi), //input
|
714 |
|
|
.address_edi (address_edi), //input
|
715 |
|
|
.address_xlat_transform (address_xlat_transform), //input
|
716 |
|
|
.address_bits_transform (address_bits_transform), //input
|
717 |
|
|
|
718 |
|
|
.address_stack_pop (address_stack_pop), //input
|
719 |
|
|
.address_stack_pop_speedup (address_stack_pop_speedup), //input
|
720 |
|
|
|
721 |
|
|
.address_stack_pop_next (address_stack_pop_next), //input
|
722 |
|
|
.address_stack_pop_esp_prev (address_stack_pop_esp_prev), //input
|
723 |
|
|
.address_stack_pop_for_call (address_stack_pop_for_call), //input
|
724 |
|
|
.address_stack_save (address_stack_save), //input
|
725 |
|
|
.address_stack_add_4_to_saved (address_stack_add_4_to_saved), //input
|
726 |
|
|
|
727 |
|
|
.address_stack_for_ret_first (address_stack_for_ret_first), //input
|
728 |
|
|
.address_stack_for_ret_second (address_stack_for_ret_second), //input
|
729 |
|
|
.address_stack_for_iret_first (address_stack_for_iret_first), //input
|
730 |
|
|
.address_stack_for_iret_second (address_stack_for_iret_second), //input
|
731 |
|
|
.address_stack_for_iret_third (address_stack_for_iret_third), //input
|
732 |
|
|
.address_stack_for_iret_last (address_stack_for_iret_last), //input
|
733 |
|
|
.address_stack_for_iret_to_v86 (address_stack_for_iret_to_v86), //input
|
734 |
|
|
.address_stack_for_call_param_first (address_stack_for_call_param_first), //input
|
735 |
|
|
|
736 |
|
|
.address_ea_buffer (address_ea_buffer), //input
|
737 |
|
|
.address_ea_buffer_plus_2 (address_ea_buffer_plus_2), //input
|
738 |
|
|
|
739 |
|
|
.address_memoffset (address_memoffset), //input
|
740 |
|
|
|
741 |
|
|
//output
|
742 |
|
|
.rd_address_effective_ready (rd_address_effective_ready), //output
|
743 |
|
|
.rd_address_effective (rd_address_effective) //output [31:0]
|
744 |
|
|
);
|
745 |
|
|
|
746 |
|
|
//------------------------------------------------------------------------------
|
747 |
|
|
|
748 |
|
|
read_debug read_debug_inst(
|
749 |
|
|
.clk (clk),
|
750 |
|
|
.rst_n (rst_n),
|
751 |
|
|
|
752 |
|
|
.dr0 (dr0), //input [31:0]
|
753 |
|
|
.dr1 (dr1), //input [31:0]
|
754 |
|
|
.dr2 (dr2), //input [31:0]
|
755 |
|
|
.dr3 (dr3), //input [31:0]
|
756 |
|
|
.dr7 (dr7), //input [31:0]
|
757 |
|
|
|
758 |
|
|
.debug_len0 (debug_len0), //input [2:0]
|
759 |
|
|
.debug_len1 (debug_len1), //input [2:0]
|
760 |
|
|
.debug_len2 (debug_len2), //input [2:0]
|
761 |
|
|
.debug_len3 (debug_len3), //input [2:0]
|
762 |
|
|
|
763 |
|
|
.rd_ready (rd_ready), // input
|
764 |
|
|
|
765 |
|
|
.read_do (read_do), //input
|
766 |
|
|
.read_address (read_address), //input [31:0]
|
767 |
|
|
.read_length (read_length), //input [3:0]
|
768 |
|
|
|
769 |
|
|
.rd_debug_read (rd_debug_read) //output [3:0]
|
770 |
|
|
);
|
771 |
|
|
|
772 |
|
|
//------------------------------------------------------------------------------
|
773 |
|
|
|
774 |
|
|
read_commands read_commands_inst(
|
775 |
|
|
.clk (clk),
|
776 |
|
|
.rst_n (rst_n),
|
777 |
|
|
|
778 |
|
|
//general input
|
779 |
|
|
.glob_descriptor (glob_descriptor), //input [63:0]
|
780 |
|
|
.glob_param_1 (glob_param_1), //input [31:0]
|
781 |
|
|
.glob_param_2 (glob_param_2), //input [31:0]
|
782 |
|
|
.glob_param_3 (glob_param_3), //input [31:0]
|
783 |
|
|
|
784 |
|
|
.glob_desc_base (glob_desc_base), //input [31:0]
|
785 |
|
|
.glob_desc_limit (glob_desc_limit), //input [31:0]
|
786 |
|
|
|
787 |
|
|
.tr (tr), //input [15:0]
|
788 |
|
|
.tr_base (tr_base), //input [31:0]
|
789 |
|
|
.tr_cache (tr_cache), //input [63:0]
|
790 |
|
|
.tr_cache_valid (tr_cache_valid), //input
|
791 |
|
|
.tr_limit (tr_limit), //input [31:0]
|
792 |
|
|
|
793 |
|
|
.gdtr_base (gdtr_base), //input [31:0]
|
794 |
|
|
.idtr_base (idtr_base), //input [31:0]
|
795 |
|
|
|
796 |
|
|
.ecx (ecx), //input [31:0]
|
797 |
|
|
.edx (edx), //input [31:0]
|
798 |
|
|
|
799 |
|
|
.iopl (iopl), //input [1:0]
|
800 |
|
|
|
801 |
|
|
.exc_vector (exc_vector), //input [7:0]
|
802 |
|
|
|
803 |
|
|
.io_allow_check_needed (io_allow_check_needed), //input
|
804 |
|
|
|
805 |
|
|
.cpl (cpl), //input [1:0]
|
806 |
|
|
.cr0_pg (cr0_pg), //input
|
807 |
|
|
|
808 |
|
|
.real_mode (real_mode), //input
|
809 |
|
|
.v8086_mode (v8086_mode), //input
|
810 |
|
|
.protected_mode (protected_mode), //input
|
811 |
|
|
|
812 |
|
|
.exe_mutex (exe_mutex), //input [10:0]
|
813 |
|
|
|
814 |
|
|
//rd input
|
815 |
|
|
.rd_decoder (rd_decoder), //input [87:0]
|
816 |
|
|
.rd_cmd (rd_cmd), //input [6:0]
|
817 |
|
|
.rd_cmdex (rd_cmdex), //input [3:0]
|
818 |
|
|
.rd_modregrm_mod (rd_modregrm_mod), //input [1:0]
|
819 |
|
|
.rd_operand_16bit (rd_operand_16bit), //input
|
820 |
|
|
.rd_operand_32bit (rd_operand_32bit), //input
|
821 |
|
|
.rd_memory_last (rd_memory_last), //input [31:0]
|
822 |
|
|
.rd_prefix_group_1_rep (rd_prefix_group_1_rep), //input [1:0]
|
823 |
|
|
.rd_address_16bit (rd_address_16bit), //input
|
824 |
|
|
.rd_address_32bit (rd_address_32bit), //input
|
825 |
|
|
.rd_ready (rd_ready), //input
|
826 |
|
|
|
827 |
|
|
.dst_wire (dst_wire), //input [31:0]
|
828 |
|
|
|
829 |
|
|
.rd_descriptor_not_in_limits (rd_descriptor_not_in_limits), //input
|
830 |
|
|
.rd_consumed (rd_consumed), //input [3:0]
|
831 |
|
|
|
832 |
|
|
//rd mutex busy
|
833 |
|
|
.rd_mutex_busy_active (rd_mutex_busy_active), //input
|
834 |
|
|
.rd_mutex_busy_memory (rd_mutex_busy_memory), //input
|
835 |
|
|
.rd_mutex_busy_eflags (rd_mutex_busy_eflags), //input
|
836 |
|
|
.rd_mutex_busy_ebp (rd_mutex_busy_ebp), //input
|
837 |
|
|
.rd_mutex_busy_esp (rd_mutex_busy_esp), //input
|
838 |
|
|
.rd_mutex_busy_edx (rd_mutex_busy_edx), //input
|
839 |
|
|
.rd_mutex_busy_ecx (rd_mutex_busy_ecx), //input
|
840 |
|
|
.rd_mutex_busy_eax (rd_mutex_busy_eax), //input
|
841 |
|
|
.rd_mutex_busy_modregrm_reg (rd_mutex_busy_modregrm_reg), //input
|
842 |
|
|
.rd_mutex_busy_modregrm_rm (rd_mutex_busy_modregrm_rm), //input
|
843 |
|
|
.rd_mutex_busy_implicit_reg (rd_mutex_busy_implicit_reg), //input
|
844 |
|
|
|
845 |
|
|
//rd output
|
846 |
|
|
.rd_extra_wire (rd_extra_wire), //output [31:0]
|
847 |
|
|
.rd_system_linear (rd_system_linear), //output [31:0]
|
848 |
|
|
|
849 |
|
|
.rd_error_code (rd_error_code), //output [15:0]
|
850 |
|
|
|
851 |
|
|
.rd_ss_esp_from_tss_fault (rd_ss_esp_from_tss_fault), //output
|
852 |
|
|
|
853 |
|
|
.rd_waiting (rd_waiting), //output
|
854 |
|
|
|
855 |
|
|
//mutex req
|
856 |
|
|
.rd_req_memory (rd_req_memory), //output
|
857 |
|
|
.rd_req_eflags (rd_req_eflags), //output
|
858 |
|
|
.rd_req_all (rd_req_all), //output
|
859 |
|
|
.rd_req_reg (rd_req_reg), //output
|
860 |
|
|
.rd_req_rm (rd_req_rm), //output
|
861 |
|
|
.rd_req_implicit_reg (rd_req_implicit_reg), //output
|
862 |
|
|
.rd_req_reg_not_8bit (rd_req_reg_not_8bit), //output
|
863 |
|
|
.rd_req_edi (rd_req_edi), //output
|
864 |
|
|
.rd_req_esi (rd_req_esi), //output
|
865 |
|
|
.rd_req_ebp (rd_req_ebp), //output
|
866 |
|
|
.rd_req_esp (rd_req_esp), //output
|
867 |
|
|
.rd_req_ebx (rd_req_ebx), //output
|
868 |
|
|
.rd_req_edx_eax (rd_req_edx_eax), //output
|
869 |
|
|
.rd_req_edx (rd_req_edx), //output
|
870 |
|
|
.rd_req_ecx (rd_req_ecx), //output
|
871 |
|
|
.rd_req_eax (rd_req_eax), //output
|
872 |
|
|
|
873 |
|
|
//address control
|
874 |
|
|
.address_enter_init (address_enter_init), //output
|
875 |
|
|
.address_enter (address_enter), //output
|
876 |
|
|
.address_enter_last (address_enter_last), //output
|
877 |
|
|
.address_leave (address_leave), //output
|
878 |
|
|
.address_esi (address_esi), //output
|
879 |
|
|
.address_edi (address_edi), //output
|
880 |
|
|
.address_xlat_transform (address_xlat_transform), //output
|
881 |
|
|
.address_bits_transform (address_bits_transform), //output
|
882 |
|
|
|
883 |
|
|
.address_stack_pop (address_stack_pop), //output
|
884 |
|
|
.address_stack_pop_speedup (address_stack_pop_speedup), //output
|
885 |
|
|
|
886 |
|
|
.address_stack_pop_next (address_stack_pop_next), //output
|
887 |
|
|
.address_stack_pop_esp_prev (address_stack_pop_esp_prev), //output
|
888 |
|
|
.address_stack_pop_for_call (address_stack_pop_for_call), //output
|
889 |
|
|
.address_stack_save (address_stack_save), //output
|
890 |
|
|
.address_stack_add_4_to_saved (address_stack_add_4_to_saved), //output
|
891 |
|
|
|
892 |
|
|
.address_stack_for_ret_first (address_stack_for_ret_first), //output
|
893 |
|
|
.address_stack_for_ret_second (address_stack_for_ret_second), //output
|
894 |
|
|
.address_stack_for_iret_first (address_stack_for_iret_first), //output
|
895 |
|
|
.address_stack_for_iret_second (address_stack_for_iret_second), //output
|
896 |
|
|
.address_stack_for_iret_third (address_stack_for_iret_third), //output
|
897 |
|
|
.address_stack_for_iret_last (address_stack_for_iret_last), //output
|
898 |
|
|
.address_stack_for_iret_to_v86 (address_stack_for_iret_to_v86), //output
|
899 |
|
|
.address_stack_for_call_param_first (address_stack_for_call_param_first), //output
|
900 |
|
|
|
901 |
|
|
.address_ea_buffer (address_ea_buffer), //output
|
902 |
|
|
.address_ea_buffer_plus_2 (address_ea_buffer_plus_2), //output
|
903 |
|
|
|
904 |
|
|
.address_memoffset (address_memoffset), //output
|
905 |
|
|
|
906 |
|
|
//read control
|
907 |
|
|
.read_virtual (read_virtual), //output
|
908 |
|
|
.read_rmw_virtual (read_rmw_virtual), //output
|
909 |
|
|
.write_virtual_check (write_virtual_check), //output
|
910 |
|
|
|
911 |
|
|
.read_system_descriptor (read_system_descriptor), //output
|
912 |
|
|
.read_system_word (read_system_word), //output
|
913 |
|
|
.read_system_dword (read_system_dword), //output
|
914 |
|
|
.read_system_qword (read_system_qword), //output
|
915 |
|
|
.read_rmw_system_dword (read_rmw_system_dword), //output
|
916 |
|
|
|
917 |
|
|
.read_length_word (read_length_word), //output
|
918 |
|
|
.read_length_dword (read_length_dword), //output
|
919 |
|
|
|
920 |
|
|
.read_for_rd_ready (read_for_rd_ready), //input
|
921 |
|
|
.write_virtual_check_ready (write_virtual_check_ready), //input
|
922 |
|
|
|
923 |
|
|
.rd_address_effective_ready (rd_address_effective_ready), //input
|
924 |
|
|
|
925 |
|
|
.read_4 (read_4), //input [31:0]
|
926 |
|
|
.read_8 (read_8), //input [63:0]
|
927 |
|
|
|
928 |
|
|
//read signals
|
929 |
|
|
.rd_src_is_memory (rd_src_is_memory), //output
|
930 |
|
|
.rd_src_is_io (rd_src_is_io), //output
|
931 |
|
|
.rd_src_is_modregrm_imm (rd_src_is_modregrm_imm), //output
|
932 |
|
|
.rd_src_is_modregrm_imm_se (rd_src_is_modregrm_imm_se), //output
|
933 |
|
|
.rd_src_is_imm (rd_src_is_imm), //output
|
934 |
|
|
.rd_src_is_imm_se (rd_src_is_imm_se), //output
|
935 |
|
|
.rd_src_is_1 (rd_src_is_1), //output
|
936 |
|
|
.rd_src_is_eax (rd_src_is_eax), //output
|
937 |
|
|
.rd_src_is_ecx (rd_src_is_ecx), //output
|
938 |
|
|
.rd_src_is_cmdex (rd_src_is_cmdex), //output
|
939 |
|
|
.rd_src_is_implicit_reg (rd_src_is_implicit_reg), //output
|
940 |
|
|
.rd_src_is_rm (rd_src_is_rm), //output
|
941 |
|
|
.rd_src_is_reg (rd_src_is_reg), //output
|
942 |
|
|
|
943 |
|
|
.rd_dst_is_0 (rd_dst_is_0), //output
|
944 |
|
|
.rd_dst_is_modregrm_imm_se (rd_dst_is_modregrm_imm_se), //output
|
945 |
|
|
.rd_dst_is_modregrm_imm (rd_dst_is_modregrm_imm), //output
|
946 |
|
|
.rd_dst_is_memory (rd_dst_is_memory), //output
|
947 |
|
|
.rd_dst_is_memory_last (rd_dst_is_memory_last), //output
|
948 |
|
|
.rd_dst_is_eip (rd_dst_is_eip), //output
|
949 |
|
|
.rd_dst_is_eax (rd_dst_is_eax), //output
|
950 |
|
|
.rd_dst_is_edx_eax (rd_dst_is_edx_eax), //output
|
951 |
|
|
.rd_dst_is_implicit_reg (rd_dst_is_implicit_reg), //output
|
952 |
|
|
.rd_dst_is_rm (rd_dst_is_rm), //output
|
953 |
|
|
.rd_dst_is_reg (rd_dst_is_reg), //output
|
954 |
|
|
|
955 |
|
|
//global set
|
956 |
|
|
.rd_glob_descriptor_set (rd_glob_descriptor_set), //output
|
957 |
|
|
.rd_glob_descriptor_value (rd_glob_descriptor_value), //output [63:0]
|
958 |
|
|
|
959 |
|
|
.rd_glob_descriptor_2_set (rd_glob_descriptor_2_set), //output
|
960 |
|
|
.rd_glob_descriptor_2_value (rd_glob_descriptor_2_value), //output [63:0]
|
961 |
|
|
|
962 |
|
|
.rd_glob_param_1_set (rd_glob_param_1_set), //output
|
963 |
|
|
.rd_glob_param_1_value (rd_glob_param_1_value), //output [31:0]
|
964 |
|
|
|
965 |
|
|
.rd_glob_param_2_set (rd_glob_param_2_set), //output
|
966 |
|
|
.rd_glob_param_2_value (rd_glob_param_2_value), //output [31:0]
|
967 |
|
|
|
968 |
|
|
.rd_glob_param_3_set (rd_glob_param_3_set), //output
|
969 |
|
|
.rd_glob_param_3_value (rd_glob_param_3_value), //output [31:0]
|
970 |
|
|
|
971 |
|
|
.rd_glob_param_4_set (rd_glob_param_4_set), //output
|
972 |
|
|
.rd_glob_param_4_value (rd_glob_param_4_value), //output [31:0]
|
973 |
|
|
|
974 |
|
|
.rd_glob_param_5_set (rd_glob_param_5_set), //output
|
975 |
|
|
.rd_glob_param_5_value (rd_glob_param_5_value), //output [31:0]
|
976 |
|
|
|
977 |
|
|
//io
|
978 |
|
|
.io_read (io_read), //output
|
979 |
|
|
.io_read_address (io_read_address), //output [15:0]
|
980 |
|
|
.rd_io_ready (rd_io_ready), //input
|
981 |
|
|
|
982 |
|
|
.rd_io_allow_fault (rd_io_allow_fault) //output
|
983 |
|
|
);
|
984 |
|
|
|
985 |
|
|
//------------------------------------------------------------------------------
|
986 |
|
|
|
987 |
|
|
read_mutex read_mutex_inst(
|
988 |
|
|
.rd_req_memory (rd_req_memory), //input
|
989 |
|
|
.rd_req_eflags (rd_req_eflags), //input
|
990 |
|
|
|
991 |
|
|
.rd_req_all (rd_req_all), //input
|
992 |
|
|
.rd_req_reg (rd_req_reg), //input
|
993 |
|
|
.rd_req_rm (rd_req_rm), //input
|
994 |
|
|
.rd_req_implicit_reg (rd_req_implicit_reg), //input
|
995 |
|
|
.rd_req_reg_not_8bit (rd_req_reg_not_8bit), //input
|
996 |
|
|
.rd_req_edi (rd_req_edi), //input
|
997 |
|
|
.rd_req_esi (rd_req_esi), //input
|
998 |
|
|
.rd_req_ebp (rd_req_ebp), //input
|
999 |
|
|
.rd_req_esp (rd_req_esp), //input
|
1000 |
|
|
.rd_req_ebx (rd_req_ebx), //input
|
1001 |
|
|
.rd_req_edx_eax (rd_req_edx_eax), //input
|
1002 |
|
|
.rd_req_edx (rd_req_edx), //input
|
1003 |
|
|
.rd_req_ecx (rd_req_ecx), //input
|
1004 |
|
|
.rd_req_eax (rd_req_eax), //input
|
1005 |
|
|
|
1006 |
|
|
.rd_decoder (rd_decoder), //input [87:0]
|
1007 |
|
|
.rd_is_8bit (rd_is_8bit), //input
|
1008 |
|
|
.rd_modregrm_mod (rd_modregrm_mod), //input [1:0]
|
1009 |
|
|
.rd_modregrm_reg (rd_modregrm_reg), //input [2:0]
|
1010 |
|
|
.rd_modregrm_rm (rd_modregrm_rm), //input [2:0]
|
1011 |
|
|
.rd_address_16bit (rd_address_16bit), //input
|
1012 |
|
|
.rd_address_32bit (rd_address_32bit), //input
|
1013 |
|
|
.rd_sib (rd_sib), //input [7:0]
|
1014 |
|
|
|
1015 |
|
|
.exe_mutex (exe_mutex), //input [10:0]
|
1016 |
|
|
.wr_mutex (wr_mutex), //input [10:0]
|
1017 |
|
|
|
1018 |
|
|
.address_bits_transform (address_bits_transform), //input
|
1019 |
|
|
.address_xlat_transform (address_xlat_transform), //input
|
1020 |
|
|
.address_stack_pop (address_stack_pop), //input
|
1021 |
|
|
.address_stack_pop_next (address_stack_pop_next), //input
|
1022 |
|
|
.address_enter (address_enter), //input
|
1023 |
|
|
.address_enter_last (address_enter_last), //input
|
1024 |
|
|
.address_leave (address_leave), //input
|
1025 |
|
|
.address_esi (address_esi), //input
|
1026 |
|
|
.address_edi (address_edi), //input
|
1027 |
|
|
|
1028 |
|
|
|
1029 |
|
|
.rd_mutex_next (rd_mutex_next), //output [10:0]
|
1030 |
|
|
|
1031 |
|
|
.rd_mutex_busy_active (rd_mutex_busy_active), //output
|
1032 |
|
|
.rd_mutex_busy_memory (rd_mutex_busy_memory), //output
|
1033 |
|
|
.rd_mutex_busy_eflags (rd_mutex_busy_eflags), //output
|
1034 |
|
|
.rd_mutex_busy_ebp (rd_mutex_busy_ebp), //output
|
1035 |
|
|
.rd_mutex_busy_esp (rd_mutex_busy_esp), //output
|
1036 |
|
|
.rd_mutex_busy_edx (rd_mutex_busy_edx), //output
|
1037 |
|
|
.rd_mutex_busy_ecx (rd_mutex_busy_ecx), //output
|
1038 |
|
|
.rd_mutex_busy_eax (rd_mutex_busy_eax), //output
|
1039 |
|
|
.rd_mutex_busy_modregrm_reg (rd_mutex_busy_modregrm_reg), //output
|
1040 |
|
|
.rd_mutex_busy_modregrm_rm (rd_mutex_busy_modregrm_rm), //output
|
1041 |
|
|
.rd_mutex_busy_implicit_reg (rd_mutex_busy_implicit_reg), //output
|
1042 |
|
|
|
1043 |
|
|
.rd_address_waiting (rd_address_waiting) //output
|
1044 |
|
|
);
|
1045 |
|
|
|
1046 |
|
|
//------------------------------------------------------------------------------
|
1047 |
|
|
|
1048 |
|
|
endmodule
|