runtime_step_gate_hold_formal.v 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. // Production gate hold-until-engine-low: one engine high phase ⇒ ≤1 gated rise.
  2. // Instantiates prod2u_runtime_step_limit_gate (clk/rst). Bounded BMC — not unbounded.
  3. `timescale 1ns/1ps
  4. module runtime_step_gate_hold_formal (
  5. input wire clk,
  6. input wire rst_n,
  7. input wire [2:0] engine_step,
  8. input wire [2:0] engine_dir,
  9. input wire [2:0] close_limit,
  10. input wire [2:0] open_limit
  11. );
  12. wire [2:0] selected_limit;
  13. wire [2:0] gated_step;
  14. reg [1:0] reset_cycles;
  15. reg [2:0] prev_engine_step;
  16. reg [2:0] prev_gated_step;
  17. reg [2:0] phase_truncated;
  18. reg past_valid;
  19. prod2u_runtime_step_limit_gate #(.AXIS_COUNT(3)) dut (
  20. .clk(clk),
  21. .rst_n(rst_n),
  22. .engine_step(engine_step),
  23. .engine_dir(engine_dir),
  24. .close_limit(close_limit),
  25. .open_limit(open_limit),
  26. .selected_limit(selected_limit),
  27. .gated_step(gated_step)
  28. );
  29. initial begin
  30. reset_cycles = 2'd0;
  31. prev_engine_step = 3'b000;
  32. prev_gated_step = 3'b000;
  33. phase_truncated = 3'b000;
  34. past_valid = 1'b0;
  35. end
  36. integer ai;
  37. always @(posedge clk) begin
  38. assume (rst_n == 1'b0 || rst_n == 1'b1);
  39. if ($initstate || reset_cycles < 2) begin
  40. assume (!rst_n);
  41. reset_cycles <= reset_cycles + 1'b1;
  42. end else begin
  43. assume (rst_n);
  44. end
  45. if (!rst_n) begin
  46. prev_engine_step <= 3'b000;
  47. prev_gated_step <= 3'b000;
  48. phase_truncated <= 3'b000;
  49. past_valid <= 1'b0;
  50. end else begin
  51. past_valid <= 1'b1;
  52. // Immediate hard-stop: selected limit and gated STEP never both high.
  53. assert ((gated_step & selected_limit) == 3'b000);
  54. for (ai = 0; ai < 3; ai = ai + 1) begin
  55. if (!engine_step[ai])
  56. phase_truncated[ai] <= 1'b0;
  57. else if (selected_limit[ai] ||
  58. (prev_engine_step[ai] && prev_gated_step[ai] && !gated_step[ai]))
  59. phase_truncated[ai] <= 1'b1;
  60. // After truncate in this engine-high phase, gated stays low until engine low.
  61. if (past_valid && engine_step[ai] && phase_truncated[ai])
  62. assert (gated_step[ai] == 1'b0);
  63. // Rising edge cannot occur while selected limit is high.
  64. if (past_valid)
  65. assert (!((gated_step[ai] & ~prev_gated_step[ai]) & selected_limit[ai]));
  66. end
  67. // Cover: truncate then limit release while engine still high (hold prevents re-open).
  68. cover (past_valid && engine_step[0] && phase_truncated[0] &&
  69. !selected_limit[0] && (gated_step[0] == 1'b0) && prev_engine_step[0]);
  70. cover (|gated_step);
  71. cover (past_valid && engine_step[0] && selected_limit[0] && (gated_step[0] == 1'b0));
  72. prev_engine_step <= engine_step;
  73. prev_gated_step <= gated_step;
  74. end
  75. end
  76. endmodule