|
|
@@ -1,18 +1,37 @@
|
|
|
-// Runtime limit hard-stop mux: DIR=1 -> LS, DIR=0 -> HS; active only after startup_done.
|
|
|
+// Runtime limit hard-stop BMC against REAL door_motor_engine + top-style
|
|
|
+// external STEP truncate gate (mirrors prod2u_p4_normal_v3_top.v).
|
|
|
+//
|
|
|
+// ACTUAL RTL stop semantics (encode as truncate, not finish-high):
|
|
|
+// truncate_current_high_pulse_immediately_after_synchronized_limit
|
|
|
+// Engine clears STEP on the stop_mask sampling edge; top combinationally
|
|
|
+// gates engine_step with the direction-selected synchronized limit so the
|
|
|
+// pin cannot stay high after the target-side limit syncs.
|
|
|
+//
|
|
|
+// Mux shell asserts are retained for static contract string checks.
|
|
|
module runtime_limit_hard_stop_formal (
|
|
|
input wire clk,
|
|
|
input wire rst_n,
|
|
|
input wire startup_done,
|
|
|
+ input wire start,
|
|
|
+ input wire [2:0] active_mask,
|
|
|
input wire [2:0] motor_dir_mask,
|
|
|
+ input wire tick_500us,
|
|
|
+ input wire abort,
|
|
|
input wire [2:0] limit_ls_sync,
|
|
|
input wire [2:0] limit_hs_sync
|
|
|
);
|
|
|
+ localparam integer FORMAL_MAX_STEPS = 4;
|
|
|
+ localparam integer FORMAL_DIR_SETUP_TICKS = 1;
|
|
|
+ localparam integer AXIS_COUNT = 3;
|
|
|
+
|
|
|
wire [2:0] runtime_limit_stop_mask;
|
|
|
reg [2:0] reset_cycles;
|
|
|
+ reg [2:0] prev_gated_step;
|
|
|
+ reg past_valid;
|
|
|
|
|
|
genvar gi;
|
|
|
generate
|
|
|
- for (gi = 0; gi < 3; gi = gi + 1) begin : gen_runtime_limit_stop
|
|
|
+ for (gi = 0; gi < AXIS_COUNT; gi = gi + 1) begin : gen_runtime_limit_stop
|
|
|
assign runtime_limit_stop_mask[gi] =
|
|
|
motor_dir_mask[gi] ? limit_ls_sync[gi] : limit_hs_sync[gi];
|
|
|
end
|
|
|
@@ -20,33 +39,163 @@ module runtime_limit_hard_stop_formal (
|
|
|
|
|
|
wire [2:0] motor_stop_mask = startup_done ? runtime_limit_stop_mask : 3'b000;
|
|
|
|
|
|
- initial reset_cycles = 3'd0;
|
|
|
+ wire busy;
|
|
|
+ wire done;
|
|
|
+ wire [2:0] engine_step;
|
|
|
+ wire [2:0] engine_dir;
|
|
|
+
|
|
|
+ door_motor_engine #(
|
|
|
+ .AXIS_COUNT(AXIS_COUNT),
|
|
|
+ .MAX_STEPS(FORMAL_MAX_STEPS),
|
|
|
+ .DIR_SETUP_TICKS(FORMAL_DIR_SETUP_TICKS)
|
|
|
+ ) u_motor (
|
|
|
+ .clk(clk),
|
|
|
+ .rst_n(rst_n),
|
|
|
+ .start(start && startup_done),
|
|
|
+ .active_mask(active_mask),
|
|
|
+ .dir_mask(motor_dir_mask),
|
|
|
+ .step_count(FORMAL_MAX_STEPS[2:0]),
|
|
|
+ .tick_500us(tick_500us),
|
|
|
+ .abort(abort),
|
|
|
+ .stop_mask(motor_stop_mask),
|
|
|
+ .busy(busy),
|
|
|
+ .done(done),
|
|
|
+ .step(engine_step),
|
|
|
+ .dir(engine_dir)
|
|
|
+ );
|
|
|
+
|
|
|
+ // Top pin gate: immediate truncate of external STEP on target-side sync.
|
|
|
+ wire [2:0] gated_step;
|
|
|
+ assign gated_step[0] = engine_step[0] &
|
|
|
+ ~(engine_dir[0] ? limit_ls_sync[0] : limit_hs_sync[0]);
|
|
|
+ assign gated_step[1] = engine_step[1] &
|
|
|
+ ~(engine_dir[1] ? limit_ls_sync[1] : limit_hs_sync[1]);
|
|
|
+ assign gated_step[2] = engine_step[2] &
|
|
|
+ ~(engine_dir[2] ? limit_ls_sync[2] : limit_hs_sync[2]);
|
|
|
+
|
|
|
+ // Top permanent enable (FPGA ball constant 1 / permanent_high).
|
|
|
+ wire motor_en_n = 1'b1;
|
|
|
+
|
|
|
+ wire [2:0] target_limit_for_engine_dir;
|
|
|
+ assign target_limit_for_engine_dir[0] =
|
|
|
+ engine_dir[0] ? limit_ls_sync[0] : limit_hs_sync[0];
|
|
|
+ assign target_limit_for_engine_dir[1] =
|
|
|
+ engine_dir[1] ? limit_ls_sync[1] : limit_hs_sync[1];
|
|
|
+ assign target_limit_for_engine_dir[2] =
|
|
|
+ engine_dir[2] ? limit_ls_sync[2] : limit_hs_sync[2];
|
|
|
+
|
|
|
+ initial begin
|
|
|
+ reset_cycles = 3'd0;
|
|
|
+ prev_gated_step = 3'b000;
|
|
|
+ past_valid = 1'b0;
|
|
|
+ end
|
|
|
|
|
|
always @(posedge clk) begin
|
|
|
assume (rst_n == 1'b0 || rst_n == 1'b1);
|
|
|
assume (startup_done == 1'b0 || startup_done == 1'b1);
|
|
|
+ assume (start == 1'b0 || start == 1'b1);
|
|
|
+ assume (tick_500us == 1'b0 || tick_500us == 1'b1);
|
|
|
+ assume (abort == 1'b0 || abort == 1'b1);
|
|
|
assume ((^motor_dir_mask) == 1'b0 || (^motor_dir_mask) == 1'b1);
|
|
|
+ assume ((^active_mask) == 1'b0 || (^active_mask) == 1'b1);
|
|
|
assume ((^limit_ls_sync) == 1'b0 || (^limit_ls_sync) == 1'b1);
|
|
|
assume ((^limit_hs_sync) == 1'b0 || (^limit_hs_sync) == 1'b1);
|
|
|
+ // Host contract: no new start while busy; dir stable for a run.
|
|
|
+ assume (!busy || !start);
|
|
|
+ if (busy)
|
|
|
+ assume (motor_dir_mask == engine_dir);
|
|
|
if (!$initstate && $past(rst_n) && $past(startup_done))
|
|
|
assume (startup_done);
|
|
|
+
|
|
|
if ($initstate || reset_cycles < 2) begin
|
|
|
assume (!rst_n);
|
|
|
reset_cycles <= reset_cycles + 1'b1;
|
|
|
+ past_valid <= 1'b0;
|
|
|
+ prev_gated_step <= 3'b000;
|
|
|
end else begin
|
|
|
assume (rst_n);
|
|
|
+ past_valid <= 1'b1;
|
|
|
end
|
|
|
|
|
|
+ // Mux shell (startup gating of runtime stop mask).
|
|
|
if (rst_n && startup_done) begin
|
|
|
assert (motor_stop_mask == runtime_limit_stop_mask);
|
|
|
end
|
|
|
if (rst_n && !startup_done) begin
|
|
|
assert (motor_stop_mask == 3'b000);
|
|
|
end
|
|
|
+
|
|
|
+ if (rst_n) begin
|
|
|
+ // Permanent EN never drops on watchdog / limit paths.
|
|
|
+ assert (motor_en_n == 1'b1);
|
|
|
+
|
|
|
+ if (startup_done) begin
|
|
|
+ // Target-side synchronized limit => external STEP immediately 0
|
|
|
+ // (combinational top gate + engine truncate on stop_mask).
|
|
|
+ if (target_limit_for_engine_dir[0])
|
|
|
+ assert (gated_step[0] == 1'b0);
|
|
|
+ if (target_limit_for_engine_dir[1])
|
|
|
+ assert (gated_step[1] == 1'b0);
|
|
|
+ if (target_limit_for_engine_dir[2])
|
|
|
+ assert (gated_step[2] == 1'b0);
|
|
|
+
|
|
|
+ // Wrong-side limit does not assert stop_mask (leave allowed).
|
|
|
+ if (motor_dir_mask[0] && !limit_ls_sync[0])
|
|
|
+ assert (motor_stop_mask[0] == 1'b0);
|
|
|
+ if (!motor_dir_mask[0] && !limit_hs_sync[0])
|
|
|
+ assert (motor_stop_mask[0] == 1'b0);
|
|
|
+ if (motor_dir_mask[1] && !limit_ls_sync[1])
|
|
|
+ assert (motor_stop_mask[1] == 1'b0);
|
|
|
+ if (!motor_dir_mask[1] && !limit_hs_sync[1])
|
|
|
+ assert (motor_stop_mask[1] == 1'b0);
|
|
|
+ if (motor_dir_mask[2] && !limit_ls_sync[2])
|
|
|
+ assert (motor_stop_mask[2] == 1'b0);
|
|
|
+ if (!motor_dir_mask[2] && !limit_hs_sync[2])
|
|
|
+ assert (motor_stop_mask[2] == 1'b0);
|
|
|
+
|
|
|
+ // Axis independence of stop_mask construction.
|
|
|
+ if (!limit_ls_sync[0] && !limit_hs_sync[0])
|
|
|
+ assert (motor_stop_mask[0] == 1'b0);
|
|
|
+ if (!limit_ls_sync[1] && !limit_hs_sync[1])
|
|
|
+ assert (motor_stop_mask[1] == 1'b0);
|
|
|
+ if (!limit_ls_sync[2] && !limit_hs_sync[2])
|
|
|
+ assert (motor_stop_mask[2] == 1'b0);
|
|
|
+ end
|
|
|
+
|
|
|
+ if (past_valid) begin
|
|
|
+ // Engine truncate: after stop_mask sampled high, registered STEP is 0.
|
|
|
+ if (startup_done && $past(motor_stop_mask[0]) && $past(rst_n))
|
|
|
+ assert (engine_step[0] == 1'b0);
|
|
|
+ if (startup_done && $past(motor_stop_mask[1]) && $past(rst_n))
|
|
|
+ assert (engine_step[1] == 1'b0);
|
|
|
+ if (startup_done && $past(motor_stop_mask[2]) && $past(rst_n))
|
|
|
+ assert (engine_step[2] == 1'b0);
|
|
|
+
|
|
|
+ // No new rising edge on an axis whose target limit was already high.
|
|
|
+ if (startup_done && $past(target_limit_for_engine_dir[0]))
|
|
|
+ assert (!( !prev_gated_step[0] && gated_step[0] ));
|
|
|
+ if (startup_done && $past(target_limit_for_engine_dir[1]))
|
|
|
+ assert (!( !prev_gated_step[1] && gated_step[1] ));
|
|
|
+ if (startup_done && $past(target_limit_for_engine_dir[2]))
|
|
|
+ assert (!( !prev_gated_step[2] && gated_step[2] ));
|
|
|
+
|
|
|
+ // Watchdog abort: next cycle external STEP low; EN still high.
|
|
|
+ if ($past(abort) && $past(rst_n)) begin
|
|
|
+ assert (engine_step == 3'b000);
|
|
|
+ assert (gated_step == 3'b000);
|
|
|
+ assert (motor_en_n == 1'b1);
|
|
|
+ end
|
|
|
+ end
|
|
|
+
|
|
|
+ prev_gated_step <= gated_step;
|
|
|
+ end
|
|
|
end
|
|
|
|
|
|
always @(posedge clk) begin
|
|
|
cover (rst_n && startup_done && limit_ls_sync == 3'b001);
|
|
|
cover (rst_n && startup_done && limit_hs_sync == 3'b001 && motor_dir_mask == 3'b000);
|
|
|
+ cover (rst_n && startup_done && busy && motor_stop_mask[0] && !gated_step[0]);
|
|
|
+ cover (rst_n && startup_done && abort);
|
|
|
+ cover (rst_n && startup_done && engine_step[1] && motor_stop_mask[0] && !motor_stop_mask[1]);
|
|
|
end
|
|
|
endmodule
|