prod2u_p4_fast_jog_path_formal.v 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627
  1. `timescale 1ns/1ps
  2. `default_nettype none
  3. // Independent observable axis model. The implementation uses a four-state
  4. // phase machine; this oracle instead uses explicit setup/high/low countdowns.
  5. module prod2u_p4_fast_jog_axis_oracle #(
  6. parameter integer DIR_SETUP_CYCLES = 3,
  7. parameter integer STEP_HALF_CYCLES = 2
  8. ) (
  9. input wire clk,
  10. input wire rst_n,
  11. input wire command_start,
  12. input wire command_dir,
  13. input wire [15:0] command_steps,
  14. output reg step_out,
  15. output reg dir_out,
  16. output reg started_pulse,
  17. output reg active,
  18. output reg [15:0] steps_left
  19. );
  20. reg [15:0] setup_left;
  21. reg [15:0] high_left;
  22. reg [15:0] low_left;
  23. always @(posedge clk or negedge rst_n) begin
  24. if (!rst_n) begin
  25. step_out <= 1'b0;
  26. dir_out <= 1'b0;
  27. started_pulse <= 1'b0;
  28. active <= 1'b0;
  29. steps_left <= 16'd0;
  30. setup_left <= 16'd0;
  31. high_left <= 16'd0;
  32. low_left <= 16'd0;
  33. end else begin
  34. started_pulse <= 1'b0;
  35. if (command_start) begin
  36. step_out <= 1'b0;
  37. dir_out <= command_dir;
  38. active <= 1'b1;
  39. steps_left <= command_steps;
  40. setup_left <= DIR_SETUP_CYCLES;
  41. high_left <= 16'd0;
  42. low_left <= 16'd0;
  43. end else if (active) begin
  44. if (setup_left != 16'd0) begin
  45. if (setup_left == 16'd1) begin
  46. setup_left <= 16'd0;
  47. step_out <= 1'b1;
  48. high_left <= STEP_HALF_CYCLES;
  49. started_pulse <= 1'b1;
  50. end else begin
  51. setup_left <= setup_left - 16'd1;
  52. end
  53. end else if (step_out) begin
  54. if (high_left == 16'd1) begin
  55. step_out <= 1'b0;
  56. high_left <= 16'd0;
  57. low_left <= STEP_HALF_CYCLES;
  58. end else begin
  59. high_left <= high_left - 16'd1;
  60. end
  61. end else if (low_left != 16'd0) begin
  62. if (low_left == 16'd1) begin
  63. low_left <= 16'd0;
  64. if (steps_left == 16'd1) begin
  65. active <= 1'b0;
  66. steps_left <= 16'd0;
  67. end else begin
  68. steps_left <= steps_left - 16'd1;
  69. step_out <= 1'b1;
  70. high_left <= STEP_HALF_CYCLES;
  71. end
  72. end else begin
  73. low_left <= low_left - 16'd1;
  74. end
  75. end
  76. end
  77. end
  78. end
  79. endmodule
  80. // End-to-end core proof with deliberately short periods. A legal fast JOG is
  81. // compared against two independent axis oracles while an unrelated ordinary
  82. // command and TX backpressure are unconstrained. Any dependency on
  83. // request_ready, the core state, command_inflight, or frame_ready breaks the
  84. // observable equivalence.
  85. module prod2u_p4_fast_jog_path_formal;
  86. localparam integer FORMAL_DIR_SETUP_CYCLES = 3;
  87. localparam integer FORMAL_STEP_HALF_CYCLES = 2;
  88. (* gclk *) reg clk;
  89. reg rst_n = 1'b0;
  90. reg past_valid = 1'b0;
  91. (* anyseq *) reg ordinary_request_valid;
  92. (* anyseq *) reg ordinary_request_is_snapshot;
  93. (* anyseq *) reg frame_ready;
  94. (* anyseq *) reg fast_jog_valid;
  95. (* anyseq *) reg [1:0] fast_jog_axis;
  96. (* anyseq *) reg fast_jog_dir;
  97. (* anyseq *) reg [15:0] fast_jog_steps;
  98. wire request_ready;
  99. wire frame_valid;
  100. wire [7:0] frame_type;
  101. wire [7:0] frame_payload_len;
  102. wire [143:0] frame_payload;
  103. wire [191:0] ptc_percent;
  104. wire [31:0] fan_percent;
  105. wire [7:0] solenoid_percent;
  106. wire [15:0] state_hash16;
  107. wire [2:0] step_out;
  108. wire [2:0] dir_out;
  109. wire en_n;
  110. wire disabled;
  111. wire watchdog_timeout;
  112. wire [2:0] dut_state;
  113. wire x_spec_step;
  114. wire x_spec_dir;
  115. wire x_spec_started;
  116. wire x_spec_active;
  117. wire [15:0] x_spec_steps_left;
  118. wire y_spec_step;
  119. wire y_spec_dir;
  120. wire y_spec_started;
  121. wire y_spec_active;
  122. wire [15:0] y_spec_steps_left;
  123. reg [2:0] previous_step = 3'd0;
  124. reg saw_tx_blocked_fast = 1'b0;
  125. reg blocked_fast_axis = 1'b0;
  126. reg saw_nonidle_fast = 1'b0;
  127. reg nonidle_fast_axis = 1'b0;
  128. reg saw_ffff_fast = 1'b0;
  129. reg x_two_active = 1'b0;
  130. reg [1:0] x_two_rises = 2'd0;
  131. reg x_two_complete = 1'b0;
  132. // GET_STATUS occupies the response scheduler; a valid snapshot reaches
  133. // the non-IDLE validate/commit states without creating a motor command.
  134. reg [271:0] snapshot_request_payload;
  135. integer snapshot_index;
  136. always @* begin
  137. snapshot_request_payload = 272'd0;
  138. snapshot_request_payload[7:0] = 8'h2a;
  139. for (snapshot_index = 0; snapshot_index < 24;
  140. snapshot_index = snapshot_index + 1) begin
  141. snapshot_request_payload[(snapshot_index + 2) * 8 +: 8] = 8'd10;
  142. end
  143. for (snapshot_index = 0; snapshot_index < 4;
  144. snapshot_index = snapshot_index + 1) begin
  145. snapshot_request_payload[(snapshot_index + 26) * 8 +: 8] = 8'd30;
  146. end
  147. end
  148. wire [7:0] ordinary_request_type =
  149. ordinary_request_is_snapshot ? 8'h07 : 8'h05;
  150. wire [5:0] ordinary_request_length =
  151. ordinary_request_is_snapshot ? 6'd34 : 6'd4;
  152. wire [271:0] ordinary_payload = ordinary_request_is_snapshot ?
  153. snapshot_request_payload : {264'd0, 8'h24};
  154. prod2u_p4_normal_v3_core #(
  155. .CLK_HZ(4),
  156. .WATCHDOG_SECONDS(2),
  157. .DIR_SETUP_CYCLES(FORMAL_DIR_SETUP_CYCLES),
  158. .STEP_HALF_CYCLES(FORMAL_STEP_HALF_CYCLES)
  159. ) dut (
  160. .clk(clk),
  161. .rst_n(rst_n),
  162. .request_valid(ordinary_request_valid),
  163. .request_ready(request_ready),
  164. .request_type(ordinary_request_type),
  165. .request_length(ordinary_request_length),
  166. .request_payload(ordinary_payload),
  167. .request_crc16(16'h1234),
  168. .fast_jog_valid(fast_jog_valid),
  169. .fast_jog_axis(fast_jog_axis),
  170. .fast_jog_dir(fast_jog_dir),
  171. .fast_jog_steps(fast_jog_steps),
  172. .frame_valid(frame_valid),
  173. .frame_ready(frame_ready),
  174. .frame_type(frame_type),
  175. .frame_payload_len(frame_payload_len),
  176. .frame_payload(frame_payload),
  177. .ptc_percent(ptc_percent),
  178. .fan_percent(fan_percent),
  179. .solenoid_percent(solenoid_percent),
  180. .state_hash16(state_hash16),
  181. .step_out(step_out),
  182. .dir_out(dir_out),
  183. .en_n(en_n),
  184. .disabled(disabled),
  185. .watchdog_timeout(watchdog_timeout),
  186. .formal_state(dut_state)
  187. );
  188. prod2u_p4_fast_jog_axis_oracle #(
  189. .DIR_SETUP_CYCLES(FORMAL_DIR_SETUP_CYCLES),
  190. .STEP_HALF_CYCLES(FORMAL_STEP_HALF_CYCLES)
  191. ) x_oracle (
  192. .clk(clk),
  193. .rst_n(rst_n),
  194. .command_start(fast_jog_valid && (fast_jog_axis == 2'd0)),
  195. .command_dir(fast_jog_dir),
  196. .command_steps(fast_jog_steps),
  197. .step_out(x_spec_step),
  198. .dir_out(x_spec_dir),
  199. .started_pulse(x_spec_started),
  200. .active(x_spec_active),
  201. .steps_left(x_spec_steps_left)
  202. );
  203. prod2u_p4_fast_jog_axis_oracle #(
  204. .DIR_SETUP_CYCLES(FORMAL_DIR_SETUP_CYCLES),
  205. .STEP_HALF_CYCLES(FORMAL_STEP_HALF_CYCLES)
  206. ) y_oracle (
  207. .clk(clk),
  208. .rst_n(rst_n),
  209. .command_start(fast_jog_valid && (fast_jog_axis == 2'd1)),
  210. .command_dir(fast_jog_dir),
  211. .command_steps(fast_jog_steps),
  212. .step_out(y_spec_step),
  213. .dir_out(y_spec_dir),
  214. .started_pulse(y_spec_started),
  215. .active(y_spec_active),
  216. .steps_left(y_spec_steps_left)
  217. );
  218. always @(posedge clk) begin
  219. past_valid <= 1'b1;
  220. rst_n <= 1'b1;
  221. previous_step <= step_out;
  222. if (rst_n && fast_jog_valid) begin
  223. assume(fast_jog_axis <= 2'd1);
  224. // RAW_U16_TRUSTED_HOST_NO_CPLD_CAP: the host owns zero rejection.
  225. assume(fast_jog_steps != 16'd0);
  226. end
  227. if (!rst_n) begin
  228. saw_tx_blocked_fast <= 1'b0;
  229. blocked_fast_axis <= 1'b0;
  230. saw_nonidle_fast <= 1'b0;
  231. nonidle_fast_axis <= 1'b0;
  232. saw_ffff_fast <= 1'b0;
  233. x_two_active <= 1'b0;
  234. x_two_rises <= 2'd0;
  235. x_two_complete <= 1'b0;
  236. end else begin
  237. if (frame_valid && !frame_ready && fast_jog_valid) begin
  238. saw_tx_blocked_fast <= 1'b1;
  239. blocked_fast_axis <= fast_jog_axis[0];
  240. end
  241. if (fast_jog_valid && (dut_state != 3'd0)) begin
  242. saw_nonidle_fast <= 1'b1;
  243. nonidle_fast_axis <= fast_jog_axis[0];
  244. end
  245. if (fast_jog_valid && (fast_jog_steps == 16'hffff)) begin
  246. saw_ffff_fast <= 1'b1;
  247. end
  248. if (fast_jog_valid && (fast_jog_axis == 2'd0)) begin
  249. x_two_active <= (fast_jog_steps == 16'd2);
  250. x_two_rises <= 2'd0;
  251. x_two_complete <= 1'b0;
  252. end else if (x_two_active) begin
  253. if (step_out[0] && !previous_step[0]) begin
  254. x_two_rises <= x_two_rises + 1'b1;
  255. end
  256. if (!x_spec_active && (x_two_rises == 2'd2)) begin
  257. x_two_active <= 1'b0;
  258. x_two_complete <= 1'b1;
  259. end
  260. end
  261. end
  262. if (rst_n) begin
  263. assert(step_out[0] == x_spec_step);
  264. assert(dir_out[0] == x_spec_dir);
  265. assert(step_out[1] == y_spec_step);
  266. assert(dir_out[1] == y_spec_dir);
  267. assert(!step_out[2]);
  268. assert(!dir_out[2]);
  269. assert(!en_n);
  270. assert(!x_spec_started || x_spec_step);
  271. assert(!y_spec_started || y_spec_step);
  272. end
  273. cover(saw_tx_blocked_fast &&
  274. step_out[blocked_fast_axis] &&
  275. !previous_step[blocked_fast_axis]);
  276. cover(saw_nonidle_fast &&
  277. step_out[nonidle_fast_axis] &&
  278. !previous_step[nonidle_fast_axis]);
  279. cover(rst_n && step_out[0] && step_out[1]);
  280. cover(saw_ffff_fast && (step_out[0] || step_out[1]));
  281. cover(x_two_complete);
  282. end
  283. wire unused = request_ready ^ frame_type[0] ^ frame_payload_len[0] ^
  284. frame_payload[0] ^ ptc_percent[0] ^ fan_percent[0] ^
  285. solenoid_percent[0] ^ state_hash16[0] ^ disabled ^
  286. watchdog_timeout ^ x_spec_steps_left[0] ^ y_spec_steps_left[0] ^
  287. dut_state[0] ^ past_valid;
  288. endmodule
  289. // A complete CRC-correct JOG must use the RX fast exit even while an older
  290. // ordinary request is held. Axis, direction, speed, and steps remain symbolic;
  291. // the classifier intentionally has no assumption on the raw 16-bit steps.
  292. module prod2u_p4_fast_jog_rx_formal;
  293. (* gclk *) reg clk;
  294. reg rst_n = 1'b0;
  295. reg [6:0] stream_index = 7'd0;
  296. reg [15:0] harness_crc = 16'hffff;
  297. reg held_request_seen = 1'b0;
  298. reg fast_event_seen = 1'b0;
  299. reg fast_event_previous = 1'b0;
  300. reg [7:0] held_request_type = 8'd0;
  301. reg [5:0] held_request_length = 6'd0;
  302. reg [271:0] held_request_payload = 272'd0;
  303. reg [15:0] held_request_crc16 = 16'd0;
  304. (* anyconst *) reg [1:0] jog_axis;
  305. (* anyconst *) reg jog_dir;
  306. (* anyconst *) reg [1:0] jog_speed;
  307. (* anyconst *) reg [15:0] jog_steps;
  308. wire first_frame = (stream_index <= 7'd19);
  309. wire second_frame = (stream_index >= 7'd22) &&
  310. (stream_index <= 7'd45);
  311. wire drive_valid = rst_n && (first_frame || second_frame);
  312. wire [6:0] local_index = second_frame ?
  313. (stream_index - 7'd22) : stream_index;
  314. wire [6:0] crc_low_index = second_frame ? 7'd22 : 7'd18;
  315. wire [6:0] crc_high_index = second_frame ? 7'd23 : 7'd19;
  316. reg [7:0] drive_data;
  317. wire [15:0] harness_crc_next;
  318. wire rx_ready;
  319. wire request_valid;
  320. wire [7:0] request_type;
  321. wire [5:0] request_length;
  322. wire [271:0] request_payload;
  323. wire [15:0] request_crc16;
  324. wire fast_jog_valid;
  325. wire [1:0] fast_jog_axis;
  326. wire fast_jog_dir;
  327. wire [15:0] fast_jog_steps;
  328. wire [15:0] crc_error_count;
  329. wire [15:0] timeout_count;
  330. wire [15:0] format_error_count;
  331. binary921_crc16 u_harness_crc (
  332. .crc_in(harness_crc),
  333. .data(drive_data),
  334. .crc_out(harness_crc_next)
  335. );
  336. prod2u_p4_normal_v3_rx #(
  337. .CLK_HZ(1000),
  338. .INTER_BYTE_TIMEOUT_MS(2)
  339. ) dut (
  340. .clk(clk),
  341. .rst_n(rst_n),
  342. .rx_valid(drive_valid),
  343. .rx_ready(rx_ready),
  344. .rx_data(drive_data),
  345. .request_valid(request_valid),
  346. .request_ready(1'b0),
  347. .request_type(request_type),
  348. .request_length(request_length),
  349. .request_payload(request_payload),
  350. .request_crc16(request_crc16),
  351. .fast_jog_valid(fast_jog_valid),
  352. .fast_jog_axis(fast_jog_axis),
  353. .fast_jog_dir(fast_jog_dir),
  354. .fast_jog_steps(fast_jog_steps),
  355. .crc_error_count(crc_error_count),
  356. .timeout_count(timeout_count),
  357. .format_error_count(format_error_count)
  358. );
  359. always @* begin
  360. if (local_index == 7'd0) begin
  361. drive_data = 8'ha5;
  362. end else if (local_index == 7'd1) begin
  363. drive_data = 8'h5a;
  364. end else if (local_index == 7'd2) begin
  365. drive_data = 8'h02;
  366. end else if (local_index == 7'd3) begin
  367. drive_data = 8'h04;
  368. end else if (local_index == 7'd4) begin
  369. drive_data = second_frame ? 8'h11 : 8'h05;
  370. end else if (local_index >= 7'd5 && local_index <= 7'd12) begin
  371. drive_data = 8'd0;
  372. end else if (local_index == 7'd13) begin
  373. drive_data = second_frame ? 8'd8 : 8'd4;
  374. end else if (local_index < crc_low_index) begin
  375. if (!second_frame) begin
  376. case (local_index)
  377. 7'd14: drive_data = 8'h24;
  378. default: drive_data = 8'd0;
  379. endcase
  380. end else begin
  381. case (local_index)
  382. 7'd14: drive_data = 8'h35;
  383. 7'd15: drive_data = {6'd0, jog_axis};
  384. 7'd16: drive_data = {7'd0, jog_dir};
  385. 7'd17: drive_data = {6'd0, jog_speed};
  386. 7'd18: drive_data = jog_steps[7:0];
  387. 7'd19: drive_data = jog_steps[15:8];
  388. default: drive_data = 8'd0;
  389. endcase
  390. end
  391. end else if (local_index == crc_low_index) begin
  392. drive_data = harness_crc[7:0];
  393. end else begin
  394. drive_data = harness_crc[15:8];
  395. end
  396. end
  397. always @(posedge clk) begin
  398. assume(jog_axis <= 2'd1);
  399. rst_n <= 1'b1;
  400. fast_event_previous <= fast_jog_valid;
  401. if (!rst_n) begin
  402. stream_index <= 7'd0;
  403. harness_crc <= 16'hffff;
  404. held_request_seen <= 1'b0;
  405. fast_event_seen <= 1'b0;
  406. fast_event_previous <= 1'b0;
  407. held_request_type <= 8'd0;
  408. held_request_length <= 6'd0;
  409. held_request_payload <= 272'd0;
  410. held_request_crc16 <= 16'd0;
  411. end else begin
  412. assert(rx_ready);
  413. assert(crc_error_count == 16'd0);
  414. assert(timeout_count == 16'd0);
  415. assert(format_error_count == 16'd0);
  416. if (stream_index < 7'd50) begin
  417. stream_index <= stream_index + 1'b1;
  418. end
  419. if (drive_valid && (local_index >= 7'd2) &&
  420. (local_index < crc_low_index)) begin
  421. harness_crc <= harness_crc_next;
  422. end else if (drive_valid && (local_index == crc_high_index)) begin
  423. harness_crc <= 16'hffff;
  424. end
  425. if (request_valid && !held_request_seen) begin
  426. held_request_seen <= 1'b1;
  427. held_request_type <= request_type;
  428. held_request_length <= request_length;
  429. held_request_payload <= request_payload;
  430. held_request_crc16 <= request_crc16;
  431. assert(request_type == 8'h05);
  432. assert(request_length == 6'd4);
  433. assert(request_payload == {240'd0, 32'h00000024});
  434. end
  435. if (held_request_seen) begin
  436. assert(request_valid);
  437. assert(request_type == held_request_type);
  438. assert(request_length == held_request_length);
  439. assert(request_payload == held_request_payload);
  440. assert(request_crc16 == held_request_crc16);
  441. end
  442. if (fast_jog_valid) begin
  443. assert(!fast_event_previous);
  444. assert(!fast_event_seen);
  445. assert(held_request_seen);
  446. assert(fast_jog_axis == jog_axis);
  447. assert(fast_jog_dir == jog_dir);
  448. assert(fast_jog_steps == jog_steps);
  449. fast_event_seen <= 1'b1;
  450. end
  451. if (stream_index >= 7'd48) begin
  452. assert(held_request_seen);
  453. assert(fast_event_seen);
  454. end
  455. end
  456. cover(fast_event_seen && held_request_seen);
  457. end
  458. endmodule
  459. // The small-parameter proof above supplies the independent countdown oracle.
  460. // This production instance proves the exact reload constants and every local
  461. // transition, which establishes 25,000 setup clocks and 12,500 clocks for each
  462. // STEP level without unrolling those full intervals.
  463. module prod2u_p4_fast_jog_production_timing_formal;
  464. localparam integer PRODUCTION_DIR_SETUP_CYCLES = 25000;
  465. localparam integer PRODUCTION_STEP_HALF_CYCLES = 12500;
  466. (* gclk *) reg clk;
  467. reg rst_n = 1'b0;
  468. (* anyseq *) reg fast_jog_valid;
  469. (* anyseq *) reg fast_jog_dir;
  470. (* anyseq *) reg [15:0] fast_jog_steps;
  471. reg past_valid = 1'b0;
  472. wire dut_step;
  473. wire dut_dir;
  474. wire dut_started;
  475. wire [1:0] dut_motion_phase;
  476. wire [31:0] dut_phase_counter;
  477. wire [15:0] dut_remaining_steps;
  478. prod2u_p4_axis_executor #(
  479. .DIR_SETUP_CYCLES(PRODUCTION_DIR_SETUP_CYCLES),
  480. .STEP_HALF_CYCLES(PRODUCTION_STEP_HALF_CYCLES)
  481. ) dut (
  482. .clk(clk),
  483. .rst_n(rst_n),
  484. .command_start(fast_jog_valid),
  485. .command_dir(fast_jog_dir),
  486. .command_steps(fast_jog_steps),
  487. .step_out(dut_step),
  488. .dir_out(dut_dir),
  489. .started_pulse(dut_started),
  490. .formal_motion_phase(dut_motion_phase),
  491. .formal_phase_counter(dut_phase_counter),
  492. .formal_remaining_steps(dut_remaining_steps)
  493. );
  494. always @(posedge clk) begin
  495. past_valid <= 1'b1;
  496. rst_n <= 1'b1;
  497. if (rst_n && fast_jog_valid) begin
  498. assume(fast_jog_steps != 16'd0);
  499. end
  500. if (!rst_n) begin
  501. assert(!dut_step);
  502. assert(!dut_started);
  503. end
  504. if (past_valid && $past(rst_n)) begin
  505. if ($past(fast_jog_valid)) begin
  506. assert(dut_motion_phase == 2'd1);
  507. assert(dut_phase_counter == 32'd24999);
  508. assert(dut_remaining_steps == $past(fast_jog_steps));
  509. assert(dut_dir == $past(fast_jog_dir));
  510. assert(!dut_step);
  511. assert(!dut_started);
  512. end else begin
  513. case ($past(dut_motion_phase))
  514. 2'd0: begin
  515. assert(dut_motion_phase == 2'd0);
  516. assert(dut_phase_counter == 32'd0);
  517. assert(dut_remaining_steps == 16'd0);
  518. assert(!dut_step);
  519. assert(!dut_started);
  520. end
  521. 2'd1: begin
  522. if ($past(dut_phase_counter) != 32'd0) begin
  523. assert(dut_motion_phase == 2'd1);
  524. assert(dut_phase_counter ==
  525. $past(dut_phase_counter) - 1'b1);
  526. assert(!dut_step);
  527. assert(!dut_started);
  528. end else begin
  529. assert(dut_motion_phase == 2'd2);
  530. assert(dut_phase_counter == 32'd12499);
  531. assert(dut_step);
  532. assert(dut_started);
  533. end
  534. assert(dut_remaining_steps ==
  535. $past(dut_remaining_steps));
  536. assert(dut_dir == $past(dut_dir));
  537. end
  538. 2'd2: begin
  539. if ($past(dut_phase_counter) != 32'd0) begin
  540. assert(dut_motion_phase == 2'd2);
  541. assert(dut_phase_counter ==
  542. $past(dut_phase_counter) - 1'b1);
  543. assert(dut_step);
  544. end else begin
  545. assert(dut_motion_phase == 2'd3);
  546. assert(dut_phase_counter == 32'd12499);
  547. assert(!dut_step);
  548. end
  549. assert(dut_remaining_steps ==
  550. $past(dut_remaining_steps));
  551. assert(dut_dir == $past(dut_dir));
  552. assert(!dut_started);
  553. end
  554. 2'd3: begin
  555. if ($past(dut_phase_counter) != 32'd0) begin
  556. assert(dut_motion_phase == 2'd3);
  557. assert(dut_phase_counter ==
  558. $past(dut_phase_counter) - 1'b1);
  559. assert(dut_remaining_steps ==
  560. $past(dut_remaining_steps));
  561. assert(!dut_step);
  562. end else if ($past(dut_remaining_steps) == 16'd1) begin
  563. assert(dut_motion_phase == 2'd0);
  564. assert(dut_phase_counter == 32'd0);
  565. assert(dut_remaining_steps == 16'd0);
  566. assert(!dut_step);
  567. end else begin
  568. assert(dut_motion_phase == 2'd2);
  569. assert(dut_phase_counter == 32'd12499);
  570. assert(dut_remaining_steps ==
  571. $past(dut_remaining_steps) - 1'b1);
  572. assert(dut_step);
  573. end
  574. assert(dut_dir == $past(dut_dir));
  575. assert(!dut_started);
  576. end
  577. endcase
  578. end
  579. assert(!dut_started || dut_step);
  580. end
  581. cover(rst_n && fast_jog_valid && (fast_jog_steps == 16'hffff));
  582. end
  583. endmodule
  584. `default_nettype wire