mirror of
https://github.com/NawfalMotii79/PLFM_RADAR.git
synced 2026-06-10 23:41:18 +00:00
cfar_ca: reset detect_count per frame (AUDIT-C6)
Bug: 16-bit detect_count was reset only on power-on; increments at three sites (ST_IDLE/ST_BUFFER simple-threshold paths and ST_CFAR_CMP) accumulate across frames. At 178 fps with even 2-3 average detections per frame the counter wraps in 100-180 seconds, breaking any rate-based host telemetry or health check that reads it. Fix: add `detect_count <= 16'd0` in ST_DONE so the counter represents "detections this frame" instead of cumulative-since-boot. Updated $display wording from "total detections" to "frame detections". T13 flipped from "count keeps growing" to "identical-scene frames produce identical counts" (the actual contract a per-frame counter must satisfy). TB snapshots detect_count during ST_DONE because cfar_busy only goes low on ST_IDLE entry — after the reset has fired. Verification: tb_cfar_ca 24/24 PASS, quick regression 31/31 PASS. Note: detect_count output port is now "live" (accumulates during frame, 0 between frames). Audit confirmed no current host telemetry consumes this port. If future host code needs a stable last-frame total, add a detect_count_last_frame snapshot register then.
This commit is contained in:
@@ -575,13 +575,21 @@ always @(posedge clk or negedge reset_n) begin
|
||||
// ================================================================
|
||||
// ST_DONE: Frame complete, return to idle
|
||||
// ================================================================
|
||||
// AUDIT-C6 fix: reset detect_count per-frame so it represents
|
||||
// "detections this frame" instead of "total since power-on". The
|
||||
// 16-bit counter saturates after ~6500 frames at typical detection
|
||||
// rates (tens of seconds of real traffic), breaking any rate-based
|
||||
// host telemetry that reads it.
|
||||
// ================================================================
|
||||
ST_DONE: begin
|
||||
cfar_status <= 8'd0;
|
||||
state <= ST_IDLE;
|
||||
|
||||
`ifdef SIMULATION
|
||||
$display("[CFAR] Frame complete: %0d total detections", detect_count);
|
||||
$display("[CFAR] Frame complete: %0d frame detections", detect_count);
|
||||
`endif
|
||||
|
||||
detect_count <= 16'd0;
|
||||
end
|
||||
|
||||
default: state <= ST_IDLE;
|
||||
|
||||
Reference in New Issue
Block a user