Quellcode durchsuchen

feat: per-axis limit stop during startup burst

- door_motor_engine: add stop_mask input; finish current high pulse then
  produce no new STEP rising edge for the stopped axis.
- startup_close_seek: output motor_stop_mask from reached limit & active mask
  while a burst is running; reached stays latched and excluded next rounds.
- prod2u_p4_normal_v3_top: wire startup_motor_stop_mask/motor_stop_mask;
  stop mask is zero in host-motor mode.
- project contract: add runtime_use=false, startup limit_stop_during_burst,
  stop_semantics, additional_rising_edges_after_synchronized_limit=0,
  runtime_limit_use=false.
- Update requirements, protocol, schema, generator, host-contract and formal
  wrappers to keep compiling.

Generated with Devin

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Codex Resource Selftest vor 4 Monaten
Ursprung
Commit
4c11840881

Datei-Diff unterdrückt, da er zu groß ist
+ 1 - 1
docs/prod2u-door-temp-protocol.zh-CN.md


+ 6 - 1
projects/prod2u-door-temp/project.json

@@ -75,6 +75,7 @@
     "limit_count": 2,
     "active_level": "high",
     "functional_use": true,
+    "runtime_use": false,
     "startup": {
       "enabled": true,
       "direction_value": 1,
@@ -83,7 +84,11 @@
       "burst_step_rate_hz": 1000,
       "inter_burst_ms": 50,
       "max_bursts": 10,
-      "axis_order": ["x", "y"]
+      "axis_order": ["x", "y"],
+      "limit_stop_during_burst": true,
+      "stop_semantics": "finish_current_high_pulse_then_no_next_rising_edge",
+      "additional_rising_edges_after_synchronized_limit": 0,
+      "runtime_limit_use": false
     },
     "channels": [
       {"name": "x_limit_raw", "ball": "B9"},

Datei-Diff unterdrückt, da er zu groß ist
+ 1 - 1
projects/prod2u-door-temp/requirements.zh-CN.md


+ 22 - 2
schemas/project.schema.json

@@ -297,6 +297,7 @@
                                                        "limit_count",
                                                        "active_level",
                                                        "functional_use",
+                                                       "runtime_use",
                                                        "startup",
                                                        "channels"
                                                    ],
@@ -310,6 +311,9 @@
                                                          "functional_use":  {
                                                                                 "type":  "boolean"
                                                                             },
+                                                         "runtime_use":  {
+                                                                            "type":  "boolean"
+                                                                        },
                                                          "startup":  {
                                                                          "type":  "object",
                                                                          "required":  [
@@ -320,7 +324,11 @@
                                                                                           "burst_step_rate_hz",
                                                                                           "inter_burst_ms",
                                                                                           "max_bursts",
-                                                                                          "axis_order"
+                                                                                          "axis_order",
+                                                                                          "limit_stop_during_burst",
+                                                                                          "stop_semantics",
+                                                                                          "additional_rising_edges_after_synchronized_limit",
+                                                                                          "runtime_limit_use"
                                                                                       ],
                                                                          "properties":  {
                                                                                             "enabled":  {
@@ -349,7 +357,19 @@
                                                                                                              "items":  {
                                                                                                                           "type":  "string"
                                                                                                                       }
-                                                                                                         }
+                                                                                                         },
+                                                                                            "limit_stop_during_burst":  {
+                                                                                                                            "type":  "boolean"
+                                                                                                                        },
+                                                                                            "stop_semantics":  {
+                                                                                                                 "type":  "string"
+                                                                                                             },
+                                                                                            "additional_rising_edges_after_synchronized_limit":  {
+                                                                                                                                                    "type":  "integer"
+                                                                                                                                                },
+                                                                                            "runtime_limit_use":  {
+                                                                                                                    "type":  "boolean"
+                                                                                                                }
                                                                                         },
                                                                          "additionalProperties":  false
                                                                      },

+ 6 - 1
src/generated/host-contract.json

@@ -43,7 +43,9 @@
     ],
     "functional_use": true,
     "limit_count": 2,
