From fa0379135df32825b405e167785bfb806ed3bb97 Mon Sep 17 00:00:00 2001 From: dylanbenzi Date: Thu, 8 Oct 2026 09:53:00 -0400 Subject: [PATCH] update halt condition fixed in design onboarding --- src/verilog/cpu/cpu_top.sv | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/verilog/cpu/cpu_top.sv b/src/verilog/cpu/cpu_top.sv index edba9bf..12e943b 100644 --- a/src/verilog/cpu/cpu_top.sv +++ b/src/verilog/cpu/cpu_top.sv @@ -58,23 +58,28 @@ module cpu_top ( assign result = result_src ? dsram_rdata_i : alu_result; logic ebreak_latch; + logic halted_latch; logic load_stall; logic load_stall_cycle; logic load_stall_ff; 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 if (rst_i) begin halted_o <= 1'b0; + halted_latch <= 1'b0; load_stall_cycle <= 1'b0; - end else if (ebreak_latch) halted_o <= 1'b1; - else if (load_stall & ~load_stall_cycle) begin - load_stall_cycle <= 1'b1; - end else if (load_stall & load_stall_cycle) begin - load_stall_cycle <= 1'b0; + end else begin + halted_o <= ebreak_latch & ~halted_latch; + if (ebreak_latch) halted_latch <= 1'b1; + if (load_stall & ~load_stall_cycle) begin + load_stall_cycle <= 1'b1; + end else if (load_stall & load_stall_cycle) begin + load_stall_cycle <= 1'b0; + end end end