URL
https://opencores.org/ocsvn/ao486/ao486/trunk
Subversion Repositories ao486
[/] [ao486/] [trunk/] [rtl/] [ao486/] [commands/] [CMD_int.txt] - Rev 2
Compare with Previous | Blame | View Log
<defines>
`define CMD_int #AUTOGEN_NEXT_CMD
// need to set:
//-------------
// exc_soft_int -- is software interrupt
// exc_soft_int_ib -- is software interrupt from INT Ib
// exc_push_error --
// exc_error_code --
// exc_vector --
`define CMDEX_int_STEP_0 4'd0
`define CMDEX_int_STEP_1 4'd1
`define CMDEX_int_real_STEP_0 4'd2
`define CMDEX_int_real_STEP_1 4'd3
`define CMDEX_int_real_STEP_2 4'd4
// glob_param_2 -- eip
`define CMDEX_int_real_STEP_3 4'd5
`define CMDEX_int_real_STEP_4 4'd6
`define CMDEX_int_real_STEP_5 4'd7
`define CMDEX_int_protected_STEP_0 4'd8
`define CMDEX_int_protected_STEP_1 4'd9
// wait for gate descriptor
`define CMDEX_int_protected_STEP_2 4'd10
`define CMDEX_int_task_gate_STEP_0 4'd11
`define CMDEX_int_task_gate_STEP_1 4'd12
`define CMDEX_int_int_trap_gate_STEP_0 4'd13
// glob_param_1[15:0] -- CS selector
// glob_param_1[18:16] -- CS segment type
// glob_param_1[19] -- 0: 286, 1: 386 GATE
// glob_param_1[20] -- 0: interrupt, 1: trap
// glob_param_2 -- eip
// glob_descriptor -- new cs descriptor
`define CMDEX_int_int_trap_gate_STEP_1 4'd14
`define CMDEX_int_int_trap_gate_STEP_2 4'd15
//------------------------------------------------------------------------------
`define CMD_int_2 #AUTOGEN_NEXT_CMD
`define CMDEX_int_2_int_trap_gate_same_STEP_0 4'd0
`define CMDEX_int_2_int_trap_gate_same_STEP_1 4'd1
`define CMDEX_int_2_int_trap_gate_same_STEP_2 4'd2
`define CMDEX_int_2_int_trap_gate_same_STEP_3 4'd3
`define CMDEX_int_2_int_trap_gate_same_STEP_4 4'd4
`define CMDEX_int_2_int_trap_gate_same_STEP_5 4'd5
`define CMDEX_int_2_int_trap_gate_more_STEP_0 4'd6
`define CMDEX_int_2_int_trap_gate_more_STEP_1 4'd7
// glob_param_1[15:0] -- CS selector
// glob_param_1[18:16] -- CS segment type
// glob_param_1[19] -- 0: 286, 1: 386 GATE
// glob_param_1[20] -- 0: interrupt, 1: trap
// glob_param_2 -- eip
// glob_param_3[15:0] -- new ss
// glob_param_4 -- new esp
// mc_descriptor -- new cs descriptor
//after exe:
// glob_param_1[15:0] -- new ss
// glob_param_1[18:16] -- SS type
// glob_param_2 -- new eip
// glob_param_3 -- cs selector, type, 286/386 interrupt/trap
// glob_param_4 -- new esp
// glob_descriptor_2 -- new cs descriptor
`define CMDEX_int_2_int_trap_gate_more_STEP_2 4'd8
`define CMDEX_int_2_int_trap_gate_more_STEP_3 4'd9
//v8086 mode
`define CMDEX_int_2_int_trap_gate_more_STEP_4 4'd10
`define CMDEX_int_2_int_trap_gate_more_STEP_5 4'd11
`define CMDEX_int_2_int_trap_gate_more_STEP_6 4'd12
`define CMDEX_int_2_int_trap_gate_more_STEP_7 4'd13
//push interrupt data
`define CMDEX_int_2_int_trap_gate_more_STEP_8 4'd14
`define CMDEX_int_2_int_trap_gate_more_STEP_9 4'd15
//------------------------------------------------------------------------------
`define CMD_int_3 #AUTOGEN_NEXT_CMD
//push interrupt data
`define CMDEX_int_3_int_trap_gate_more_STEP_0 4'd0
`define CMDEX_int_3_int_trap_gate_more_STEP_1 4'd1
`define CMDEX_int_3_int_trap_gate_more_STEP_2 4'd2
// push error code
`define CMDEX_int_3_int_trap_gate_more_STEP_3 4'd3
// save cs
`define CMDEX_int_3_int_trap_gate_more_STEP_4 4'd4
//after exe:
// glob_param_1[15:0] -- CS selector
// glob_param_1[18:16] -- CS segment type
// glob_param_1[19] -- 0: 286, 1: 386 GATE
// glob_param_1[20] -- 0: interrupt, 1: trap
// glob_param_2 -- eip
// glob_param_3[15:0] -- new ss
// glob_param_3[18:16] -- SS type
// glob_param_4 -- new esp
// glob_descriptor -- new cs descriptor
// glob_descriptor_2 -- new ss descriptor
// save ss
`define CMDEX_int_3_int_trap_gate_more_STEP_5 4'd5
// save eip; if v8086 - invalidate seg reg
`define CMDEX_int_3_int_trap_gate_more_STEP_6 4'd6
</defines>
<microcode>
`CMDEX_int_STEP_0
`CMDEX_int_STEP_1
//real mode
IF(`CMDEX_int_STEP_1 && real_mode);
`CMDEX_int_real_STEP_0
`CMDEX_int_real_STEP_1
`CMDEX_int_real_STEP_2
`CMDEX_int_real_STEP_3
`CMDEX_int_real_STEP_4
CALL(`CMDEX_load_seg_STEP_1);
LOOP(`CMDEX_int_real_STEP_5);
ENDIF();
// v8086 / protected mode
IF(`CMDEX_int_STEP_1 && ~(real_mode));
`CMDEX_int_protected_STEP_0
`CMDEX_int_protected_STEP_1
`CMDEX_int_protected_STEP_2
IF(`CMDEX_int_protected_STEP_2 && glob_descriptor[`DESC_BITS_TYPE] == `DESC_TASK_GATE);
`CMDEX_int_task_gate_STEP_0
`CMDEX_int_task_gate_STEP_1
JMP(`CMDEX_task_switch_STEP_1);
ENDIF();
IF(`CMDEX_int_protected_STEP_2 && glob_descriptor[`DESC_BITS_TYPE] != `DESC_TASK_GATE);
`CMDEX_int_int_trap_gate_STEP_0
`CMDEX_int_int_trap_gate_STEP_1
`CMDEX_int_int_trap_gate_STEP_2
//interrupt trap gate more
IF(`CMDEX_int_int_trap_gate_STEP_2 && `DESC_IS_CODE_NON_CONFORMING(glob_descriptor) && glob_descriptor[`DESC_BITS_DPL] < cpl);
`CMDEX_int_2_int_trap_gate_more_STEP_0
`CMDEX_int_2_int_trap_gate_more_STEP_1
`CMDEX_int_2_int_trap_gate_more_STEP_2
`CMDEX_int_2_int_trap_gate_more_STEP_3
IF(`CMDEX_int_2_int_trap_gate_more_STEP_3 && v8086_mode);
`CMDEX_int_2_int_trap_gate_more_STEP_4
`CMDEX_int_2_int_trap_gate_more_STEP_5
`CMDEX_int_2_int_trap_gate_more_STEP_6
`CMDEX_int_2_int_trap_gate_more_STEP_7
`CMDEX_int_2_int_trap_gate_more_STEP_8
ENDIF();
IF(`CMDEX_int_2_int_trap_gate_more_STEP_3 && ~(v8086_mode));
`CMDEX_int_2_int_trap_gate_more_STEP_8
ENDIF();
`CMDEX_int_2_int_trap_gate_more_STEP_9
`CMDEX_int_3_int_trap_gate_more_STEP_0
`CMDEX_int_3_int_trap_gate_more_STEP_1
`CMDEX_int_3_int_trap_gate_more_STEP_2
IF(`CMDEX_int_3_int_trap_gate_more_STEP_2 && exc_push_error);
`CMDEX_int_3_int_trap_gate_more_STEP_3
`CMDEX_int_3_int_trap_gate_more_STEP_4
ENDIF();
IF(`CMDEX_int_3_int_trap_gate_more_STEP_2 && ~(exc_push_error));
`CMDEX_int_3_int_trap_gate_more_STEP_4
ENDIF();
`CMDEX_int_3_int_trap_gate_more_STEP_5
LOOP(`CMDEX_int_3_int_trap_gate_more_STEP_6);
ENDIF();
//interrupt trap gate same
IF(`CMDEX_int_int_trap_gate_STEP_2 && ~(`DESC_IS_CODE_NON_CONFORMING(glob_descriptor) && glob_descriptor[`DESC_BITS_DPL] < cpl));
`CMDEX_int_2_int_trap_gate_same_STEP_0
`CMDEX_int_2_int_trap_gate_same_STEP_1
`CMDEX_int_2_int_trap_gate_same_STEP_2
IF(`CMDEX_int_2_int_trap_gate_same_STEP_2 && exc_push_error);
`CMDEX_int_2_int_trap_gate_same_STEP_3
`CMDEX_int_2_int_trap_gate_same_STEP_4
ENDIF();
IF(`CMDEX_int_2_int_trap_gate_same_STEP_2 && ~(exc_push_error));
`CMDEX_int_2_int_trap_gate_same_STEP_4
ENDIF();
LOOP(`CMDEX_int_2_int_trap_gate_same_STEP_5);
ENDIF();
ENDIF();
ENDIF();
</microcode>
<read>
IF(rd_cmd == `CMD_int && rd_cmdex == `CMDEX_int_task_gate_STEP_0);
IF(rd_mutex_busy_active); SET(rd_waiting); // wait for previous step -- loading glob_param_1
ELSE();
SET(rd_glob_param_1_set);
SET(rd_glob_param_1_value, { 16'd0, glob_descriptor[31:16] });
ENDIF();
ENDIF();
</read>
<read>
IF(rd_cmd == `CMD_int && rd_cmdex == `CMDEX_int_task_gate_STEP_1);
//TODO: null not checked
IF(glob_param_1[`SELECTOR_BIT_TI] == 1'b0); // skip if TI set
SET(rd_error_code, `SELECTOR_FOR_CODE(glob_param_1));
SET(rd_glob_descriptor_set);
SET(rd_glob_descriptor_value, read_8);
SET(read_system_descriptor);
IF(~(read_for_rd_ready)); SET(rd_waiting); ENDIF();
ENDIF();
ENDIF();
</read>
<read>
IF(rd_cmd == `CMD_int && rd_cmdex == `CMDEX_int_int_trap_gate_STEP_1);
IF(rd_mutex_busy_active); SET(rd_waiting); // wait for previous step -- loading glob_param_1
ELSE();
IF(glob_param_1[15:2] != 14'd0); // load null
SET(rd_error_code, `SELECTOR_FOR_CODE(glob_param_1));
SET(rd_glob_descriptor_set);
SET(rd_glob_descriptor_value, read_8);
SET(read_system_descriptor);
IF(~(read_for_rd_ready)); SET(rd_waiting);
ENDIF();
ENDIF();
ENDIF();
ENDIF();
</read>
<read>
IF(rd_cmd == `CMD_int && rd_cmdex == `CMDEX_int_real_STEP_3);
SET(rd_system_linear, idtr_base + { 22'd0, exc_vector[7:0], 2'b00 });
SET(rd_glob_param_2_set);
SET(rd_glob_param_2_value, { 16'd0, read_4[15:0] });
IF(rd_mutex_busy_active); SET(rd_waiting); // wait for previous step -- push on stack
ELSE();
SET(read_system_word);
IF(~(read_for_rd_ready)); SET(rd_waiting); ENDIF();
ENDIF();
ENDIF();
</read>
<read>
IF(rd_cmd == `CMD_int && rd_cmdex == `CMDEX_int_real_STEP_4);
SET(rd_system_linear, idtr_base + { 22'd0, exc_vector[7:0], 2'b10 });
SET(rd_glob_param_1_set);
SET(rd_glob_param_1_value, { 13'd0, `SEGMENT_CS, read_4[15:0] });
IF(rd_mutex_busy_active); SET(rd_waiting); // wait for previous step -- exception possible
ELSE();
SET(read_system_word);
IF(~(read_for_rd_ready)); SET(rd_waiting); ENDIF();
ENDIF();
ENDIF();
</read>
<read>
IF(rd_cmd == `CMD_int && rd_cmdex == `CMDEX_int_protected_STEP_1);
SET(rd_system_linear, idtr_base + { 21'd0, exc_vector[7:0], 3'b000 });
SET(rd_glob_descriptor_set);
SET(rd_glob_descriptor_value, read_8);
IF(rd_mutex_busy_active); SET(rd_waiting); // wait for previous step -- exception possible
ELSE();
SET(read_system_qword);
IF(~(read_for_rd_ready)); SET(rd_waiting); ENDIF();
ENDIF();
ENDIF();
</read>
<execute>
IF(exe_cmd == `CMD_int && exe_cmdex == `CMDEX_int_int_trap_gate_STEP_0);
SET(exe_glob_param_1_set);
SET(exe_glob_param_1_value, { 11'd0, glob_descriptor[`DESC_BIT_TYPE_BIT_0], glob_descriptor[`DESC_BITS_TYPE] >= `DESC_INTERRUPT_GATE_386, `SEGMENT_CS, glob_descriptor[31:16] });
SET(exe_glob_param_2_set);
SET(exe_glob_param_2_value, (glob_descriptor[`DESC_BITS_TYPE] >= `DESC_INTERRUPT_GATE_386)? { glob_descriptor[63:48], glob_descriptor[15:0] } : { 16'd0, glob_descriptor[15:0] });
ENDIF();
</execute>
<execute>
IF(exe_cmd == `CMD_int_2 && exe_cmdex == `CMDEX_int_2_int_trap_gate_more_STEP_1);
IF(v8086_mode && exe_descriptor[`DESC_BITS_DPL] != 2'd0);
SET(exe_waiting);
SET(exe_trigger_gp_fault); //exception GP(val)
SET(exe_error_code, `SELECTOR_FOR_CODE(glob_param_1));
ENDIF();
IF(~(exe_trigger_gp_fault) && glob_param_3[15:2] == 14'd0);
SET(exe_waiting);
SET(exe_trigger_ts_fault); //exception TS(0)
ENDIF();
IF(exe_ready);
SET(exe_glob_param_1_set);
SET(exe_glob_param_1_value, { 13'd0, `SEGMENT_SS, glob_param_3[15:0] });
SET(exe_glob_param_3_set);
SET(exe_glob_param_3_value, glob_param_1);
SET(exe_glob_descriptor_2_set);
SET(exe_glob_descriptor_2_value, glob_descriptor);
ENDIF();
ENDIF();
</execute>
<execute>
IF(exe_cmd == `CMD_int_2 && exe_cmdex == `CMDEX_int_2_int_trap_gate_more_STEP_3);
SET(offset_new_stack);
IF(glob_param_2 > glob_desc_2_limit);
SET(exe_waiting);
SET(exe_trigger_gp_fault); //exception GP(0)
ENDIF();
ENDIF();
</execute>
<execute>
IF(exe_cmd == `CMD_int_2 && exe_cmdex == `CMDEX_int_2_int_trap_gate_same_STEP_5);
SET(exe_eip_from_glob_param_2);
ENDIF();
</execute>
<execute>
IF(exe_cmd == `CMD_int_3 && (exe_cmdex == `CMDEX_int_3_int_trap_gate_more_STEP_4 || exe_cmdex == `CMDEX_int_3_int_trap_gate_more_STEP_5));
IF(exe_mutex_current[`MUTEX_ACTIVE_BIT]); SET(exe_waiting); ENDIF();
IF(~(exe_mutex_current[`MUTEX_ACTIVE_BIT]) && exe_ready);
SET(exe_glob_param_1_set);
SET(exe_glob_param_1_value, glob_param_3);
SET(exe_glob_param_3_set);
SET(exe_glob_param_3_value, glob_param_1);
SET(exe_glob_descriptor_2_set);
SET(exe_glob_descriptor_2_value, glob_descriptor);
SET(exe_glob_descriptor_set);
SET(exe_glob_descriptor_value, glob_descriptor_2);
ENDIF();
ENDIF();
</execute>
<execute>
IF(exe_cmd == `CMD_int_3 && exe_cmdex == `CMDEX_int_3_int_trap_gate_more_STEP_6);
SET(exe_eip_from_glob_param_2);
ENDIF();
</execute>
<execute>
IF(exe_cmd == `CMD_int && exe_cmdex == `CMDEX_int_STEP_0);
IF(exe_mutex_current[`MUTEX_ACTIVE_BIT]); SET(exe_waiting); ENDIF(); // wait for finish
ENDIF();
</execute>
<execute>
IF(exe_cmd == `CMD_int && exe_cmdex == `CMDEX_int_STEP_1);
IF(exc_soft_int_ib && v8086_mode && iopl < 2'd3);
SET(exe_waiting);
SET(exe_trigger_gp_fault); //exception GP(0)
ENDIF();
ENDIF();
</execute>
<execute>
IF(exe_cmd == `CMD_int && exe_cmdex == `CMDEX_int_real_STEP_0);
SET(exe_result_push, exe_push_eflags);
SET(offset_int_real);
IF({ 6'd0, exc_vector[7:0], 2'b11 } > idtr_limit);
SET(exe_waiting);
SET(exe_trigger_gp_fault); //exception GP(0)
ENDIF();
ENDIF();
</execute>
<execute>
IF(exe_cmd == `CMD_int && exe_cmdex == `CMDEX_int_real_STEP_1);
SET(offset_int_real_next);
SET(exe_result_push, { 16'd0, cs[15:0] });
ENDIF();
</execute>
<execute>
IF(exe_cmd == `CMD_int && exe_cmdex == `CMDEX_int_real_STEP_2);
SET(offset_int_real_next);
SET(exe_result_push, exe_eip);
ENDIF();
</execute>
<execute>
IF(exe_cmd == `CMD_int && exe_cmdex == `CMDEX_int_real_STEP_3);
IF(glob_param_2 > cs_limit);
SET(exe_waiting);
SET(exe_trigger_gp_fault); //exception GP(0)
ENDIF();
ENDIF();
</execute>
<execute>
IF(exe_cmd == `CMD_int && exe_cmdex == `CMDEX_int_real_STEP_5);
SET(exe_eip_from_glob_param_2);
ENDIF();
</execute>
<execute>
IF(exe_cmd == `CMD_int && exe_cmdex == `CMDEX_int_protected_STEP_0);
IF({ 5'd0, exc_vector[7:0], 3'b111 } > idtr_limit);
SET(exe_waiting);
SET(exe_trigger_gp_fault); //exception GP(vector*8 +2)
SET(exe_error_code, { 5'd0, exc_vector[7:0], 3'b010 });
ENDIF();
ENDIF();
</execute>
<execute>
IF(exe_cmd == `CMD_int && exe_cmdex == `CMDEX_int_protected_STEP_1);
IF(exe_descriptor[`DESC_BIT_SEG] || (
( exe_descriptor[`DESC_BITS_TYPE] != `DESC_TASK_GATE &&
exe_descriptor[`DESC_BITS_TYPE] != `DESC_INTERRUPT_GATE_386 && exe_descriptor[`DESC_BITS_TYPE] != `DESC_INTERRUPT_GATE_286 &&
exe_descriptor[`DESC_BITS_TYPE] != `DESC_TRAP_GATE_386 && exe_descriptor[`DESC_BITS_TYPE] != `DESC_TRAP_GATE_286
) ||
(exc_soft_int && exe_descriptor[`DESC_BITS_DPL] < cpl)
));
SET(exe_waiting);
SET(exe_trigger_gp_fault); //exception GP(val)
SET(exe_error_code, { 5'd0, exc_vector[7:0], 3'b010 });
ENDIF();
IF(~(exe_trigger_gp_fault) && exe_descriptor[`DESC_BIT_P] == `FALSE);
SET(exe_waiting);
SET(exe_trigger_np_fault); //exception GP(val)
SET(exe_error_code, { 5'd0, exc_vector[7:0], 3'b010 });
ENDIF();
ENDIF();
</execute>
<execute_local>
wire exe_int_2_int_trap_same_exception;
assign exe_int_2_int_trap_same_exception = (v8086_mode && (`DESC_IS_CODE_CONFORMING(exe_descriptor) || exe_descriptor[`DESC_BITS_DPL] != 2'd0));
</execute_local>
<execute>
IF(exe_cmd == `CMD_int_2 && exe_cmdex == `CMDEX_int_2_int_trap_gate_same_STEP_0);
SET(exe_result_push, exe_push_eflags);
SET(offset_call_int_same_first);
IF(exe_int_2_int_trap_same_exception || (glob_param_2 > glob_desc_limit));
SET(exe_waiting);
SET(exe_trigger_gp_fault); //exception GP(val)
SET(exe_error_code, (exe_int_2_int_trap_same_exception)? `SELECTOR_FOR_CODE(glob_param_1) : 16'd0);
ENDIF();
ENDIF();
</execute>
<execute>
IF(exe_cmd == `CMD_int_2 && exe_cmdex == `CMDEX_int_2_int_trap_gate_same_STEP_1);
SET(exe_result_push, { 16'd0, cs[15:0] });
SET(offset_call_int_same_next);
ENDIF();
</execute>
<execute>
IF(exe_cmd == `CMD_int_2 && exe_cmdex == `CMDEX_int_2_int_trap_gate_same_STEP_2);
SET(exe_result_push, exe_eip);
SET(offset_call_int_same_next);
ENDIF();
</execute>
<execute>
IF(exe_cmd == `CMD_int_2 && exe_cmdex == `CMDEX_int_2_int_trap_gate_same_STEP_3);
SET(exe_result_push, { 16'd0, exc_error_code[15:0] });
SET(offset_call_int_same_next);
ENDIF();
</execute>
<execute>
IF(exe_cmd == `CMD_int_2 && exe_cmdex >= `CMDEX_int_2_int_trap_gate_more_STEP_4);
SET(exe_result_push, (exe_cmdex == `CMDEX_int_2_int_trap_gate_more_STEP_4)? { 16'd0, gs } :
(exe_cmdex == `CMDEX_int_2_int_trap_gate_more_STEP_5)? { 16'd0, fs } :
(exe_cmdex == `CMDEX_int_2_int_trap_gate_more_STEP_6)? { 16'd0, ds } :
(exe_cmdex == `CMDEX_int_2_int_trap_gate_more_STEP_7)? { 16'd0, es } :
(exe_cmdex == `CMDEX_int_2_int_trap_gate_more_STEP_8)? { 16'd0, ss } :
esp);
SET(offset_new_stack_continue);
ENDIF();
</execute>
<execute>
IF(exe_cmd == `CMD_int_3 && exe_cmdex == `CMDEX_int_3_int_trap_gate_more_STEP_0);
SET(exe_result_push, exe_push_eflags);
SET(offset_new_stack_continue);
ENDIF();
</execute>
<execute>
IF(exe_cmd == `CMD_int_3 && exe_cmdex == `CMDEX_int_3_int_trap_gate_more_STEP_1);
SET(exe_result_push, { 16'd0, cs[15:0] });
SET(offset_new_stack_continue);
ENDIF();
</execute>
<execute>
IF(exe_cmd == `CMD_int_3 && exe_cmdex == `CMDEX_int_3_int_trap_gate_more_STEP_2);
SET(exe_result_push, exe_eip);
SET(offset_new_stack_continue);
ENDIF();
</execute>
<execute>
IF(exe_cmd == `CMD_int_3 && exe_cmdex == `CMDEX_int_3_int_trap_gate_more_STEP_3);
SET(exe_result_push, { 16'd0, exc_error_code[15:0] });
SET(offset_new_stack_continue);
ENDIF();
</execute>
<write>
IF(wr_cmd == `CMD_int_2 && wr_cmdex == `CMDEX_int_2_int_trap_gate_more_STEP_2);
SET(wr_not_finished);
ENDIF();
</write>
<write>
IF(wr_cmd == `CMD_int_2 && wr_cmdex == `CMDEX_int_2_int_trap_gate_more_STEP_3);
SET(wr_not_finished);
ENDIF();
</write>
<write>
IF(wr_cmd == `CMD_int_2 && (
wr_cmdex == `CMDEX_int_2_int_trap_gate_more_STEP_4 || wr_cmdex == `CMDEX_int_2_int_trap_gate_more_STEP_5 ||
wr_cmdex == `CMDEX_int_2_int_trap_gate_more_STEP_6 || wr_cmdex == `CMDEX_int_2_int_trap_gate_more_STEP_7 ||
wr_cmdex == `CMDEX_int_2_int_trap_gate_more_STEP_8 || wr_cmdex == `CMDEX_int_2_int_trap_gate_more_STEP_9));
SET(wr_not_finished);
SET(wr_new_push_ss_fault_check);
SET(wr_one_cycle_wait);
SET(wr_push_length_word, ~(glob_param_3[19]));
SET(wr_push_length_dword, glob_param_3[19]);
SET(wr_error_code, (glob_param_1[`SELECTOR_BITS_RPL] != cpl)? `SELECTOR_FOR_CODE(glob_param_1) : 16'd0);
IF(~(write_for_wr_ready)); SET(wr_waiting); ENDIF();
IF(~(wr_new_push_ss_fault));
SET(write_new_stack_virtual);
//esp not yet updated
ENDIF();
ENDIF();
</write>
<write>
IF(wr_cmd == `CMD_int_3 && (
wr_cmdex == `CMDEX_int_3_int_trap_gate_more_STEP_0 || wr_cmdex == `CMDEX_int_3_int_trap_gate_more_STEP_1 ||
wr_cmdex == `CMDEX_int_3_int_trap_gate_more_STEP_2 || wr_cmdex == `CMDEX_int_3_int_trap_gate_more_STEP_3));
SET(wr_not_finished);
SET(wr_new_push_ss_fault_check);
SET(wr_one_cycle_wait);
SET(wr_push_length_word, ~(glob_param_3[19]));
SET(wr_push_length_dword, glob_param_3[19]);
SET(wr_error_code, (glob_param_1[`SELECTOR_BITS_RPL] != cpl)? `SELECTOR_FOR_CODE(glob_param_1) : 16'd0);
IF(~(write_for_wr_ready)); SET(wr_waiting); ENDIF();
IF(~(wr_new_push_ss_fault));
SET(write_new_stack_virtual);
IF((wr_cmdex == `CMDEX_int_3_int_trap_gate_more_STEP_2 && ~(exc_push_error)) || wr_cmdex == `CMDEX_int_3_int_trap_gate_more_STEP_3);
SAVE(esp, wr_new_stack_esp); // speculative set before
ENDIF();
ENDIF();
ENDIF();
</write>
<write>
IF(wr_cmd == `CMD_int && wr_cmdex == `CMDEX_int_STEP_0);
SET(wr_not_finished);
SET(wr_debug_trap_clear);
SET(wr_make_esp_speculative);
ENDIF();
</write>
<write>
IF(wr_cmd == `CMD_int && wr_cmdex == `CMDEX_int_STEP_1);
SET(wr_not_finished);
ENDIF();
</write>
<write>
IF(wr_cmd == `CMD_int && (wr_cmdex == `CMDEX_int_real_STEP_3 || wr_cmdex == `CMDEX_int_real_STEP_4));
SET(wr_not_finished);
ENDIF();
</write>
<write>
IF(wr_cmd == `CMD_int && wr_cmdex == `CMDEX_int_real_STEP_5);
SET(wr_make_esp_commit);
SAVE(iflag, `FALSE);
SAVE(tflag, `FALSE);
SAVE(acflag, `FALSE);
SAVE(rflag, `FALSE);
// clear pipeline
SET(wr_req_reset_pr);
SET(wr_req_reset_dec);
SET(wr_req_reset_micro);
SET(wr_req_reset_rd);
SET(wr_req_reset_exe);
// finish exception/interrupt
SET(wr_exception_finished);
ENDIF();
</write>
<write>
IF(wr_cmd == `CMD_int && (wr_cmdex == `CMDEX_int_protected_STEP_0 || wr_cmdex == `CMDEX_int_protected_STEP_1 || wr_cmdex == `CMDEX_int_protected_STEP_2));
SET(wr_not_finished);
ENDIF();
</write>
<write>
IF(wr_cmd == `CMD_int_2 && wr_cmdex == `CMDEX_int_2_int_trap_gate_same_STEP_5);
SET(wr_make_esp_commit);
SAVE(iflag, (glob_param_1[20] == 1'b0)? `FALSE : iflag);
SAVE(tflag, `FALSE);
SAVE(ntflag, `FALSE);
SAVE(vmflag, `FALSE);
SAVE(rflag, `FALSE);
// clear pipeline
SET(wr_req_reset_pr);
SET(wr_req_reset_dec);
SET(wr_req_reset_micro);
SET(wr_req_reset_rd);
SET(wr_req_reset_exe);
// finish exception/interrupt
SET(wr_exception_finished);
ENDIF();
</write>
<write>
IF(wr_cmd == `CMD_int_3 && wr_cmdex == `CMDEX_int_3_int_trap_gate_more_STEP_6);
SET(wr_make_esp_commit);
SAVE(iflag, (glob_param_3[20] == 1'b0)? `FALSE : iflag); // glob_param_3 -- cs info, interrupt/trap
SAVE(tflag, `FALSE);
SAVE(ntflag, `FALSE);
SAVE(vmflag, `FALSE);
SAVE(rflag, `FALSE);
IF(v8086_mode);
SAVE(ds, 16'd0);
SAVE(ds_cache_valid, `FALSE);
SAVE(es, 16'd0);
SAVE(es_cache_valid, `FALSE);
SAVE(fs, 16'd0);
SAVE(fs_cache_valid, `FALSE);
SAVE(gs, 16'd0);
SAVE(gs_cache_valid, `FALSE);
ENDIF();
// clear pipeline
SET(wr_req_reset_pr);
SET(wr_req_reset_dec);
SET(wr_req_reset_micro);
SET(wr_req_reset_rd);
SET(wr_req_reset_exe);
// finish exception/interrupt
SET(wr_exception_finished);
ENDIF();
</write>
<write>
IF(wr_cmd == `CMD_int && (wr_cmdex == `CMDEX_int_real_STEP_0 || wr_cmdex == `CMDEX_int_real_STEP_1 || wr_cmdex == `CMDEX_int_real_STEP_2));
SET(wr_not_finished);
SET(wr_push_length_word);
SET(wr_push_ss_fault_check);
SET(wr_one_cycle_wait);
IF(~(write_for_wr_ready)); SET(wr_waiting); ENDIF();
IF(~(wr_push_ss_fault));
SET(write_stack_virtual);
SAVE(esp, wr_stack_esp);
ENDIF();
ENDIF();
</write>