diff --git a/system/execute.v b/system/execute.v index fe5ae96..ad7a324 100644 --- a/system/execute.v +++ b/system/execute.v @@ -79,7 +79,7 @@ always @(posedge valid_input) begin end end -always @(negedge set_initial_values) begin +always @( set_initial_values) begin PARAM1 <= PARAM1_INIT; PARAM2 <= PARAM2_INIT; end diff --git a/system/processor.v b/system/processor.v index a55bdee..215614a 100644 --- a/system/processor.v +++ b/system/processor.v @@ -26,7 +26,6 @@ `define PROC_STATE_BITS 3 `define PROC_RESET 3'b000 `define PROC_DE_STATE_ENTRY 3'b001 -`define PROC_WAIT 3'b010 `define PROC_HALT 3'b011 //HALT: active high @@ -215,38 +214,48 @@ always @(posedge clock) begin SIMPLE_MICRO <= 0; proc_state <= `PROC_DE_STATE_ENTRY; owe_set_init <= 0; + set_initial_values<=0; end `PROC_DE_STATE_ENTRY:begin - if(VALID_INSTRUCTION==1 || SIMPLE_MICRO == 1 ) begin + if( VALID_INSTRUCTION==1 || SIMPLE_MICRO == 1 ) begin if(work==0) begin DE_OUTPUT_sampled <= DE_OUTPUT; if(SIMPLE_MICRO==0||owe_set_init==1)begin - valid_instruction_ack <= !valid_instruction_ack; - owe_set_init<=0; - set_initial_values<=0; - + /* This runs at the start of the execution of an 8086 instruction */ `ifdef DEBUG_PC_ADDRESS $display("Running command at %04x (%08x)",INSTRUCTION_LOCATION,INSTRUCTION); `endif `ifdef CALCULATE_IPC new_instruction <= !new_instruction; `endif + valid_instruction_ack <= !valid_instruction_ack; + owe_set_init<=0; + set_initial_values<= !set_initial_values; ProgCount <= INSTRUCTION_LOCATION+{12'b0,instr_end}; INSTRUCTION_BUFFER<=INSTRUCTION[23:0]; end + if ( (ucode_seq_addr==`UCODE_NO_INSTRUCTION) && (ucode_seq_addr_entry!=`UCODE_NO_INSTRUCTION) )begin - /*switch to microcode decoding*/ + /* switch to microcode decoding */ ucode_seq_addr <= ucode_seq_addr_entry; SIMPLE_MICRO <= 1; /*keep proc_state the same and rerun decode this time with all the data from the microcode rom*/ end else begin + /* This runs at the start of each execution cycle, with microcode this is more than once per 8086 instruction */ valid_exec_data <= 1; - proc_state <= `PROC_WAIT; + if( SIMPLE_MICRO == 1 ) begin + ucode_seq_addr <= ucode_seq_addr_entry; /*Reused for next address*/ + if( ucode_seq_addr_entry == `UCODE_NO_INSTRUCTION )begin + /*Finished microcode*/ + SIMPLE_MICRO <= 0; + end + end end end else begin - if( DE_DEPENDS_ON_PREVIOUS == 0) - if ( (ucode_seq_addr==`UCODE_NO_INSTRUCTION) && (ucode_seq_addr_entry!=`UCODE_NO_INSTRUCTION) )begin + valid_exec_data <= 0; + if( DE_DEPENDS_ON_PREVIOUS == 0 ) + if ( (ucode_seq_addr==`UCODE_NO_INSTRUCTION) && (ucode_seq_addr_entry!=`UCODE_NO_INSTRUCTION) && valid_exec_data==0 )begin /*switch to microcode decoding*/ ucode_seq_addr <= ucode_seq_addr_entry; SIMPLE_MICRO <= 1; @@ -254,19 +263,8 @@ always @(posedge clock) begin /*keep proc_state the same and rerun decode this time with all the data from the microcode rom*/ end end - end - end - `PROC_WAIT:begin - set_initial_values<=1; - valid_exec_data<=0; - proc_state <= `PROC_DE_STATE_ENTRY; - if( SIMPLE_MICRO == 1 ) begin - ucode_seq_addr <= ucode_seq_addr_entry; /*Reused for next address*/ - if( ucode_seq_addr_entry == `UCODE_NO_INSTRUCTION )begin - /*Finished microcode*/ - SIMPLE_MICRO <= 0; - end - end + end else + valid_exec_data <= 0; end `PROC_HALT:begin end