fix halt rtl logic

This commit is contained in:
2026-10-06 01:14:23 -04:00
parent e575c25c9f
commit c3391e4599
+11 -6
View File
@@ -58,23 +58,28 @@ module cpu_top (
assign result = result_src ? dsram_rdata_i : alu_result; assign result = result_src ? dsram_rdata_i : alu_result;
logic ebreak_latch; logic ebreak_latch;
logic halted_latch;
logic load_stall; logic load_stall;
logic load_stall_cycle; logic load_stall_cycle;
logic load_stall_ff; logic load_stall_ff;
assign load_stall_ff = (load_stall & ~load_stall_cycle); assign load_stall_ff = (load_stall & ~load_stall_cycle);
assign stall_core = ebreak_latch | halted_o | ~en_i | load_stall_ff; assign stall_core = halted_latch | ebreak_latch | ~en_i | load_stall_ff;
always_ff @(posedge clk_i) begin always_ff @(posedge clk_i) begin
if (rst_i) begin if (rst_i) begin
halted_o <= 1'b0; halted_o <= 1'b0;
halted_latch <= 1'b0;
load_stall_cycle <= 1'b0; load_stall_cycle <= 1'b0;
end else if (ebreak_latch) halted_o <= 1'b1; end else begin
else if (load_stall & ~load_stall_cycle) begin halted_o <= ebreak_latch & ~halted_latch;
load_stall_cycle <= 1'b1; if (ebreak_latch) halted_latch <= 1'b1;
end else if (load_stall & load_stall_cycle) begin if (load_stall & ~load_stall_cycle) begin
load_stall_cycle <= 1'b0; load_stall_cycle <= 1'b1;
end else if (load_stall & load_stall_cycle) begin
load_stall_cycle <= 1'b0;
end
end end
end end