prod2u_mrdimm_uart_e2e_tb.v 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. `timescale 1ns/1ps
  2. // UART-level end-to-end test for the mrdimm-chamber product stack over the
  3. // unified 16-bit-length protocol: real UART byte timing -> frame_rx ->
  4. // mrdimm_host_command -> mrdimm_output_core + motor_engine. Vectors are
  5. // generated by the independent Python codec (hth_protocol).
  6. module prod2u_mrdimm_uart_e2e_tb;
  7. localparam integer CLKS = 8;
  8. reg clk = 1'b0;
  9. reg rst_n = 1'b0;
  10. reg rx = 1'b1;
  11. reg tick_us = 1'b0;
  12. reg tick_1s = 1'b0;
  13. reg [2:0] limit_lower_raw = 3'b000;
  14. reg [2:0] limit_upper_raw = 3'b000;
  15. wire frame_valid, frame_ready, frame_accept_enable;
  16. wire [7:0] frame_type;
  17. wire [15:0] frame_length;
  18. wire [15:0] payload_rd_addr;
  19. wire [7:0] payload_rd_data;
  20. wire payload_wr_en;
  21. wire [15:0] payload_wr_addr;
  22. wire [7:0] payload_wr_data;
  23. wire thermal_wr_en, thermal_commit, thermal_commit_done, thermal_commit_ok;
  24. wire [2:0] thermal_wr_addr;
  25. wire [7:0] thermal_wr_data;
  26. wire keepalive_reload, snapshot_capture, snapshot_ready;
  27. wire qw_byte_we, qw_submit, qw_accept, ctl_valid, ctl_accept;
  28. wire [6:0] qw_byte_addr;
  29. wire [7:0] qw_byte_data, qw_status, ctl_status;
  30. wire [3:0] qw_count;
  31. wire [15:0] qw_detail, ctl_detail;
  32. wire [2:0] ctl_op;
  33. wire [15:0] ctl_axis_mask;
  34. wire [7:0] ctl_flags;
  35. wire [31:0] ctl_value;
  36. wire [7:0] ev_rd_index_w;
  37. wire ev_hold;
  38. wire [127:0] ev_rd_data;
  39. wire ev_view_ready;
  40. wire [7:0] ev_view_count;
  41. wire [7:0] ev_count, ev_overflow;
  42. wire [31:0] ev_time_us;
  43. wire ev_clear_n_w;
  44. wire [7:0] ev_clear_count_w;
  45. wire [7:0] status_byte_in;
  46. wire tx_start, tx_done;
  47. wire [7:0] tx_frame_type, tx_payload_data;
  48. wire [15:0] tx_payload_length;
  49. wire host_command_busy;
  50. wire [3:0] fan_on, ptc_on;
  51. wire [7:0] applied_fan0;
  52. wire [2:0] step_bus, dir_bus;
  53. wire host_response_done_w;
  54. integer commits, acks;
  55. reg in_data_phase;
  56. reg [15:0] data_len_seen;
  57. always #1 clk = ~clk;
  58. // Accelerated wall clock, but the production25 clocks per microsecond
  59. // and one-clock enable are preserved for motor/snapshot scheduling.
  60. integer tick_divider=0;
  61. always @(negedge clk)begin
  62. if(!rst_n)begin tick_divider=0;tick_us=0;end
  63. else if(tick_divider==24)begin tick_divider=0;tick_us=1;end
  64. else begin tick_divider=tick_divider+1;tick_us=0;end
  65. end
  66. uart_rx_byte #(.CLKS_PER_BIT(CLKS)) u_uart_rx (
  67. .clk(clk), .rst_n(rst_n), .rx_i(rx),
  68. .byte_valid(), .byte_data(), .framing_error()
  69. );
  70. // Byte-level feeder shared by frame_rx: reuse uart_rx_byte output via
  71. // explicit wires (declared above as internal names).
  72. wire uart_rx_valid_w;
  73. wire [7:0] uart_rx_data_w;
  74. wire uart_framing_error_w;
  75. uart_rx_byte #(.CLKS_PER_BIT(CLKS)) u_host_rx (
  76. .clk(clk), .rst_n(rst_n), .rx_i(rx),
  77. .byte_valid(uart_rx_valid_w), .byte_data(uart_rx_data_w),
  78. .framing_error(uart_framing_error_w)
  79. );
  80. frame_rx #(.MAX_PAYLOAD(256), .INTER_BYTE_TIMEOUT_CYCLES(400), .EXTERNAL_CRC(1)) u_frame_rx (
  81. .clk(clk), .rst_n(rst_n), .byte_valid(uart_rx_valid_w),
  82. .byte_data(uart_rx_data_w), .accept_enable(frame_accept_enable),
  83. .frame_valid(frame_valid), .frame_ready(frame_ready),
  84. .frame_type(frame_type), .frame_length(frame_length),
  85. .payload_read_addr(payload_rd_addr), .payload_read_data(payload_rd_data),
  86. .payload_wr_en(payload_wr_en), .payload_wr_addr(payload_wr_addr),
  87. .payload_wr_data(payload_wr_data),
  88. .crc_start_o(crc_start_w), .crc_data_valid_o(crc_dv_w), .crc_data_o(crc_byte_w),
  89. .crc_busy_i(host_crc_busy_w), .crc_data_done_i(crc_done_w), .crc_value_i(crc_val_w)
  90. );
  91. payload_ram #(.DEPTH(256), .ADDR_WIDTH(8)) u_payload (
  92. .clk(clk), .wr_en(payload_wr_en), .wr_addr(payload_wr_addr),
  93. .wr_data(payload_wr_data), .rd_addr(payload_rd_addr), .rd_data(payload_rd_data)
  94. );
  95. wire host_crc_busy_w, crc_start_w, crc_dv_w, crc_done_w;
  96. wire [7:0] crc_byte_w;
  97. wire [15:0] crc_val_w;
  98. crc16_serial u_crc (
  99. .clk(clk), .rst_n(rst_n),
  100. .start(crc_start_w), .data_valid(crc_dv_w),
  101. .data(crc_byte_w), .busy(host_crc_busy_w),
  102. .data_done(crc_done_w), .crc(crc_val_w)
  103. );
  104. mrdimm_host_command #(.SNAPSHOT_LENGTH(352)) dut (
  105. .clk(clk), .rst_n(rst_n),
  106. .frame_valid(frame_valid), .frame_ready(frame_ready),
  107. .frame_accept_enable(frame_accept_enable), .frame_type(frame_type),
  108. .frame_length(frame_length),
  109. .payload_read_addr(payload_rd_addr), .payload_read_data(payload_rd_data),
  110. .thermal_wr_en(thermal_wr_en), .thermal_wr_addr(thermal_wr_addr),
  111. .thermal_wr_data(thermal_wr_data), .thermal_commit(thermal_commit),
  112. .thermal_commit_done(thermal_commit_done), .thermal_commit_ok(thermal_commit_ok),
  113. .lease_active(lease_active_w), .keepalive_reload(keepalive_reload),
  114. .snapshot_capture(snapshot_capture), .snapshot_ready(snapshot_ready),
  115. .qw_byte_we(qw_byte_we), .qw_byte_addr(qw_byte_addr),
  116. .qw_byte_data(qw_byte_data), .qw_submit(qw_submit), .qw_count(qw_count),
  117. .qw_accept(qw_accept), .qw_status(qw_status), .qw_detail(qw_detail),
  118. .ctl_valid(ctl_valid), .ctl_op(ctl_op), .ctl_axis_mask(ctl_axis_mask),
  119. .ctl_flags(ctl_flags), .ctl_value(ctl_value),
  120. .ctl_accept(ctl_accept), .ctl_status(ctl_status), .ctl_detail(ctl_detail),
  121. .ev_rd_index(ev_rd_index_w), .ev_hold(ev_hold),
  122. .ev_rd_data(ev_rd_data), .ev_count(ev_count), .ev_overflow(ev_overflow),
  123. .ev_view_ready(ev_view_ready), .ev_view_count(ev_view_count),
  124. .ev_clear_n(ev_clear_n_w), .ev_clear_count(ev_clear_count_w),
  125. .status_byte_in(status_byte_in),
  126. .tx_payload_addr(u_frame_tx.payload_addr),
  127. .ack_payload_data(), .tx_payload_data(tx_payload_data),
  128. .tx_start(tx_start), .tx_frame_type(tx_frame_type),
  129. .tx_payload_length(tx_payload_length), .tx_done(host_response_done_w),
  130. .transaction_done(), .busy(host_command_busy)
  131. );
  132. wire lease_active_w;
  133. wire [7:0] applied_fan [0:3];
  134. wire [7:0] applied_ptc [0:3];
  135. wire [7:0] watchdog_remaining_w;
  136. wire [31:0] applied_fan_packed;
  137. assign applied_fan[0]=applied_fan_packed[0*8 +:8];
  138. assign applied_fan[1]=applied_fan_packed[1*8 +:8];
  139. assign applied_fan[2]=applied_fan_packed[2*8 +:8];
  140. assign applied_fan[3]=applied_fan_packed[3*8 +:8];
  141. wire [31:0] applied_ptc_packed;
  142. assign applied_ptc[0]=applied_ptc_packed[0*8 +:8];
  143. assign applied_ptc[1]=applied_ptc_packed[1*8 +:8];
  144. assign applied_ptc[2]=applied_ptc_packed[2*8 +:8];
  145. assign applied_ptc[3]=applied_ptc_packed[3*8 +:8];
  146. mrdimm_output_core #(
  147. .LEASE_SECONDS(8'd30), .PWM_PERIOD_CLKS(1000), .PWM_CLKS_PER_PERCENT(10)
  148. ) u_output (
  149. .clk(clk), .rst_n(rst_n), .tick_1s(tick_1s),
  150. .wr_en(thermal_wr_en), .wr_addr(thermal_wr_addr), .wr_data(thermal_wr_data),
  151. .commit(thermal_commit), .commit_done(thermal_commit_done),
  152. .commit_ok(thermal_commit_ok), .keepalive_reload(keepalive_reload),
  153. .applied_fan(applied_fan_packed), .applied_ptc(applied_ptc_packed),
  154. .manual_active(), .lease_active(lease_active_w),
  155. .watchdog_remaining(watchdog_remaining_w),
  156. .fan_pwm_on(fan_on), .ptc_pwm_on(ptc_on)
  157. );
  158. wire [1535:0] axis_telemetry;
  159. wire [4:0] status_word_addr;
  160. wire [3:0] status_axis;
  161. wire [15:0] status_word_data;
  162. wire [31:0] unused_time;
  163. motor_engine #(
  164. .AXIS_COUNT(3),
  165. .X_DEFAULT_HALF_US(32'd500), .Y_DEFAULT_HALF_US(32'd500), .Z_DEFAULT_HALF_US(32'd20000),
  166. .X_MIN_HALF_US(32'd500), .Y_MIN_HALF_US(32'd500), .Z_MIN_HALF_US(32'd20000),
  167. .DIR_SETUP_TICKS(1000)
  168. ) u_motor (
  169. .clk(clk), .rst_n(rst_n), .tick_us(tick_us),
  170. .limit_lower_raw(limit_lower_raw), .limit_upper_raw(limit_upper_raw),
  171. .qw_byte_we(qw_byte_we), .qw_byte_addr(qw_byte_addr),
  172. .qw_byte_data(qw_byte_data), .qw_submit(qw_submit), .qw_count(qw_count),
  173. .qw_accept(qw_accept), .qw_status(qw_status), .qw_detail(qw_detail),
  174. .ctl_valid(ctl_valid), .ctl_op(ctl_op), .ctl_axis_mask(ctl_axis_mask),
  175. .ctl_flags(ctl_flags), .ctl_value(ctl_value),
  176. .ctl_accept(ctl_accept), .ctl_status(ctl_status), .ctl_detail(ctl_detail),
  177. .startup_seek(1'b0),
  178. .ev_rd_index(ev_rd_index_w), .ev_hold(ev_hold),
  179. .ev_rd_data(ev_rd_data), .ev_count(ev_count), .ev_overflow(ev_overflow),
  180. .ev_view_ready(ev_view_ready), .ev_view_count(ev_view_count),
  181. .ev_time_us(unused_time),
  182. .ev_clear_n(ev_clear_n_w), .ev_clear_count(ev_clear_count_w),
  183. .axis_telemetry(axis_telemetry),
  184. .telemetry_word_addr(status_word_addr),.telemetry_axis(status_axis),.telemetry_word_data(status_word_data),
  185. .step_out(step_bus), .dir_out(dir_bus)
  186. );
  187. mrdimm_snapshot_mux #(.SCANNER_WORD_PORT(1)) u_snapshot (
  188. .clk(clk),.rst_n(rst_n),.capture(snapshot_capture),.source_ready(u_motor.motor_telemetry_ready),.source_epoch(u_motor.motor_status_epoch),.ready(snapshot_ready),.locked(),
  189. .bmc_locked_bank(),.ct_locked_bank(),
  190. .fan_applied({applied_fan[3],applied_fan[2],applied_fan[1],applied_fan[0]}),
  191. .ptc_applied({applied_ptc[3],applied_ptc[2],applied_ptc[1],applied_ptc[0]}),
  192. .fan_requested({applied_fan[3],applied_fan[2],applied_fan[1],applied_fan[0]}),
  193. .ptc_requested({applied_ptc[3],applied_ptc[2],applied_ptc[1],applied_ptc[0]}),
  194. .watchdog_active(lease_active_w),.watchdog_remaining(watchdog_remaining_w),
  195. .bmc_active_bank(1'b0),.ct_active_bank(1'b0),.bmc_stale(1'b1),.ct_stale(1'b1),
  196. .bmc_epoch(16'd0),.ct_epoch(16'd0),.bmc_age(16'd0),.ct_age(16'd0),
  197. .bmc_valid_mask(24'd0),.ct_valid_mask(27'd0),.bmc_rd_index(),.ct_rd_index(),
  198. .bmc_rd_raw(16'd0),.ct_rd_raw(16'd0),.axis_data(axis_telemetry),
  199. .scanner_axis(status_axis),.scanner_word_data(status_word_data),.scanner_word_addr(status_word_addr),
  200. .time_us(unused_time),.time_high(32'd0),.event_overflow(32'd0),
  201. .event_pending_overflow(32'd0),.ev_count(ev_count),.global_flags(32'd0),
  202. .read_addr(frame_tx_payload_addr_w[9:0]),.read_data(status_byte_in)
  203. );
  204. // frame_tx consumes the command core payload for ACK/DATA lengths.
  205. wire frame_tx_done_w, frame_tx_busy_w, frame_tx_byte_valid_w;
  206. wire [7:0] frame_tx_byte_data_w;
  207. wire [15:0] frame_tx_payload_addr_w;
  208. frame_tx #(.PAYLOAD_IDX_BITS(10), .EXTERNAL_CRC(0), .PAYLOAD_READ_LATENCY(1)) u_frame_tx (
  209. .clk(clk), .rst_n(rst_n), .start(tx_start), .frame_type(tx_frame_type),
  210. .payload_length(tx_payload_length), .busy(frame_tx_busy_w),
  211. .byte_valid(frame_tx_byte_valid_w), .byte_data(frame_tx_byte_data_w),
  212. .byte_ready(1'b1), .payload_addr(frame_tx_payload_addr_w),
  213. .payload_data(tx_payload_data), .done(frame_tx_done_w),
  214. .crc_start_o(), .crc_data_valid_o(), .crc_data_o(),
  215. .crc_busy_i(1'b0), .crc_data_done_i(), .crc_value_i()
  216. );
  217. assign host_response_done_w = frame_tx_done_w;
  218. // ---- UART byte feeder (shared for all frames) ----
  219. task send_byte;
  220. input [7:0] value;
  221. integer k;
  222. begin
  223. rx = 1'b0;
  224. repeat (CLKS) @(posedge clk);
  225. for (k = 0; k < 8; k = k + 1) begin
  226. rx = value[k];
  227. repeat (CLKS) @(posedge clk);
  228. end
  229. rx = 1'b1;
  230. repeat (CLKS) @(posedge clk);
  231. end
  232. endtask
  233. initial begin
  234. commits = 0; acks = 0;
  235. forever begin
  236. @(posedge clk);
  237. if (thermal_commit) commits = commits + 1;
  238. if (tx_start && tx_frame_type==8'h80) begin
  239. acks = acks + 1;
  240. if (tx_frame_type !== 8'h80)
  241. $fatal(1, "frame %02x is not an ACK", tx_frame_type);
  242. if (tx_payload_length !== 16'd4)
  243. $fatal(1, "ACK payload length %0d", tx_payload_length);
  244. end
  245. end
  246. end
  247. initial begin
  248. wait (rst_n);
  249. // ---- SET_ALL fan20/ptc0, endpoints FF (no motor touch) ----
  250. send_byte(8'hA5); send_byte(8'h5A); send_byte(8'h01);
  251. send_byte(8'h0B); send_byte(8'h00);
  252. send_byte(8'h14); send_byte(8'h14); send_byte(8'h14); send_byte(8'h14);
  253. send_byte(8'h00); send_byte(8'h00); send_byte(8'h00); send_byte(8'h00);
  254. send_byte(8'hFF); send_byte(8'hFF); send_byte(8'hFF);
  255. send_byte(8'h89); send_byte(8'h04);
  256. repeat (2000) @(posedge clk);
  257. if (commits !== 1) $fatal(1, "SET_ALL commits=%0d", commits);
  258. if (acks !== 1) $fatal(1, "SET_ALL acks=%0d", acks);
  259. if (applied_fan[0] !== 8'd20) $fatal(1, "fan duty not applied");
  260. if (u_motor.ax_active[0] !== 1'b0)
  261. $fatal(1, "FF endpoint must not touch motors");
  262. // ---- SET_ALL with X=lower endpoint: commit + engine accepted ----
  263. send_byte(8'hA5); send_byte(8'h5A); send_byte(8'h01);
  264. send_byte(8'h0B); send_byte(8'h00);
  265. send_byte(8'h14); send_byte(8'h14); send_byte(8'h14); send_byte(8'h14);
  266. send_byte(8'h00); send_byte(8'h00); send_byte(8'h00); send_byte(8'h00);
  267. send_byte(8'hFF); send_byte(8'h00); send_byte(8'hFF);
  268. send_byte(8'h76); send_byte(8'h07);
  269. repeat (3000) @(posedge clk);
  270. if (commits !== 2) $fatal(1, "X-low commits=%0d", commits);
  271. if (u_motor.ax_active[0] !== 1'b1)
  272. $fatal(1, "X seek not accepted");
  273. if (u_motor.u_axes.r_mode[0] !== 3'd1)
  274. $fatal(1, "X must run seek_lower");
  275. // ---- bad CRC: silent ----
  276. send_byte(8'hA5); send_byte(8'h5A); send_byte(8'h01);
  277. send_byte(8'h0B); send_byte(8'h00);
  278. send_byte(8'h14); send_byte(8'h14); send_byte(8'h14); send_byte(8'h14);
  279. send_byte(8'h00); send_byte(8'h00); send_byte(8'h00); send_byte(8'h00);
  280. send_byte(8'hFF); send_byte(8'hFF); send_byte(8'hFF);
  281. send_byte(8'h89); send_byte(8'hFB);
  282. repeat (1000) @(posedge clk);
  283. if (commits !== 2) $fatal(1, "bad CRC committed");
  284. if (acks !== 2) $fatal(1, "bad CRC acked");
  285. // ---- MOTOR_QUEUE_WRITE with count=0: BAD_LENGTH NACK ----
  286. send_byte(8'hA5); send_byte(8'h5A); send_byte(8'h03);
  287. send_byte(8'h11); send_byte(8'h00);
  288. for (int j = 0; j < 17; j = j + 1) send_byte(8'h00);
  289. send_byte(8'h2F); send_byte(8'h46);
  290. repeat (2000) @(posedge clk);
  291. if (acks !== 3) $fatal(1, "QW acks=%0d", acks);
  292. if (commits !== 2) $fatal(1, "QW must not commit");
  293. // ---- KEEPALIVE contract vector: ACK only ----
  294. send_byte(8'hA5); send_byte(8'h5A); send_byte(8'h05);
  295. send_byte(8'h00); send_byte(8'h00);
  296. send_byte(8'h6C); send_byte(8'h27);
  297. repeat (500) @(posedge clk);
  298. if (acks !== 4) $fatal(1, "keepalive acks=%0d", acks);
  299. if (commits !== 2) $fatal(1, "keepalive must not commit");
  300. // ---- GET_ALL while a real seek is active: ACK then81 DATA(352B) ----
  301. wait(step_bus[0]);
  302. send_byte(8'hA5); send_byte(8'h5A); send_byte(8'h02);
  303. send_byte(8'h00); send_byte(8'h00);
  304. send_byte(8'hFC); send_byte(8'hA2);
  305. wait(response_checks==6);@(negedge clk);
  306. if (data_len_seen !== 16'd352) $fatal(1, "ALL_STATUS length %0d", data_len_seen);
  307. if (response_checks!==6) $fatal(1,"incomplete serialized responses: %0d",response_checks);
  308. // Abort the running X seek, then read its stable event through 80/83.
  309. send_byte(8'hA5);send_byte(8'h5A);send_byte(8'h04);send_byte(8'h08);send_byte(0);
  310. send_byte(1);send_byte(1);repeat(6) send_byte(0);send_byte(8'hB1);send_byte(8'h30);
  311. repeat(1000) @(posedge clk);
  312. if(u_motor.ax_active[0] || acks!=6) $fatal(1,"control abort transaction");
  313. send_byte(8'hA5);send_byte(8'h5A);send_byte(8'h08);send_byte(1);send_byte(0);
  314. send_byte(8);send_byte(8'h3B);send_byte(8'hB7);
  315. repeat(2000) @(posedge clk);
  316. if(response_checks!=9 || acks!=7) $fatal(1,"EVENT_READ did not complete ACK plus DATA");
  317. send_byte(8'hA5);send_byte(8'h5A);send_byte(4);send_byte(8);send_byte(0);
  318. send_byte(8);send_byte(1);repeat(6)send_byte(0);send_byte(8'hB8);send_byte(8'h69);
  319. repeat(1000)@(posedge clk);
  320. if(response_checks!=10 || acks!=8)$fatal(1,"invalid MOTOR_CONTROL did not NACK");
  321. $display("prod2u_mrdimm_uart_e2e_tb PASS");
  322. $finish;
  323. end
  324. // track the DATA phase length of GET_ALL responses
  325. always @(posedge clk) begin
  326. if (tx_start && tx_frame_type == 8'h81) data_len_seen <= tx_payload_length;
  327. end
  328. // Independently inspect the actual serializer bytes. Counting tx_start
  329. // alone would miss a one-bit payload bus or DATA being sent in an ACK.
  330. reg [7:0] response_bytes [0:1023];
  331. integer response_count=0, response_checks=0, rb, bitno;
  332. reg [15:0] crc_check;
  333. always @(posedge clk) begin
  334. if (frame_tx_byte_valid_w) begin
  335. response_bytes[response_count]=frame_tx_byte_data_w;
  336. response_count=response_count+1;
  337. end
  338. if (frame_tx_done_w) begin
  339. if(response_count != 7+{response_bytes[4],response_bytes[3]})
  340. $fatal(1,"response length does not match wire bytes");
  341. crc_check=16'hFFFF;
  342. for(rb=2;rb<response_count-2;rb=rb+1) begin
  343. crc_check=crc_check ^ {response_bytes[rb],8'd0};
  344. for(bitno=0;bitno<8;bitno=bitno+1)
  345. crc_check=crc_check[15] ? (crc_check<<1)^16'h1021 : crc_check<<1;
  346. end
  347. if(crc_check !== {response_bytes[response_count-1],response_bytes[response_count-2]})
  348. $fatal(1,"response CRC mismatch");
  349. if(response_bytes[2]==8'h80) begin
  350. if(response_bytes[5] !== ((acks<=2) ? 8'h01 : (acks==3 ? 8'h03 : (acks==4 ? 8'h05 : (acks==5 ? 8'h02 : (acks==7 ? 8'h08 : 8'h04))))))
  351. $fatal(1,"ACK request type corrupted: %02x",response_bytes[5]);
  352. if(response_bytes[6] !== (acks==3 ? 8'd2 : (acks==8 ? 8'd3 : 8'd0)))
  353. $fatal(1,"ACK business status corrupted: %02x",response_bytes[6]);
  354. end else if(response_bytes[2]==8'h81) begin
  355. if(acks!=5) $fatal(1,"DATA preceded its ACK");
  356. end else if(response_bytes[2]==8'h83) begin
  357. if(acks!=7 || response_bytes[5]!=2 || response_bytes[10]!=8'hFF || response_bytes[11]!=6 ||
  358. response_bytes[26]!=0 || response_bytes[27]!=4)
  359. $fatal(1,"EVENT payload count/axis/code corruption");
  360. end else $fatal(1,"unexpected response type");
  361. response_checks=response_checks+1;response_count=0;
  362. end
  363. end
  364. initial begin #1000000; $fatal(1,"MRDIMM e2e deadline");end
  365. initial begin
  366. clk = 1'b0;
  367. repeat (4) @(posedge clk);
  368. rst_n = 1'b1;
  369. end
  370. endmodule