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

Subversion Repositories ao486

[/] [ao486/] [trunk/] [rtl/] [ao486/] [pipeline/] [execute.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 execute(
30
    input               clk,
31
    input               rst_n,
32
 
33
    input               exe_reset,
34
 
35
    //general input
36
    input       [31:0]  eax,
37
    input       [31:0]  ecx,
38
    input       [31:0]  edx,
39
    input       [31:0]  ebp,
40
    input       [31:0]  esp,
41
 
42
    input       [63:0]  cs_cache,
43
    input       [63:0]  tr_cache,
44
    input       [63:0]  ss_cache,
45
 
46
    input       [15:0]  es,
47
    input       [15:0]  cs,
48
    input       [15:0]  ss,
49
    input       [15:0]  ds,
50
    input       [15:0]  fs,
51
    input       [15:0]  gs,
52
    input       [15:0]  ldtr,
53
    input       [15:0]  tr,
54
 
55
    input       [31:0]  cr2,
56
    input       [31:0]  cr3,
57
 
58
    input       [31:0]  dr0,
59
    input       [31:0]  dr1,
60
    input       [31:0]  dr2,
61
    input       [31:0]  dr3,
62
    input               dr6_bt,
63
    input               dr6_bs,
64
    input               dr6_bd,
65
    input               dr6_b12,
66
    input       [3:0]   dr6_breakpoints,
67
    input       [31:0]  dr7,
68
 
69
    input       [1:0]   cpl,
70
 
71
    input               real_mode,
72
    input               v8086_mode,
73
    input               protected_mode,
74
 
75
    input               idflag,
76
    input               acflag,
77
    input               vmflag,
78
    input               rflag,
79
    input               ntflag,
80
    input       [1:0]   iopl,
81
    input               oflag,
82
    input               dflag,
83
    input               iflag,
84
    input               tflag,
85
    input               sflag,
86
    input               zflag,
87
    input               aflag,
88
    input               pflag,
89
    input               cflag,
90
 
91
    input               cr0_pg,
92
    input               cr0_cd,
93
    input               cr0_nw,
94
    input               cr0_am,
95
    input               cr0_wp,
96
    input               cr0_ne,
97
    input               cr0_ts,
98
    input               cr0_em,
99
    input               cr0_mp,
100
    input               cr0_pe,
101
 
102
    input       [15:0]  idtr_limit,
103
    input       [31:0]  idtr_base,
104
 
105
    input       [15:0]  gdtr_limit,
106
    input       [31:0]  gdtr_base,
107
 
108
    //exception input
109
    input               exc_push_error,
110
    input       [15:0]  exc_error_code,
111
    input               exc_soft_int_ib,
112
    input               exc_soft_int,
113
    input       [7:0]   exc_vector,
114
 
115
    //tlbcheck
116
    output              tlbcheck_do,
117
    input               tlbcheck_done,
118
    input               tlbcheck_page_fault,
119
 
120
    output      [31:0]  tlbcheck_address,
121
    output              tlbcheck_rw,
122
 
123
    //tlbflushsingle
124
    output              tlbflushsingle_do,
125
    input               tlbflushsingle_done,
126
 
127
    output      [31:0]  tlbflushsingle_address,
128
 
129
    //invd
130
    output              invdcode_do,
131
    input               invdcode_done,
132
 
133
    output              invddata_do,
134
    input               invddata_done,
135
 
136
    output              wbinvddata_do,
137
    input               wbinvddata_done,
138
 
139
    //pipeline input
140
    input       [31:0]  wr_esp_prev,
141
    input       [31:0]  wr_stack_offset,
142
 
143
    input       [10:0]  wr_mutex,
144
 
145
    //pipeline output
146
    output              exe_is_front,
147
 
148
    //global input
149
    input       [63:0]  glob_descriptor,
150
    input       [63:0]  glob_descriptor_2,
151
    input       [31:0]  glob_param_1,
152
    input       [31:0]  glob_param_2,
153
    input       [31:0]  glob_param_3,
154
    input       [31:0]  glob_param_4,
155
    input       [31:0]  glob_param_5,
156
 
157
    input       [1:0]   wr_task_rpl,
158
 
159
    input       [31:0]  glob_desc_base,
160
 
161
    input       [31:0]  glob_desc_limit,
162
    input       [31:0]  glob_desc_2_limit,
163
 
164
    //global set
165
    output              exe_glob_descriptor_set,
166
    output      [63:0]  exe_glob_descriptor_value,
167
 
168
    output              exe_glob_descriptor_2_set,
169
    output      [63:0]  exe_glob_descriptor_2_value,
170
 
171
    output              exe_glob_param_1_set,
172
    output      [31:0]  exe_glob_param_1_value,
173
 
174
    output              exe_glob_param_2_set,
175
    output      [31:0]  exe_glob_param_2_value,
176
 
177
    output              exe_glob_param_3_set,
178
    output      [31:0]  exe_glob_param_3_value,
179
 
180
    output              dr6_bd_set,
181
 
182
    //to microcode
183
    output      [31:0]  task_eip,
184
    //to wr
185
    output      [31:0]  exe_buffer,
186
    output      [463:0] exe_buffer_shifted,
187
 
188
    //exceptions
189
    output              exe_bound_fault,
190
    output              exe_trigger_gp_fault,
191
    output              exe_trigger_ts_fault,
192
    output              exe_trigger_ss_fault,
193
    output              exe_trigger_np_fault,
194
    output              exe_trigger_pf_fault,
195
    output              exe_trigger_db_fault,
196
    output              exe_trigger_nm_fault,
197
    output              exe_load_seg_gp_fault,
198
    output              exe_load_seg_ss_fault,
199
    output              exe_load_seg_np_fault,
200
    output              exe_div_exception,
201
 
202
    output      [15:0]  exe_error_code,
203
 
204
    output reg  [31:0]  exe_eip,
205
    output reg  [3:0]   exe_consumed,
206
 
207
    //rd pipeline
208
    output              exe_busy,
209
    input               rd_ready,
210
 
211
    input       [87:0]  rd_decoder,
212
    input       [31:0]  rd_eip,
213
    input               rd_operand_32bit,
214
    input               rd_address_32bit,
215
    input       [1:0]   rd_prefix_group_1_rep,
216
    input               rd_prefix_group_1_lock,
217
    input               rd_prefix_2byte,
218
    input       [3:0]   rd_consumed,
219
    input               rd_is_8bit,
220
    input       [6:0]   rd_cmd,
221
    input       [3:0]   rd_cmdex,
222
    input       [31:0]  rd_modregrm_imm,
223
    input       [10:0]  rd_mutex_next,
224
    input               rd_dst_is_reg,
225
    input               rd_dst_is_rm,
226
    input               rd_dst_is_memory,
227
    input               rd_dst_is_eax,
228
    input               rd_dst_is_edx_eax,
229
    input               rd_dst_is_implicit_reg,
230
    input       [31:0]  rd_extra_wire,
231
    input       [31:0]  rd_linear,
232
    input       [3:0]   rd_debug_read,
233
    input       [31:0]  src_wire,
234
    input       [31:0]  dst_wire,
235
    input       [31:0]  rd_address_effective,
236
 
237
    //exe pipeline
238
    input               wr_busy,
239
    output              exe_ready,
240
 
241
    output reg  [39:0]  exe_decoder,
242
    output      [31:0]  exe_eip_final,
243
    output reg          exe_operand_32bit,
244
    output reg          exe_address_32bit,
245
    output reg  [1:0]   exe_prefix_group_1_rep,
246
    output reg          exe_prefix_group_1_lock,
247
    output      [3:0]   exe_consumed_final,
248
    output              exe_is_8bit_final,
249
    output reg  [6:0]   exe_cmd,
250
    output reg  [3:0]   exe_cmdex,
251
    output reg  [10:0]  exe_mutex,
252
    output reg          exe_dst_is_reg,
253
    output reg          exe_dst_is_rm,
254
    output reg          exe_dst_is_memory,
255
    output reg          exe_dst_is_eax,
256
    output reg          exe_dst_is_edx_eax,
257
    output reg          exe_dst_is_implicit_reg,
258
    output reg  [31:0]  exe_linear,
259
    output reg  [3:0]   exe_debug_read,
260
 
261
    output      [31:0]  exe_result,
262
    output      [31:0]  exe_result2,
263
    output      [31:0]  exe_result_push,
264
    output      [4:0]   exe_result_signals,
265
 
266
    output      [3:0]   exe_arith_index,
267
 
268
    output              exe_arith_sub_carry,
269
    output              exe_arith_add_carry,
270
    output              exe_arith_adc_carry,
271
    output              exe_arith_sbb_carry,
272
 
273
    output      [31:0]  src_final,
274
    output      [31:0]  dst_final,
275
 
276
    output              exe_mult_overflow,
277
    output      [31:0]  exe_stack_offset
278
);
279
 
280
//------------------------------------------------------------------------------
281
 
282
wire [31:0] tr_base;
283
wire [31:0] tr_limit;
284
 
285
wire [31:0] cs_limit;
286
 
287
assign tr_base  = { tr_cache[63:56], tr_cache[39:16] };
288
 
289
assign tr_limit = tr_cache[`DESC_BIT_G]? { tr_cache[51:48], tr_cache[15:0], 12'hFFF } : { 12'd0, tr_cache[51:48], tr_cache[15:0] };
290
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] };
291
 
292
//------------------------------------------------------------------------------
293
 
294
wire        e_load;
295
 
296
wire        exe_operand_16bit;
297
wire        exe_address_16bit;
298
 
299
wire [10:0] exe_mutex_current;
300
 
301
wire [2:0]  exe_modregrm_reg;
302
 
303
//------------------------------------------------------------------------------
304
 
305
wire exe_waiting;
306
 
307
wire exe_is_8bit_clear;
308
 
309
wire exe_cmpxchg_switch;
310
 
311
wire exe_task_switch_finished;
312
 
313
wire exe_eip_from_glob_param_2;
314
wire exe_eip_from_glob_param_2_16bit;
315
 
316
//------------------------------------------------------------------------------
317
 
318
assign exe_ready = ~(exe_reset) && ~(exe_waiting) && exe_cmd != `CMD_NULL && ~(wr_busy);
319
 
320
assign exe_busy = exe_waiting || (exe_ready == `FALSE && exe_cmd != `CMD_NULL);
321
 
322
assign e_load = rd_ready;
323
 
324
//------------------------------------------------------------------------------
325
 
326
reg         exe_is_8bit;
327
reg [7:0]   exe_modregrm_imm;
328
reg [31:0]  exe_extra;
329
reg [31:0]  src;
330
reg [31:0]  dst;
331
reg [31:0]  exe_address_effective;
332
reg         exe_prefix_2byte;
333
 
334
always @(posedge clk or negedge rst_n) begin if(rst_n == 1'b0) exe_decoder              <= 40'd0;     else if(e_load) exe_decoder              <= rd_decoder[39:0];        end
335
always @(posedge clk or negedge rst_n) begin if(rst_n == 1'b0) exe_eip                  <= 32'd0;     else if(e_load) exe_eip                  <= rd_eip;                  end
336
always @(posedge clk or negedge rst_n) begin if(rst_n == 1'b0) exe_operand_32bit        <= `FALSE;    else if(e_load) exe_operand_32bit        <= rd_operand_32bit;        end
337
always @(posedge clk or negedge rst_n) begin if(rst_n == 1'b0) exe_address_32bit        <= `FALSE;    else if(e_load) exe_address_32bit        <= rd_address_32bit;        end
338
always @(posedge clk or negedge rst_n) begin if(rst_n == 1'b0) exe_prefix_group_1_rep   <= 2'd0;      else if(e_load) exe_prefix_group_1_rep   <= rd_prefix_group_1_rep;   end
339
always @(posedge clk or negedge rst_n) begin if(rst_n == 1'b0) exe_prefix_group_1_lock  <= `FALSE;    else if(e_load) exe_prefix_group_1_lock  <= rd_prefix_group_1_lock;  end
340
always @(posedge clk or negedge rst_n) begin if(rst_n == 1'b0) exe_prefix_2byte         <= `FALSE;    else if(e_load) exe_prefix_2byte         <= rd_prefix_2byte;         end
341
always @(posedge clk or negedge rst_n) begin if(rst_n == 1'b0) exe_consumed             <= 4'd0;      else if(e_load) exe_consumed             <= rd_consumed;             end
342
always @(posedge clk or negedge rst_n) begin if(rst_n == 1'b0) exe_is_8bit              <= `FALSE;    else if(e_load) exe_is_8bit              <= rd_is_8bit;              end
343
always @(posedge clk or negedge rst_n) begin if(rst_n == 1'b0) exe_cmdex                <= 4'd0;      else if(e_load) exe_cmdex                <= rd_cmdex;                end
344
always @(posedge clk or negedge rst_n) begin if(rst_n == 1'b0) exe_modregrm_imm         <= 8'd0;      else if(e_load) exe_modregrm_imm         <= rd_modregrm_imm[7:0];    end
345
always @(posedge clk or negedge rst_n) begin if(rst_n == 1'b0) exe_dst_is_reg           <= `FALSE;    else if(e_load) exe_dst_is_reg           <= rd_dst_is_reg;           end
346
always @(posedge clk or negedge rst_n) begin if(rst_n == 1'b0) exe_dst_is_rm            <= `FALSE;    else if(e_load) exe_dst_is_rm            <= rd_dst_is_rm;            end
347
always @(posedge clk or negedge rst_n) begin if(rst_n == 1'b0) exe_dst_is_memory        <= `FALSE;    else if(e_load) exe_dst_is_memory        <= rd_dst_is_memory;        end
348
always @(posedge clk or negedge rst_n) begin if(rst_n == 1'b0) exe_dst_is_eax           <= `FALSE;    else if(e_load) exe_dst_is_eax           <= rd_dst_is_eax;           end
349
always @(posedge clk or negedge rst_n) begin if(rst_n == 1'b0) exe_dst_is_edx_eax       <= `FALSE;    else if(e_load) exe_dst_is_edx_eax       <= rd_dst_is_edx_eax;       end
350
always @(posedge clk or negedge rst_n) begin if(rst_n == 1'b0) exe_dst_is_implicit_reg  <= `FALSE;    else if(e_load) exe_dst_is_implicit_reg  <= rd_dst_is_implicit_reg;  end
351
always @(posedge clk or negedge rst_n) begin if(rst_n == 1'b0) exe_extra                <= 32'd0;     else if(e_load) exe_extra                <= rd_extra_wire;           end
352
always @(posedge clk or negedge rst_n) begin if(rst_n == 1'b0) exe_linear               <= 32'd0;     else if(e_load) exe_linear               <= rd_linear;               end
353
always @(posedge clk or negedge rst_n) begin if(rst_n == 1'b0) exe_debug_read           <= 4'd0;      else if(e_load) exe_debug_read           <= rd_debug_read;           end
354
always @(posedge clk or negedge rst_n) begin if(rst_n == 1'b0) src                      <= 32'd0;     else if(e_load) src                      <= src_wire;                end
355
always @(posedge clk or negedge rst_n) begin if(rst_n == 1'b0) dst                      <= 32'd0;     else if(e_load) dst                      <= dst_wire;                end
356
always @(posedge clk or negedge rst_n) begin if(rst_n == 1'b0) exe_address_effective    <= 32'd0;     else if(e_load) exe_address_effective    <= rd_address_effective;    end
357
 
358
always @(posedge clk or negedge rst_n) begin
359
    if(rst_n == 1'b0)   exe_mutex <= 11'd0;
360
    else if(exe_reset)  exe_mutex <= 11'd0;
361
    else if(e_load)     exe_mutex <= rd_mutex_next;
362
    else if(exe_ready)  exe_mutex <= 11'd0;
363
end
364
 
365
always @(posedge clk or negedge rst_n) begin
366
    if(rst_n == 1'b0)   exe_cmd <= `CMD_NULL;
367
    else if(exe_reset)  exe_cmd <= `CMD_NULL;
368
    else if(e_load)     exe_cmd <= rd_cmd;
369
    else if(exe_ready)  exe_cmd <= `CMD_NULL;
370
end
371
 
372
//------------------------------------------------------------------------------
373
 
374
assign exe_operand_16bit = ~(exe_operand_32bit);
375
assign exe_address_16bit = ~(exe_address_32bit);
376
 
377
assign exe_mutex_current      = wr_mutex;
378
 
379
assign exe_modregrm_reg = exe_decoder[13:11];
380
 
381
//------------------------------------------------------------------------------ misc
382
 
383
assign exe_is_8bit_final = (exe_is_8bit_clear)? `FALSE : exe_is_8bit;
384
 
385
assign exe_is_front = exe_cmd != `CMD_NULL && ~(exe_mutex_current[`MUTEX_ACTIVE_BIT]);
386
 
387
assign dst_final     = (exe_cmpxchg_switch)? eax : dst;
388
assign src_final     = (exe_cmpxchg_switch)? dst : src;
389
 
390
assign exe_consumed_final = (exe_task_switch_finished)?   glob_param_3[21:18] : exe_consumed;
391
 
392
//------------------------------------------------------------------------------ eip
393
 
394
wire        exe_branch;
395
wire [31:0] exe_branch_eip;
396
 
397
assign exe_eip_final =
398
    (exe_eip_from_glob_param_2 && ~(exe_task_switch_finished))? glob_param_2 :
399
    (exe_eip_from_glob_param_2_16bit)?                          { 16'd0, glob_param_2[15:0] } :
400
    (exe_branch)?                                               exe_branch_eip :
401
                                                                exe_eip;
402
 
403
//------------------------------------------------------------------------------
404
 
405
wire offset_ret_far_se;
406
wire offset_new_stack;
407
wire offset_new_stack_minus;
408
wire offset_new_stack_continue;
409
wire offset_leave;
410
wire offset_pop;
411
wire offset_enter_last;
412
wire offset_ret;
413
wire offset_iret_glob_param_4;
414
wire offset_iret;
415
wire offset_ret_imm;
416
wire offset_esp;
417
wire offset_call;
418
wire offset_call_keep;
419
wire offset_call_int_same_first;
420
wire offset_call_int_same_next;
421
wire offset_int_real;
422
wire offset_int_real_next;
423
wire offset_task;
424
 
425
wire [31:0] exe_enter_offset;
426
 
427
execute_offset execute_offset_inst(
428
 
429
    .exe_operand_16bit          (exe_operand_16bit),        //input
430
    .exe_decoder                (exe_decoder),              //input [39:0]
431
 
432
    .ebp                        (ebp),                      //input [31:0]
433
    .esp                        (esp),                      //input [31:0]
434
    .ss_cache                   (ss_cache),                 //input [63:0]
435
 
436
    .glob_descriptor            (glob_descriptor),          //input [63:0]
437
 
438
    .glob_param_1               (glob_param_1),             //input [31:0]
439
    .glob_param_3               (glob_param_3),             //input [31:0]
440
    .glob_param_4               (glob_param_4),             //input [31:0]
441
 
442
    .exe_address_effective      (exe_address_effective),    //input [31:0]
443
 
444
    .wr_stack_offset            (wr_stack_offset),          //input [31:0]
445
 
446
    //offset control
447
    .offset_ret_far_se          (offset_ret_far_se),          //input
448
    .offset_new_stack           (offset_new_stack),           //input
449
    .offset_new_stack_minus     (offset_new_stack_minus),     //input
450
    .offset_new_stack_continue  (offset_new_stack_continue),  //input
451
    .offset_leave               (offset_leave),               //input
452
    .offset_pop                 (offset_pop),                 //input
453
    .offset_enter_last          (offset_enter_last),          //input
454
    .offset_ret                 (offset_ret),                 //input
455
    .offset_iret_glob_param_4   (offset_iret_glob_param_4),   //input
456
    .offset_iret                (offset_iret),                //input
457
    .offset_ret_imm             (offset_ret_imm),             //input
458
    .offset_esp                 (offset_esp),                 //input
459
    .offset_call                (offset_call),                //input
460
    .offset_call_keep           (offset_call_keep),           //input
461
    .offset_call_int_same_first (offset_call_int_same_first), //input
462
    .offset_call_int_same_next  (offset_call_int_same_next),  //input
463
    .offset_int_real            (offset_int_real),            //input
464
    .offset_int_real_next       (offset_int_real_next),       //input
465
    .offset_task                (offset_task),                //input
466
 
467
    //output
468
    .exe_stack_offset           (exe_stack_offset),           //output [31:0]
469
 
470
    .exe_enter_offset           (exe_enter_offset)            //output [31:0]
471
);
472
 
473
//------------------------------------------------------------------------------
474
 
475
wire e_shift_no_write;
476
wire e_shift_oszapc_update;
477
wire e_shift_cf_of_update;
478
wire e_shift_oflag;
479
wire e_shift_cflag;
480
 
481
wire [31:0] e_shift_result;
482
 
483
execute_shift execute_shift_inst(
484
 
485
    .exe_is_8bit            (exe_is_8bit),              //input
486
    .exe_operand_16bit      (exe_operand_16bit),        //input
487
    .exe_operand_32bit      (exe_operand_32bit),        //input
488
    .exe_prefix_2byte       (exe_prefix_2byte),         //input
489
 
490
    .exe_cmd                (exe_cmd),                  //input [6:0]
491
    .exe_cmdex              (exe_cmdex),                //input [3:0]
492
    .exe_decoder            (exe_decoder),              //input [39:0]
493
    .exe_modregrm_imm       (exe_modregrm_imm),         //input [7:0]
494
 
495
    .cflag                  (cflag),                    //input
496
 
497
    .ecx                    (ecx),                      //input [31:0]
498
 
499
    .dst                    (dst),                      //input [31:0]
500
    .src                    (src),                      //input [31:0]
501
 
502
    //output
503
    .e_shift_no_write       (e_shift_no_write),         //output
504
    .e_shift_oszapc_update  (e_shift_oszapc_update),    //output
505
    .e_shift_cf_of_update   (e_shift_cf_of_update),     //output
506
    .e_shift_oflag          (e_shift_oflag),            //output
507
    .e_shift_cflag          (e_shift_cflag),            //output
508
 
509
    .e_shift_result         (e_shift_result)            //output [31:0]
510
);
511
 
512
//------------------------------------------------------------------------------
513
 
514
wire [65:0] mult_result;
515
wire        mult_busy;
516
 
517
execute_multiply execute_multiply_inst(
518
    .clk                    (clk),
519
    .rst_n                  (rst_n),
520
 
521
    .exe_reset              (exe_reset),
522
 
523
    .exe_cmd                (exe_cmd),            //input [6:0]
524
    .exe_is_8bit            (exe_is_8bit),        //input
525
    .exe_operand_16bit      (exe_operand_16bit),  //input
526
    .exe_operand_32bit      (exe_operand_32bit),  //input
527
 
528
    .src                    (src),                //input [31:0]
529
    .dst                    (dst),                //input [31:0]
530
 
531
    //output
532
    .mult_result            (mult_result),        //output [65:0]
533
    .mult_busy              (mult_busy),          //output
534
 
535
    .exe_mult_overflow      (exe_mult_overflow)   //output
536
);
537
 
538
//------------------------------------------------------------------------------
539
wire        div_busy;
540
 
541
wire [31:0] div_result_quotient;
542
wire [31:0] div_result_remainder;
543
 
544
execute_divide execute_divide_inst(
545
    .clk                    (clk),
546
    .rst_n                  (rst_n),
547
 
548
    .exe_reset              (exe_reset),
549
    .exe_ready              (exe_ready),
550
 
551
    .exe_is_8bit            (exe_is_8bit),          //input
552
    .exe_operand_16bit      (exe_operand_16bit),    //input
553
    .exe_operand_32bit      (exe_operand_32bit),    //input
554
    .exe_cmd                (exe_cmd),              //input [6:0]
555
 
556
    .eax                    (eax),                  //input [31:0]
557
    .edx                    (edx),                  //input [31:0]
558
 
559
    .src                    (src),                  //input [31:0]
560
 
561
    //output
562
    .div_busy               (div_busy),             //output
563
 
564
    .exe_div_exception      (exe_div_exception),    //output
565
 
566
    .div_result_quotient    (div_result_quotient),  //output [31:0]
567
    .div_result_remainder   (div_result_remainder)  //output [31:0]
568
);
569
 
570
//------------------------------------------------------------------------------
571
 
572
execute_commands execute_commands_inst(
573
    .clk                (clk),
574
    .rst_n              (rst_n),
575
 
576
    .exe_reset          (exe_reset),
577
 
578
    //general input
579
    .eax                (eax),              //input [31:0]
580
    .ecx                (ecx),              //input [31:0]
581
    .edx                (edx),              //input [31:0]
582
    .ebp                (ebp),              //input [31:0]
583
    .esp                (esp),              //input [31:0]
584
 
585
    .tr_base            (tr_base),          //input [31:0]
586
 
587
    .es                 (es),               //input [15:0]
588
    .cs                 (cs),               //input [15:0]
589
    .ss                 (ss),               //input [15:0]
590
    .ds                 (ds),               //input [15:0]
591
    .fs                 (fs),               //input [15:0]
592
    .gs                 (gs),               //input [15:0]
593
    .ldtr               (ldtr),             //input [15:0]
594
    .tr                 (tr),               //input [15:0]
595
 
596
    .cr2                (cr2),              //input [31:0]
597
    .cr3                (cr3),              //input [31:0]
598
 
599
    .dr0                (dr0),              //input [31:0]
600
    .dr1                (dr1),              //input [31:0]
601
    .dr2                (dr2),              //input [31:0]
602
    .dr3                (dr3),              //input [31:0]
603
    .dr6_bt             (dr6_bt),           //input
604
    .dr6_bs             (dr6_bs),           //input
605
    .dr6_bd             (dr6_bd),           //input
606
    .dr6_b12            (dr6_b12),          //input
607
    .dr6_breakpoints    (dr6_breakpoints),    //input [3:0]
608
    .dr7                (dr7),                //input [31:0]
609
 
610
    .cpl                (cpl),                //input [1:0]
611
 
612
    .real_mode          (real_mode),          //input
613
    .v8086_mode         (v8086_mode),         //input
614
    .protected_mode     (protected_mode),     //input
615
 
616
    .idflag                             (idflag),                           //input
617
    .acflag                             (acflag),                           //input
618
    .vmflag                             (vmflag),                           //input
619
    .rflag                              (rflag),                            //input
620
    .ntflag                             (ntflag),                           //input
621
    .iopl                               (iopl),                             //input [1:0]
622
    .oflag                              (oflag),                            //input
623
    .dflag                              (dflag),                            //input
624
    .iflag                              (iflag),                            //input
625
    .tflag                              (tflag),                            //input
626
    .sflag                              (sflag),                            //input
627
    .zflag                              (zflag),                            //input
628
    .aflag                              (aflag),                            //input
629
    .pflag                              (pflag),                            //input
630
    .cflag                              (cflag),                            //input
631
 
632
    .cr0_pg                             (cr0_pg),                           //input
633
    .cr0_cd                             (cr0_cd),                           //input
634
    .cr0_nw                             (cr0_nw),                           //input
635
    .cr0_am                             (cr0_am),                           //input
636
    .cr0_wp                             (cr0_wp),                           //input
637
    .cr0_ne                             (cr0_ne),                           //input
638
    .cr0_ts                             (cr0_ts),                           //input
639
    .cr0_em                             (cr0_em),                           //input
640
    .cr0_mp                             (cr0_mp),                           //input
641
    .cr0_pe                             (cr0_pe),                           //input
642
 
643
    .cs_limit                           (cs_limit),                         //input [31:0]
644
    .tr_limit                           (tr_limit),                         //input [31:0]
645
    .tr_cache                           (tr_cache),                         //input [63:0]
646
    .ss_cache                           (ss_cache),                         //input [63:0]
647
 
648
    .idtr_limit                         (idtr_limit),                       //input [15:0]
649
    .idtr_base                          (idtr_base),                        //input [15:0]
650
 
651
    .gdtr_limit                         (gdtr_limit),                       //input [15:0]
652
    .gdtr_base                          (gdtr_base),                        //input [31:0]
653
 
654
    //exception input
655
    .exc_push_error                     (exc_push_error),                   //input
656
    .exc_error_code                     (exc_error_code),                   //input [15:0]
657
    .exc_soft_int_ib                    (exc_soft_int_ib),                  //input
658
    .exc_soft_int                       (exc_soft_int),                     //input
659
    .exc_vector                         (exc_vector),                       //input [7:0]
660
 
661
    //exe input
662
    .exe_mutex_current                  (exe_mutex_current),                //input [10:0]
663
 
664
    .exe_eip                            (exe_eip),                          //input [31:0]
665
    .exe_extra                          (exe_extra),                        //input [31:0]
666
    .exe_linear                         (exe_linear),                       //input [31:0]
667
    .exe_cmd                            (exe_cmd),                          //input [6:0]
668
    .exe_cmdex                          (exe_cmdex),                        //input [3:0]
669
    .exe_decoder                        (exe_decoder),                      //input [39:0]
670
    .exe_modregrm_reg                   (exe_modregrm_reg),                 //input [2:0]
671
    .exe_address_effective              (exe_address_effective),            //input [31:0]
672
    .exe_is_8bit                        (exe_is_8bit),                      //input
673
    .exe_operand_16bit                  (exe_operand_16bit),                //input
674
    .exe_operand_32bit                  (exe_operand_32bit),                //input
675
    .exe_address_16bit                  (exe_address_16bit),                //input
676
    .exe_consumed                       (exe_consumed),                     //input [3:0]
677
 
678
    .src                                (src),                              //input [31:0]
679
    .dst                                (dst),                              //input [31:0]
680
 
681
    .exe_enter_offset                   (exe_enter_offset),                 //input [31:0]
682
 
683
    .exe_ready                          (exe_ready),                        //input
684
 
685
    //mult
686
    .mult_busy                          (mult_busy),                        //input
687
    .mult_result                        (mult_result),                      //input [31:0]
688
 
689
    //div
690
    .div_busy                           (div_busy),                         //input
691
    .exe_div_exception                  (exe_div_exception),                //input
692
 
693
    .div_result_quotient                (div_result_quotient),              //input [31:0]
694
    .div_result_remainder               (div_result_remainder),             //input [31:0]
695
 
696
    //shift
697
    .e_shift_no_write                   (e_shift_no_write),                 //input
698
    .e_shift_oszapc_update              (e_shift_oszapc_update),            //input
699
    .e_shift_cf_of_update               (e_shift_cf_of_update),             //input
700
    .e_shift_oflag                      (e_shift_oflag),                    //input
701
    .e_shift_cflag                      (e_shift_cflag),                    //input
702
 
703
    .e_shift_result                     (e_shift_result),                   //input [31:0]
704
 
705
    //tlbcheck
706
    .tlbcheck_do                        (tlbcheck_do),                      //output
707
    .tlbcheck_done                      (tlbcheck_done),                    //input
708
    .tlbcheck_page_fault                (tlbcheck_page_fault),              //input
709
 
710
    .tlbcheck_address                   (tlbcheck_address),                 //output [31:0]
711
    .tlbcheck_rw                        (tlbcheck_rw),                      //output
712
 
713
    //tlbflushsingle
714
    .tlbflushsingle_do                  (tlbflushsingle_do),                //output
715
    .tlbflushsingle_done                (tlbflushsingle_done),              //input
716
 
717
    .tlbflushsingle_address             (tlbflushsingle_address),           //output [31:0]
718
 
719
    //invd
720
    .invdcode_do                        (invdcode_do),                      //output
721
    .invdcode_done                      (invdcode_done),                    //input
722
 
723
    .invddata_do                        (invddata_do),                      //output
724
    .invddata_done                      (invddata_done),                    //input
725
 
726
    .wbinvddata_do                      (wbinvddata_do),                    //output
727
    .wbinvddata_done                    (wbinvddata_done),                  //input
728
 
729
    //pipeline input
730
    .wr_task_rpl                        (wr_task_rpl),                      //input [1:0]
731
    .wr_esp_prev                        (wr_esp_prev),                      //input [31:0]
732
 
733
    //global input
734
    .glob_descriptor                    (glob_descriptor),                  //input [63:0]
735
    .glob_descriptor_2                  (glob_descriptor_2),                //input [63:0]
736
    .glob_param_1                       (glob_param_1),                     //input [31:0]
737
    .glob_param_2                       (glob_param_2),                     //input [31:0]
738
    .glob_param_3                       (glob_param_3),                     //input [31:0]
739
    .glob_param_5                       (glob_param_5),                     //input [31:0]
740
 
741
    .glob_desc_base                     (glob_desc_base),                   //input [31:0]
742
 
743
    .glob_desc_limit                    (glob_desc_limit),                  //input [31:0]
744
    .glob_desc_2_limit                  (glob_desc_2_limit),                //input [31:0]
745
 
746
    //global set
747
    .exe_glob_descriptor_set                (exe_glob_descriptor_set),              //output
748
    .exe_glob_descriptor_value              (exe_glob_descriptor_value),            //output [63:0]
749
 
750
    .exe_glob_descriptor_2_set              (exe_glob_descriptor_2_set),            //output
751
    .exe_glob_descriptor_2_value            (exe_glob_descriptor_2_value),          //output [63:0]
752
 
753
    .exe_glob_param_1_set                   (exe_glob_param_1_set),                 //output
754
    .exe_glob_param_1_value                 (exe_glob_param_1_value),               //output [31:0]
755
 
756
    .exe_glob_param_2_set                   (exe_glob_param_2_set),                 //output
757
    .exe_glob_param_2_value                 (exe_glob_param_2_value),               //output [31:0]
758
 
759
    .exe_glob_param_3_set                   (exe_glob_param_3_set),                 //output
760
    .exe_glob_param_3_value                 (exe_glob_param_3_value),               //output [31:0]
761
 
762
    .dr6_bd_set                         (dr6_bd_set),                       //output
763
 
764
    //offset control
765
    .offset_ret_far_se                  (offset_ret_far_se),                //output
766
    .offset_new_stack                   (offset_new_stack),                 //output
767
    .offset_new_stack_minus             (offset_new_stack_minus),           //output
768
    .offset_new_stack_continue          (offset_new_stack_continue),        //output
769
    .offset_leave                       (offset_leave),                     //output
770
    .offset_pop                         (offset_pop),                       //output
771
    .offset_enter_last                  (offset_enter_last),                //output
772
    .offset_ret                         (offset_ret),                       //output
773
    .offset_iret_glob_param_4           (offset_iret_glob_param_4),         //output
774
    .offset_iret                        (offset_iret),                      //output
775
    .offset_ret_imm                     (offset_ret_imm),                   //output
776
    .offset_esp                         (offset_esp),                       //output
777
    .offset_call                        (offset_call),                      //output
778
    .offset_call_keep                   (offset_call_keep),                 //output
779
    .offset_call_int_same_first         (offset_call_int_same_first),       //output
780
    .offset_call_int_same_next          (offset_call_int_same_next),        //output
781
    .offset_int_real                    (offset_int_real),                  //output
782
    .offset_int_real_next               (offset_int_real_next),             //output
783
    .offset_task                        (offset_task),                      //output
784
 
785
    //task output
786
    .task_eip                           (task_eip),                         //output [31:0]
787
 
788
    //exe output
789
    .exe_waiting                        (exe_waiting),                      //output
790
 
791
    .exe_bound_fault                    (exe_bound_fault),                  //output
792
    .exe_trigger_gp_fault               (exe_trigger_gp_fault),             //output
793
    .exe_trigger_ts_fault               (exe_trigger_ts_fault),             //output
794
    .exe_trigger_ss_fault               (exe_trigger_ss_fault),             //output
795
    .exe_trigger_np_fault               (exe_trigger_np_fault),             //output
796
    .exe_trigger_pf_fault               (exe_trigger_pf_fault),             //output
797
    .exe_trigger_db_fault               (exe_trigger_db_fault),             //output
798
    .exe_trigger_nm_fault               (exe_trigger_nm_fault),             //output
799
    .exe_load_seg_gp_fault              (exe_load_seg_gp_fault),            //output
800
    .exe_load_seg_ss_fault              (exe_load_seg_ss_fault),            //output
801
    .exe_load_seg_np_fault              (exe_load_seg_np_fault),            //output
802
 
803
    .exe_error_code                     (exe_error_code),                   //output [15:0]
804
 
805
    .exe_result                         (exe_result),                       //output [31:0]
806
    .exe_result2                        (exe_result2),                      //output [31:0]
807
    .exe_result_push                    (exe_result_push),                  //output [31:0]
808
    .exe_result_signals                 (exe_result_signals),               //output [4:0]
809
 
810
    .exe_arith_index                    (exe_arith_index),                  //output [3:0]
811
 
812
    .exe_arith_sub_carry                (exe_arith_sub_carry),              //output
813
    .exe_arith_add_carry                (exe_arith_add_carry),              //output
814
    .exe_arith_adc_carry                (exe_arith_adc_carry),              //output
815
    .exe_arith_sbb_carry                (exe_arith_sbb_carry),              //output
816
 
817
    .exe_buffer                         (exe_buffer),                       //output [31:0]
818
    .exe_buffer_shifted                 (exe_buffer_shifted),               //output [463:0]
819
 
820
    //output local
821
    .exe_is_8bit_clear                  (exe_is_8bit_clear),                //output
822
 
823
    .exe_cmpxchg_switch                 (exe_cmpxchg_switch),               //output
824
 
825
    .exe_task_switch_finished           (exe_task_switch_finished),         //output
826
 
827
    .exe_eip_from_glob_param_2          (exe_eip_from_glob_param_2),        //output
828
    .exe_eip_from_glob_param_2_16bit    (exe_eip_from_glob_param_2_16bit),  //output
829
 
830
    //branch
831
    .exe_branch                         (exe_branch),                       //output
832
    .exe_branch_eip                     (exe_branch_eip)                    //output [31:0]
833
);
834
 
835
//------------------------------------------------------------------------------
836
 
837
// synthesis translate_off
838
wire _unused_ok = &{ 1'b0, cs_cache[63:56], cs_cache[54:52], cs_cache[47:16], rd_decoder[87:24], rd_modregrm_imm[31:8], 1'b0 };
839
// synthesis translate_on
840
 
841
//------------------------------------------------------------------------------
842
 
843
endmodule

powered by: WebSVN 2.1.0

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