+    "runtime_use": false,
     "startup": {
+      "additional_rising_edges_after_synchronized_limit": 0,
       "axis_order": [
         "x",
         "y"
@@ -54,7 +56,10 @@
       "direction_value": 1,
       "enabled": true,
       "inter_burst_ms": 50,
-      "max_bursts": 10
+      "limit_stop_during_burst": true,
+      "max_bursts": 10,
+      "runtime_limit_use": false,
+      "stop_semantics": "finish_current_high_pulse_then_no_next_rising_edge"
     }
   },
   "motors": {

+ 29 - 14
src/modules/door_motor_engine.v

@@ -11,6 +11,7 @@ module door_motor_engine #(
     input  wire [1:0] dir_mask,
     input  wire       tick_500us,
     input  wire       abort,
+    input  wire [1:0] stop_mask,
     output reg        busy,
     output reg        done,
     output reg  [1:0] step,
@@ -22,6 +23,8 @@ module door_motor_engine #(
     reg [STEP_COUNT_WIDTH-1:0] rising_edges;
     reg [1:0] active_reg;
 
+    wire [1:0] active_after_stop = active_reg & ~stop_mask;
+
     always @(posedge clk or negedge rst_n) begin
         if (!rst_n) begin
             busy <= 1'b0;
@@ -54,21 +57,33 @@ module door_motor_engine #(
                         busy <= 1'b1;
                     end
                 end
-            end else if (tick_500us) begin
-                if (setup_count < DIR_SETUP_TICKS) begin
-                    setup_count <= setup_count + 1'b1;
-                    step <= 2'b00;
-                end else if (step == 2'b00) begin
-                    step <= active_reg;
-                end else begin
-                    step <= 2'b00;
-                    if (rising_edges + 1 >= FIXED_STEPS) begin
-                        rising_edges <= {STEP_COUNT_WIDTH{1'b0}};
-                        active_reg <= 2'b00;
-                        busy <= 1'b0;
-                        done <= 1'b1;
+            end else begin
+                active_reg <= active_after_stop;
+                if (tick_500us) begin
+                    if (setup_count < DIR_SETUP_TICKS) begin
+                        setup_count <= setup_count + 1'b1;
+                        step <= 2'b00;
+                    end else if (step == 2'b00) begin
+                        if (active_after_stop == 2'b00) begin
+                            busy <= 1'b0;
+                            done <= 1'b1;
+                            setup_count <= {SETUP_BITS{1'b0}};
+                            rising_edges <= {STEP_COUNT_WIDTH{1'b0}};
+                            active_reg <= 2'b00;
+                        end else begin
+                            step <= active_after_stop;
+                        end
                     end else begin
-                        rising_edges <= rising_edges + 1'b1;
+                        step <= 2'b00;
+                        if ((rising_edges + 1'b1 >= FIXED_STEPS) || (active_after_stop == 2'b00)) begin
+                            busy <= 1'b0;
+                            done <= 1'b1;
+                            setup_count <= {SETUP_BITS{1'b0}};
+                            rising_edges <= {STEP_COUNT_WIDTH{1'b0}};
+                            active_reg <= 2'b00;
+                        end else begin
+                            rising_edges <= rising_edges + 1'b1;
+                        end
                     end
                 end
             end

+ 3 - 0
src/modules/startup_close_seek.v

@@ -19,6 +19,7 @@ module startup_close_seek #(
     output reg        motor_start,
     output reg  [1:0] motor_active_mask,
     output reg  [1:0] motor_dir_mask,
+    output wire [1:0] motor_stop_mask,
     input  wire       motor_done
 );
     localparam integer BURST_WIDTH = (MAX_BURSTS <= 1) ? 1 : $clog2(MAX_BURSTS + 1);
@@ -41,6 +42,8 @@ module startup_close_seek #(
     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;
 
+    assign motor_stop_mask = (state == ST_WAIT_DONE) ? (reached_mask_next & motor_active_mask) : 2'b00;
+
     always @(posedge clk or negedge rst_n) begin
         if (!rst_n) begin
             state <= ST_WAIT_SYNC;

+ 5 - 0
src/top/prod2u_p4_normal_v3_top.v

@@ -51,6 +51,8 @@ module prod2u_p4_normal_v3_top (
     wire startup_motor_start;
     wire [1:0] startup_motor_active_mask;
     wire [1:0] startup_motor_dir_mask;
+    wire [1:0] startup_motor_stop_mask;
+    wire [1:0] motor_stop_mask;
     (* async_reg = "true" *) reg x_limit_sync0, x_limit_sync1;
     (* async_reg = "true" *) reg y_limit_sync0, y_limit_sync1;
     wire [1:0] limit_sync;
@@ -102,6 +104,7 @@ module prod2u_p4_normal_v3_top (
     assign motor_start = startup_done ? host_motor_start : startup_motor_start;
     assign motor_active_mask = startup_done ? host_motor_active_mask : startup_motor_active_mask;
     assign motor_dir_mask = startup_done ? host_motor_dir_mask : startup_motor_dir_mask;
+    assign motor_stop_mask = startup_done ? 2'b00 : startup_motor_stop_mask;
     assign limit_sync = {y_limit_sync1, x_limit_sync1};
 
     always @(posedge sys_clk or negedge sys_rst_n) begin
@@ -195,6 +198,7 @@ module prod2u_p4_normal_v3_top (
         .limit_sync_valid(limit_sync_valid), .limit_sync(limit_sync),
         .startup_done(startup_done), .motor_start(startup_motor_start),
         .motor_active_mask(startup_motor_active_mask), .motor_dir_mask(startup_motor_dir_mask),
+        .motor_stop_mask(startup_motor_stop_mask),
         .motor_done(motor_done)
     );
 
@@ -227,6 +231,7 @@ module prod2u_p4_normal_v3_top (
         .clk(sys_clk), .rst_n(sys_rst_n), .start(motor_start),
         .active_mask(motor_active_mask), .dir_mask(motor_dir_mask),
         .tick_500us(tick_500us), .abort(watchdog_timeout_event),
+        .stop_mask(motor_stop_mask),
         .busy(motor_busy), .done(motor_done), .step({y_step, x_step}),
         .dir({y_dir, x_dir})
     );

+ 9 - 2
tests/formal/simple_motor_temperature_contract_formal.v

@@ -5,7 +5,8 @@ module simple_motor_temperature_contract_formal (
     input wire [1:0] active_mask,
     input wire [1:0] dir_mask,
     input wire tick_500us,
-    input wire abort
+    input wire abort,
+    input wire [1:0] stop_mask
 );
     // This target proves parameterized motor invariants. Production 450-step
     // timing is covered by tests/sim/door_motor_engine_tb.v.
@@ -29,8 +30,14 @@ module simple_motor_temperature_contract_formal (
         .DIR_SETUP_TICKS(FORMAL_DIR_SETUP_TICKS)
     ) motor (
         .clk(clk), .rst_n(dut_rst_n), .start(start), .active_mask(active_mask), .dir_mask(dir_mask),
-        .tick_500us(tick_500us), .abort(abort), .busy(busy), .done(done), .step(step), .dir(dir)
+        .tick_500us(tick_500us), .abort(abort), .stop_mask(stop_mask),
+        .busy(busy), .done(done), .step(step), .dir(dir)
     );
+    // Existing contract target proves behavior without stop_mask; stop semantics are
+    // covered by additional dedicated targets.
+    always @(posedge clk) begin
+        assume (stop_mask == 2'b00);
+    end
 
     initial begin
         expected_active = 2'b00;

+ 2 - 0
tests/formal/startup_close_seek_formal.v

@@ -15,6 +15,7 @@ module startup_close_seek_formal (
     wire motor_start;
     wire [1:0] motor_active_mask;
     wire [1:0] motor_dir_mask;
+    wire [1:0] motor_stop_mask;
     wire motor_done;
 
     reg [2:0] reset_cycles;
@@ -50,6 +51,7 @@ module startup_close_seek_formal (
         .motor_start(motor_start),
         .motor_active_mask(motor_active_mask),
         .motor_dir_mask(motor_dir_mask),
+        .motor_stop_mask(motor_stop_mask),
         .motor_done(motor_done)
     );
 

+ 2 - 0
tests/sim/door_motor_engine_tb.v

@@ -7,6 +7,7 @@ module door_motor_engine_tb;
     reg [1:0] dir_mask = 2'b01;
     reg tick_500us = 1'b0;
     reg abort = 1'b0;
+    reg [1:0] stop_mask = 2'b00;
     wire busy;
     wire done;
     wire [1:0] step;
@@ -38,6 +39,7 @@ module door_motor_engine_tb;
     ) dut (
         .clk(clk), .rst_n(rst_n), .start(start),
         .active_mask(active_mask), .dir_mask(dir_mask), .tick_500us(tick_500us), .abort(abort),
+        .stop_mask(stop_mask),
         .busy(busy), .done(done), .step(step), .dir(dir)
     );
 

+ 2 - 0
tests/sim/startup_close_seek_tb.v

@@ -10,6 +10,7 @@ module startup_close_seek_tb;
     wire motor_start;
     wire [1:0] motor_active_mask;
     wire [1:0] motor_dir_mask;
+    wire [1:0] motor_stop_mask;
     reg motor_done;
 
     integer burst_count;
@@ -36,6 +37,7 @@ module startup_close_seek_tb;
         .motor_start(motor_start),
         .motor_active_mask(motor_active_mask),
         .motor_dir_mask(motor_dir_mask),
+        .motor_stop_mask(motor_stop_mask),
         .motor_done(motor_done)
     );
 

+ 7 - 2
tools/generate_project.py

@@ -214,13 +214,18 @@ def _validate_project(payload: Mapping[str, Any]) -> None:
     _require(enable == {"ball": "A10", "active_level": "low", "policy": "shared_constant_low"}, "motor enable mapping mismatch")
 
     limits = _object(payload["limits"], "limits")
-    _keys(limits, {"limit_count", "active_level", "functional_use", "startup", "channels"}, "limits")
+    _keys(limits, {"limit_count", "active_level", "functional_use", "runtime_use", "startup", "channels"}, "limits")
     _require(limits["limit_count"] == len(limits["channels"]) == 2, "limit count/list mismatch")
     _require(limits["active_level"] == "high" and limits["functional_use"] is True, "limit policy mismatch")
+    _require(limits["runtime_use"] is False, "runtime limit use must be false")
     startup = _object(limits["startup"], "limits.startup")
-    _keys(startup, {"enabled", "direction_value", "direction_meaning", "burst_step_count", "burst_step_rate_hz", "inter_burst_ms", "max_bursts", "axis_order"}, "limits.startup")
+    _keys(startup, {"enabled", "direction_value", "direction_meaning", "burst_step_count", "burst_step_rate_hz", "inter_burst_ms", "max_bursts", "axis_order", "limit_stop_during_burst", "stop_semantics", "additional_rising_edges_after_synchronized_limit", "runtime_limit_use"}, "limits.startup")
     _require(startup["enabled"] is True, "startup must be enabled")
     _require(startup["direction_meaning"] == "close", "startup direction must be close")
+    _require(startup["limit_stop_during_burst"] is True, "startup limit stop during burst must be enabled")
+    _require(startup["stop_semantics"] == "finish_current_high_pulse_then_no_next_rising_edge", "unsupported stop semantics")
+    _require(startup["additional_rising_edges_after_synchronized_limit"] == 0, "additional rising edges after limit must be zero")
+    _require(startup["runtime_limit_use"] is False, "startup runtime limit use must be false")
     _integer(startup["direction_value"], "limits.startup.direction_value", minimum=0)
     _integer(startup["burst_step_count"], "limits.startup.burst_step_count", minimum=1)
     _integer(startup["burst_step_rate_hz"], "limits.startup.burst_step_rate_hz", minimum=1)