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

Subversion Repositories ao486

[/] [ao486/] [trunk/] [rtl/] [ao486/] [pipeline/] [write.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
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 write(
30
    input               clk,
31
    input               rst_n,
32
 
33
    input               exe_reset,
34
    input               wr_reset,
35
 
36
    //global input
37
    input       [63:0]  glob_descriptor,
38
    input       [63:0]  glob_descriptor_2,
39
    input       [31:0]  glob_desc_base,
40
    input       [31:0]  glob_desc_limit,
41
 
42
    input       [31:0]  glob_param_1,
43
    input       [31:0]  glob_param_2,
44
    input       [31:0]  glob_param_3,
45
    input       [31:0]  glob_param_4,
46
    input       [31:0]  glob_param_5,
47
 
48
    //general input
49
    input       [31:0]  eip,
50
 
51
    //registers output
52
    output      [31:0]  gdtr_base,
53
    output      [15:0]  gdtr_limit,
54
 
55
    output      [31:0]  idtr_base,
56
    output      [15:0]  idtr_limit,
57
 
58
    //pipeline input
59
    input       [31:0]  exe_buffer,
60
    input       [463:0] exe_buffer_shifted,
61
 
62
    input               dr6_bd_set,
63
 
64
    //interrupt input
65
    input               interrupt_do,
66
 
67
    //exception input
68
    input               exc_init,
69
    input               exc_set_rflag,
70
    input               exc_debug_start,
71
    input               exc_pf_read,
72
    input               exc_pf_write,
73
    input               exc_pf_code,
74
    input               exc_pf_check,
75
    input               exc_restore_esp,
76
    input               exc_push_error,
77
    input       [31:0]  exc_eip,
78
 
79
    //output
80
    output              real_mode,
81
    output              v8086_mode,
82
    output              protected_mode,
83
 
84
    output      [1:0]   cpl,
85
 
86
    output              io_allow_check_needed,
87
 
88
    output      [2:0]   debug_len0,
89
    output      [2:0]   debug_len1,
90
    output      [2:0]   debug_len2,
91
    output      [2:0]   debug_len3,
92
 
93
    //wr output
94
    output              wr_is_front,
95
 
96
    output reg          wr_interrupt_possible,
97
    output              wr_string_in_progress_final,
98
    output reg          wr_is_esp_speculative,
99
 
100
    output reg  [10:0]  wr_mutex,
101
 
102
    output reg  [31:0]  wr_stack_offset,
103
    output reg  [31:0]  wr_esp_prev,
104
 
105
    output      [1:0]   wr_task_rpl,
106
 
107
    output reg  [3:0]   wr_consumed,
108
 
109
    //software interrupt
110
    output              wr_int,
111
    output              wr_int_soft_int,
112
    output              wr_int_soft_int_ib,
113
    output      [7:0]   wr_int_vector,
114
 
115
    output              wr_exception_external_set,
116
    output              wr_exception_finished,
117
 
118
    output      [15:0]  wr_error_code,
119
 
120
    //wr exception
121
    output reg          wr_debug_init,
122
 
123
    output              wr_new_push_ss_fault,
124
    output              wr_string_es_fault,
125
    output              wr_push_ss_fault,
126
 
127
    //eip control
128
    output reg  [31:0]  wr_eip,
129
 
130
    //reset request
131
    output              wr_req_reset_pr,
132
    output              wr_req_reset_dec,
133
    output              wr_req_reset_micro,
134
    output              wr_req_reset_rd,
135
    output              wr_req_reset_exe,
136
 
137
    //memory page fault
138
    input       [31:0]  tlb_code_pf_cr2,
139
    input       [31:0]  tlb_write_pf_cr2,
140
    input       [31:0]  tlb_read_pf_cr2,
141
    input       [31:0]  tlb_check_pf_cr2,
142
 
143
    //memory write
144
    output              write_do,
145
    input               write_done,
146
    input               write_page_fault,
147
    input               write_ac_fault,
148
 
149
    output      [1:0]   write_cpl,
150
    output      [31:0]  write_address,
151
    output      [2:0]   write_length,
152
    output              write_lock,
153
    output              write_rmw,
154
    output      [31:0]  write_data,
155
 
156
    //flush tlb
157
    output              tlbflushall_do,
158
 
159
    //io write
160
    output              io_write_do,
161
    output      [15:0]  io_write_address,
162
    output      [2:0]   io_write_length,
163
    output      [31:0]  io_write_data,
164
    input               io_write_done,
165
 
166
    //global write
167
    output              wr_glob_param_1_set,
168
    output      [31:0]  wr_glob_param_1_value,
169
 
170
    output              wr_glob_param_3_set,
171
    output      [31:0]  wr_glob_param_3_value,
172
 
173
    output              wr_glob_param_4_set,
174
    output      [31:0]  wr_glob_param_4_value,
175
 
176
    //registers output
177
    output      [31:0]  eax,
178
    output      [31:0]  ebx,
179
    output      [31:0]  ecx,
180
    output      [31:0]  edx,
181
    output      [31:0]  esi,
182
    output      [31:0]  edi,
183
    output      [31:0]  ebp,
184
    output      [31:0]  esp,
185
 
186
    output              cr0_pe,
187
    output              cr0_mp,
188
    output              cr0_em,
189
    output              cr0_ts,
190
    output              cr0_ne,
191
    output              cr0_wp,
192
    output              cr0_am,
193
    output              cr0_nw,
194
    output              cr0_cd,
195
    output              cr0_pg,
196
 
197
    output      [31:0]  cr2,
198
    output      [31:0]  cr3,
199
 
200
    output              cflag,
201
    output              pflag,
202
    output              aflag,
203
    output              zflag,
204
    output              sflag,
205
    output              oflag,
206
    output              tflag,
207
    output              iflag,
208
    output              dflag,
209
    output      [1:0]   iopl,
210
    output              ntflag,
211
    output              rflag,
212
    output              vmflag,
213
    output              acflag,
214
    output              idflag,
215
 
216
    output      [31:0]  dr0,
217
    output      [31:0]  dr1,
218
    output      [31:0]  dr2,
219
    output      [31:0]  dr3,
220
    output      [3:0]   dr6_breakpoints,
221
    output              dr6_b12,
222
    output              dr6_bd,
223
    output              dr6_bs,
224
    output              dr6_bt,
225
    output      [31:0]  dr7,
226
 
227
    output      [15:0]  es,
228
    output      [15:0]  ds,
229
    output      [15:0]  ss,
230
    output      [15:0]  fs,
231
    output      [15:0]  gs,
232
    output      [15:0]  cs,
233
    output      [15:0]  ldtr,
234
    output      [15:0]  tr,
235
 
236
    output      [63:0]  es_cache,
237
    output      [63:0]  ds_cache,
238
    output      [63:0]  ss_cache,
239
    output      [63:0]  fs_cache,
240
    output      [63:0]  gs_cache,
241
    output      [63:0]  cs_cache,
242
    output      [63:0]  ldtr_cache,
243
    output      [63:0]  tr_cache,
244
 
245
    output              es_cache_valid,
246
    output              ds_cache_valid,
247
    output              ss_cache_valid,
248
    output              fs_cache_valid,
249
    output              gs_cache_valid,
250
    output              cs_cache_valid,
251
    output              ldtr_cache_valid,
252
    output              tr_cache_valid,
253
 
254
    //pipeline wr
255
    output              wr_busy,
256
    input               exe_ready,
257
 
258
    input       [39:0]  exe_decoder,
259
    input       [31:0]  exe_eip_final,
260
    input               exe_operand_32bit,
261
    input               exe_address_32bit,
262
    input       [1:0]   exe_prefix_group_1_rep,
263
    input               exe_prefix_group_1_lock,
264
    input       [3:0]   exe_consumed_final,
265
    input               exe_is_8bit_final,
266
    input       [6:0]   exe_cmd,
267
    input       [3:0]   exe_cmdex,
268
    input       [10:0]  exe_mutex,
269
    input               exe_dst_is_reg,
270
    input               exe_dst_is_rm,
271
    input               exe_dst_is_memory,
272
    input               exe_dst_is_eax,
273
    input               exe_dst_is_edx_eax,
274
    input               exe_dst_is_implicit_reg,
275
    input       [31:0]  exe_linear,
276
    input       [3:0]   exe_debug_read,
277
 
278
    input       [31:0]  exe_result,
279
    input       [31:0]  exe_result2,
280
    input       [31:0]  exe_result_push,
281
    input       [4:0]   exe_result_signals,
282
 
283
    input       [3:0]   exe_arith_index,
284
 
285
    input               exe_arith_sub_carry,
286
    input               exe_arith_add_carry,
287
    input               exe_arith_adc_carry,
288
    input               exe_arith_sbb_carry,
289
 
290
    input       [31:0]  src_final,
291
    input       [31:0]  dst_final,
292
 
293
    input               exe_mult_overflow,
294
    input       [31:0]  exe_stack_offset
295
);
296
 
297
//------------------------------------------------------------------------------
298
 
299
wire [31:0] tr_base;
300
 
301
wire [31:0] cs_base;
302
wire [31:0] cs_limit;
303
 
304
wire [31:0] es_base;
305
wire [31:0] es_limit;
306
 
307
wire [31:0] ss_base;
308
wire [31:0] ss_limit;
309
 
310
wire [31:0] ldtr_base;
311
 
312
assign tr_base     = {   tr_cache[63:56],   tr_cache[39:16] };
313
 
314
assign cs_base     = { cs_cache[63:56], cs_cache[39:16] };
315
assign cs_limit    = cs_cache[`DESC_BIT_G]? { cs_cache[51:48], cs_cache[15:0], 12'hFFF } : { 12'd0, cs_cache[51:48], cs_cache[15:0] };
316
 
317
assign es_base     = { es_cache[63:56], es_cache[39:16] };
318
assign es_limit    = es_cache[`DESC_BIT_G]? { es_cache[51:48], es_cache[15:0], 12'hFFF } : { 12'd0, es_cache[51:48], es_cache[15:0] };
319
 
320
assign ss_base     = { ss_cache[63:56], ss_cache[39:16] };
321
assign ss_limit    = ss_cache[`DESC_BIT_G]? { ss_cache[51:48], ss_cache[15:0], 12'hFFF } : { 12'd0, ss_cache[51:48], ss_cache[15:0] };
322
 
323
assign ldtr_base   = { ldtr_cache[63:56], ldtr_cache[39:16] };
324
 
325
//------------------------------------------------------------------------------
326
 
327
//------------------------------------------------------------------------------
328
 
329
//------------------------------------------------------------------------------
330
 
331
//------------------------------------------------------------------------------
332
 
333
//------------------------------------------------------------------------------
334
 
335
wire wr_ready;
336
wire w_load;
337
 
338
wire wr_waiting;
339
 
340
wire wr_one_cycle_wait;
341
 
342
//------------------------------------------------------------------------------
343
 
344
assign wr_ready = ~(wr_waiting) && wr_cmd != `CMD_NULL; //NOTE: do not use: wr_mutex[`MUTEX_ACTIVE_BIT];
345
 
346
assign wr_busy = wr_waiting || exc_init || wr_debug_prepare || wr_interrupt_possible_prepare || (wr_one_cycle_wait && wr_first_cycle);
347
 
348
assign w_load = exe_ready;
349
 
350
assign wr_is_front = wr_cmd != `CMD_NULL;
351
 
352
//------------------------------------------------------------------------------
353
 
354
wire wr_finished;
355
 
356
wire wr_not_finished;
357
wire wr_hlt_in_progress;
358
wire wr_inhibit_interrupts_and_debug;
359
wire wr_inhibit_interrupts;
360
wire iflag_to_reg;
361
 
362
wire wr_debug_prepare;
363
wire wr_interrupt_possible_prepare;
364
 
365
wire wr_clear_rflag;
366
 
367
wire wr_string_in_progress;
368
reg  wr_string_in_progress_last;
369
 
370
assign wr_finished =
371
    wr_ready && (~(wr_not_finished) || (wr_hlt_in_progress && iflag_to_reg && interrupt_do) || wr_string_in_progress);
372
 
373
assign wr_interrupt_possible_prepare =
374
    interrupt_do &&
375
    wr_ready && (~(wr_not_finished) || wr_hlt_in_progress || wr_string_in_progress) &&
376
    ~(wr_debug_prepare) &&
377
    ~(wr_inhibit_interrupts_and_debug) && ~(wr_inhibit_interrupts) && iflag_to_reg;
378
 
379
assign wr_clear_rflag = wr_finished && wr_eip <= cs_limit && ~(exc_init) && ~(wr_debug_prepare) && ~(wr_interrupt_possible_prepare);
380
 
381
always @(posedge clk or negedge rst_n) begin
382
    if(rst_n == 1'b0)   wr_interrupt_possible <= `FALSE;
383
    else if(wr_reset)   wr_interrupt_possible <= `FALSE;
384
    else                wr_interrupt_possible <= wr_interrupt_possible_prepare;
385
end
386
 
387
always @(posedge clk or negedge rst_n) begin
388
    if(rst_n == 1'b0)   wr_debug_init <= `FALSE;
389
    else                wr_debug_init <= wr_debug_prepare;
390
end
391
 
392
always @(posedge clk or negedge rst_n) begin
393
    if(rst_n == 1'b0)   wr_string_in_progress_last <= `FALSE;
394
    else                wr_string_in_progress_last <= wr_string_in_progress;
395
end
396
 
397
assign wr_string_in_progress_final = wr_string_in_progress || ((wr_debug_init || wr_interrupt_possible) && wr_string_in_progress_last);
398
 
399
//------------------------------------------------------------------------------
400
 
401
reg wr_first_cycle;
402
 
403
always @(posedge clk or negedge rst_n) begin
404
    if(rst_n == 1'b0)   wr_first_cycle <= `FALSE;
405
    else if(wr_reset)   wr_first_cycle <= `FALSE;
406
    else if(w_load)     wr_first_cycle <= `TRUE;
407
    else                wr_first_cycle <= `FALSE;
408
end
409
 
410
//------------------------------------------------------------------------------
411
 
412
reg [15:0]  wr_decoder;
413
reg         wr_operand_32bit;
414
reg         wr_address_32bit;
415
reg [1:0]   wr_prefix_group_1_rep;
416
reg         wr_prefix_group_1_lock;
417
reg         wr_is_8bit;
418
reg [6:0]   wr_cmd;
419
reg [3:0]   wr_cmdex;
420
reg         wr_dst_is_reg;
421
reg         wr_dst_is_rm;
422
reg         wr_dst_is_memory;
423
reg         wr_dst_is_eax;
424
reg         wr_dst_is_edx_eax;
425
reg         wr_dst_is_implicit_reg;
426
reg [31:0]  wr_linear;
427
 
428
reg [31:0]  result;
429
reg [31:0]  result2;
430
reg [4:0]   result_signals;
431
reg [31:0]  result_push;
432
 
433
reg [3:0]   wr_arith_index;
434
reg [31:0]  wr_src;
435
reg [31:0]  wr_dst;
436
 
437
reg         wr_arith_add_carry;
438
reg         wr_arith_adc_carry;
439
reg         wr_arith_sub_carry;
440
reg         wr_arith_sbb_carry;
441
reg         wr_mult_overflow;
442
 
443
always @(posedge clk or negedge rst_n) begin if(rst_n == 1'b0) wr_decoder              <= 16'd0;     else if(w_load) wr_decoder              <= exe_decoder[15:0];        end
444
always @(posedge clk or negedge rst_n) begin if(rst_n == 1'b0) wr_eip                  <= 32'd0;     else if(w_load) wr_eip                  <= exe_eip_final;            end
445
always @(posedge clk or negedge rst_n) begin if(rst_n == 1'b0) wr_operand_32bit        <= `FALSE;    else if(w_load) wr_operand_32bit        <= exe_operand_32bit;        end
446
always @(posedge clk or negedge rst_n) begin if(rst_n == 1'b0) wr_address_32bit        <= `FALSE;    else if(w_load) wr_address_32bit        <= exe_address_32bit;        end
447
always @(posedge clk or negedge rst_n) begin if(rst_n == 1'b0) wr_prefix_group_1_rep   <= 2'd0;      else if(w_load) wr_prefix_group_1_rep   <= exe_prefix_group_1_rep;   end
448
always @(posedge clk or negedge rst_n) begin if(rst_n == 1'b0) wr_prefix_group_1_lock  <= `FALSE;    else if(w_load) wr_prefix_group_1_lock  <= exe_prefix_group_1_lock;  end
449
always @(posedge clk or negedge rst_n) begin if(rst_n == 1'b0) wr_consumed             <= 4'd0;      else if(w_load) wr_consumed             <= exe_consumed_final;       end
450
always @(posedge clk or negedge rst_n) begin if(rst_n == 1'b0) wr_is_8bit              <= `FALSE;    else if(w_load) wr_is_8bit              <= exe_is_8bit_final;        end
451
always @(posedge clk or negedge rst_n) begin if(rst_n == 1'b0) wr_cmdex                <= 4'd0;      else if(w_load) wr_cmdex                <= exe_cmdex;                end
452
always @(posedge clk or negedge rst_n) begin if(rst_n == 1'b0) wr_dst_is_reg           <= `FALSE;    else if(w_load) wr_dst_is_reg           <= exe_dst_is_reg;           end
453
always @(posedge clk or negedge rst_n) begin if(rst_n == 1'b0) wr_dst_is_rm            <= `FALSE;    else if(w_load) wr_dst_is_rm            <= exe_dst_is_rm;            end
454
always @(posedge clk or negedge rst_n) begin if(rst_n == 1'b0) wr_dst_is_memory        <= `FALSE;    else if(w_load) wr_dst_is_memory        <= exe_dst_is_memory;        end
455
always @(posedge clk or negedge rst_n) begin if(rst_n == 1'b0) wr_dst_is_eax           <= `FALSE;    else if(w_load) wr_dst_is_eax           <= exe_dst_is_eax;           end
456
always @(posedge clk or negedge rst_n) begin if(rst_n == 1'b0) wr_dst_is_edx_eax       <= `FALSE;    else if(w_load) wr_dst_is_edx_eax       <= exe_dst_is_edx_eax;       end
457
always @(posedge clk or negedge rst_n) begin if(rst_n == 1'b0) wr_dst_is_implicit_reg  <= `FALSE;    else if(w_load) wr_dst_is_implicit_reg  <= exe_dst_is_implicit_reg;  end
458
always @(posedge clk or negedge rst_n) begin if(rst_n == 1'b0) wr_linear               <= 32'd0;     else if(w_load) wr_linear               <= exe_linear;               end
459
 
460
always @(posedge clk or negedge rst_n) begin if(rst_n == 1'b0) result                  <= 32'd0;     else if(w_load) result                  <= exe_result;               end
461
always @(posedge clk or negedge rst_n) begin if(rst_n == 1'b0) result2                 <= 32'd0;     else if(w_load) result2                 <= exe_result2;              end
462
always @(posedge clk or negedge rst_n) begin if(rst_n == 1'b0) result_push             <= 32'd0;     else if(w_load) result_push             <= exe_result_push;          end
463
always @(posedge clk or negedge rst_n) begin if(rst_n == 1'b0) result_signals          <= 5'd0;      else if(w_load) result_signals          <= exe_result_signals;       end
464
 
465
always @(posedge clk or negedge rst_n) begin if(rst_n == 1'b0) wr_arith_index          <= 4'd0;      else if(w_load) wr_arith_index          <= exe_arith_index;          end
466
always @(posedge clk or negedge rst_n) begin if(rst_n == 1'b0) wr_src                  <= 32'd0;     else if(w_load) wr_src                  <= src_final;                end
467
always @(posedge clk or negedge rst_n) begin if(rst_n == 1'b0) wr_dst                  <= 32'd0;     else if(w_load) wr_dst                  <= dst_final;                end
468
 
469
always @(posedge clk or negedge rst_n) begin if(rst_n == 1'b0) wr_arith_sub_carry      <= 1'd0;      else if(w_load) wr_arith_sub_carry      <= exe_arith_sub_carry;      end
470
always @(posedge clk or negedge rst_n) begin if(rst_n == 1'b0) wr_arith_add_carry      <= 1'd0;      else if(w_load) wr_arith_add_carry      <= exe_arith_add_carry;      end
471
always @(posedge clk or negedge rst_n) begin if(rst_n == 1'b0) wr_arith_adc_carry      <= 1'd0;      else if(w_load) wr_arith_adc_carry      <= exe_arith_adc_carry;      end
472
always @(posedge clk or negedge rst_n) begin if(rst_n == 1'b0) wr_arith_sbb_carry      <= 1'd0;      else if(w_load) wr_arith_sbb_carry      <= exe_arith_sbb_carry;      end
473
always @(posedge clk or negedge rst_n) begin if(rst_n == 1'b0) wr_mult_overflow        <= 1'd0;      else if(w_load) wr_mult_overflow        <= exe_mult_overflow;        end
474
 
475
always @(posedge clk or negedge rst_n) begin if(rst_n == 1'b0) wr_stack_offset         <= 32'd0;     else if(w_load) wr_stack_offset         <= exe_stack_offset;         end
476
 
477
always @(posedge clk or negedge rst_n) begin
478
    if(rst_n == 1'b0)   wr_cmd <= `CMD_NULL;
479
    else if(wr_reset)   wr_cmd <= `CMD_NULL;
480
    else if(w_load)     wr_cmd <= exe_cmd;
481
    else if(wr_ready)   wr_cmd <= `CMD_NULL;
482
end
483
 
484
always @(posedge clk or negedge rst_n) begin
485
    if(rst_n == 1'b0)                                       wr_mutex <= 11'd0;
486
    else if(wr_reset)                                       wr_mutex <= 11'd0;
487
    else if(w_load)                                         wr_mutex <= exe_mutex;
488
    else if(wr_ready && ~(wr_interrupt_possible_prepare))   wr_mutex <= 11'd0;
489
end
490
 
491
//------------------------------------------------------------------------------
492
 
493
wire wr_operand_16bit;
494
wire wr_address_16bit;
495
 
496
wire [1:0] wr_modregrm_mod;
497
wire [2:0] wr_modregrm_reg;
498
wire [2:0] wr_modregrm_rm;
499
 
500
assign wr_operand_16bit = ~(wr_operand_32bit);
501
assign wr_address_16bit = ~(wr_address_32bit);
502
 
503
assign wr_modregrm_mod = wr_decoder[15:14];
504
assign wr_modregrm_reg = wr_decoder[13:11];
505
assign wr_modregrm_rm  = wr_decoder[10:8];
506
 
507
//------------------------------------------------------------------------------
508
 
509
wire [31:0] wr_descriptor_touch_offset;
510
wire [31:0] wr_descriptor_busy_tss_offset;
511
 
512
assign wr_descriptor_touch_offset =
513
    (glob_param_1[2] == 1'b0)?   gdtr_base + { 16'd0, glob_param_1[15:3], 3'd0 } + 32'd5 :
514
                                 ldtr_base + { 16'd0, glob_param_1[15:3], 3'd0 } + 32'd5;
515
 
516
assign wr_descriptor_busy_tss_offset =
517
                                gdtr_base + { 16'd0, glob_param_1[15:3], 3'd0 } + 32'd4;
518
 
519
//------------------------------------------------------------------------------ write memory
520
 
521
wire memory_write_system;
522
 
523
wire        write_for_wr_ready;
524
wire [31:0] wr_string_es_linear;
525
 
526
assign memory_write_system =
527
    write_system_touch || write_system_busy_tss || write_system_dword || write_system_word || write_rmw_system_dword;
528
 
529
assign write_cpl =
530
    (write_new_stack_virtual)?      glob_descriptor_2[`DESC_BITS_DPL] :
531
    (memory_write_system)?          2'd0 :
532
                                    cpl;
533
 
534
assign write_lock = wr_prefix_group_1_lock;
535
 
536
assign write_rmw = write_rmw_virtual || write_rmw_system_dword;
537
 
538
assign write_address =
539
    (write_string_es_virtual)?                  wr_string_es_linear :
540
    (write_stack_virtual)?                      wr_push_linear :
541
    (write_new_stack_virtual)?                  wr_new_push_linear :
542
    (write_system_touch)?                       wr_descriptor_touch_offset :
543
    (write_system_busy_tss)?                    wr_descriptor_busy_tss_offset :
544
    (write_system_dword || write_system_word)?  wr_system_linear :
545
                                                wr_linear; //used by write_rmw_system_dword
546
 
547
assign write_data =
548
    (write_stack_virtual || write_string_es_virtual || write_new_stack_virtual)?    result_push :
549
    (write_system_touch)?                                                           { 24'd0, glob_descriptor[47:41], 1'b1 } :
550
    (write_system_busy_tss)?                                                        glob_descriptor[63:32] | 32'h00000200 :
551
    (write_rmw_system_dword || write_system_dword || write_system_word)?            wr_system_dword :
552
                                                                                    result;
553
 
554
assign write_length =
555
    (write_stack_virtual || write_new_stack_virtual)?   wr_push_length :
556
    (write_system_touch)?       3'd1 :
557
    (write_system_busy_tss)?    3'd4 :
558
    (write_length_word)?        3'd2 :
559
    (write_rmw_system_dword)?   3'd4 :
560
    (write_system_dword)?       3'd4 :
561
    (write_system_word)?        3'd2 :
562
    (write_length_dword)?       3'd4 :
563
    wr_is_8bit?                 3'd1 : //last 3: write_string_es_virtual also
564
    wr_operand_16bit?           3'd2 :
565
                                3'd4;
566
 
567
assign write_do = ~(wr_reset) && ~(write_done) && ~(write_page_fault) && ~(write_ac_fault) &&
568
    (write_rmw_virtual || write_virtual || write_stack_virtual || write_new_stack_virtual ||
569
     write_string_es_virtual || memory_write_system);
570
 
571
 
572
assign write_for_wr_ready = write_done && ~(write_page_fault) && ~(write_ac_fault);
573
 
574
//------------------------------------------------------------------------------ write io
575
 
576
wire write_io_for_wr_ready;
577
 
578
assign io_write_do      = write_io;
579
assign io_write_address = glob_param_1[15:0];
580
assign io_write_length  = (wr_is_8bit)? 3'd1 : (wr_operand_16bit)? 3'd2 : 3'd4;
581
assign io_write_data    = result_push;
582
 
583
assign write_io_for_wr_ready = io_write_done;
584
 
585
//------------------------------------------------------------------------------ esp speculative
586
 
587
always @(posedge clk or negedge rst_n) begin
588
    if(rst_n == 1'b0)                                               wr_esp_prev <= 32'd0;
589
    else if(wr_make_esp_speculative && ~(wr_is_esp_speculative))    wr_esp_prev <= esp;
590
end
591
 
592
always @(posedge clk or negedge rst_n) begin
593
    if(rst_n == 1'b0)                   wr_is_esp_speculative <= `FALSE;
594
    else if(wr_reset || exe_reset)      wr_is_esp_speculative <= `FALSE;
595
    else if(wr_make_esp_commit)         wr_is_esp_speculative <= `FALSE;
596
    else if(wr_make_esp_speculative)    wr_is_esp_speculative <= `TRUE;
597
end
598
 
599
//------------------------------------------------------------------------------
600
 
601
//------------------------------------------------------------------------------
602
 
603
// synthesis translate_off
604
wire _unused_ok = &{ 1'b0, glob_descriptor_2[63:47], glob_descriptor_2[44:0], exe_decoder[39:16], 1'b0 };
605
// synthesis translate_on
606
 
607
//------------------------------------------------------------------------------
608
 
609
wire        write_stack_virtual;
610
wire        write_new_stack_virtual;
611
wire        wr_push_length_word;
612
wire        wr_push_length_dword;
613
wire        wr_push_ss_fault_check;
614
wire        wr_new_push_ss_fault_check;
615
wire        wr_make_esp_speculative;
616
wire        wr_make_esp_commit;
617
 
618
wire        wr_validate_seg_regs;
619
 
620
wire [15:0] wr_seg_sel;
621
wire        wr_seg_cache_valid;
622
wire [1:0]  wr_seg_rpl;
623
wire [63:0] wr_seg_cache_mask;
624
 
625
wire        write_seg_cache;
626
wire        write_seg_sel;
627
wire        write_seg_cache_valid;
628
wire        write_seg_rpl;
629
 
630
wire        wr_debug_trap_clear;
631
wire        wr_debug_task_trigger;
632
 
633
wire        write_rmw_virtual;
634
wire        write_virtual;
635
wire        write_rmw_system_dword;
636
wire        write_system_word;
637
wire        write_system_dword;
638
wire        write_system_busy_tss;
639
wire        write_system_touch;
640
 
641
wire        write_length_word;
642
wire        write_length_dword;
643
 
644
wire [31:0] wr_system_dword;
645
wire [31:0] wr_system_linear;
646
 
647
wire        write_regrm;
648
wire        write_eax;
649
wire        wr_regrm_word;
650
wire        wr_regrm_dword;
651
 
652
wire        wr_string_gp_fault_check;
653
wire        write_string_es_virtual;
654
 
655
wire        write_io;
656
 
657
//registers
658
wire [1:0]  es_rpl;
659
wire [1:0]  ds_rpl;
660
wire [1:0]  ss_rpl;
661
wire [1:0]  fs_rpl;
662
wire [1:0]  gs_rpl;
663
wire [1:0]  cs_rpl;
664
wire [1:0]  ldtr_rpl;
665
wire [1:0]  tr_rpl;
666
 
667
wire [31:0] eax_to_reg;
668
wire [31:0] ebx_to_reg;
669
wire [31:0] ecx_to_reg;
670
wire [31:0] edx_to_reg;
671
wire [31:0] esi_to_reg;
672
wire [31:0] edi_to_reg;
673
wire [31:0] ebp_to_reg;
674
wire [31:0] esp_to_reg;
675
wire        cr0_pe_to_reg;
676
wire        cr0_mp_to_reg;
677
wire        cr0_em_to_reg;
678
wire        cr0_ts_to_reg;
679
wire        cr0_ne_to_reg;
680
wire        cr0_wp_to_reg;
681
wire        cr0_am_to_reg;
682
wire        cr0_nw_to_reg;
683
wire        cr0_cd_to_reg;
684
wire        cr0_pg_to_reg;
685
wire [31:0] cr2_to_reg;
686
wire [31:0] cr3_to_reg;
687
wire        cflag_to_reg;
688
wire        pflag_to_reg;
689
wire        aflag_to_reg;
690
wire        zflag_to_reg;
691
wire        sflag_to_reg;
692
wire        oflag_to_reg;
693
wire        tflag_to_reg;
694
//wire        iflag_to_reg; --declared above
695
wire        dflag_to_reg;
696
wire [1:0]  iopl_to_reg;
697
wire        ntflag_to_reg;
698
wire        rflag_to_reg;
699
wire        vmflag_to_reg;
700
wire        acflag_to_reg;
701
wire        idflag_to_reg;
702
wire [31:0] gdtr_base_to_reg;
703
wire [15:0] gdtr_limit_to_reg;
704
wire [31:0] idtr_base_to_reg;
705
wire [15:0] idtr_limit_to_reg;
706
wire [31:0] dr0_to_reg;
707
wire [31:0] dr1_to_reg;
708
wire [31:0] dr2_to_reg;
709
wire [31:0] dr3_to_reg;
710
wire [3:0]  dr6_breakpoints_to_reg;
711
wire        dr6_b12_to_reg;
712
wire        dr6_bd_to_reg;
713
wire        dr6_bs_to_reg;
714
wire        dr6_bt_to_reg;
715
wire [31:0] dr7_to_reg;
716
wire [15:0] es_to_reg;
717
wire [15:0] ds_to_reg;
718
wire [15:0] ss_to_reg;
719
wire [15:0] fs_to_reg;
720
wire [15:0] gs_to_reg;
721
wire [15:0] cs_to_reg;
722
wire [15:0] ldtr_to_reg;
723
wire [15:0] tr_to_reg;
724
wire [63:0] es_cache_to_reg;
725
wire [63:0] ds_cache_to_reg;
726
wire [63:0] ss_cache_to_reg;
727
wire [63:0] fs_cache_to_reg;
728
wire [63:0] gs_cache_to_reg;
729
wire [63:0] cs_cache_to_reg;
730
wire [63:0] ldtr_cache_to_reg;
731
wire [63:0] tr_cache_to_reg;
732
wire        es_cache_valid_to_reg;
733
wire        ds_cache_valid_to_reg;
734
wire        ss_cache_valid_to_reg;
735
wire        fs_cache_valid_to_reg;
736
wire        gs_cache_valid_to_reg;
737
wire        cs_cache_valid_to_reg;
738
wire        ldtr_cache_valid_to_reg;
739
wire [1:0]  es_rpl_to_reg;
740
wire [1:0]  ds_rpl_to_reg;
741
wire [1:0]  ss_rpl_to_reg;
742
wire [1:0]  fs_rpl_to_reg;
743
wire [1:0]  gs_rpl_to_reg;
744
wire [1:0]  cs_rpl_to_reg;
745
wire [1:0]  ldtr_rpl_to_reg;
746
wire [1:0]  tr_rpl_to_reg;
747
 
748
//stack
749
wire [31:0] wr_stack_esp;
750
wire [31:0] wr_push_linear;
751
wire [31:0] wr_new_stack_esp;
752
wire [31:0] wr_new_push_linear;
753
wire [2:0]  wr_push_length;
754
 
755
//string
756
wire [31:0] wr_esi_final;
757
wire [31:0] wr_edi_final;
758
wire [31:0] wr_ecx_final;
759
 
760
wire        wr_string_ignore;
761
 
762
wire        wr_zflag_result;
763
wire        wr_string_zf_finish;
764
wire        wr_string_finish;
765
 
766
write_commands write_commands_inst(
767
    .clk                (clk),
768
    .rst_n              (rst_n),
769
 
770
    //general input
771
    .real_mode              (real_mode),                //input
772
    .v8086_mode             (v8086_mode),               //input
773
    .protected_mode         (protected_mode),           //input
774
 
775
    .cpl                    (cpl),                      //input [1:0]
776
 
777
    .tr_base                (tr_base),                  //input [31:0]
778
 
779
    .eip                    (eip),                      //input [31:0]
780
 
781
    .io_allow_check_needed  (io_allow_check_needed),    //input
782
 
783
    .exc_push_error         (exc_push_error),           //input
784
    .exc_eip                (exc_eip),                  //input [31:0]
785
 
786
    //global input
787
    .glob_descriptor               (glob_descriptor),               //input [63:0]
788
    .glob_desc_base                (glob_desc_base),                //input [31:0]
789
 
790
    .glob_param_1                  (glob_param_1),                  //input [31:0]
791
    .glob_param_2                  (glob_param_2),                  //input [31:0]
792
    .glob_param_3                  (glob_param_3),                  //input [31:0]
793
    .glob_param_4                  (glob_param_4),                  //input [31:0]
794
    .glob_param_5                  (glob_param_5),                  //input [31:0]
795
 
796
    //write
797
    .wr_ready                      (wr_ready),                      //input
798
    .wr_decoder                    (wr_decoder),                    //input [15:0]
799
    .wr_cmd                        (wr_cmd),                        //input [6:0]
800
    .wr_cmdex                      (wr_cmdex),                      //input [3:0]
801
    .wr_is_8bit                    (wr_is_8bit),                    //input
802
    .wr_address_16bit              (wr_address_16bit),              //input
803
    .wr_operand_16bit              (wr_operand_16bit),              //input
804
    .wr_operand_32bit              (wr_operand_32bit),              //input
805
    .wr_mult_overflow              (wr_mult_overflow),              //input
806
    .wr_arith_index                (wr_arith_index),                //input [3:0]
807
    .wr_modregrm_mod               (wr_modregrm_mod),               //input [1:0]
808
    .wr_modregrm_reg               (wr_modregrm_reg),               //input [2:0]
809
    .wr_modregrm_rm                (wr_modregrm_rm),                //input [2:0]
810
    .wr_dst_is_memory              (wr_dst_is_memory),              //input
811
    .wr_dst_is_reg                 (wr_dst_is_reg),                 //input
812
    .wr_dst_is_rm                  (wr_dst_is_rm),                  //input
813
    .wr_dst_is_implicit_reg        (wr_dst_is_implicit_reg),        //input
814
    .wr_dst_is_edx_eax             (wr_dst_is_edx_eax),             //input
815
    .wr_dst_is_eax                 (wr_dst_is_eax),                 //input
816
 
817
    .wr_arith_add_carry            (wr_arith_add_carry),            //input
818
    .wr_arith_adc_carry            (wr_arith_adc_carry),            //input
819
    .wr_arith_sbb_carry            (wr_arith_sbb_carry),            //input
820
    .wr_arith_sub_carry            (wr_arith_sub_carry),            //input
821
 
822
    .result                        (result),                        //input [31:0]
823
    .result2                       (result2),                       //input [31:0]
824
 
825
    .wr_src                        (wr_src),                        //input [31:0]
826
    .wr_dst                        (wr_dst),                        //input [31:0]
827
    .result_signals                (result_signals),                //input [4:0]
828
    .result_push                   (result_push),                   //input [31:0]
829
 
830
    .exe_buffer                    (exe_buffer),                    //input [31:0]
831
    .exe_buffer_shifted            (exe_buffer_shifted),            //input [463:0]
832
 
833
    //global output
834
    .wr_glob_param_1_set              (wr_glob_param_1_set),            //output
835
    .wr_glob_param_1_value            (wr_glob_param_1_value),          //output [31:0]
836
 
837
    .wr_glob_param_3_set              (wr_glob_param_3_set),            //output
838
    .wr_glob_param_3_value            (wr_glob_param_3_value),          //output [31:0]
839
 
840
    .wr_glob_param_4_set              (wr_glob_param_4_set),            //output
841
    .wr_glob_param_4_value            (wr_glob_param_4_value),          //output [31:0]
842
 
843
    //debug output
844
    .wr_debug_trap_clear     (wr_debug_trap_clear),                     //output
845
    .wr_debug_task_trigger   (wr_debug_task_trigger),                   //output
846
 
847
    //exception
848
    .wr_int                          (wr_int),                          //output
849
    .wr_int_soft_int                 (wr_int_soft_int),                 //output
850
    .wr_int_soft_int_ib              (wr_int_soft_int_ib),              //output
851
    .wr_int_vector                   (wr_int_vector),                   //output [7:0]
852
 
853
    .wr_exception_external_set       (wr_exception_external_set),       //output
854
    .wr_exception_finished           (wr_exception_finished),           //output
855
 
856
    .wr_inhibit_interrupts           (wr_inhibit_interrupts),           //output
857
    .wr_inhibit_interrupts_and_debug (wr_inhibit_interrupts_and_debug), //output
858
 
859
    //memory
860
    .write_for_wr_ready            (write_for_wr_ready),            //input
861
 
862
    .write_rmw_virtual             (write_rmw_virtual),             //output
863
    .write_virtual                 (write_virtual),                 //output
864
    .write_rmw_system_dword        (write_rmw_system_dword),        //output
865
    .write_system_word             (write_system_word),             //output
866
    .write_system_dword            (write_system_dword),            //output
867
    .write_system_busy_tss         (write_system_busy_tss),         //output
868
    .write_system_touch            (write_system_touch),            //output
869
 
870
    .write_length_word             (write_length_word),             //output
871
    .write_length_dword            (write_length_dword),            //output
872
 
873
    .wr_system_dword               (wr_system_dword),               //output [31:0]
874
    .wr_system_linear              (wr_system_linear),              //output [31:0]
875
 
876
 
877
    //write regrm
878
    .write_regrm                   (write_regrm),                   //output
879
    .write_eax                     (write_eax),                     //output
880
    .wr_regrm_word                 (wr_regrm_word),                 //output
881
    .wr_regrm_dword                (wr_regrm_dword),                //output
882
 
883
 
884
    //write output
885
    .wr_not_finished               (wr_not_finished),               //output
886
    .wr_hlt_in_progress            (wr_hlt_in_progress),            //output
887
    .wr_string_in_progress         (wr_string_in_progress),         //output
888
    .wr_waiting                    (wr_waiting),                    //output
889
 
890
    .wr_req_reset_pr               (wr_req_reset_pr),               //output
891
    .wr_req_reset_dec              (wr_req_reset_dec),              //output
892
    .wr_req_reset_micro            (wr_req_reset_micro),            //output
893
    .wr_req_reset_rd               (wr_req_reset_rd),               //output
894
    .wr_req_reset_exe              (wr_req_reset_exe),              //output
895
 
896
    .wr_zflag_result               (wr_zflag_result),               //output
897
 
898
    .wr_task_rpl                   (wr_task_rpl),                   //output [1:0]
899
 
900
    .wr_one_cycle_wait             (wr_one_cycle_wait),             //output
901
 
902
    //stack
903
    .write_stack_virtual           (write_stack_virtual),           //output
904
    .write_new_stack_virtual       (write_new_stack_virtual),       //output
905
 
906
    .wr_push_length_word           (wr_push_length_word),           //output
907
    .wr_push_length_dword          (wr_push_length_dword),          //output
908
 
909
    .wr_stack_esp                  (wr_stack_esp),                  //input [31:0]
910
    .wr_new_stack_esp              (wr_new_stack_esp),              //input [31:0]
911
 
912
 
913
    .wr_push_ss_fault_check        (wr_push_ss_fault_check),        //output
914
    .wr_push_ss_fault              (wr_push_ss_fault),              //input
915
 
916
    .wr_new_push_ss_fault_check    (wr_new_push_ss_fault_check),    //output
917
    .wr_new_push_ss_fault          (wr_new_push_ss_fault),          //input
918
 
919
    .wr_error_code                 (wr_error_code),                 //output [15:0]
920
 
921
    .wr_make_esp_speculative       (wr_make_esp_speculative),       //output
922
    .wr_make_esp_commit            (wr_make_esp_commit),            //output
923
 
924
    //string
925
    .wr_string_ignore              (wr_string_ignore),              //input
926
    .wr_prefix_group_1_rep         (wr_prefix_group_1_rep),         //input [1:0]
927
    .wr_string_zf_finish           (wr_string_zf_finish),           //input
928
    .wr_string_es_fault            (wr_string_es_fault),            //input
929
    .wr_string_finish              (wr_string_finish),              //input
930
 
931
    .wr_esi_final                  (wr_esi_final),                  //input [31:0]
932
    .wr_edi_final                  (wr_edi_final),                  //input [31:0]
933
    .wr_ecx_final                  (wr_ecx_final),                  //input [31:0]
934
 
935
    .wr_string_gp_fault_check      (wr_string_gp_fault_check),      //output
936
    .write_string_es_virtual       (write_string_es_virtual),       //output
937
 
938
    //io write
939
    .write_io                      (write_io),                      //output
940
    .write_io_for_wr_ready         (write_io_for_wr_ready),         //input
941
 
942
    //segment
943
    .wr_seg_sel                    (wr_seg_sel),                    //output [15:0]
944
    .wr_seg_cache_valid            (wr_seg_cache_valid),            //output
945
    .wr_seg_rpl                    (wr_seg_rpl),                    //output [1:0]
946
    .wr_seg_cache_mask             (wr_seg_cache_mask),             //output [63:0]
947
 
948
    .write_seg_cache               (write_seg_cache),               //output
949
    .write_seg_sel                 (write_seg_sel),                 //output
950
    .write_seg_cache_valid         (write_seg_cache_valid),         //output
951
    .write_seg_rpl                 (write_seg_rpl),                 //output
952
 
953
    .wr_validate_seg_regs          (wr_validate_seg_regs),          //output
954
 
955
    //flush tlb
956
    .tlbflushall_do                (tlbflushall_do),                //output
957
 
958
    //---------------------
959
 
960
    .eax_to_reg                    (eax_to_reg),                    //output [31:0]
961
    .ebx_to_reg                    (ebx_to_reg),                    //output [31:0]
962
    .ecx_to_reg                    (ecx_to_reg),                    //output [31:0]
963
    .edx_to_reg                    (edx_to_reg),                    //output [31:0]
964
    .esi_to_reg                    (esi_to_reg),                    //output [31:0]
965
    .edi_to_reg                    (edi_to_reg),                    //output [31:0]
966
    .ebp_to_reg                    (ebp_to_reg),                    //output [31:0]
967
    .esp_to_reg                    (esp_to_reg),                    //output [31:0]
968
    .cr0_pe_to_reg                 (cr0_pe_to_reg),                 //output
969
    .cr0_mp_to_reg                 (cr0_mp_to_reg),                 //output
970
    .cr0_em_to_reg                 (cr0_em_to_reg),                 //output
971
    .cr0_ts_to_reg                 (cr0_ts_to_reg),                 //output
972
    .cr0_ne_to_reg                 (cr0_ne_to_reg),                 //output
973
    .cr0_wp_to_reg                 (cr0_wp_to_reg),                 //output
974
    .cr0_am_to_reg                 (cr0_am_to_reg),                 //output
975
    .cr0_nw_to_reg                 (cr0_nw_to_reg),                 //output
976
    .cr0_cd_to_reg                 (cr0_cd_to_reg),                 //output
977
    .cr0_pg_to_reg                 (cr0_pg_to_reg),                 //output
978
    .cr2_to_reg                    (cr2_to_reg),                    //output [31:0]
979
    .cr3_to_reg                    (cr3_to_reg),                    //output [31:0]
980
    .cflag_to_reg                  (cflag_to_reg),                  //output
981
    .pflag_to_reg                  (pflag_to_reg),                  //output
982
    .aflag_to_reg                  (aflag_to_reg),                  //output
983
    .zflag_to_reg                  (zflag_to_reg),                  //output
984
    .sflag_to_reg                  (sflag_to_reg),                  //output
985
    .oflag_to_reg                  (oflag_to_reg),                  //output
986
    .tflag_to_reg                  (tflag_to_reg),                  //output
987
    .iflag_to_reg                  (iflag_to_reg),                  //output
988
    .dflag_to_reg                  (dflag_to_reg),                  //output
989
    .iopl_to_reg                   (iopl_to_reg),                   //output [1:0]
990
    .ntflag_to_reg                 (ntflag_to_reg),                 //output
991
    .rflag_to_reg                  (rflag_to_reg),                  //output
992
    .vmflag_to_reg                 (vmflag_to_reg),                 //output
993
    .acflag_to_reg                 (acflag_to_reg),                 //output
994
    .idflag_to_reg                 (idflag_to_reg),                 //output
995
    .gdtr_base_to_reg              (gdtr_base_to_reg),              //output [31:0]
996
    .gdtr_limit_to_reg             (gdtr_limit_to_reg),             //output [15:0]
997
    .idtr_base_to_reg              (idtr_base_to_reg),              //output [31:0]
998
    .idtr_limit_to_reg             (idtr_limit_to_reg),             //output [15:0]
999
    .dr0_to_reg                    (dr0_to_reg),                    //output [31:0]
1000
    .dr1_to_reg                    (dr1_to_reg),                    //output [31:0]
1001
    .dr2_to_reg                    (dr2_to_reg),                    //output [31:0]
1002
    .dr3_to_reg                    (dr3_to_reg),                    //output [31:0]
1003
    .dr6_breakpoints_to_reg        (dr6_breakpoints_to_reg),        //output [3:0]
1004
    .dr6_b12_to_reg                (dr6_b12_to_reg),                //output
1005
    .dr6_bd_to_reg                 (dr6_bd_to_reg),                 //output
1006
    .dr6_bs_to_reg                 (dr6_bs_to_reg),                 //output
1007
    .dr6_bt_to_reg                 (dr6_bt_to_reg),                 //output
1008
    .dr7_to_reg                    (dr7_to_reg),                    //output [31:0]
1009
    .es_to_reg                     (es_to_reg),                     //output [15:0]
1010
    .ds_to_reg                     (ds_to_reg),                     //output [15:0]
1011
    .ss_to_reg                     (ss_to_reg),                     //output [15:0]
1012
    .fs_to_reg                     (fs_to_reg),                     //output [15:0]
1013
    .gs_to_reg                     (gs_to_reg),                     //output [15:0]
1014
    .cs_to_reg                     (cs_to_reg),                     //output [15:0]
1015
    .ldtr_to_reg                   (ldtr_to_reg),                   //output [15:0]
1016
    .tr_to_reg                     (tr_to_reg),                     //output [15:0]
1017
    .es_cache_to_reg               (es_cache_to_reg),               //output [63:0]
1018
    .ds_cache_to_reg               (ds_cache_to_reg),               //output [63:0]
1019
    .ss_cache_to_reg               (ss_cache_to_reg),               //output [63:0]
1020
    .fs_cache_to_reg               (fs_cache_to_reg),               //output [63:0]
1021
    .gs_cache_to_reg               (gs_cache_to_reg),               //output [63:0]
1022
    .cs_cache_to_reg               (cs_cache_to_reg),               //output [63:0]
1023
    .ldtr_cache_to_reg             (ldtr_cache_to_reg),             //output [63:0]
1024
    .tr_cache_to_reg               (tr_cache_to_reg),               //output [63:0]
1025
    .es_cache_valid_to_reg         (es_cache_valid_to_reg),         //output
1026
    .ds_cache_valid_to_reg         (ds_cache_valid_to_reg),         //output
1027
    .ss_cache_valid_to_reg         (ss_cache_valid_to_reg),         //output
1028
    .fs_cache_valid_to_reg         (fs_cache_valid_to_reg),         //output
1029
    .gs_cache_valid_to_reg         (gs_cache_valid_to_reg),         //output
1030
    .cs_cache_valid_to_reg         (cs_cache_valid_to_reg),         //output
1031
    .ldtr_cache_valid_to_reg       (ldtr_cache_valid_to_reg),       //output
1032
    .es_rpl_to_reg                 (es_rpl_to_reg),                 //output [1:0]
1033
    .ds_rpl_to_reg                 (ds_rpl_to_reg),                 //output [1:0]
1034
    .ss_rpl_to_reg                 (ss_rpl_to_reg),                 //output [1:0]
1035
    .fs_rpl_to_reg                 (fs_rpl_to_reg),                 //output [1:0]
1036
    .gs_rpl_to_reg                 (gs_rpl_to_reg),                 //output [1:0]
1037
    .cs_rpl_to_reg                 (cs_rpl_to_reg),                 //output [1:0]
1038
    .ldtr_rpl_to_reg               (ldtr_rpl_to_reg),               //output [1:0]
1039
    .tr_rpl_to_reg                 (tr_rpl_to_reg),                 //output [1:0]
1040
 
1041
    //output
1042
    .eax                           (eax),                           //input [31:0]
1043
    .ebx                           (ebx),                           //input [31:0]
1044
    .ecx                           (ecx),                           //input [31:0]
1045
    .edx                           (edx),                           //input [31:0]
1046
    .esi                           (esi),                           //input [31:0]
1047
    .edi                           (edi),                           //input [31:0]
1048
    .ebp                           (ebp),                           //input [31:0]
1049
    .esp                           (esp),                           //input [31:0]
1050
    .cr0_pe                        (cr0_pe),                        //input
1051
    .cr0_mp                        (cr0_mp),                        //input
1052
    .cr0_em                        (cr0_em),                        //input
1053
    .cr0_ts                        (cr0_ts),                        //input
1054
    .cr0_ne                        (cr0_ne),                        //input
1055
    .cr0_wp                        (cr0_wp),                        //input
1056
    .cr0_am                        (cr0_am),                        //input
1057
    .cr0_nw                        (cr0_nw),                        //input
1058
    .cr0_cd                        (cr0_cd),                        //input
1059
    .cr0_pg                        (cr0_pg),                        //input
1060
    .cr2                           (cr2),                           //input [31:0]
1061
    .cr3                           (cr3),                           //input [31:0]
1062
    .cflag                         (cflag),                         //input
1063
    .pflag                         (pflag),                         //input
1064
    .aflag                         (aflag),                         //input
1065
    .zflag                         (zflag),                         //input
1066
    .sflag                         (sflag),                         //input
1067
    .oflag                         (oflag),                         //input
1068
    .tflag                         (tflag),                         //input
1069
    .iflag                         (iflag),                         //input
1070
    .dflag                         (dflag),                         //input
1071
    .iopl                          (iopl),                          //input [1:0]
1072
    .ntflag                        (ntflag),                        //input
1073
    .rflag                         (rflag),                         //input
1074
    .vmflag                        (vmflag),                        //input
1075
    .acflag                        (acflag),                        //input
1076
    .idflag                        (idflag),                        //input
1077
    .gdtr_base                     (gdtr_base),                     //input [31:0]
1078
    .gdtr_limit                    (gdtr_limit),                    //input [15:0]
1079
    .idtr_base                     (idtr_base),                     //input [31:0]
1080
    .idtr_limit                    (idtr_limit),                    //input [15:0]
1081
    .dr0                           (dr0),                           //input [31:0]
1082
    .dr1                           (dr1),                           //input [31:0]
1083
    .dr2                           (dr2),                           //input [31:0]
1084
    .dr3                           (dr3),                           //input [31:0]
1085
    .dr6_breakpoints               (dr6_breakpoints),               //input [3:0]
1086
    .dr6_b12                       (dr6_b12),                       //input
1087
    .dr6_bd                        (dr6_bd),                        //input
1088
    .dr6_bs                        (dr6_bs),                        //input
1089
    .dr6_bt                        (dr6_bt),                        //input
1090
    .dr7                           (dr7),                           //input [31:0]
1091
    .es                            (es),                            //input [15:0]
1092
    .ds                            (ds),                            //input [15:0]
1093
    .ss                            (ss),                            //input [15:0]
1094
    .fs                            (fs),                            //input [15:0]
1095
    .gs                            (gs),                            //input [15:0]
1096
    .cs                            (cs),                            //input [15:0]
1097
    .ldtr                          (ldtr),                          //input [15:0]
1098
    .tr                            (tr),                            //input [15:0]
1099
    .es_cache                      (es_cache),                      //input [63:0]
1100
    .ds_cache                      (ds_cache),                      //input [63:0]
1101
    .ss_cache                      (ss_cache),                      //input [63:0]
1102
    .fs_cache                      (fs_cache),                      //input [63:0]
1103
    .gs_cache                      (gs_cache),                      //input [63:0]
1104
    .cs_cache                      (cs_cache),                      //input [63:0]
1105
    .ldtr_cache                    (ldtr_cache),                    //input [63:0]
1106
    .tr_cache                      (tr_cache),                      //input [63:0]
1107
    .es_cache_valid                (es_cache_valid),                //input
1108
    .ds_cache_valid                (ds_cache_valid),                //input
1109
    .ss_cache_valid                (ss_cache_valid),                //input
1110
    .fs_cache_valid                (fs_cache_valid),                //input
1111
    .gs_cache_valid                (gs_cache_valid),                //input
1112
    .cs_cache_valid                (cs_cache_valid),                //input
1113
    .ldtr_cache_valid              (ldtr_cache_valid),              //input
1114
    .es_rpl                        (es_rpl),                        //input [1:0]
1115
    .ds_rpl                        (ds_rpl),                        //input [1:0]
1116
    .ss_rpl                        (ss_rpl),                        //input [1:0]
1117
    .fs_rpl                        (fs_rpl),                        //input [1:0]
1118
    .gs_rpl                        (gs_rpl),                        //input [1:0]
1119
    .cs_rpl                        (cs_rpl),                        //input [1:0]
1120
    .ldtr_rpl                      (ldtr_rpl),                      //input [1:0]
1121
    .tr_rpl                        (tr_rpl)                         //input [1:0]
1122
);
1123
 
1124
//------------------------------------------------------------------------------
1125
 
1126
wire [3:0]  wr_debug_code_reg;
1127
wire [3:0]  wr_debug_write_reg;
1128
wire [3:0]  wr_debug_read_reg;
1129
wire        wr_debug_step_reg;
1130
wire        wr_debug_task_reg;
1131
 
1132
write_debug write_debug_inst(
1133
    .clk            (clk),
1134
    .rst_n          (rst_n),
1135
 
1136
    //general input
1137
    .dr0                                (dr0),              //input [31:0]
1138
    .dr1                                (dr1),              //input [31:0]
1139
    .dr2                                (dr2),              //input [31:0]
1140
    .dr3                                (dr3),              //input [31:0]
1141
    .dr7                                (dr7),              //input [31:0]
1142
 
1143
    .debug_len0                         (debug_len0),       //input [2:0]
1144
    .debug_len1                         (debug_len1),       //input [2:0]
1145
    .debug_len2                         (debug_len2),       //input [2:0]
1146
    .debug_len3                         (debug_len3),       //input [2:0]
1147
 
1148
    .rflag_to_reg                       (rflag_to_reg),     //input
1149
    .tflag_to_reg                       (tflag_to_reg),     //input
1150
 
1151
    .wr_eip                             (wr_eip),           //input [31:0]
1152
 
1153
    .cs_base                            (cs_base),          //input [31:0]
1154
    .cs_limit                           (cs_limit),         //input [31:0]
1155
 
1156
    //memory write
1157
    .write_address                      (write_address),                    //input [31:0]
1158
    .write_length                       (write_length),                     //input [2:0]
1159
    .write_for_wr_ready                 (write_for_wr_ready),               //input
1160
 
1161
    //write control
1162
    .w_load                             (w_load),                           //input
1163
    .wr_finished                        (wr_finished),                      //input
1164
    .wr_inhibit_interrupts_and_debug    (wr_inhibit_interrupts_and_debug),  //input
1165
    .wr_debug_task_trigger              (wr_debug_task_trigger),            //input
1166
    .wr_debug_trap_clear                (wr_debug_trap_clear),              //input
1167
 
1168
    .wr_string_in_progress              (wr_string_in_progress),            //input
1169
 
1170
    //pipeline input
1171
    .exe_debug_read                     (exe_debug_read),                   //input [3:0]
1172
 
1173
    //output
1174
    .wr_debug_prepare                   (wr_debug_prepare),                 //output
1175
 
1176
    .wr_debug_code_reg                  (wr_debug_code_reg),                //output [3:0]
1177
    .wr_debug_write_reg                 (wr_debug_write_reg),               //output [3:0]
1178
    .wr_debug_read_reg                  (wr_debug_read_reg),                //output [3:0]
1179
    .wr_debug_step_reg                  (wr_debug_step_reg),                //output
1180
    .wr_debug_task_reg                  (wr_debug_task_reg)                 //output
1181
);
1182
 
1183
//------------------------------------------------------------------------------
1184
 
1185
write_register write_register_inst(
1186
    .clk                (clk),
1187
    .rst_n              (rst_n),
1188
 
1189
    //general input
1190
    .glob_descriptor               (glob_descriptor),               //input [63:0]
1191
    .glob_param_1                  (glob_param_1),                  //input [31:0]
1192
 
1193
    //wr input
1194
    .wr_is_8bit                    (wr_is_8bit),                    //input
1195
    .wr_operand_32bit              (wr_operand_32bit),              //input
1196
    .wr_decoder                    (wr_decoder),                    //input [15:0]
1197
    .wr_modregrm_reg               (wr_modregrm_reg),               //input [2:0]
1198
    .wr_modregrm_rm                (wr_modregrm_rm),                //input [2:0]
1199
 
1200
    .wr_clear_rflag                (wr_clear_rflag),                //input
1201
 
1202
    //segment control
1203
    .wr_seg_sel                    (wr_seg_sel),                    //input [15:0]
1204
    .wr_seg_rpl                    (wr_seg_rpl),                    //input [1:0]
1205
    .wr_seg_cache_valid            (wr_seg_cache_valid),            //input
1206
 
1207
    .write_seg_sel                 (write_seg_sel),                 //input
1208
    .write_seg_rpl                 (write_seg_rpl),                 //input
1209
    .write_seg_cache               (write_seg_cache),               //input
1210
    .write_seg_cache_valid         (write_seg_cache_valid),         //input
1211
    .wr_seg_cache_mask             (wr_seg_cache_mask),             //input [63:0]
1212
 
1213
    .wr_validate_seg_regs          (wr_validate_seg_regs),          //input
1214
 
1215
    .write_system_touch            (write_system_touch),            //input
1216
    .write_system_busy_tss         (write_system_busy_tss),         //input
1217
 
1218
    //exe exception write
1219
    .dr6_bd_set                    (dr6_bd_set), //input
1220
 
1221
    //exception input
1222
    .exc_set_rflag                 (exc_set_rflag),                 //input
1223
    .exc_debug_start               (exc_debug_start),               //input
1224
    .exc_pf_read                   (exc_pf_read),                   //input
1225
    .exc_pf_write                  (exc_pf_write),                  //input
1226
    .exc_pf_code                   (exc_pf_code),                   //input
1227
    .exc_pf_check                  (exc_pf_check),                  //input
1228
    .exc_restore_esp               (exc_restore_esp),               //input
1229
 
1230
    .wr_esp_prev                   (wr_esp_prev),                   //input [31:0]
1231
 
1232
    //cr2 input
1233
    .tlb_code_pf_cr2               (tlb_code_pf_cr2),               //input [31:0]
1234
    .tlb_write_pf_cr2              (tlb_write_pf_cr2),              //input [31:0]
1235
    .tlb_read_pf_cr2               (tlb_read_pf_cr2),               //input [31:0]
1236
    .tlb_check_pf_cr2              (tlb_check_pf_cr2),              //input [31:0]
1237
 
1238
    //debug input
1239
    .wr_debug_code_reg             (wr_debug_code_reg),             //input [3:0]
1240
    .wr_debug_write_reg            (wr_debug_write_reg),            //input [3:0]
1241
    .wr_debug_read_reg             (wr_debug_read_reg),             //input [3:0]
1242
    .wr_debug_step_reg             (wr_debug_step_reg),             //input
1243
    .wr_debug_task_reg             (wr_debug_task_reg),             //input
1244
 
1245
    //write reg
1246
    .write_eax                     (write_eax),                     //input
1247
    .write_regrm                   (write_regrm),                   //input
1248
 
1249
    //write reg options
1250
    .wr_dst_is_rm                  (wr_dst_is_rm),                  //input
1251
    .wr_dst_is_reg                 (wr_dst_is_reg),                 //input
1252
    .wr_dst_is_implicit_reg        (wr_dst_is_implicit_reg),        //input
1253
    .wr_regrm_word                 (wr_regrm_word),                 //input
1254
    .wr_regrm_dword                (wr_regrm_dword),                //input
1255
 
1256
    //write reg data
1257
    .result                        (result),                        //input [31:0]
1258
 
1259
    //output
1260
    .cpl                           (cpl),                           //output [1:0]
1261
 
1262
    .protected_mode                 (protected_mode),               //output
1263
    .v8086_mode                     (v8086_mode),                   //output
1264
    .real_mode                      (real_mode),                    //output
1265
 
1266
    .io_allow_check_needed         (io_allow_check_needed),         //output
1267
 
1268
    .debug_len0                    (debug_len0),                    //output [2:0]
1269
    .debug_len1                    (debug_len1),                    //output [2:0]
1270
    .debug_len2                    (debug_len2),                    //output [2:0]
1271
    .debug_len3                    (debug_len3),                    //output [2:0]
1272
 
1273
    //registers input
1274
 
1275
    .eax_to_reg                    (eax_to_reg),                    //input [31:0]
1276
    .ebx_to_reg                    (ebx_to_reg),                    //input [31:0]
1277
    .ecx_to_reg                    (ecx_to_reg),                    //input [31:0]
1278
    .edx_to_reg                    (edx_to_reg),                    //input [31:0]
1279
    .esi_to_reg                    (esi_to_reg),                    //input [31:0]
1280
    .edi_to_reg                    (edi_to_reg),                    //input [31:0]
1281
    .ebp_to_reg                    (ebp_to_reg),                    //input [31:0]
1282
    .esp_to_reg                    (esp_to_reg),                    //input [31:0]
1283
    .cr0_pe_to_reg                 (cr0_pe_to_reg),                 //input
1284
    .cr0_mp_to_reg                 (cr0_mp_to_reg),                 //input
1285
    .cr0_em_to_reg                 (cr0_em_to_reg),                 //input
1286
    .cr0_ts_to_reg                 (cr0_ts_to_reg),                 //input
1287
    .cr0_ne_to_reg                 (cr0_ne_to_reg),                 //input
1288
    .cr0_wp_to_reg                 (cr0_wp_to_reg),                 //input
1289
    .cr0_am_to_reg                 (cr0_am_to_reg),                 //input
1290
    .cr0_nw_to_reg                 (cr0_nw_to_reg),                 //input
1291
    .cr0_cd_to_reg                 (cr0_cd_to_reg),                 //input
1292
    .cr0_pg_to_reg                 (cr0_pg_to_reg),                 //input
1293
    .cr2_to_reg                    (cr2_to_reg),                    //input [31:0]
1294
    .cr3_to_reg                    (cr3_to_reg),                    //input [31:0]
1295
    .cflag_to_reg                  (cflag_to_reg),                  //input
1296
    .pflag_to_reg                  (pflag_to_reg),                  //input
1297
    .aflag_to_reg                  (aflag_to_reg),                  //input
1298
    .zflag_to_reg                  (zflag_to_reg),                  //input
1299
    .sflag_to_reg                  (sflag_to_reg),                  //input
1300
    .oflag_to_reg                  (oflag_to_reg),                  //input
1301
    .tflag_to_reg                  (tflag_to_reg),                  //input
1302
    .iflag_to_reg                  (iflag_to_reg),                  //input
1303
    .dflag_to_reg                  (dflag_to_reg),                  //input
1304
    .iopl_to_reg                   (iopl_to_reg),                   //input [1:0]
1305
    .ntflag_to_reg                 (ntflag_to_reg),                 //input
1306
    .rflag_to_reg                  (rflag_to_reg),                  //input
1307
    .vmflag_to_reg                 (vmflag_to_reg),                 //input
1308
    .acflag_to_reg                 (acflag_to_reg),                 //input
1309
    .idflag_to_reg                 (idflag_to_reg),                 //input
1310
    .gdtr_base_to_reg              (gdtr_base_to_reg),              //input [31:0]
1311
    .gdtr_limit_to_reg             (gdtr_limit_to_reg),             //input [15:0]
1312
    .idtr_base_to_reg              (idtr_base_to_reg),              //input [31:0]
1313
    .idtr_limit_to_reg             (idtr_limit_to_reg),             //input [15:0]
1314
    .dr0_to_reg                    (dr0_to_reg),                    //input [31:0]
1315
    .dr1_to_reg                    (dr1_to_reg),                    //input [31:0]
1316
    .dr2_to_reg                    (dr2_to_reg),                    //input [31:0]
1317
    .dr3_to_reg                    (dr3_to_reg),                    //input [31:0]
1318
    .dr6_breakpoints_to_reg        (dr6_breakpoints_to_reg),        //input [3:0]
1319
    .dr6_b12_to_reg                (dr6_b12_to_reg),                //input
1320
    .dr6_bd_to_reg                 (dr6_bd_to_reg),                 //input
1321
    .dr6_bs_to_reg                 (dr6_bs_to_reg),                 //input
1322
    .dr6_bt_to_reg                 (dr6_bt_to_reg),                 //input
1323
    .dr7_to_reg                    (dr7_to_reg),                    //input [31:0]
1324
    .es_to_reg                     (es_to_reg),                     //input [15:0]
1325
    .ds_to_reg                     (ds_to_reg),                     //input [15:0]
1326
    .ss_to_reg                     (ss_to_reg),                     //input [15:0]
1327
    .fs_to_reg                     (fs_to_reg),                     //input [15:0]
1328
    .gs_to_reg                     (gs_to_reg),                     //input [15:0]
1329
    .cs_to_reg                     (cs_to_reg),                     //input [15:0]
1330
    .ldtr_to_reg                   (ldtr_to_reg),                   //input [15:0]
1331
    .tr_to_reg                     (tr_to_reg),                     //input [15:0]
1332
    .es_cache_to_reg               (es_cache_to_reg),               //input [63:0]
1333
    .ds_cache_to_reg               (ds_cache_to_reg),               //input [63:0]
1334
    .ss_cache_to_reg               (ss_cache_to_reg),               //input [63:0]
1335
    .fs_cache_to_reg               (fs_cache_to_reg),               //input [63:0]
1336
    .gs_cache_to_reg               (gs_cache_to_reg),               //input [63:0]
1337
    .cs_cache_to_reg               (cs_cache_to_reg),               //input [63:0]
1338
    .ldtr_cache_to_reg             (ldtr_cache_to_reg),             //input [63:0]
1339
    .tr_cache_to_reg               (tr_cache_to_reg),               //input [63:0]
1340
    .es_cache_valid_to_reg         (es_cache_valid_to_reg),         //input
1341
    .ds_cache_valid_to_reg         (ds_cache_valid_to_reg),         //input
1342
    .ss_cache_valid_to_reg         (ss_cache_valid_to_reg),         //input
1343
    .fs_cache_valid_to_reg         (fs_cache_valid_to_reg),         //input
1344
    .gs_cache_valid_to_reg         (gs_cache_valid_to_reg),         //input
1345
    .cs_cache_valid_to_reg         (cs_cache_valid_to_reg),         //input
1346
    .ldtr_cache_valid_to_reg       (ldtr_cache_valid_to_reg),       //input
1347
    .es_rpl_to_reg                 (es_rpl_to_reg),                 //input [1:0]
1348
    .ds_rpl_to_reg                 (ds_rpl_to_reg),                 //input [1:0]
1349
    .ss_rpl_to_reg                 (ss_rpl_to_reg),                 //input [1:0]
1350
    .fs_rpl_to_reg                 (fs_rpl_to_reg),                 //input [1:0]
1351
    .gs_rpl_to_reg                 (gs_rpl_to_reg),                 //input [1:0]
1352
    .cs_rpl_to_reg                 (cs_rpl_to_reg),                 //input [1:0]
1353
    .ldtr_rpl_to_reg               (ldtr_rpl_to_reg),               //input [1:0]
1354
    .tr_rpl_to_reg                 (tr_rpl_to_reg),                 //input [1:0]
1355
 
1356
    //registers output
1357
    .eax                 (eax),                 //output [31:0]
1358
    .ebx                 (ebx),                 //output [31:0]
1359
    .ecx                 (ecx),                 //output [31:0]
1360
    .edx                 (edx),                 //output [31:0]
1361
    .esi                 (esi),                 //output [31:0]
1362
    .edi                 (edi),                 //output [31:0]
1363
    .ebp                 (ebp),                 //output [31:0]
1364
    .esp                 (esp),                 //output [31:0]
1365
    .cr0_pe              (cr0_pe),              //output
1366
    .cr0_mp              (cr0_mp),              //output
1367
    .cr0_em              (cr0_em),              //output
1368
    .cr0_ts              (cr0_ts),              //output
1369
    .cr0_ne              (cr0_ne),              //output
1370
    .cr0_wp              (cr0_wp),              //output
1371
    .cr0_am              (cr0_am),              //output
1372
    .cr0_nw              (cr0_nw),              //output
1373
    .cr0_cd              (cr0_cd),              //output
1374
    .cr0_pg              (cr0_pg),              //output
1375
    .cr2                 (cr2),                 //output [31:0]
1376
    .cr3                 (cr3),                 //output [31:0]
1377
    .cflag               (cflag),               //output
1378
    .pflag               (pflag),               //output
1379
    .aflag               (aflag),               //output
1380
    .zflag               (zflag),               //output
1381
    .sflag               (sflag),               //output
1382
    .oflag               (oflag),               //output
1383
    .tflag               (tflag),               //output
1384
    .iflag               (iflag),               //output
1385
    .dflag               (dflag),               //output
1386
    .iopl                (iopl),                //output [1:0]
1387
    .ntflag              (ntflag),              //output
1388
    .rflag               (rflag),               //output
1389
    .vmflag              (vmflag),              //output
1390
    .acflag              (acflag),              //output
1391
    .idflag              (idflag),              //output
1392
    .gdtr_base           (gdtr_base),           //output [31:0]
1393
    .gdtr_limit          (gdtr_limit),          //output [15:0]
1394
    .idtr_base           (idtr_base),           //output [31:0]
1395
    .idtr_limit          (idtr_limit),          //output [15:0]
1396
    .dr0                 (dr0),                 //output [31:0]
1397
    .dr1                 (dr1),                 //output [31:0]
1398
    .dr2                 (dr2),                 //output [31:0]
1399
    .dr3                 (dr3),                 //output [31:0]
1400
    .dr6_breakpoints     (dr6_breakpoints),     //output [3:0]
1401
    .dr6_b12             (dr6_b12),             //output
1402
    .dr6_bd              (dr6_bd),              //output
1403
    .dr6_bs              (dr6_bs),              //output
1404
    .dr6_bt              (dr6_bt),              //output
1405
    .dr7                 (dr7),                 //output [31:0]
1406
    .es                  (es),                  //output [15:0]
1407
    .ds                  (ds),                  //output [15:0]
1408
    .ss                  (ss),                  //output [15:0]
1409
    .fs                  (fs),                  //output [15:0]
1410
    .gs                  (gs),                  //output [15:0]
1411
    .cs                  (cs),                  //output [15:0]
1412
    .ldtr                (ldtr),                //output [15:0]
1413
    .tr                  (tr),                  //output [15:0]
1414
    .es_cache            (es_cache),            //output [63:0]
1415
    .ds_cache            (ds_cache),            //output [63:0]
1416
    .ss_cache            (ss_cache),            //output [63:0]
1417
    .fs_cache            (fs_cache),            //output [63:0]
1418
    .gs_cache            (gs_cache),            //output [63:0]
1419
    .cs_cache            (cs_cache),            //output [63:0]
1420
    .ldtr_cache          (ldtr_cache),          //output [63:0]
1421
    .tr_cache            (tr_cache),            //output [63:0]
1422
    .es_cache_valid      (es_cache_valid),      //output
1423
    .ds_cache_valid      (ds_cache_valid),      //output
1424
    .ss_cache_valid      (ss_cache_valid),      //output
1425
    .fs_cache_valid      (fs_cache_valid),      //output
1426
    .gs_cache_valid      (gs_cache_valid),      //output
1427
    .cs_cache_valid      (cs_cache_valid),      //output
1428
    .ldtr_cache_valid    (ldtr_cache_valid),    //output
1429
    .tr_cache_valid      (tr_cache_valid),      //output
1430
    .es_rpl              (es_rpl),              //output [1:0]
1431
    .ds_rpl              (ds_rpl),              //output [1:0]
1432
    .ss_rpl              (ss_rpl),              //output [1:0]
1433
    .fs_rpl              (fs_rpl),              //output [1:0]
1434
    .gs_rpl              (gs_rpl),              //output [1:0]
1435
    .cs_rpl              (cs_rpl),              //output [1:0]
1436
    .ldtr_rpl            (ldtr_rpl),            //output [1:0]
1437
    .tr_rpl              (tr_rpl)               //output [1:0]
1438
);
1439
 
1440
//------------------------------------------------------------------------------
1441
 
1442
write_stack write_stack_inst(
1443
 
1444
    .glob_descriptor            (glob_descriptor),              //input [63:0]
1445
 
1446
    .esp                        (esp),                          //input [31:0]
1447
 
1448
    .ss_cache                   (ss_cache),                     //input [63:0]
1449
    .ss_base                    (ss_base),                      //input [31:0]
1450
    .ss_limit                   (ss_limit),                     //input [31:0]
1451
 
1452
    .glob_desc_base             (glob_desc_base),               //input [31:0]
1453
    .glob_desc_limit            (glob_desc_limit),              //input [31:0]
1454
 
1455
    .wr_operand_16bit           (wr_operand_16bit),             //input
1456
    .wr_stack_offset            (wr_stack_offset),              //input [31:0]
1457
 
1458
    .wr_new_push_ss_fault_check (wr_new_push_ss_fault_check),   //input
1459
    .wr_push_length_word        (wr_push_length_word),          //input
1460
    .wr_push_length_dword       (wr_push_length_dword),         //input
1461
 
1462
    .wr_push_ss_fault_check     (wr_push_ss_fault_check),       //input
1463
 
1464
    //output
1465
    .wr_stack_esp               (wr_stack_esp),                 //output [31:0]
1466
    .wr_push_linear             (wr_push_linear),               //output [31:0]
1467
 
1468
    .wr_new_stack_esp           (wr_new_stack_esp),             //output [31:0]
1469
    .wr_new_push_linear         (wr_new_push_linear),           //output [31:0]
1470
 
1471
    .wr_push_length             (wr_push_length),               //output [2:0]
1472
 
1473
    .wr_push_ss_fault           (wr_push_ss_fault),             //output
1474
    .wr_new_push_ss_fault       (wr_new_push_ss_fault)          //output
1475
);
1476
 
1477
//------------------------------------------------------------------------------
1478
 
1479
write_string write_string_inst(
1480
 
1481
    .wr_is_8bit                 (wr_is_8bit),               //input
1482
    .wr_operand_16bit           (wr_operand_16bit),         //input
1483
    .wr_address_16bit           (wr_address_16bit),         //input
1484
    .wr_address_32bit           (wr_address_32bit),         //input
1485
    .wr_prefix_group_1_rep      (wr_prefix_group_1_rep),    //input [1:0]
1486
 
1487
    .wr_string_gp_fault_check   (wr_string_gp_fault_check), //input
1488
 
1489
    .dflag                      (dflag),                    //input
1490
 
1491
    .wr_zflag_result            (wr_zflag_result),          //input
1492
 
1493
    .ecx                        (ecx),                      //input [31:0]
1494
    .esi                        (esi),                      //input [31:0]
1495
    .edi                        (edi),                      //input [31:0]
1496
 
1497
    .es_cache                   (es_cache),                 //input [63:0]
1498
    .es_cache_valid             (es_cache_valid),           //input
1499
    .es_base                    (es_base),                  //input [31:0]
1500
    .es_limit                   (es_limit),                 //input [31:0]
1501
 
1502
    //output
1503
    .wr_esi_final               (wr_esi_final),             //output [31:0]
1504
    .wr_edi_final               (wr_edi_final),             //output [31:0]
1505
    .wr_ecx_final               (wr_ecx_final),             //output [31:0]
1506
 
1507
    .wr_string_ignore           (wr_string_ignore),         //output
1508
    .wr_string_finish           (wr_string_finish),         //output
1509
    .wr_string_zf_finish        (wr_string_zf_finish),      //output
1510
 
1511
    .wr_string_es_linear        (wr_string_es_linear),      //output [31:0]
1512
 
1513
    .wr_string_es_fault         (wr_string_es_fault)        //output
1514
);
1515
 
1516
//------------------------------------------------------------------------------
1517
 
1518
endmodule

powered by: WebSVN 2.1.0

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