Removed duplicate code and improved microcode entry

This commit is contained in:
(Tim) Efthimis Kritikos 2023-05-27 17:59:52 +01:00
parent 79d598fc64
commit d2a98c02ff

View File

@ -198,7 +198,10 @@ always @(negedge reset) begin
end end
always @(posedge reset) begin always @(posedge reset) begin
proc_state <= `PROC_RESET; proc_state <= `PROC_RESET;
valid_instruction_ack <= 0; // needs early init /* need early init */
valid_instruction_ack <= 0;
instant_response <= 0;
stalled_response <= 0;
end end
/*** Processor stages ***/ /*** Processor stages ***/
@ -216,44 +219,19 @@ reg owe_set_init;
reg VALID_INSTRUCTION_lc; reg VALID_INSTRUCTION_lc;
always @(VALID_INSTRUCTION)begin VALID_INSTRUCTION_lc<=VALID_INSTRUCTION; end always @(VALID_INSTRUCTION)begin VALID_INSTRUCTION_lc<=VALID_INSTRUCTION; end
reg instant_response, stalled_response;
reg wait_exec;
always @(next_exec) begin always @(next_exec) begin
proc_state<=`PROC_DE_STATE_ENTRY; proc_state<=`PROC_DE_STATE_ENTRY;
if ( VALID_INSTRUCTION_lc == 1 && SIMPLE_MICRO == 0 && DE_DEPENDS_ON_PREVIOUS == 0 && ucode_seq_addr_entry==`UCODE_NO_INSTRUCTION) begin if ( VALID_INSTRUCTION_lc == 1 && DE_DEPENDS_ON_PREVIOUS == 0 && ucode_seq_addr_entry==`UCODE_NO_INSTRUCTION) begin
`ifdef DEBUG_PC_ADDRESS instant_response <= !instant_response;
$display("Running command at %04x (%08x)",INSTRUCTION_LOCATION,INSTRUCTION);
`endif
`ifdef CALCULATE_IPC
new_instruction <= !new_instruction;
`endif
DE_OUTPUT_sampled <= DE_OUTPUT;
set_initial_values<= !set_initial_values;
valid_instruction_ack <= !valid_instruction_ack;
ProgCount <= INSTRUCTION_LOCATION+{12'b0,instr_end};
INSTRUCTION_BUFFER<=INSTRUCTION[23:0];
wait_exec<=1;
valid_exec_data<=!valid_exec_data;
end else begin end else begin
wait_exec<=0; wait_exec<=0;
end end
end end
reg wait_exec; always @(instant_response or stalled_response) begin
always @(posedge clock) begin
case(proc_state)
`PROC_RESET:begin
ucode_seq_addr <= `UCODE_NO_INSTRUCTION;
DE_OUTPUT_sampled <= 0;
SIMPLE_MICRO <= 0;
proc_state <= `PROC_DE_STATE_ENTRY;
owe_set_init <= 0;
set_initial_values<=0;
wait_exec<=0;
valid_exec_data<=0;
end
`PROC_DE_STATE_ENTRY:begin
if( VALID_INSTRUCTION==1 || SIMPLE_MICRO == 1 ) begin
if(wait_exec==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
@ -289,6 +267,22 @@ always @(posedge clock) begin
wait_exec<=1; wait_exec<=1;
end end
end end
always @(posedge clock) begin
case(proc_state)
`PROC_RESET:begin
ucode_seq_addr <= `UCODE_NO_INSTRUCTION;
DE_OUTPUT_sampled <= 0;
SIMPLE_MICRO <= 0;
proc_state <= `PROC_DE_STATE_ENTRY;
owe_set_init <= 0;
set_initial_values<=0;
wait_exec<=0;
valid_exec_data<=0;
end
`PROC_DE_STATE_ENTRY:begin
if ( ( VALID_INSTRUCTION==1 || SIMPLE_MICRO == 1 ) && wait_exec==0) begin
stalled_response <= !stalled_response;
end end
end end
`PROC_HALT:begin `PROC_HALT:begin