Просмотр исходного кода

Harden door one-shot path and keep internal solenoid net.

Document inferred solenoid polarity until V1.2 ball evidence, retain adapter logic without a package pin, make startup axis enable explicit for motor dampers only, and de-race the solenoid Icarus bench sampling.

Co-authored-by: Cursor <cursoragent@cursor.com>
root 3 месяцев назад
Родитель
Сommit
acc204acb1

+ 2 - 1
PLAN.md

@@ -18,7 +18,8 @@
 
 ## TD 说明
 
-- `intake_solenoid_out` 物理 ball 仍为 blocked;TD 综合通过 `td_omit_intake_solenoid_pin.vh` 省略该封装脚以便 bitgen,逻辑仍保留在网表中。
+- `intake_solenoid_out` 物理 ball 仍为 blocked;顶层保持内部 net(非封装脚),`keep` + unused sink 保留 adapter 逻辑,避免 unconstrained IO 阻断 bitgen。
+- 电磁铁极性为 inferred,待 V1.2 证据确认后再绑定 FPGA ball / 翻转电平。
 - 硬件烧录未授权:hardware validation = not_run。
 
 ## 历史计划

+ 4 - 0
src/modules/door_action_dispatcher.v

@@ -1,5 +1,9 @@
 `timescale 1ns/1ps
 
+// Exhaust X/Y jog dispatcher. DIR=0 open/up, DIR=1 close/down.
+// Commands: 00 stop, 01 DIR0, 02 DIR1. Latest door_action_valid overrides any
+// in-flight move (re-pulses motor_start with the new mask/dir, including stop).
+// Intake is solenoid-owned elsewhere; this module only drives motor axes.
 module door_action_dispatcher #(
     parameter integer OPEN_DIR = 0,
     parameter integer CLOSE_DIR = 1

+ 4 - 0
src/modules/door_motor_engine.v

@@ -1,5 +1,9 @@
 `timescale 1ns/1ps
 
+// Shared X/Y stepper engine: FIXED_STEPS rising edges per start at tick_500us
+// (1000 steps/s with 500 us half-period). start reloads dir/active (latest wins).
+// stop_mask clears axes mid-burst without a new rising edge after the current
+// high half-cycle completes. Used by startup close-seek and host jog.
 module door_motor_engine #(
     parameter integer FIXED_STEPS = 450,
     parameter integer DIR_SETUP_TICKS = 2

+ 10 - 3
src/modules/intake_solenoid_adapter.v

@@ -1,9 +1,16 @@
 `timescale 1ns/1ps
 
+// Chamber-1 intake default actuator is a solenoid (not the static motor profile).
+// Command contract: 00 = hold latched level, 01 = open, 02 = closed.
+// Reset / watchdog -> inactive.
+//
+// Polarity: OPEN/CLOSED/INACTIVE levels below are *inferred* placeholders from
+// project.json while doors.solenoid.evidence_status remains "blocked". Do not
+// invert them until V1.2 board evidence confirms the FPGA ball and drive sense.
 module intake_solenoid_adapter #(
-    parameter OPEN_LEVEL = 1'b1,
-    parameter CLOSED_LEVEL = 1'b0,
-    parameter INACTIVE_LEVEL = 1'b0
+    parameter OPEN_LEVEL = 1'b1,      // inferred (blocked evidence)
+    parameter CLOSED_LEVEL = 1'b0,    // inferred (blocked evidence)
+    parameter INACTIVE_LEVEL = 1'b0   // inferred (blocked evidence)
 ) (
     input  wire clk,
     input  wire rst_n,

+ 7 - 2
src/modules/startup_close_seek.v

@@ -1,5 +1,9 @@
 `timescale 1ns/1ps
 
+// Power-on / reconfig close-seek one-shot for motor-configured dampers only.
+// AXIS_ENABLE_MASK selects which exhaust axes participate (default both X/Y);
+// solenoid intake is never moved here. DIR_MASK defaults to close (DIR=1).
+// After sticky startup_done: no further starts, stop_mask stays 0 at the top.
 module startup_close_seek #(
     /* verilator lint_off UNUSEDPARAM */
     parameter integer FIXED_STEPS = 450,
@@ -8,7 +12,8 @@ module startup_close_seek #(
     /* verilator lint_on UNUSEDPARAM */
     parameter integer MAX_BURSTS = 10,
     parameter integer INTER_BURST_TICKS = 100,
