|
|
@@ -4,6 +4,8 @@
|
|
|
// Provenance: recovered from agent transcript 7c830c69 (Round-2 A1 implementation)
|
|
|
// matching yosys-a1-dda.stat signals (state/service_pending/f_fire/f_next).
|
|
|
// Label: reconstructed — must pass same functional tests as A2 before fair TD.
|
|
|
+// Drain semantics (Round-3): phase always wraps when active && sum>=thr;
|
|
|
+// allow_toggle only gates the STEP toggle pulse (high-pulse drain).
|
|
|
|
|
|
module door_shared_dda_scheduler #(
|
|
|
parameter integer TRAVEL_WIDTH = 13,
|
|
|
@@ -42,19 +44,19 @@ module door_shared_dda_scheduler #(
|
|
|
{{(PHASE_WIDTH-THRESH_WIDTH){1'b0}}, phase_threshold};
|
|
|
wire [PHASE_WIDTH-1:0] thr_cal = CAL_PHASE_THRESHOLD[PHASE_WIDTH-1:0];
|
|
|
|
|
|
+ // Phase always advances/wraps when enabled; allow only gates fire.
|
|
|
function automatic [PHASE_WIDTH-1:0] f_next;
|
|
|
input [PHASE_WIDTH-1:0] ph;
|
|
|
input [RATE_WIDTH-1:0] rate;
|
|
|
input [PHASE_WIDTH-1:0] thr;
|
|
|
input en;
|
|
|
- input allow;
|
|
|
reg [PHASE_WIDTH-1:0] sum;
|
|
|
begin
|
|
|
if (!en) begin
|
|
|
f_next = {PHASE_WIDTH{1'b0}};
|
|
|
end else begin
|
|
|
sum = ph + {{(PHASE_WIDTH-RATE_WIDTH){1'b0}}, rate};
|
|
|
- if (allow && (sum >= thr))
|
|
|
+ if (sum >= thr)
|
|
|
f_next = sum - thr;
|
|
|
else
|
|
|
f_next = sum;
|
|
|
@@ -109,7 +111,7 @@ module door_shared_dda_scheduler #(
|
|
|
reg [PHASE_WIDTH-1:0] thr;
|
|
|
thr = cal_mode[0] ? thr_cal : thr_run;
|
|
|
toggle_pulse[0] <= f_fire(phase0, rate0, thr, active[0], allow_toggle[0]);
|
|
|
- phase0 <= f_next(phase0, rate0, thr, active[0], allow_toggle[0]);
|
|
|
+ phase0 <= f_next(phase0, rate0, thr, active[0]);
|
|
|
end
|
|
|
state <= ST_Y;
|
|
|
end
|
|
|
@@ -118,7 +120,7 @@ module door_shared_dda_scheduler #(
|
|
|
reg [PHASE_WIDTH-1:0] thr;
|
|
|
thr = cal_mode[1] ? thr_cal : thr_run;
|
|
|
toggle_pulse[1] <= f_fire(phase1, rate1, thr, active[1], allow_toggle[1]);
|
|
|
- phase1 <= f_next(phase1, rate1, thr, active[1], allow_toggle[1]);
|
|
|
+ phase1 <= f_next(phase1, rate1, thr, active[1]);
|
|
|
end
|
|
|
state <= ST_Z;
|
|
|
end
|
|
|
@@ -127,7 +129,7 @@ module door_shared_dda_scheduler #(
|
|
|
reg [PHASE_WIDTH-1:0] thr;
|
|
|
thr = cal_mode[2] ? thr_cal : thr_run;
|
|
|
toggle_pulse[2] <= f_fire(phase2, rate2, thr, active[2], allow_toggle[2]);
|
|
|
- phase2 <= f_next(phase2, rate2, thr, active[2], allow_toggle[2]);
|
|
|
+ phase2 <= f_next(phase2, rate2, thr, active[2]);
|
|
|
end
|
|
|
busy <= 1'b0;
|
|
|
state <= ST_IDLE;
|
|
|
@@ -135,4 +137,4 @@ module door_shared_dda_scheduler #(
|
|
|
endcase
|
|
|
end
|
|
|
end
|
|
|
-endmodule
|
|
|
+endmodule
|