소스 검색

fix(mse): atomic rate-dispatch launch + A1 drain; choose A1 winner

Close shared rate-quantum axis-tag skew with door_rate_quantum_dispatcher
(old tip FAIL / new tip PASS). Fix A1 serial-cal by firing DDA wraps without
allow_toggle so STEP high can drain. Stop A2 on PHY-8155 axis/profile
congestion evidence and keep A1 as provisional routable winner.

Co-authored-by: Cursor <cursoragent@cursor.com>
root 3 달 전
부모
커밋
d5cd0952a8

+ 2 - 0
config/prod2u_p4_verification_targets_v1.json

@@ -39,6 +39,8 @@
       "pwm_scheduler_tb",
       "pwm_scheduler_tb",
       "door_percent_planner_tb",
       "door_percent_planner_tb",
       "door_rate_quantum_builder_exhaustive_tb",
       "door_rate_quantum_builder_exhaustive_tb",
+      "door_rate_quantum_dispatch_tb",
+      "door_rate_quantum_dispatcher_cases_tb",
       "door_motion_controller_tb",
       "door_motion_controller_tb",
       "door_motion_three_axis_overlap_tb",
       "door_motion_three_axis_overlap_tb",
       "door_axis_watchdog_drain_tb",
       "door_axis_watchdog_drain_tb",

+ 1 - 0
config/source_closure.json

@@ -19,6 +19,7 @@
     "src/modules/door_calibration_sequencer.v",
     "src/modules/door_calibration_sequencer.v",
     "src/modules/door_profile_quantum_builder.v",
     "src/modules/door_profile_quantum_builder.v",
     "src/modules/door_rate_quantum_builder.v",
     "src/modules/door_rate_quantum_builder.v",
+    "src/modules/door_rate_quantum_dispatcher.v",
     "src/modules/door_shared_dda_scheduler.v",
     "src/modules/door_shared_dda_scheduler.v",
     "src/modules/door_axis_controller.v",
     "src/modules/door_axis_controller.v",
     "src/modules/door_motion_controller.v",
     "src/modules/door_motion_controller.v",

+ 15 - 12
receipts/mse-a1-a2-hierarchy-compare.json

@@ -1,30 +1,33 @@
 {
 {
   "schema": "prod2u-mse-a1-a2-hierarchy-compare-v1",
   "schema": "prod2u-mse-a1-a2-hierarchy-compare-v1",
-  "generated_utc": "2026-08-11T22:45:01Z",
+  "generated_utc": "2026-08-12T01:45:00Z",
   "method": "fullchip_td_plus_yosys_note",
   "method": "fullchip_td_plus_yosys_note",
-  "note": "A2 restored from a978ff6 as active. A1 TD pass recorded but serial_cal icarus gap remains. Winner not frozen.",
+  "note": "R4: A1 active after rate-dispatch P0 + A1 drain fix. A2 stopped on PHY-8155 (profile/axis_z mux, not DSP). Winner provisional A1 pending fresh tip TD.",
   "A1": {
   "A1": {
-    "provenance": "reconstructed",
-    "source": "receipts/scheme-a-a2-attempt/door_shared_dda_scheduler_a1.v",
-    "sha256": "e51b7228d90e216561e3fb596574add8a92061430130c493e6e5acca8805b15b",
+    "provenance": "reconstructed_active",
+    "source": "src/modules/door_shared_dda_scheduler.v",
+    "archive": "receipts/scheme-a-a2-attempt/door_shared_dda_scheduler_a1.v",
+    "sha256": "eeabe56e0a8dd236b25534a6091b2f28c75daf550bbabe709ea1bcb302a5a60b",
     "td": "receipts/mse-td-a1-f5cd525.json",
     "td": "receipts/mse-td-a1-f5cd525.json",
-    "td_status": "pass_with_icarus_gap",
+    "td_status": "prior_pass_needs_fresh_rerun",
     "fmax_mhz": 44.53,
     "fmax_mhz": 44.53,
     "mslice": 1113,
     "mslice": 1113,
-    "dsp": 1
+    "dsp": 1,
+    "total_cells": 1113
   },
   },
   "A2": {
   "A2": {
-    "provenance": "active",
-    "source": "src/modules/door_shared_dda_scheduler.v",
+    "provenance": "archived_loser",
+    "source": "receipts/scheme-a-a2-attempt/door_parallel_dda_scheduler_a2.v",
     "sha256": "5330c708999b3be8a3e5315291e9bbd450dc9da0c0ce70f00af2b606b4013fec",
     "sha256": "5330c708999b3be8a3e5315291e9bbd450dc9da0c0ce70f00af2b606b4013fec",
     "td": "receipts/mse-td-a2-dsp-a978ff6.json",
     "td": "receipts/mse-td-a2-dsp-a978ff6.json",
     "td_status": "fail_route_packing_fit",
     "td_status": "fail_route_packing_fit",
     "mslice_pack": 1082,
     "mslice_pack": 1082,
-    "dsp": 1
+    "dsp": 1,
+    "total_cells": 1082
   },
   },
-  "winner_provisional": "none_pending_functional_and_route_closure",
+  "winner_provisional": "A1",
   "rate_builder": {
   "rate_builder": {
-    "impl": "registered_multiply_dsp",
+    "impl": "registered_multiply_dsp_via_dispatcher",
     "dsp": 1
     "dsp": 1
   },
   },
   "hardware": "NOT RUN"
   "hardware": "NOT RUN"

+ 9 - 0
receipts/mse-r4-a1-serial-cal-diagnosis.json

@@ -0,0 +1,9 @@
+{
+  "schema": "prod2u-mse-r4-a1-serial-cal-diagnosis-v1",
+  "Lmax_clks_after_service_ce": 3,
+  "MOTION_SERVICE_CLKS_product": 625,
+  "verdict": "Lmax=3 < 625; accelerated SERVICE_CLKS=4 is within product bound for non-overlap, but sticky pending+overrun still required",
+  "root_cause_X_not_faulted": "A1 f_fire required allow_toggle, blocking STEP high-pulse drain when allow=0; serial TB left step stuck high so seek-close never reached MAX_CAL_STEPS",
+  "fix": "fire on wrap whenever active; axis helper gates rises",
+  "accelerated_tb": "SERVICE_CLKS=4 remains valid after drain fix; L+margin would be >=4"
+}

+ 18 - 0
receipts/mse-r4-a2-route-stop.json

@@ -0,0 +1,18 @@
+{
+  "schema": "prod2u-mse-r4-a2-route-stop-v1",
+  "decision": "A2 structurally unroutable on this device under current full design",
+  "evidence": {
+    "receipt": "receipts/mse-td-a2-dsp-a978ff6.json",
+    "run_id": "20260811T213507Z-ad8fd263",
+    "packing": "MSLICE 1082/1120 FIT",
+    "route": "PHY-8155 FAIL",
+    "violation": "x14y15_local4 nets profile/done_n1 vs axis_z/mux",
+    "rate_builder_lut": 3,
+    "dsp": 1,
+    "dda_lut": 202
+  },
+  "interpretation": "Congestion nodes are profile/axis_z mux fabric, not the rate multiplier/DSP hard block. One allowed attempt = report-driven stop; no DSP/shift-add scapegoat experiment.",
+  "attempt_count": 1,
+  "further_a2_iteration": false,
+  "hardware_validation": "NOT RUN"
+}

+ 13 - 0
receipts/mse-r4-rate-dispatch-newtip-pass.json

@@ -0,0 +1,13 @@
+{
+  "schema": "prod2u-mse-r4-rate-dispatch-newtip-pass-v1",
+  "status": "PASS",
+  "tb": "tests/sim/door_rate_quantum_dispatch_tb.v",
+  "observed": "rq=292/504/784 skew_hits=0 lvl=2/3/4",
+  "fix": "door_rate_quantum_dispatcher atomic launch record",
+  "log_tail": [
+    "Case A PASS rq=292/504/784 lvl=2/3/4",
+    "Case multi-round PASS done=82",
+    "door_rate_quantum_dispatch_tb PASS done=82 rq=292/504/784 skew_hits=0",
+    "tests/sim/door_rate_quantum_dispatch_tb.v:211: $finish called at 500000 (1ps)"
+  ]
+}

+ 13 - 0
receipts/mse-r4-rate-dispatch-oldtip-fail.json

@@ -0,0 +1,13 @@
+{
+  "schema": "prod2u-mse-r4-rate-dispatch-oldtip-fail-v1",
+  "tip": "760b2508dc1f41b2aebd92c175418c0a83c6c26f",
+  "tb": "tests/sim/door_rate_quantum_dispatch_tb.v",
+  "status": "FAIL",
+  "observed": "rq=784/292/504 exp~292/504/784 skew_hits=2666 (axis rotation)",
+  "lvl": "2/3/4",
+  "note": "Same TB against 760b2508 door_motion_controller.v without dispatcher.",
+  "log_tail": [
+    "FATAL: tests/sim/door_rate_quantum_dispatch_tb.v:183: Case A FAIL rq=784/292/504 exp~292/504/784 skew_hits=2666 done=2725 lvl=2/3/4",
+    "       Time: 16358000  Scope: door_rate_quantum_dispatch_tb.settle"
+  ]
+}

+ 16 - 0
receipts/mse-r4-winner-decision.json

@@ -0,0 +1,16 @@
+{
+  "schema": "prod2u-mse-r4-winner-decision-v1",
+  "winner": "A1",
+  "loser": "A2",
+  "reason_order": [
+    "A1 serial_cal PASS after drain fix",
+    "A1 prior full-chip TD route/timing/bitgen PASS @ f5cd525 (~44.5 MHz)",
+    "A2 packing FIT but PHY-8155 route FAIL; report points to parallel DDA/axis fabric",
+    "route FAIL = candidate FAIL; prefer reliable bitstream over ~31 MSLICE"
+  ],
+  "active_scheduler": "src/modules/door_shared_dda_scheduler.v (A1)",
+  "loser_archive": "receipts/scheme-a-a2-attempt/door_parallel_dda_scheduler_a2.v",
+  "provisional": true,
+  "note": "Winner functional after R4 P0 dispatch + A1 drain fixes; fresh TD on new tip still required before final freeze",
+  "hardware_validation": "NOT RUN"
+}

+ 6 - 4
receipts/scheme-a-a2-attempt/door_parallel_dda_scheduler_a2.v

@@ -2,7 +2,8 @@
 
 
 // Scheme A2: three parallel narrow DDA datapaths (one add/compare/sub each).
 // Scheme A2: three parallel narrow DDA datapaths (one add/compare/sub each).
 // On each motion_service_ce, all active axes update in one clock.
 // On each motion_service_ce, all active axes update in one clock.
-// allow_toggle gates wrap/fire (same semantics as reconstructed A1).
+// Rise permission is enforced in the axis STEP toggle helper; this datapath
+// always wraps when active so high pulses can still drain (!allow_rise).
 // busy is always 0 after the single service cycle (1-cycle datapath).
 // busy is always 0 after the single service cycle (1-cycle datapath).
 // service_overrun stays 0: next service cannot overlap a multi-cycle busy.
 // service_overrun stays 0: next service cannot overlap a multi-cycle busy.
 module door_shared_dda_scheduler #(
 module door_shared_dda_scheduler #(
@@ -27,6 +28,7 @@ module door_shared_dda_scheduler #(
 );
 );
     reg [PHASE_WIDTH-1:0] phase0, phase1, phase2;
     reg [PHASE_WIDTH-1:0] phase0, phase1, phase2;
     assign service_overrun = 1'b0;
     assign service_overrun = 1'b0;