-    parameter [1:0] DIR_MASK = 2'b11
+    parameter [1:0] DIR_MASK = 2'b11,
+    parameter [1:0] AXIS_ENABLE_MASK = 2'b11
 ) (
     input  wire       clk,
     input  wire       rst_n,
@@ -40,7 +45,7 @@ module startup_close_seek #(
 
     wire [1:0] reached_mask_next = reached_mask | (limit_sync_valid ? limit_sync : 2'b00);
     wire [1:0] exhausted_mask = {(burst_count_y >= MAX_BURSTS), (burst_count_x >= MAX_BURSTS)};
-    wire [1:0] move_mask = ~reached_mask_next & ~exhausted_mask;
+    wire [1:0] move_mask = ~reached_mask_next & ~exhausted_mask & AXIS_ENABLE_MASK;
 
     assign motor_stop_mask = (state == ST_WAIT_DONE) ? (reached_mask_next & motor_active_mask) : 2'b00;
 

+ 3 - 0
src/project/project_adapter.v

@@ -88,6 +88,9 @@ module project_adapter #(
         .motor_busy(motor_busy)
     );
 
+    // Intake uses solenoid adapter; static motor profile remains in project.json
+    // for exhaust X/Y only. Solenoid polarity parameters are inferred until V1.2
+    // evidence_status is confirmed (do not flip without board evidence).
     intake_solenoid_adapter #(
         .OPEN_LEVEL(INTAKE_SOLENOID_OPEN_LEVEL[0]),
         .CLOSED_LEVEL(INTAKE_SOLENOID_CLOSED_LEVEL[0]),

+ 11 - 4
src/top/prod2u_p4_normal_v3_top.v

@@ -17,9 +17,14 @@ module prod2u_p4_normal_v3_top (
     inout  wire       temp_scl,
     inout  wire       temp_sda
 );
-    // intake_solenoid_out remains an internal net until V1.2 IO evidence assigns a
-    // confirmed FPGA ball. Exposing an unconstrained package pin blocks TD bitgen.
-    wire intake_solenoid_out;
+    // intake_solenoid_out stays internal until V1.2 IO evidence assigns a confirmed
+    // FPGA ball. An unconstrained package pin previously blocked Anlogic bitgen.
+    // keep + unused sink retain adapter logic in the netlist without a package pin.
+    //
+    // Sim hooks (hierarchical, no extra ports): startup_done, tick_500us,
+    // host_motor_*, motor_stop_mask, startup_motor_*, intake_solenoid_out,
+    // limit_sync / limit_sync_valid, watchdog_timeout_event.
+    (* keep = "true" *) wire intake_solenoid_out;
     wire sys_rst_n;
     wire uart_rx_valid;
     wire [7:0] uart_rx_data;
@@ -305,6 +310,8 @@ module prod2u_p4_normal_v3_top (
 
     /* Limit inputs are two-stage synchronized and used during startup close-seek. */
     wire unused_abort_done = motor_abort_done;
+    // Sink keeps intake_solenoid_out (and related adapter) live without a package pin.
     wire unused_inputs = &{1'b0, uart_framing_error, frame_tx_busy, adapter_busy,
-        i2c_busy, temperature_busy, uart_tx_byte_done, unused_abort_done};
+        i2c_busy, temperature_busy, uart_tx_byte_done, unused_abort_done,
+        intake_solenoid_out};
 endmodule

+ 22 - 17
tests/sim/intake_solenoid_adapter_tb.v

@@ -15,29 +15,34 @@ module intake_solenoid_adapter_tb;
         .solenoid_out(solenoid_out)
     );
 
+    // Drive on negedge; sample on the following negedge so DUT NBA from the
+    // intervening posedge is settled (avoids same-edge race with the DUT).
+    task apply_and_check;
+        input [1:0] cmd;
+        input expect_level;
+        input [127:0] label;
+        begin
+            @(negedge clk);
+            door_action_valid = 1'b1;
+            intake_door_cmd = cmd;
+            @(posedge clk);
+            @(negedge clk);
+            door_action_valid = 1'b0;
+            if (solenoid_out !== expect_level)
+                $fatal(1, "%0s (got %b expected %b)", label, solenoid_out, expect_level);
+        end
+    endtask
+
     initial begin
         repeat (3) @(posedge clk);
         rst_n = 1'b1;
+        apply_and_check(2'd1, 1'b1, "open level");
+        apply_and_check(2'd0, 1'b1, "hold open");
+        apply_and_check(2'd2, 1'b0, "closed level");
         @(negedge clk);
-        door_action_valid = 1'b1;
-        intake_door_cmd = 2'd1;
-        @(posedge clk);
-        door_action_valid = 1'b0;
-        if (solenoid_out !== 1'b1) $fatal(1, "open level");
-        @(negedge clk);
-        door_action_valid = 1'b1;
-        intake_door_cmd = 2'd0;
-        @(posedge clk);
-        door_action_valid = 1'b0;
-        if (solenoid_out !== 1'b1) $fatal(1, "hold open");
-        @(negedge clk);
-        door_action_valid = 1'b1;
-        intake_door_cmd = 2'd2;
-        @(posedge clk);
-        door_action_valid = 1'b0;
-        if (solenoid_out !== 1'b0) $fatal(1, "closed level");
         watchdog_inactive = 1'b1;
         @(posedge clk);
+        @(negedge clk);
         if (solenoid_out !== 1'b0) $fatal(1, "watchdog inactive");
         $display("intake_solenoid_adapter_tb PASS");
         $finish;