Cleaned up processor.v a bit

This commit is contained in:
(Tim) Efthimis Kritikos 2023-05-16 16:29:48 +01:00
parent aca3357cda
commit f914d1ec8f
2 changed files with 22 additions and 24 deletions

View File

@ -79,7 +79,7 @@ always @(posedge valid_input) begin
end end
end end
always @(negedge set_initial_values) begin always @( set_initial_values) begin
PARAM1 <= PARAM1_INIT; PARAM1 <= PARAM1_INIT;
PARAM2 <= PARAM2_INIT; PARAM2 <= PARAM2_INIT;
end end

View File

@ -26,7 +26,6 @@
`define PROC_STATE_BITS 3 `define PROC_STATE_BITS 3
`define PROC_RESET 3'b000 `define PROC_RESET 3'b000
`define PROC_DE_STATE_ENTRY 3'b001 `define PROC_DE_STATE_ENTRY 3'b001
`define PROC_WAIT 3'b010
`define PROC_HALT 3'b011 `define PROC_HALT 3'b011
//HALT: active high //HALT: active high
@ -215,51 +214,36 @@ always @(posedge clock) begin
SIMPLE_MICRO <= 0; SIMPLE_MICRO <= 0;
proc_state <= `PROC_DE_STATE_ENTRY; proc_state <= `PROC_DE_STATE_ENTRY;
owe_set_init <= 0; owe_set_init <= 0;
set_initial_values<=0;
end end
`PROC_DE_STATE_ENTRY:begin `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 if(work==0) begin
DE_OUTPUT_sampled <= DE_OUTPUT; DE_OUTPUT_sampled <= DE_OUTPUT;
if(SIMPLE_MICRO==0||owe_set_init==1)begin if(SIMPLE_MICRO==0||owe_set_init==1)begin
valid_instruction_ack <= !valid_instruction_ack; /* This runs at the start of the execution of an 8086 instruction */
owe_set_init<=0;
set_initial_values<=0;
`ifdef DEBUG_PC_ADDRESS `ifdef DEBUG_PC_ADDRESS
$display("Running command at %04x (%08x)",INSTRUCTION_LOCATION,INSTRUCTION); $display("Running command at %04x (%08x)",INSTRUCTION_LOCATION,INSTRUCTION);
`endif `endif
`ifdef CALCULATE_IPC `ifdef CALCULATE_IPC
new_instruction <= !new_instruction; new_instruction <= !new_instruction;
`endif `endif
valid_instruction_ack <= !valid_instruction_ack;
owe_set_init<=0;
set_initial_values<= !set_initial_values;
ProgCount <= INSTRUCTION_LOCATION+{12'b0,instr_end}; ProgCount <= INSTRUCTION_LOCATION+{12'b0,instr_end};
INSTRUCTION_BUFFER<=INSTRUCTION[23:0]; INSTRUCTION_BUFFER<=INSTRUCTION[23:0];
end end
if ( (ucode_seq_addr==`UCODE_NO_INSTRUCTION) && (ucode_seq_addr_entry!=`UCODE_NO_INSTRUCTION) )begin 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; ucode_seq_addr <= ucode_seq_addr_entry;
SIMPLE_MICRO <= 1; SIMPLE_MICRO <= 1;
/*keep proc_state the same and rerun decode this time with all the data from the microcode rom*/ /*keep proc_state the same and rerun decode this time with all the data from the microcode rom*/
end else begin 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; valid_exec_data <= 1;
proc_state <= `PROC_WAIT;
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
/*switch to microcode decoding*/
ucode_seq_addr <= ucode_seq_addr_entry;
SIMPLE_MICRO <= 1;
owe_set_init <= 1;
/*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 if( SIMPLE_MICRO == 1 ) begin
ucode_seq_addr <= ucode_seq_addr_entry; /*Reused for next address*/ ucode_seq_addr <= ucode_seq_addr_entry; /*Reused for next address*/
if( ucode_seq_addr_entry == `UCODE_NO_INSTRUCTION )begin if( ucode_seq_addr_entry == `UCODE_NO_INSTRUCTION )begin
@ -268,6 +252,20 @@ always @(posedge clock) begin
end end
end end
end end
end else 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;
owe_set_init <= 1;
/*keep proc_state the same and rerun decode this time with all the data from the microcode rom*/
end
end
end else
valid_exec_data <= 0;
end
`PROC_HALT:begin `PROC_HALT:begin
end end
default:begin default:begin