+    wire _unused_allow = |allow_toggle;
 
 
     wire [PHASE_WIDTH-1:0] thr_run =
     wire [PHASE_WIDTH-1:0] thr_run =
         {{(PHASE_WIDTH-THRESH_WIDTH){1'b0}}, phase_threshold};
         {{(PHASE_WIDTH-THRESH_WIDTH){1'b0}}, phase_threshold};
@@ -51,7 +53,7 @@ module door_shared_dda_scheduler #(
                     t2 = cal_mode[2] ? thr_cal : thr_run;
                     t2 = cal_mode[2] ? thr_cal : thr_run;
                     if (active[0]) begin
                     if (active[0]) begin
                         s0 = phase0 + {{(PHASE_WIDTH-RATE_WIDTH){1'b0}}, rate0};
                         s0 = phase0 + {{(PHASE_WIDTH-RATE_WIDTH){1'b0}}, rate0};
-                        if (allow_toggle[0] && (s0 >= t0)) begin
+                        if (s0 >= t0) begin
                             toggle_pulse[0] <= 1'b1;
                             toggle_pulse[0] <= 1'b1;
                             phase0 <= s0 - t0;
                             phase0 <= s0 - t0;
                         end else begin
                         end else begin
@@ -62,7 +64,7 @@ module door_shared_dda_scheduler #(
                     end
                     end
                     if (active[1]) begin
                     if (active[1]) begin
                         s1 = phase1 + {{(PHASE_WIDTH-RATE_WIDTH){1'b0}}, rate1};
                         s1 = phase1 + {{(PHASE_WIDTH-RATE_WIDTH){1'b0}}, rate1};
-                        if (allow_toggle[1] && (s1 >= t1)) begin
+                        if (s1 >= t1) begin
                             toggle_pulse[1] <= 1'b1;
                             toggle_pulse[1] <= 1'b1;
                             phase1 <= s1 - t1;
                             phase1 <= s1 - t1;
                         end else begin
                         end else begin
@@ -73,7 +75,7 @@ module door_shared_dda_scheduler #(
                     end
                     end
                     if (active[2]) begin
                     if (active[2]) begin
                         s2 = phase2 + {{(PHASE_WIDTH-RATE_WIDTH){1'b0}}, rate2};
                         s2 = phase2 + {{(PHASE_WIDTH-RATE_WIDTH){1'b0}}, rate2};
-                        if (allow_toggle[2] && (s2 >= t2)) begin
+                        if (s2 >= t2) begin
                             toggle_pulse[2] <= 1'b1;
                             toggle_pulse[2] <= 1'b1;
                             phase2 <= s2 - t2;
                             phase2 <= s2 - t2;
                         end else begin
                         end else begin

+ 10 - 7
receipts/scheme-a-a2-attempt/door_shared_dda_scheduler_a1.v

@@ -4,8 +4,9 @@
 // Provenance: recovered from agent transcript 7c830c69 (Round-2 A1 implementation)
 // Provenance: recovered from agent transcript 7c830c69 (Round-2 A1 implementation)
 // matching yosys-a1-dda.stat signals (state/service_pending/f_fire/f_next).
 // 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.
 // 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).
+// Drain semantics (Round-4): phase always wraps when active && sum>=thr;
+// toggle fires on wrap without allow_toggle (axis helper gates rises; high drain
+// must still receive pulses). service_pending sticky + overrun when busy.
 
 
 module door_shared_dda_scheduler #(
 module door_shared_dda_scheduler #(
     parameter integer TRAVEL_WIDTH = 13,
     parameter integer TRAVEL_WIDTH = 13,
@@ -37,6 +38,7 @@ module door_shared_dda_scheduler #(
     reg [PHASE_WIDTH-1:0] phase0, phase1, phase2;
     reg [PHASE_WIDTH-1:0] phase0, phase1, phase2;
     reg service_pending;
     reg service_pending;
     reg overrun_r;
     reg overrun_r;
+    wire _unused_allow = |allow_toggle;
 
 
     assign service_overrun = overrun_r;
     assign service_overrun = overrun_r;
 
 
@@ -64,16 +66,17 @@ module door_shared_dda_scheduler #(
         end
         end
     endfunction
     endfunction
 
 
+    // Fire on wrap whenever active. Axis helper gates rises via allow_rise and
+    // always accepts a pulse to drain STEP high (!allow must not stick high).
     function automatic f_fire;
     function automatic f_fire;
         input [PHASE_WIDTH-1:0] ph;
         input [PHASE_WIDTH-1:0] ph;
         input [RATE_WIDTH-1:0]  rate;
         input [RATE_WIDTH-1:0]  rate;
         input [PHASE_WIDTH-1:0] thr;
         input [PHASE_WIDTH-1:0] thr;
         input                   en;
         input                   en;
-        input                   allow;
         reg   [PHASE_WIDTH-1:0] sum;
         reg   [PHASE_WIDTH-1:0] sum;
         begin
         begin
             sum = ph + {{(PHASE_WIDTH-RATE_WIDTH){1'b0}}, rate};
             sum = ph + {{(PHASE_WIDTH-RATE_WIDTH){1'b0}}, rate};
-            f_fire = en && allow && (sum >= thr);
+            f_fire = en && (sum >= thr);
         end
         end
     endfunction
     endfunction
 
 
@@ -111,7 +114,7 @@ module door_shared_dda_scheduler #(
                     begin : ax0
                     begin : ax0
                         reg [PHASE_WIDTH-1:0] thr;
                         reg [PHASE_WIDTH-1:0] thr;
                         thr = cal_mode[0] ? thr_cal : thr_run;
                         thr = cal_mode[0] ? thr_cal : thr_run;
-                        toggle_pulse[0] <= f_fire(phase0, rate0, thr, active[0], allow_toggle[0]);
+                        toggle_pulse[0] <= f_fire(phase0, rate0, thr, active[0]);
                         phase0 <= f_next(phase0, rate0, thr, active[0]);
                         phase0 <= f_next(phase0, rate0, thr, active[0]);
                     end
                     end
                     state <= ST_Y;
                     state <= ST_Y;
@@ -120,7 +123,7 @@ module door_shared_dda_scheduler #(
                     begin : ax1
                     begin : ax1
                         reg [PHASE_WIDTH-1:0] thr;
                         reg [PHASE_WIDTH-1:0] thr;
                         thr = cal_mode[1] ? thr_cal : thr_run;
                         thr = cal_mode[1] ? thr_cal : thr_run;
-                        toggle_pulse[1] <= f_fire(phase1, rate1, thr, active[1], allow_toggle[1]);
+                        toggle_pulse[1] <= f_fire(phase1, rate1, thr, active[1]);
                         phase1 <= f_next(phase1, rate1, thr, active[1]);
                         phase1 <= f_next(phase1, rate1, thr, active[1]);
                     end
                     end
                     state <= ST_Z;
                     state <= ST_Z;
@@ -129,7 +132,7 @@ module door_shared_dda_scheduler #(
                     begin : ax2
                     begin : ax2
                         reg [PHASE_WIDTH-1:0] thr;
                         reg [PHASE_WIDTH-1:0] thr;
                         thr = cal_mode[2] ? thr_cal : thr_run;
                         thr = cal_mode[2] ? thr_cal : thr_run;
-                        toggle_pulse[2] <= f_fire(phase2, rate2, thr, active[2], allow_toggle[2]);
+                        toggle_pulse[2] <= f_fire(phase2, rate2, thr, active[2]);
                         phase2 <= f_next(phase2, rate2, thr, active[2]);
                         phase2 <= f_next(phase2, rate2, thr, active[2]);
                     end
                     end
                     if (service_pending) begin
                     if (service_pending) begin

+ 91 - 0
receipts/scheme-a-a2-attempt/door_shared_dda_scheduler_a2_r4_pre_dispatch.v

@@ -0,0 +1,91 @@
+`timescale 1ns/1ps
+
+// Scheme A2: three parallel narrow DDA datapaths (one add/compare/sub each).
+// On each motion_service_ce, all active axes update in one clock.
+// Rise permission is enforced in the axis STEP toggle helper; this datapath
+// always wraps when active so high pulses can still drain (!allow_rise).
+// busy is always 0 after the single service cycle (1-cycle datapath).
+// service_overrun stays 0: next service cannot overlap a multi-cycle busy.
+module door_shared_dda_scheduler #(
+    parameter integer PHASE_WIDTH  = 26,
+    parameter integer RATE_WIDTH   = 21,
+    parameter integer THRESH_WIDTH = 25,
+    parameter integer CAL_PHASE_THRESHOLD = 5120
+) (
+    input  wire                         clk,
+    input  wire                         rst_n,
+    input  wire                         service_ce,
+    input  wire [2:0]                   active,
+    input  wire [2:0]                   allow_toggle,
+    input  wire [2:0]                   cal_mode,
+    input  wire [RATE_WIDTH-1:0]        rate0,
+    input  wire [RATE_WIDTH-1:0]        rate1,
+    input  wire [RATE_WIDTH-1:0]        rate2,
+    input  wire [THRESH_WIDTH-1:0]      phase_threshold,
+    output reg  [2:0]                   toggle_pulse,
+    output reg                          busy,
+    output wire                         service_overrun
+);
+    reg [PHASE_WIDTH-1:0] phase0, phase1, phase2;
+    assign service_overrun = 1'b0;
+    wire _unused_allow = |allow_toggle;
+
+    wire [PHASE_WIDTH-1:0] thr_run =
+        {{(PHASE_WIDTH-THRESH_WIDTH){1'b0}}, phase_threshold};
+    wire [PHASE_WIDTH-1:0] thr_cal = CAL_PHASE_THRESHOLD[PHASE_WIDTH-1:0];
+
+    always @(posedge clk or negedge rst_n) begin
+        if (!rst_n) begin
+            phase0 <= {PHASE_WIDTH{1'b0}};
+            phase1 <= {PHASE_WIDTH{1'b0}};
+            phase2 <= {PHASE_WIDTH{1'b0}};
+            toggle_pulse <= 3'b000;
+            busy <= 1'b0;
+        end else begin
+            toggle_pulse <= 3'b000;
+            busy <= 1'b0;
+            if (service_ce) begin
+                begin : par
+                    reg [PHASE_WIDTH-1:0] t0, t1, t2;
+                    reg [PHASE_WIDTH-1:0] s0, s1, s2;
+                    t0 = cal_mode[0] ? thr_cal : thr_run;
+                    t1 = cal_mode[1] ? thr_cal : thr_run;
+                    t2 = cal_mode[2] ? thr_cal : thr_run;
+                    if (active[0]) begin
+                        s0 = phase0 + {{(PHASE_WIDTH-RATE_WIDTH){1'b0}}, rate0};
+                        if (s0 >= t0) begin
+                            toggle_pulse[0] <= 1'b1;
+                            phase0 <= s0 - t0;
+                        end else begin
+                            phase0 <= s0;
+                        end
+                    end else begin
+                        phase0 <= {PHASE_WIDTH{1'b0}};
+                    end
+                    if (active[1]) begin
+                        s1 = phase1 + {{(PHASE_WIDTH-RATE_WIDTH){1'b0}}, rate1};
+                        if (s1 >= t1) begin
+                            toggle_pulse[1] <= 1'b1;
+                            phase1 <= s1 - t1;
+                        end else begin
+                            phase1 <= s1;
+                        end
+                    end else begin
+                        phase1 <= {PHASE_WIDTH{1'b0}};
+                    end
+                    if (active[2]) begin
+                        s2 = phase2 + {{(PHASE_WIDTH-RATE_WIDTH){1'b0}}, rate2};
+                        if (s2 >= t2) begin
+                            toggle_pulse[2] <= 1'b1;
+                            phase2 <= s2 - t2;
+                        end else begin
+                            phase2 <= s2;
+                        end
+                    end else begin
+                        phase2 <= {PHASE_WIDTH{1'b0}};
+                    end
+                end
+            end
+        end
+    end
+endmodule

+ 1 - 0
src/generated/td-source-manifest.json

@@ -208,6 +208,7 @@
     "src/modules/door_calibration_sequencer.v",
     "src/modules/door_calibration_sequencer.v",
     "src/modules/door_profile_quantum_builder.v",
     "src/modules/door_profile_quantum_builder.v",
     "src/modules/door_rate_quantum_builder.v",
     "src/modules/door_rate_quantum_builder.v",
+    "src/modules/door_rate_quantum_dispatcher.v",
     "src/modules/door_shared_dda_scheduler.v",
     "src/modules/door_shared_dda_scheduler.v",
     "src/modules/door_axis_controller.v",
     "src/modules/door_axis_controller.v",
     "src/modules/door_motion_controller.v",
     "src/modules/door_motion_controller.v",

+ 20 - 53
src/modules/door_motion_controller.v

@@ -3,7 +3,7 @@
 // Three-axis door motion: Scheme A full-feature
 // Three-axis door motion: Scheme A full-feature
 // - per-axis safety kernels
 // - per-axis safety kernels
 // - serial X→Y→Z calibration
 // - serial X→Y→Z calibration
-// - shared 25 us DDA (active A2 parallel) + shared profile/rate builders
+// - shared 25 us DDA (active A1 sequential) + shared profile/rate builders
 module door_motion_controller #(
 module door_motion_controller #(
     parameter integer MAX_CAL_STEPS = 5000,
     parameter integer MAX_CAL_STEPS = 5000,
     parameter integer MIN_TRAVEL = 2,
     parameter integer MIN_TRAVEL = 2,
@@ -94,19 +94,16 @@ module door_motion_controller #(
     wire [12:0] profile_ramp_unit_unused_z;
     wire [12:0] profile_ramp_unit_unused_z;
 
 
     // Shared rate refresh: travel * profile_scale[level] (or scale alone in cal).
     // Shared rate refresh: travel * profile_scale[level] (or scale alone in cal).
-    // Exact 21-bit product via door_rate_quantum_builder (no 13-bit shift truncate).
-    reg         rate_start;
-    reg [1:0]   rate_axis;
-    reg [12:0]  rate_travel_in;
-    reg [8:0]   rate_scale_in;
+    // Exact 21-bit product via door_rate_quantum_dispatcher (atomic launch record).
     wire        rate_busy;
     wire        rate_busy;
     wire        rate_done;
     wire        rate_done;
     wire [1:0]  rate_axis_done;
     wire [1:0]  rate_axis_done;
     wire [12:0] rate_travel_done;
     wire [12:0] rate_travel_done;
     wire [8:0]  rate_scale_done;
     wire [8:0]  rate_scale_done;
     wire [20:0] rate_result;
     wire [20:0] rate_result;
-    reg         rate_valid;
-    reg [1:0]   rate_axis_busy;
+    wire        rate_valid_x;
+    wire        rate_valid_y;
+    wire        rate_valid_z;
 
 
     function automatic [8:0] f_profile_scale;
     function automatic [8:0] f_profile_scale;
         input [3:0] level;
         input [3:0] level;
@@ -244,61 +241,31 @@ module door_motion_controller #(
         .service_overrun(dda_overrun)
         .service_overrun(dda_overrun)
     );
     );
 
 
-    // Round-robin shared rate builder (exact product module).
-    door_rate_quantum_builder u_rate_q (
+    wire [8:0] scale_x_w = f_profile_scale(crawl_x ? 4'd0 : lvl_x);
+    wire [8:0] scale_y_w = f_profile_scale(crawl_y ? 4'd0 : lvl_y);
+    wire [8:0] scale_z_w = f_profile_scale(crawl_z ? 4'd0 : lvl_z);
+
+    // Round-robin shared rate builder with atomic launch record (no axis-tag skew).
+    door_rate_quantum_dispatcher u_rate_disp (
         .clk(clk), .rst_n(rst_n),
         .clk(clk), .rst_n(rst_n),
-        .start(rate_start),
-        .axis_id_in(rate_axis),
-        .travel_in(rate_travel_in),
-        .scale_in(rate_scale_in),
+        .travel_x(st_trav_x), .travel_y(st_trav_y), .travel_z(st_trav_z),
+        .scale_x(scale_x_w),
+        .scale_y(scale_y_w),
+        .scale_z(scale_z_w),
+        .cal_x(in_cal_x), .cal_y(in_cal_y), .cal_z(in_cal_z),
         .busy(rate_busy),
         .busy(rate_busy),
         .done(rate_done),
         .done(rate_done),
+        .rate_valid_x(rate_valid_x),
+        .rate_valid_y(rate_valid_y),
+        .rate_valid_z(rate_valid_z),
         .axis_id_out(rate_axis_done),
         .axis_id_out(rate_axis_done),
         .travel_out(rate_travel_done),
         .travel_out(rate_travel_done),
         .scale_out(rate_scale_done),
         .scale_out(rate_scale_done),
         .product(rate_result)
         .product(rate_result)
     );
     );
 
 
-    always @(posedge clk or negedge rst_n) begin
-        if (!rst_n) begin
-            rate_start <= 1'b0;
-            rate_valid <= 1'b0;
-            rate_axis <= 2'd0;
-            rate_axis_busy <= 2'd0;
-            rate_travel_in <= 13'd0;
-            rate_scale_in <= 9'd0;
-        end else begin
-            rate_start <= 1'b0;
-            rate_valid <= rate_done;
-            if (rate_done)
-                rate_axis_busy <= rate_axis_done;
-            if (!rate_busy && !rate_start) begin
-                rate_start <= 1'b1;
-                case (rate_axis)
-                    2'd0: begin
-                        rate_travel_in <= in_cal_x ? 13'd1 : ((st_trav_x == 0) ? 13'd1 : st_trav_x);
-                        rate_scale_in <= f_profile_scale(crawl_x ? 4'd0 : lvl_x);
-                    end
-                    2'd1: begin
-                        rate_travel_in <= in_cal_y ? 13'd1 : ((st_trav_y == 0) ? 13'd1 : st_trav_y);
-                        rate_scale_in <= f_profile_scale(crawl_y ? 4'd0 : lvl_y);
-                    end
-                    default: begin
-                        rate_travel_in <= in_cal_z ? 13'd1 : ((st_trav_z == 0) ? 13'd1 : st_trav_z);
-                        rate_scale_in <= f_profile_scale(crawl_z ? 4'd0 : lvl_z);
-                    end
-                endcase
-                rate_axis <= (rate_axis == 2'd2) ? 2'd0 : (rate_axis + 1'b1);
-            end
-        end
-    end
-
     // Silence unused capture ports (identity checked in dedicated TB).
     // Silence unused capture ports (identity checked in dedicated TB).
-    wire _unused_rate_tags = |{rate_travel_done, rate_scale_done};
-
-    wire rate_valid_x = rate_valid && (rate_axis_busy == 2'd0);
-    wire rate_valid_y = rate_valid && (rate_axis_busy == 2'd1);
-    wire rate_valid_z = rate_valid && (rate_axis_busy == 2'd2);
+    wire _unused_rate_tags = |{rate_travel_done, rate_scale_done, rate_busy};
 
 
     door_axis_controller #(
     door_axis_controller #(
         .AXIS_ID(0),
         .AXIS_ID(0),

+ 111 - 0
src/modules/door_rate_quantum_dispatcher.v

@@ -0,0 +1,111 @@
+`timescale 1ns/1ps
+
+// Shared rate-quantum launch + builder wrapper.
+// Atomic launch record (axis/travel/scale) held stable until builder accepts.
+// Round-robin cursor (rate_next_axis) is never connected to builder axis_id_in.
+module door_rate_quantum_dispatcher (
+    input  wire        clk,
+    input  wire        rst_n,
+    input  wire [12:0] travel_x,
+    input  wire [12:0] travel_y,
+    input  wire [12:0] travel_z,
+    input  wire [8:0]  scale_x,
+    input  wire [8:0]  scale_y,
+    input  wire [8:0]  scale_z,
+    input  wire        cal_x,
+    input  wire        cal_y,
+    input  wire        cal_z,
+    output wire        busy,
+    output wire        done,
+    output wire        rate_valid_x,
+    output wire        rate_valid_y,
+    output wire        rate_valid_z,
+    output wire [1:0]  axis_id_out,
+    output wire [12:0] travel_out,
+    output wire [8:0]  scale_out,
+    output wire [20:0] product
+);
+    reg         rate_start;
+    reg [1:0]   rate_next_axis;
+    reg [1:0]   rate_launch_axis;
+    reg [12:0]  rate_launch_travel;
+    reg [8:0]   rate_launch_scale;
+    wire        rate_busy;
+    wire        rate_done;
+    wire [1:0]  rate_axis_done;
+    wire [12:0] rate_travel_done;
+    wire [8:0]  rate_scale_done;
+    wire [20:0] rate_result;
+    reg         rate_valid;
+    reg [1:0]   rate_axis_busy;
+
+    reg [12:0] travel_sel;
+    reg [8:0]  scale_sel;
+
+    always @(*) begin
+        case (rate_next_axis)
+            2'd0: begin
+                travel_sel = cal_x ? 13'd1 : ((travel_x == 0) ? 13'd1 : travel_x);
+                scale_sel = scale_x;
+            end
+            2'd1: begin
+                travel_sel = cal_y ? 13'd1 : ((travel_y == 0) ? 13'd1 : travel_y);
+                scale_sel = scale_y;
+            end
+            default: begin
+                travel_sel = cal_z ? 13'd1 : ((travel_z == 0) ? 13'd1 : travel_z);
+                scale_sel = scale_z;
+            end
+        endcase
+    end
+
+    door_rate_quantum_builder u_rate_q (
+        .clk(clk), .rst_n(rst_n),
+        .start(rate_start),
+        .axis_id_in(rate_launch_axis),
+        .travel_in(rate_launch_travel),
+        .scale_in(rate_launch_scale),
+        .busy(rate_busy),
+        .done(rate_done),
+        .axis_id_out(rate_axis_done),
+        .travel_out(rate_travel_done),
+        .scale_out(rate_scale_done),
+        .product(rate_result)
+    );
+
+    assign busy = rate_busy;
+    assign done = rate_done;
+    assign axis_id_out = rate_axis_done;
+    assign travel_out = rate_travel_done;
+    assign scale_out = rate_scale_done;
+    assign product = rate_result;
+    assign rate_valid_x = rate_valid && (rate_axis_busy == 2'd0);
+    assign rate_valid_y = rate_valid && (rate_axis_busy == 2'd1);
+    assign rate_valid_z = rate_valid && (rate_axis_busy == 2'd2);
+
+    always @(posedge clk or negedge rst_n) begin
+        if (!rst_n) begin
+            rate_start <= 1'b0;
+            rate_valid <= 1'b0;
+            rate_next_axis <= 2'd0;
+            rate_launch_axis <= 2'd0;
+            rate_launch_travel <= 13'd0;
+            rate_launch_scale <= 9'd0;
+            rate_axis_busy <= 2'd0;
+        end else begin
+            rate_start <= 1'b0;
+            rate_valid <= rate_done;
+            if (rate_done)
+                rate_axis_busy <= rate_axis_done;
+
+            // Atomic launch: hold axis/travel/scale together; cursor is not the tag.
+            if (!rate_busy && !rate_start) begin
+                rate_launch_axis <= rate_next_axis;
+                rate_launch_travel <= travel_sel;
+                rate_launch_scale <= scale_sel;
+                rate_start <= 1'b1;
+                rate_next_axis <= (rate_next_axis == 2'd2) ? 2'd0 : (rate_next_axis + 1'b1);
+            end
+        end
+    end
+endmodule

+ 103 - 44
src/modules/door_shared_dda_scheduler.v

@@ -1,12 +1,15 @@
 `timescale 1ns/1ps
 `timescale 1ns/1ps
 
 
-// Scheme A2: three parallel narrow DDA datapaths (one add/compare/sub each).
-// On each motion_service_ce, all active axes update in one clock.
-// Rise permission is enforced in the axis STEP toggle helper; this datapath
-// always wraps when active so high pulses can still drain (!allow_rise).
-// busy is always 0 after the single service cycle (1-cycle datapath).
-// service_overrun stays 0: next service cannot overlap a multi-cycle busy.
+// RECONSTRUCTED Scheme A1 sequential shared DDA (pending-queue + drain parity).
+// 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-4): phase always wraps when active && sum>=thr;
+// toggle fires on wrap without allow_toggle (axis helper gates rises; high drain
+// must still receive pulses). service_pending sticky + overrun when busy.
+
 module door_shared_dda_scheduler #(
 module door_shared_dda_scheduler #(
+    parameter integer TRAVEL_WIDTH = 13,
     parameter integer PHASE_WIDTH  = 26,
     parameter integer PHASE_WIDTH  = 26,
     parameter integer RATE_WIDTH   = 21,
     parameter integer RATE_WIDTH   = 21,
     parameter integer THRESH_WIDTH = 25,
     parameter integer THRESH_WIDTH = 25,
@@ -26,66 +29,122 @@ module door_shared_dda_scheduler #(
     output reg                          busy,
     output reg                          busy,
     output wire                         service_overrun
     output wire                         service_overrun
 );
 );
+    localparam [1:0] ST_IDLE = 2'd0,
+                     ST_X    = 2'd1,
+                     ST_Y    = 2'd2,
+                     ST_Z    = 2'd3;
+
+    reg [1:0] state;
     reg [PHASE_WIDTH-1:0] phase0, phase1, phase2;
     reg [PHASE_WIDTH-1:0] phase0, phase1, phase2;
-    assign service_overrun = 1'b0;
+    reg service_pending;
+    reg overrun_r;
     wire _unused_allow = |allow_toggle;
     wire _unused_allow = |allow_toggle;
 
 
+    assign service_overrun = overrun_r;
+
     wire [PHASE_WIDTH-1:0] thr_run =
     wire [PHASE_WIDTH-1:0] thr_run =
         {{(PHASE_WIDTH-THRESH_WIDTH){1'b0}}, phase_threshold};
         {{(PHASE_WIDTH-THRESH_WIDTH){1'b0}}, phase_threshold};
     wire [PHASE_WIDTH-1:0] thr_cal = CAL_PHASE_THRESHOLD[PHASE_WIDTH-1:0];
     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;
+        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 (sum >= thr)
+                    f_next = sum - thr;
+                else
+                    f_next = sum;
+            end
+        end
+    endfunction
+
+    // Fire on wrap whenever active. Axis helper gates rises via allow_rise and
+    // always accepts a pulse to drain STEP high (!allow must not stick high).
+    function automatic f_fire;
+        input [PHASE_WIDTH-1:0] ph;
+        input [RATE_WIDTH-1:0]  rate;
+        input [PHASE_WIDTH-1:0] thr;
+        input                   en;
+        reg   [PHASE_WIDTH-1:0] sum;
+        begin
+            sum = ph + {{(PHASE_WIDTH-RATE_WIDTH){1'b0}}, rate};
+            f_fire = en && (sum >= thr);
+        end
+    endfunction
+
     always @(posedge clk or negedge rst_n) begin
     always @(posedge clk or negedge rst_n) begin
         if (!rst_n) begin
         if (!rst_n) begin
+            state <= ST_IDLE;
             phase0 <= {PHASE_WIDTH{1'b0}};
             phase0 <= {PHASE_WIDTH{1'b0}};
             phase1 <= {PHASE_WIDTH{1'b0}};
             phase1 <= {PHASE_WIDTH{1'b0}};
             phase2 <= {PHASE_WIDTH{1'b0}};
             phase2 <= {PHASE_WIDTH{1'b0}};
             toggle_pulse <= 3'b000;
             toggle_pulse <= 3'b000;
             busy <= 1'b0;
             busy <= 1'b0;
+            service_pending <= 1'b0;
+            overrun_r <= 1'b0;
         end else begin
         end else begin
             toggle_pulse <= 3'b000;
             toggle_pulse <= 3'b000;
-            busy <= 1'b0;
+
+            // Always latch the request. Short SERVICE_CLKS TBs (e.g. 4) would
+            // otherwise drop pulses while the 3-cycle X→Y→Z walk is busy.
             if (service_ce) begin
             if (service_ce) begin
-                begin : par
-                    reg [PHASE_WIDTH-1:0] t0, t1, t2;
-                    reg [PHASE_WIDTH-1:0] s0, s1, s2;
-                    t0 = cal_mode[0] ? thr_cal : thr_run;
-                    t1 = cal_mode[1] ? thr_cal : thr_run;
-                    t2 = cal_mode[2] ? thr_cal : thr_run;
-                    if (active[0]) begin
-                        s0 = phase0 + {{(PHASE_WIDTH-RATE_WIDTH){1'b0}}, rate0};
-                        if (s0 >= t0) begin
-                            toggle_pulse[0] <= 1'b1;
-                            phase0 <= s0 - t0;
-                        end else begin
-                            phase0 <= s0;
-                        end
-                    end else begin
-                        phase0 <= {PHASE_WIDTH{1'b0}};
+                if (busy)
+                    overrun_r <= 1'b1;
+                service_pending <= 1'b1;
+            end
+
+            case (state)
+                ST_IDLE: begin
+                    busy <= 1'b0;
+                    if (service_pending) begin
+                        service_pending <= 1'b0;
+                        busy <= 1'b1;
+                        state <= ST_X;
                     end
                     end
-                    if (active[1]) begin
-                        s1 = phase1 + {{(PHASE_WIDTH-RATE_WIDTH){1'b0}}, rate1};
-                        if (s1 >= t1) begin
-                            toggle_pulse[1] <= 1'b1;
-                            phase1 <= s1 - t1;
-                        end else begin
-                            phase1 <= s1;
-                        end
-                    end else begin
-                        phase1 <= {PHASE_WIDTH{1'b0}};
+                end
+                ST_X: begin
+                    begin : ax0
+                        reg [PHASE_WIDTH-1:0] thr;
+                        thr = cal_mode[0] ? thr_cal : thr_run;
+                        toggle_pulse[0] <= f_fire(phase0, rate0, thr, active[0]);
+                        phase0 <= f_next(phase0, rate0, thr, active[0]);
                     end
                     end
-                    if (active[2]) begin
-                        s2 = phase2 + {{(PHASE_WIDTH-RATE_WIDTH){1'b0}}, rate2};
-                        if (s2 >= t2) begin
-                            toggle_pulse[2] <= 1'b1;
-                            phase2 <= s2 - t2;
-                        end else begin
-                            phase2 <= s2;
-                        end
+                    state <= ST_Y;
+                end
+                ST_Y: begin
+                    begin : ax1
+                        reg [PHASE_WIDTH-1:0] thr;
+                        thr = cal_mode[1] ? thr_cal : thr_run;
+                        toggle_pulse[1] <= f_fire(phase1, rate1, thr, active[1]);
+                        phase1 <= f_next(phase1, rate1, thr, active[1]);
+                    end
+                    state <= ST_Z;
+                end
+                default: begin
+                    begin : ax2
+                        reg [PHASE_WIDTH-1:0] thr;
+                        thr = cal_mode[2] ? thr_cal : thr_run;
+                        toggle_pulse[2] <= f_fire(phase2, rate2, thr, active[2]);
+                        phase2 <= f_next(phase2, rate2, thr, active[2]);
+                    end
+                    if (service_pending) begin
+                        service_pending <= 1'b0;
+                        busy <= 1'b1;
+                        state <= ST_X;
                     end else begin
                     end else begin
-                        phase2 <= {PHASE_WIDTH{1'b0}};
+                        busy <= 1'b0;
+                        state <= ST_IDLE;
                     end
                     end
                 end
                 end
-            end
+            endcase
         end
         end
     end
     end
 endmodule
 endmodule

+ 16 - 16
td/prod2u_p4_normal_v3.prj

@@ -10,22 +10,22 @@
     </HardWare>
     </HardWare>
     <Source_Files>
     <Source_Files>
         <Verilog>
         <Verilog>
-            <File Path="../src/generated/prod2u_door_temp_params.vh"><FileInfo><Attr Name="UsedInSyn" Val="true"/><Attr Name="UsedInP&amp;R" Val="true"/><Attr Name="BelongTo" Val="design_1"/><Attr Name="CompileOrder" Val="1"/></FileInfo></File>
-            <File Path="../src/common/uart_rx_byte.v"><FileInfo><Attr Name="UsedInSyn" Val="true"/><Attr Name="UsedInP&amp;R" Val="true"/><Attr Name="BelongTo" Val="design_1"/><Attr Name="CompileOrder" Val="2"/></FileInfo></File>
-            <File Path="../src/common/uart_tx_byte.v"><FileInfo><Attr Name="UsedInSyn" Val="true"/><Attr Name="UsedInP&amp;R" Val="true"/><Attr Name="BelongTo" Val="design_1"/><Attr Name="CompileOrder" Val="3"/></FileInfo></File>
-            <File Path="../src/common/crc16_serial.v"><FileInfo><Attr Name="UsedInSyn" Val="true"/><Attr Name="UsedInP&amp;R" Val="true"/><Attr Name="BelongTo" Val="design_1"/><Attr Name="CompileOrder" Val="4"/></FileInfo></File>
-            <File Path="../src/common/frame_rx.v"><FileInfo><Attr Name="UsedInSyn" Val="true"/><Attr Name="UsedInP&amp;R" Val="true"/><Attr Name="BelongTo" Val="design_1"/><Attr Name="CompileOrder" Val="5"/></FileInfo></File>
-            <File Path="../src/common/frame_tx.v"><FileInfo><Attr Name="UsedInSyn" Val="true"/><Attr Name="UsedInP&amp;R" Val="true"/><Attr Name="BelongTo" Val="design_1"/><Attr Name="CompileOrder" Val="6"/></FileInfo></File>
-            <File Path="../src/common/payload_ram.v"><FileInfo><Attr Name="UsedInSyn" Val="true"/><Attr Name="UsedInP&amp;R" Val="true"/><Attr Name="BelongTo" Val="design_1"/><Attr Name="CompileOrder" Val="7"/></FileInfo></File>
-            <File Path="../src/modules/output_target_ram.v"><FileInfo><Attr Name="UsedInSyn" Val="true"/><Attr Name="UsedInP&amp;R" Val="true"/><Attr Name="BelongTo" Val="design_1"/><Attr Name="CompileOrder" Val="8"/></FileInfo></File>
-            <File Path="../src/modules/pwm_scheduler.v"><FileInfo><Attr Name="UsedInSyn" Val="true"/><Attr Name="UsedInP&amp;R" Val="true"/><Attr Name="BelongTo" Val="design_1"/><Attr Name="CompileOrder" Val="9"/></FileInfo></File>
-            <File Path="../src/modules/shared_500us_tick.v"><FileInfo><Attr Name="UsedInSyn" Val="true"/><Attr Name="UsedInP&amp;R" Val="true"/><Attr Name="BelongTo" Val="design_1"/><Attr Name="CompileOrder" Val="10"/></FileInfo></File>
-            <File Path="../src/modules/host_watchdog.v"><FileInfo><Attr Name="UsedInSyn" Val="true"/><Attr Name="UsedInP&amp;R" Val="true"/><Attr Name="BelongTo" Val="design_1"/><Attr Name="CompileOrder" Val="11"/></FileInfo></File>
-            <File Path="../src/modules/door_percent_planner.v"><FileInfo><Attr Name="UsedInSyn" Val="true"/><Attr Name="UsedInP&amp;R" Val="true"/><Attr Name="BelongTo" Val="design_1"/><Attr Name="CompileOrder" Val="12"/></FileInfo></File>
-            <File Path="../src/modules/door_motion_service_tick.v"><FileInfo><Attr Name="UsedInSyn" Val="true"/><Attr Name="UsedInP&amp;R" Val="true"/><Attr Name="BelongTo" Val="design_1"/><Attr Name="CompileOrder" Val="13"/></FileInfo></File>
-            <File Path="../src/modules/door_calibration_sequencer.v"><FileInfo><Attr Name="UsedInSyn" Val="true"/><Attr Name="UsedInP&amp;R" Val="true"/><Attr Name="BelongTo" Val="design_1"/><Attr Name="CompileOrder" Val="14"/></FileInfo></File>
-            <File Path="../src/modules/door_profile_quantum_builder.v"><FileInfo><Attr Name="UsedInSyn" Val="true"/><Attr Name="UsedInP&amp;R" Val="true"/><Attr Name="BelongTo" Val="design_1"/><Attr Name="CompileOrder" Val="15"/></FileInfo></File>
-            <File Path="../src/modules/door_rate_quantum_builder.v"><FileInfo><Attr Name="UsedInSyn" Val="true"/><Attr Name="UsedInP&amp;R" Val="true"/><Attr Name="BelongTo" Val="design_1"/><Attr Name="CompileOrder" Val="16"/></FileInfo></File>
+            <File Path="../src/generated/prod2u_door_temp_params.vh"><FileInfo><Attr Name="UsedInSyn" Val="true"/><Attr Name="UsedInP&amp;R" Val="true"/><Attr Name="BelongTo" Val="design_1"/><Attr Name="CompileOrder" Val="0"/></FileInfo></File>
+            <File Path="../src/common/uart_rx_byte.v"><FileInfo><Attr Name="UsedInSyn" Val="true"/><Attr Name="UsedInP&amp;R" Val="true"/><Attr Name="BelongTo" Val="design_1"/><Attr Name="CompileOrder" Val="1"/></FileInfo></File>
+            <File Path="../src/common/uart_tx_byte.v"><FileInfo><Attr Name="UsedInSyn" Val="true"/><Attr Name="UsedInP&amp;R" Val="true"/><Attr Name="BelongTo" Val="design_1"/><Attr Name="CompileOrder" Val="2"/></FileInfo></File>
+            <File Path="../src/common/crc16_serial.v"><FileInfo><Attr Name="UsedInSyn" Val="true"/><Attr Name="UsedInP&amp;R" Val="true"/><Attr Name="BelongTo" Val="design_1"/><Attr Name="CompileOrder" Val="3"/></FileInfo></File>
+            <File Path="../src/common/frame_rx.v"><FileInfo><Attr Name="UsedInSyn" Val="true"/><Attr Name="UsedInP&amp;R" Val="true"/><Attr Name="BelongTo" Val="design_1"/><Attr Name="CompileOrder" Val="4"/></FileInfo></File>
+            <File Path="../src/common/frame_tx.v"><FileInfo><Attr Name="UsedInSyn" Val="true"/><Attr Name="UsedInP&amp;R" Val="true"/><Attr Name="BelongTo" Val="design_1"/><Attr Name="CompileOrder" Val="5"/></FileInfo></File>
+            <File Path="../src/common/payload_ram.v"><FileInfo><Attr Name="UsedInSyn" Val="true"/><Attr Name="UsedInP&amp;R" Val="true"/><Attr Name="BelongTo" Val="design_1"/><Attr Name="CompileOrder" Val="6"/></FileInfo></File>
+            <File Path="../src/modules/output_target_ram.v"><FileInfo><Attr Name="UsedInSyn" Val="true"/><Attr Name="UsedInP&amp;R" Val="true"/><Attr Name="BelongTo" Val="design_1"/><Attr Name="CompileOrder" Val="7"/></FileInfo></File>
+            <File Path="../src/modules/pwm_scheduler.v"><FileInfo><Attr Name="UsedInSyn" Val="true"/><Attr Name="UsedInP&amp;R" Val="true"/><Attr Name="BelongTo" Val="design_1"/><Attr Name="CompileOrder" Val="8"/></FileInfo></File>
+            <File Path="../src/modules/shared_500us_tick.v"><FileInfo><Attr Name="UsedInSyn" Val="true"/><Attr Name="UsedInP&amp;R" Val="true"/><Attr Name="BelongTo" Val="design_1"/><Attr Name="CompileOrder" Val="9"/></FileInfo></File>
+            <File Path="../src/modules/host_watchdog.v"><FileInfo><Attr Name="UsedInSyn" Val="true"/><Attr Name="UsedInP&amp;R" Val="true"/><Attr Name="BelongTo" Val="design_1"/><Attr Name="CompileOrder" Val="10"/></FileInfo></File>
+            <File Path="../src/modules/door_percent_planner.v"><FileInfo><Attr Name="UsedInSyn" Val="true"/><Attr Name="UsedInP&amp;R" Val="true"/><Attr Name="BelongTo" Val="design_1"/><Attr Name="CompileOrder" Val="11"/></FileInfo></File>
+            <File Path="../src/modules/door_motion_service_tick.v"><FileInfo><Attr Name="UsedInSyn" Val="true"/><Attr Name="UsedInP&amp;R" Val="true"/><Attr Name="BelongTo" Val="design_1"/><Attr Name="CompileOrder" Val="12"/></FileInfo></File>
+            <File Path="../src/modules/door_calibration_sequencer.v"><FileInfo><Attr Name="UsedInSyn" Val="true"/><Attr Name="UsedInP&amp;R" Val="true"/><Attr Name="BelongTo" Val="design_1"/><Attr Name="CompileOrder" Val="13"/></FileInfo></File>
+            <File Path="../src/modules/door_profile_quantum_builder.v"><FileInfo><Attr Name="UsedInSyn" Val="true"/><Attr Name="UsedInP&amp;R" Val="true"/><Attr Name="BelongTo" Val="design_1"/><Attr Name="CompileOrder" Val="14"/></FileInfo></File>
+            <File Path="../src/modules/door_rate_quantum_builder.v"><FileInfo><Attr Name="UsedInSyn" Val="true"/><Attr Name="UsedInP&amp;R" Val="true"/><Attr Name="BelongTo" Val="design_1"/><Attr Name="CompileOrder" Val="15"/></FileInfo></File><File Path="../src/modules/door_rate_quantum_dispatcher.v"><FileInfo><Attr Name="UsedInSyn" Val="true"/><Attr Name="UsedInP&amp;R" Val="true"/><Attr Name="BelongTo" Val="design_1"/><Attr Name="CompileOrder" Val="16"/></FileInfo></File>
             <File Path="../src/modules/door_shared_dda_scheduler.v"><FileInfo><Attr Name="UsedInSyn" Val="true"/><Attr Name="UsedInP&amp;R" Val="true"/><Attr Name="BelongTo" Val="design_1"/><Attr Name="CompileOrder" Val="17"/></FileInfo></File>
             <File Path="../src/modules/door_shared_dda_scheduler.v"><FileInfo><Attr Name="UsedInSyn" Val="true"/><Attr Name="UsedInP&amp;R" Val="true"/><Attr Name="BelongTo" Val="design_1"/><Attr Name="CompileOrder" Val="17"/></FileInfo></File>
             <File Path="../src/modules/door_axis_controller.v"><FileInfo><Attr Name="UsedInSyn" Val="true"/><Attr Name="UsedInP&amp;R" Val="true"/><Attr Name="BelongTo" Val="design_1"/><Attr Name="CompileOrder" Val="18"/></FileInfo></File>
             <File Path="../src/modules/door_axis_controller.v"><FileInfo><Attr Name="UsedInSyn" Val="true"/><Attr Name="UsedInP&amp;R" Val="true"/><Attr Name="BelongTo" Val="design_1"/><Attr Name="CompileOrder" Val="18"/></FileInfo></File>
             <File Path="../src/modules/door_motion_controller.v"><FileInfo><Attr Name="UsedInSyn" Val="true"/><Attr Name="UsedInP&amp;R" Val="true"/><Attr Name="BelongTo" Val="design_1"/><Attr Name="CompileOrder" Val="19"/></FileInfo></File>
             <File Path="../src/modules/door_motion_controller.v"><FileInfo><Attr Name="UsedInSyn" Val="true"/><Attr Name="UsedInP&amp;R" Val="true"/><Attr Name="BelongTo" Val="design_1"/><Attr Name="CompileOrder" Val="19"/></FileInfo></File>

+ 1 - 100
td/syn/prod2u_p4_normal_v3.tcl

@@ -1,7 +1,3 @@
-import_device ef2_4.db -package EF2L45BG256B
-set_param rtl directive:async_reg on
-set_param place async_reg on
-
 analyze -file {src/generated/prod2u_door_temp_params.vh}
 analyze -file {src/generated/prod2u_door_temp_params.vh}
 analyze -file {src/common/uart_rx_byte.v}
 analyze -file {src/common/uart_rx_byte.v}
 analyze -file {src/common/uart_tx_byte.v}
 analyze -file {src/common/uart_tx_byte.v}
@@ -18,6 +14,7 @@ analyze -file {src/modules/door_motion_service_tick.v}
 analyze -file {src/modules/door_calibration_sequencer.v}
 analyze -file {src/modules/door_calibration_sequencer.v}
 analyze -file {src/modules/door_profile_quantum_builder.v}
 analyze -file {src/modules/door_profile_quantum_builder.v}
 analyze -file {src/modules/door_rate_quantum_builder.v}
 analyze -file {src/modules/door_rate_quantum_builder.v}
+analyze -file {src/modules/door_rate_quantum_dispatcher.v}
 analyze -file {src/modules/door_shared_dda_scheduler.v}
 analyze -file {src/modules/door_shared_dda_scheduler.v}
 analyze -file {src/modules/door_axis_controller.v}
 analyze -file {src/modules/door_axis_controller.v}
 analyze -file {src/modules/door_motion_controller.v}
 analyze -file {src/modules/door_motion_controller.v}
@@ -30,99 +27,3 @@ analyze -file {src/project/project_adapter.v}
 analyze -file {src/rtl/prod2u_por.v}
 analyze -file {src/rtl/prod2u_por.v}
 analyze -file {src/rtl/prod2u_p4_i2c_stop_start_read.v}
 analyze -file {src/rtl/prod2u_p4_i2c_stop_start_read.v}
 analyze -file {src/top/prod2u_p4_normal_v3_top.v}
 analyze -file {src/top/prod2u_p4_normal_v3_top.v}
-
-elaborate -top {prod2u_p4_normal_v3_top}
-read_adc {constraints/prod2u_p4_normal_v3.adc}
-optimize_rtl
-read_sdc {constraints/prod2u_p4_normal_v3.sdc}
-
-proc p4_find_unique_regs {patterns} {
-    set matches {}
-    foreach pattern $patterns {
-        foreach reg [get_regs -quiet $pattern] {
-            if {[lsearch -exact $matches $reg] < 0} { lappend matches $reg }
-        }
-    }
-    return $matches
-}
-
-set cdc_specs {
-    {uart_rx_0 {{u_uart_rx/rx_sync_pipe\[0\]} {*/u_uart_rx/rx_sync_pipe\[0\]}} u_uart_rx/rx_sync_pipe[0]}
-    {uart_rx_1 {{u_uart_rx/rx_sync_pipe\[1\]} {*/u_uart_rx/rx_sync_pipe\[1\]}} u_uart_rx/rx_sync_pipe[1]}
-    {i2c_scl_0 {{u_temperature_i2c/impl/scl_sync\[0\]} {*/u_temperature_i2c/impl/scl_sync\[0\]}} u_temperature_i2c/scl_sync[0]}
-    {i2c_scl_1 {{u_temperature_i2c/impl/scl_sync\[1\]} {*/u_temperature_i2c/impl/scl_sync\[1\]}} u_temperature_i2c/scl_sync[1]}
-    {i2c_sda_0 {{u_temperature_i2c/impl/sda_sync\[0\]} {*/u_temperature_i2c/impl/sda_sync\[0\]}} u_temperature_i2c/sda_sync[0]}
-    {i2c_sda_1 {{u_temperature_i2c/impl/sda_sync\[1\]} {*/u_temperature_i2c/impl/sda_sync\[1\]}} u_temperature_i2c/sda_sync[1]}
-    {x_limit_ls_0 {{x_limit_ls_sync0}} x_limit_ls_sync0}
-    {x_limit_ls_1 {{x_limit_ls_sync1}} x_limit_ls_sync1}
-    {x_limit_hs_0 {{x_limit_hs_sync0}} x_limit_hs_sync0}
-    {x_limit_hs_1 {{x_limit_hs_sync1}} x_limit_hs_sync1}
-    {y_limit_ls_0 {{y_limit_ls_sync0}} y_limit_ls_sync0}
-    {y_limit_ls_1 {{y_limit_ls_sync1}} y_limit_ls_sync1}
-    {y_limit_hs_0 {{y_limit_hs_sync0}} y_limit_hs_sync0}
-    {y_limit_hs_1 {{y_limit_hs_sync1}} y_limit_hs_sync1}
-    {z_limit_ls_0 {{z_limit_ls_sync0}} z_limit_ls_sync0}
-    {z_limit_ls_1 {{z_limit_ls_sync1}} z_limit_ls_sync1}
-    {z_limit_hs_0 {{z_limit_hs_sync0}} z_limit_hs_sync0}
-    {z_limit_hs_1 {{z_limit_hs_sync1}} z_limit_hs_sync1}
-}
-set cdc_report [open {prod2u_p4_normal_v3_cdc.rpt} w]
-puts $cdc_report {schema=prod2u-p4-normal-v3-cdc-v2}
-set cdc_failures {}
-set cdc_actual {}
-foreach group $cdc_specs {
-    lassign $group name patterns normalized
-    set matches [p4_find_unique_regs $patterns]
-    if {[llength $matches] != 1} {
-        lappend cdc_failures "$name:[llength $matches]"
-        puts $cdc_report "structural_failure=$name:[llength $matches]"
-    } else {
-        set reg [lindex $matches 0]
-        lappend cdc_actual $normalized
-        set_property async_reg true $reg
-        puts $cdc_report "retained_sync_register=$normalized"
-    }
-}
-if {[llength $cdc_actual] != 18} {
-    lappend cdc_failures "sync_total:[llength $cdc_actual]"
-}
-set false_path_pairs {
-    {host_uart_rx {u_uart_rx/rx_sync_pipe\[0\]} u_uart_rx/rx_sync_pipe[0]}
-    {temp_scl {u_temperature_i2c/impl/scl_sync\[0\]} u_temperature_i2c/scl_sync[0]}
-    {temp_sda {u_temperature_i2c/impl/sda_sync\[0\]} u_temperature_i2c/sda_sync[0]}
-    {x_limit_ls {x_limit_ls_sync0} x_limit_ls_sync0}
-    {x_limit_hs {x_limit_hs_sync0} x_limit_hs_sync0}
-    {y_limit_ls {y_limit_ls_sync0} y_limit_ls_sync0}
-    {y_limit_hs {y_limit_hs_sync0} y_limit_hs_sync0}
-    {z_limit_ls {z_limit_ls_sync0} z_limit_ls_sync0}
-    {z_limit_hs {z_limit_hs_sync0} z_limit_hs_sync0}
-}
-foreach pair $false_path_pairs {
-    lassign $pair source endpoint_pattern normalized
-    set source_obj [get_ports -quiet $source]
-    set endpoint_obj [get_regs -quiet $endpoint_pattern]
-    if {[llength $source_obj] == 1 && [llength $endpoint_obj] == 1} {
-        set_false_path -from $source_obj -to $endpoint_obj
-        puts $cdc_report "false_path_endpoint=$normalized"
-    } else {
-        lappend cdc_failures "false_path_object_count:$source:[llength $source_obj]:$normalized:[llength $endpoint_obj]"
-        puts $cdc_report "structural_failure=false_path_object_count:$source:[llength $source_obj]:$normalized:[llength $endpoint_obj]"
-    }
-}
-if {[llength $cdc_failures] != 0} {
-    foreach failure $cdc_failures {
-        puts $cdc_report "structural_failure=$failure"
-    }
-    close $cdc_report
-    error "PROD2U_P4_NORMAL_V3_CDC_GATE_FAIL:[join $cdc_failures ,]"
-}
-close $cdc_report
-puts "CDC_GATE_PASS=1"
-
-report_area -io_info -file prod2u_p4_normal_v3_rtl.area
-export_db prod2u_p4_normal_v3_rtl.db
-set_param gate opt_area high
-set_param gate pack_effort high
-optimize_gate prod2u_p4_normal_v3_gate.area
-report_area -io_info -file prod2u_p4_normal_v3_gate.area
-export_db prod2u_p4_normal_v3_gate.db

+ 213 - 0
tests/sim/door_rate_quantum_dispatch_tb.v

@@ -0,0 +1,213 @@
+`timescale 1ns/1ps
+
+// Production rate-dispatch integration TB.
+// Instantiates door_motion_controller (dispatcher + builder), not builder alone.
+// Asserts axis tags match travel and rq == travel * profile_scale[level].
+module door_rate_quantum_dispatch_tb;
+    reg clk = 1'b0;
+    reg rst_n = 1'b0;
+    reg tick_500us = 1'b0;
+    reg limit_sync_valid = 1'b0;
+    reg [2:0] open_limit = 3'b000;
+    reg [2:0] close_limit = 3'b111;
+    reg [2:0] gated_step = 3'b000;
+    reg [2:0] gated_step_rise = 3'b000;
+    wire [2:0] step, dir_close;
+    wire startup_complete;
+    wire [2:0] calibrated_mask, fault_mask;
+
+    integer done_count;
+    integer skew_hits;
+    integer t;
+    integer r;
+    integer u;
+    integer match_streak;
+    integer done_before;
+    integer rr;
+    integer exp_x;
+    integer exp_y;
+    integer exp_z;
+
+    always #1 clk = ~clk;
+
+    function [8:0] f_scale;
+        input [3:0] level;
+        input crawl;
+        begin
+            if (crawl) f_scale = 9'd64;
+            else begin
+                case (level)
+                    4'd0:  f_scale = 9'd64;
+                    4'd1:  f_scale = 9'd66;
+                    4'd2:  f_scale = 9'd73;
+                    4'd3:  f_scale = 9'd84;
+                    4'd4:  f_scale = 9'd98;
+                    4'd5:  f_scale = 9'd114;
+                    4'd6:  f_scale = 9'd132;
+                    4'd7:  f_scale = 9'd150;
+                    4'd8:  f_scale = 9'd170;
+                    4'd9:  f_scale = 9'd188;
+                    4'd10: f_scale = 9'd206;
+                    4'd11: f_scale = 9'd222;
+                    4'd12: f_scale = 9'd236;
+                    4'd13: f_scale = 9'd247;
+                    4'd14: f_scale = 9'd254;
+                    default: f_scale = 9'd256;
+                endcase
+            end
+        end
+    endfunction
+
+    door_motion_controller #(
+        .MAX_CAL_STEPS(32), .MIN_TRAVEL(2), .ENDPOINT_GUARD_EXTRA(8),
+        .DIR_SETUP_TICKS(1), .PERCENT_MAX(100),
+        .MOTION_SERVICE_CLKS(4), .PHASE_FACTOR(64), .CAL_RAMP_UNIT(2)
+    ) dut (
+        .clk(clk), .rst_n(rst_n), .tick_500us(tick_500us),
+        .limit_sync_valid(limit_sync_valid),
+        .open_limit(open_limit), .close_limit(close_limit),
+        .gated_step(gated_step), .gated_step_rise(gated_step_rise),
+        .motor_request_valid(1'b0),
+        .percent_x(8'd0), .percent_y(8'd0), .percent_z(8'd0),
+        .watchdog_stop(1'b0), .watchdog_tripped(1'b0),
+        .step(step), .dir_close(dir_close),
+        .startup_complete(startup_complete),
+        .calibrated_mask(calibrated_mask), .fault_mask(fault_mask),
+        .status_capture(1'b0), .status_rd_addr(8'd0), .status_rd_data()
+    );
+
+    always @(posedge clk) begin
+        if (rst_n && dut.rate_done) begin
+            done_count = done_count + 1;
+            if (dut.rate_result !== (dut.rate_travel_done * dut.rate_scale_done))
+                $fatal(1, "product mismatch axis=%0d t=%0d s=%0d p=%0d",
+                    dut.rate_axis_done, dut.rate_travel_done, dut.rate_scale_done,
+                    dut.rate_result);
+            if (startup_complete && !dut.in_cal_x && !dut.in_cal_y && !dut.in_cal_z) begin
+                if (dut.rate_axis_done == 2'd0 && dut.st_trav_x != 0 &&
+                    dut.rate_travel_done != dut.st_trav_x)
+                    skew_hits = skew_hits + 1;
+                if (dut.rate_axis_done == 2'd1 && dut.st_trav_y != 0 &&
+                    dut.rate_travel_done != dut.st_trav_y)
+                    skew_hits = skew_hits + 1;
+                if (dut.rate_axis_done == 2'd2 && dut.st_trav_z != 0 &&
+                    dut.rate_travel_done != dut.st_trav_z)
+                    skew_hits = skew_hits + 1;
+            end
+        end
+    end
+
+    task pulse_tick;
+        begin @(negedge clk); tick_500us = 1'b1; @(negedge clk); tick_500us = 1'b0; end
+    endtask
+    task force_rise;
+        input integer ax;
+        reg [2:0] m;
+        begin
+            m = 3'b001 << ax;
+            @(negedge clk); gated_step = gated_step | m; gated_step_rise = m;
+            @(negedge clk); gated_step_rise = 3'b0; gated_step = gated_step & ~m;
+        end
+    endtask
+    task wait_step;
+        input integer ax;
+        input want;
+        begin
+            for (t = 0; t < 10000; t = t + 1) begin
+                if (step[ax] === want) disable wait_step;
+                @(negedge clk);
+            end
+            $fatal(1, "timeout step ax=%0d want=%0d", ax, want);
+        end
+    endtask
+    task cal_ok;
+        input integer ax;
+        input integer travel;
+        begin
+            close_limit[ax] = 1'b1; open_limit[ax] = 1'b0;
+            repeat (4) pulse_tick();
+            for (r = 0; r < travel; r = r + 1) begin
+                wait_step(ax, 1); force_rise(ax); wait_step(ax, 0);
+            end
+            @(negedge clk); open_limit[ax] = 1'b1; close_limit[ax] = 1'b0;
+            begin : w
+                for (t = 0; t < 8000; t = t + 1) begin
+                    if (calibrated_mask[ax]) disable w;
+                    @(negedge clk);
+                end
+                $fatal(1, "cal ax=%0d", ax);
+            end
+        end
+    endtask
+
+    initial begin
+        #30_000_000 $fatal(1, "door_rate_quantum_dispatch_tb timeout");
+    end
+
+    initial begin
+        done_count = 0;
+        skew_hits = 0;
+        repeat (2) @(posedge clk); rst_n = 1'b1;
+        @(negedge clk); limit_sync_valid = 1'b1;
+
+        // Travels 4/6/8: on old tip axis tags rotate (skew_hits>0 / wrong rq mapping).
+        cal_ok(0, 4);
+        cal_ok(1, 6);
+        cal_ok(2, 8);
+        begin : ws
+            for (u = 0; u < 8000; u = u + 1) begin
+                if (startup_complete) disable ws;
+                @(negedge clk);
+            end
+            $fatal(1, "startup");
+        end
+
+        match_streak = 0;
+        begin : settle
+            for (t = 0; t < 8000; t = t + 1) begin
+                exp_x = dut.st_trav_x * f_scale(dut.lvl_x, dut.crawl_x);
+                exp_y = dut.st_trav_y * f_scale(dut.lvl_y, dut.crawl_y);
+                exp_z = dut.st_trav_z * f_scale(dut.lvl_z, dut.crawl_z);
+                if (dut.rq_x == exp_x[20:0] && dut.rq_y == exp_y[20:0] &&
+                    dut.rq_z == exp_z[20:0] &&
+                    !dut.in_cal_x && !dut.in_cal_y && !dut.in_cal_z &&
+                    dut.st_trav_x == 13'd4 && dut.st_trav_y == 13'd6 &&
+                    dut.st_trav_z == 13'd8) begin
+                    match_streak = match_streak + 1;
+                    if (match_streak >= 8) disable settle;
+                end else begin
+                    match_streak = 0;
+                end
+                @(negedge clk);
+            end
+            $fatal(1, "Case A FAIL rq=%0d/%0d/%0d exp~%0d/%0d/%0d skew_hits=%0d done=%0d lvl=%0d/%0d/%0d",
+                dut.rq_x, dut.rq_y, dut.rq_z, exp_x, exp_y, exp_z, skew_hits, done_count,
+                dut.lvl_x, dut.lvl_y, dut.lvl_z);
+        end
+        if (skew_hits != 0)
+            $fatal(1, "Case A skew_hits=%0d", skew_hits);
+        $display("Case A PASS rq=%0d/%0d/%0d lvl=%0d/%0d/%0d",
+            dut.rq_x, dut.rq_y, dut.rq_z, dut.lvl_x, dut.lvl_y, dut.lvl_z);
+
+        done_before = done_count;
+        for (rr = 0; rr < 64; rr = rr + 1)
+            @(negedge clk);
+        if (done_count < done_before + 3)
+            $fatal(1, "multi-round refresh delta=%0d", done_count - done_before);
+        exp_x = dut.st_trav_x * f_scale(dut.lvl_x, dut.crawl_x);
+        exp_y = dut.st_trav_y * f_scale(dut.lvl_y, dut.crawl_y);
+        exp_z = dut.st_trav_z * f_scale(dut.lvl_z, dut.crawl_z);
+        if (!(dut.rq_x == exp_x[20:0] && dut.rq_y == exp_y[20:0] && dut.rq_z == exp_z[20:0]))
+            $fatal(1, "multi-round drift rq=%0d/%0d/%0d", dut.rq_x, dut.rq_y, dut.rq_z);
+        if (skew_hits != 0)
+            $fatal(1, "multi-round skew_hits=%0d", skew_hits);
+        $display("Case multi-round PASS done=%0d", done_count);
+
+        if (dut.in_cal_x || dut.in_cal_y || dut.in_cal_z)
+            $fatal(1, "still in cal");
+
+        $display("door_rate_quantum_dispatch_tb PASS done=%0d rq=%0d/%0d/%0d skew_hits=%0d",
+            done_count, dut.rq_x, dut.rq_y, dut.rq_z, skew_hits);
+        $finish;
+    end
+endmodule

+ 152 - 0
tests/sim/door_rate_quantum_dispatcher_cases_tb.v

@@ -0,0 +1,152 @@
+`timescale 1ns/1ps
+
+// Direct production dispatcher TB: Cases A-F with explicit travel/scale.
+module door_rate_quantum_dispatcher_cases_tb;
+    reg clk = 1'b0;
+    reg rst_n = 1'b0;
+    reg [12:0] travel_x = 13'd0, travel_y = 13'd0, travel_z = 13'd0;
+    reg [8:0] scale_x = 9'd64, scale_y = 9'd64, scale_z = 9'd64;
+    reg cal_x = 1'b0, cal_y = 1'b0, cal_z = 1'b0;
+    wire busy, done;
+    wire rate_valid_x, rate_valid_y, rate_valid_z;
+    wire [1:0] axis_id_out;
+    wire [12:0] travel_out;
+    wire [8:0] scale_out;
+    wire [20:0] product;
+    reg [20:0] rq_x, rq_y, rq_z;
+
+    integer t;
+    integer done_n;
+    integer i;
+
+    always #1 clk = ~clk;
+
+    door_rate_quantum_dispatcher dut (
+        .clk(clk), .rst_n(rst_n),
+        .travel_x(travel_x), .travel_y(travel_y), .travel_z(travel_z),
+        .scale_x(scale_x), .scale_y(scale_y), .scale_z(scale_z),
+        .cal_x(cal_x), .cal_y(cal_y), .cal_z(cal_z),
+        .busy(busy), .done(done),
+        .rate_valid_x(rate_valid_x), .rate_valid_y(rate_valid_y), .rate_valid_z(rate_valid_z),
+        .axis_id_out(axis_id_out), .travel_out(travel_out), .scale_out(scale_out),
+        .product(product)
+    );
+
+    always @(posedge clk or negedge rst_n) begin
+        if (!rst_n) begin
+            rq_x <= 21'd64; rq_y <= 21'd64; rq_z <= 21'd64;
+        end else begin
+            if (rate_valid_x) rq_x <= product;
+            if (rate_valid_y) rq_y <= product;
+            if (rate_valid_z) rq_z <= product;
+        end
+    end
+
+    always @(posedge clk) begin
+        if (rst_n && done) begin
+            done_n = done_n + 1;
+            if (product !== (travel_out * scale_out))
+                $fatal(1, "product != travel*scale");
+            if (axis_id_out > 2'd2)
+                $fatal(1, "bad axis");
+        end
+    end
+
+    task wait_rq;
+        input [20:0] ex;
+        input [20:0] ey;
+        input [20:0] ez;
+        integer streak;
+        begin
+            streak = 0;
+            begin : w
+                for (t = 0; t < 2000; t = t + 1) begin
+                    if (rq_x === ex && rq_y === ey && rq_z === ez) begin
+                        streak = streak + 1;
+                        if (streak >= 4) disable w;
+                    end else streak = 0;
+                    @(negedge clk);
+                end
+                $fatal(1, "wait_rq got %0d/%0d/%0d expect %0d/%0d/%0d",
+                    rq_x, rq_y, rq_z, ex, ey, ez);
+            end
+        end
+    endtask
+
+    initial begin
+        #2_000_000 $fatal(1, "timeout");
+    end
+
+    initial begin
+        done_n = 0;
+        repeat (2) @(posedge clk); rst_n = 1'b1;
+
+        // Case A
+        travel_x = 13'd4; travel_y = 13'd6; travel_z = 13'd8;
+        scale_x = 9'd64; scale_y = 9'd73; scale_z = 9'd84;
+        wait_rq(21'd256, 21'd438, 21'd672);
+        $display("Case A PASS");
+
+        // Case B
+        travel_x = 13'd2; travel_y = 13'd4096; travel_z = 13'd5000;
+        scale_x = 9'd256; scale_y = 9'd170; scale_z = 9'd66;
+        wait_rq(21'd512, 21'd696320, 21'd330000);
+        $display("Case B PASS");
+
+        // Case C: change one axis scale at a time; others must hold
+        scale_x = 9'd64;
+        begin : c1
+            for (t = 0; t < 2000; t = t + 1) begin
+                if (rq_x === 21'd128 && rq_y === 21'd696320 && rq_z === 21'd330000)
+                    disable c1;
+                @(negedge clk);
+            end
+            $fatal(1, "Case C x-only got %0d/%0d/%0d", rq_x, rq_y, rq_z);
+        end
+        scale_y = 9'd64;
+        begin : c2
+            for (t = 0; t < 2000; t = t + 1) begin
+                if (rq_x === 21'd128 && rq_y === 21'd262144 && rq_z === 21'd330000)
+                    disable c2;
+                @(negedge clk);
+            end
+            $fatal(1, "Case C y-only got %0d/%0d/%0d", rq_x, rq_y, rq_z);
+        end
+        scale_z = 9'd64;
+        wait_rq(21'd128, 21'd262144, 21'd320000);
+        $display("Case C PASS");
+
+        // Case D: cal_mode forces travel=1
+        cal_x = 1'b1; cal_y = 1'b0; cal_z = 1'b0;
+        scale_x = 9'd150;
+        wait_rq(21'd150, 21'd262144, 21'd320000);
+        cal_x = 1'b0;
+        // travel returns to 2 with scale still 150
+        wait_rq(21'd300, 21'd262144, 21'd320000);
+        scale_x = 9'd64;
+        wait_rq(21'd128, 21'd262144, 21'd320000);
+        $display("Case D PASS");
+
+        // Case E: endpoint crawl -> level0 scale already; toggle scale back
+        scale_x = 9'd256; scale_y = 9'd256; scale_z = 9'd256;
+        wait_rq(21'd512, 21'd1048576, 21'd1280000);
+        scale_x = 9'd64; scale_y = 9'd64; scale_z = 9'd64;
+        wait_rq(21'd128, 21'd262144, 21'd320000);
+        $display("Case E PASS");
+
+        // Case F: reset clears to level0 seed then rebuilds
+        @(negedge clk); rst_n = 1'b0;
+        @(negedge clk); rst_n = 1'b1;
+        travel_x = 13'd4; travel_y = 13'd6; travel_z = 13'd8;
+        scale_x = 9'd64; scale_y = 9'd73; scale_z = 9'd84;
+        wait_rq(21'd256, 21'd438, 21'd672);
+        // busy/done adjacency: many consecutive refreshes
+        for (i = 0; i < 30; i = i + 1) @(negedge clk);
+        if (!(rq_x == 21'd256 && rq_y == 21'd438 && rq_z == 21'd672))
+            $fatal(1, "Case F drift");
+        $display("Case F PASS done_n=%0d", done_n);
+
+        $display("door_rate_quantum_dispatcher_cases_tb PASS");
+        $finish;
+    end
+endmodule