6400_transport_properties_formal.v 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. module thermal_6400_transport_properties_formal (
  2. input wire clk,
  3. input wire rst_n
  4. );
  5. (* anyseq *) reg byte_valid;
  6. (* anyseq *) reg [7:0] byte_data;
  7. (* anyseq *) reg snapshot_ready;
  8. (* anyseq *) reg tx_done;
  9. (* anyseq *) reg rs232_rx;
  10. (* anyseq *) reg ttl_rx;
  11. (* anyseq *) reg shared_tx;
  12. wire frame_valid;
  13. wire frame_ready;
  14. wire frame_accept_enable;
  15. wire [7:0] frame_type;
  16. wire [7:0] frame_length;
  17. wire [7:0] payload_read_addr;
  18. wire [7:0] payload_read_data;
  19. wire payload_wr_en;
  20. wire [7:0] payload_wr_addr;
  21. wire [7:0] payload_wr_data;
  22. wire rx_formal_crc_accepted;
  23. wire rx_formal_bad_crc_event;
  24. wire target_commit;
  25. wire [7:0] target_celsius;
  26. wire snapshot_capture;
  27. wire tx_start;
  28. wire [7:0] tx_frame_type;
  29. wire [7:0] tx_payload_length;
  30. wire transaction_done;
  31. wire command_busy;
  32. wire selected_rx;
  33. wire rs232_tx;
  34. wire ttl_tx;
  35. wire host_locked;
  36. wire host_port_sel;
  37. wire production_stimulus_accept = frame_valid && frame_ready &&
  38. frame_accept_enable && frame_type == 8'h03 && frame_length == 8'd33;
  39. frame_rx #(.MAX_PAYLOAD(33), .INTER_BYTE_TIMEOUT_CYCLES(8)) u_frame_rx (
  40. .clk(clk), .rst_n(rst_n), .byte_valid(byte_valid), .byte_data(byte_data),
  41. .accept_enable(frame_accept_enable), .frame_valid(frame_valid), .frame_ready(frame_ready),
  42. .frame_type(frame_type), .frame_length(frame_length),
  43. .payload_read_addr(payload_read_addr), .payload_read_data(payload_read_data),
  44. .payload_wr_en(payload_wr_en), .payload_wr_addr(payload_wr_addr),
  45. .payload_wr_data(payload_wr_data),
  46. .formal_crc_accepted_o(rx_formal_crc_accepted),
  47. .formal_bad_crc_event_o(rx_formal_bad_crc_event)
  48. );
  49. payload_ram #(.DEPTH(33), .ADDR_WIDTH(8)) u_payload (
  50. .clk(clk), .wr_en(payload_wr_en), .wr_addr(payload_wr_addr), .wr_data(payload_wr_data),
  51. .rd_addr(payload_read_addr), .rd_data(payload_read_data)
  52. );
  53. thermal_host_command #(.ENABLE_STIMULUS(0), .SNAPSHOT_LENGTH(193)) u_command (
  54. .clk(clk), .rst_n(rst_n), .frame_valid(frame_valid), .frame_ready(frame_ready),
  55. .frame_accept_enable(frame_accept_enable), .frame_type(frame_type), .frame_length(frame_length),
  56. .payload_read_addr(payload_read_addr), .payload_read_data(payload_read_data),
  57. .target_commit(target_commit), .target_celsius(target_celsius),
  58. .stimulus_wr_en(), .stimulus_wr_addr(), .stimulus_wr_data(),
  59. .stimulus_commit(), .stimulus_duration_seconds(), .snapshot_capture(snapshot_capture),
  60. .snapshot_ready(snapshot_ready), .tx_start(tx_start), .tx_frame_type(tx_frame_type),
  61. .tx_payload_length(tx_payload_length), .tx_done(tx_done),
  62. .transaction_done(transaction_done), .busy(command_busy)
  63. );
  64. host_port_selector #(.IDLE_UNLOCK_CLKS(16)) u_selector (
  65. .clk(clk), .rst_n(rst_n), .rs232_rx_async(rs232_rx), .ttl_rx_async(ttl_rx),
  66. .shared_tx(shared_tx), .transaction_done(transaction_done), .selected_rx(selected_rx),
  67. .rs232_tx(rs232_tx), .ttl_tx(ttl_tx), .locked(host_locked), .port_sel(host_port_sel),
  68. .rs232_rx_sync(), .ttl_rx_sync()
  69. );
  70. reg [1:0] reset_cycles = 0;
  71. reg accepted_crc_good = 0;
  72. reg bad_crc_quarantine = 0;
  73. reg [7:0] bad_crc_target = 0;
  74. always @(posedge clk) begin
  75. if (reset_cycles < 2) begin
  76. assume(!rst_n);
  77. reset_cycles <= reset_cycles + 1'b1;
  78. end else assume(rst_n);
  79. if (!rst_n) begin
  80. accepted_crc_good <= 0;
  81. bad_crc_quarantine <= 0;
  82. bad_crc_target <= target_celsius;
  83. end else begin
  84. if (rx_formal_bad_crc_event) begin
  85. bad_crc_quarantine <= 1;
  86. bad_crc_target <= target_celsius;
  87. end
  88. if (frame_valid && frame_ready) begin
  89. assert(rx_formal_crc_accepted);
  90. accepted_crc_good <= rx_formal_crc_accepted;
  91. bad_crc_quarantine <= 0;
  92. end
  93. if (transaction_done)
  94. accepted_crc_good <= 0;
  95. // P06 end-to-end: from a rejected CRC through the parser and
  96. // command engine, Target is immutable until another CRC-valid
  97. // frame is explicitly accepted.
  98. if (bad_crc_quarantine && !(frame_valid && frame_ready)) begin
  99. assert(!target_commit);
  100. assert(target_celsius == bad_crc_target);
  101. end
  102. if (target_commit)
  103. assert(accepted_crc_good);
  104. // Production has no stimulus capability. A CRC-valid stimulus
  105. // frame is still an unsupported command and therefore retires
  106. // silently without an ACK or a hidden stimulus commit.
  107. if (formal_past_valid && $past(rst_n) &&
  108. $past(production_stimulus_accept)) begin
  109. assert(transaction_done);
  110. assert(!tx_start);
  111. assert(!stimulus_commit);
  112. end
  113. cover(bad_crc_quarantine && !target_commit &&
  114. target_celsius == bad_crc_target);
  115. cover(target_commit && accepted_crc_good && tx_start &&
  116. tx_frame_type == 8'h81);
  117. cover(formal_past_valid && $past(production_stimulus_accept) &&
  118. transaction_done && !tx_start && !stimulus_commit);
  119. end
  120. end
  121. endmodule