|
|
@@ -0,0 +1,251 @@
|
|
|
+// Command-level Identification proof. Physical UART serialization and its
|
|
|
+// final Stop Bit remain covered by source inspection and full-UART Cocotb;
|
|
|
+// this harness proves command admission, atomic stimulus commit, ACK metadata,
|
|
|
+// repeat handling, and silent invalid-command retirement.
|
|
|
+module thermal_6400_transport_identification_properties_formal (
|
|
|
+ input wire clk,
|
|
|
+ input wire rst_n
|
|
|
+);
|
|
|
+ (* anyseq *) reg frame_valid;
|
|
|
+ (* anyseq *) reg [7:0] frame_type;
|
|
|
+ (* anyseq *) reg [7:0] frame_length;
|
|
|
+ (* anyseq *) reg snapshot_ready;
|
|
|
+ (* anyseq *) reg tx_done;
|
|
|
+ // Every request in one proof trace uses the same payload case. Case zero
|
|
|
+ // is valid duration=2 / duty=50, case one has duration zero, and cases two
|
|
|
+ // and three contain a duty of 101. All four anyconst values therefore have
|
|
|
+ // an explicit semantic class without an extra proof assumption.
|
|
|
+ (* anyconst *) reg [1:0] payload_case;
|
|
|
+
|
|
|
+ wire frame_ready;
|
|
|
+ wire frame_accept_enable;
|
|
|
+ wire [7:0] payload_read_addr;
|
|
|
+ reg [7:0] payload_read_data;
|
|
|
+ wire target_commit;
|
|
|
+ wire [7:0] target_celsius;
|
|
|
+ wire stimulus_wr_en;
|
|
|
+ wire [4:0] stimulus_wr_addr;
|
|
|
+ wire [7:0] stimulus_wr_data;
|
|
|
+ wire stimulus_commit;
|
|
|
+ wire [7:0] stimulus_duration_seconds;
|
|
|
+ wire snapshot_capture;
|
|
|
+ wire tx_start;
|
|
|
+ wire [7:0] tx_frame_type;
|
|
|
+ wire [7:0] tx_payload_length;
|
|
|
+ wire transaction_done;
|
|
|
+ wire command_busy;
|
|
|
+ wire [3:0] formal_state;
|
|
|
+ wire [5:0] formal_index;
|
|
|
+ wire formal_stimulus_bad;
|
|
|
+ wire bank_commit_applied;
|
|
|
+ wire stimulus_bank_active;
|
|
|
+ (* anyconst *) reg [4:0] formal_bank_address;
|
|
|
+ wire [7:0] formal_active_stimulus_data;
|
|
|
+
|
|
|
+ always @* begin
|
|
|
+ if (payload_read_addr == 0)
|
|
|
+ payload_read_data = (payload_case == 1) ? 8'd0 : 8'd2;
|
|
|
+ else if (payload_case[1] && payload_read_addr == 17)
|
|
|
+ payload_read_data = 8'd101;
|
|
|
+ else
|
|
|
+ payload_read_data = 8'd50;
|
|
|
+ end
|
|
|
+
|
|
|
+ thermal_host_command #(.ENABLE_STIMULUS(1), .SNAPSHOT_LENGTH(193)) u_command (
|
|
|
+ .clk(clk), .rst_n(rst_n), .frame_valid(frame_valid), .frame_ready(frame_ready),
|
|
|
+ .frame_accept_enable(frame_accept_enable), .frame_type(frame_type),
|
|
|
+ .frame_length(frame_length), .payload_read_addr(payload_read_addr),
|
|
|
+ .payload_read_data(payload_read_data), .target_commit(target_commit),
|
|
|
+ .target_celsius(target_celsius), .stimulus_wr_en(stimulus_wr_en),
|
|
|
+ .stimulus_wr_addr(stimulus_wr_addr), .stimulus_wr_data(stimulus_wr_data),
|
|
|
+ .stimulus_commit(stimulus_commit),
|
|
|
+ .stimulus_duration_seconds(stimulus_duration_seconds),
|
|
|
+ .snapshot_capture(snapshot_capture), .snapshot_ready(snapshot_ready),
|
|
|
+ .tx_start(tx_start), .tx_frame_type(tx_frame_type),
|
|
|
+ .tx_payload_length(tx_payload_length), .tx_done(tx_done),
|
|
|
+ .transaction_done(transaction_done), .busy(command_busy),
|
|
|
+ .formal_state_o(formal_state), .formal_index_o(formal_index),
|
|
|
+ .formal_stimulus_bad_o(formal_stimulus_bad)
|
|
|
+ );
|
|
|
+
|
|
|
+ // Real Identification command-to-storage wiring. Physical UART
|
|
|
+ // serialization and its final Stop Bit are deliberately outside this
|
|
|
+ // command-level proof and remain covered by full-UART Cocotb.
|
|
|
+ stimulus_atomic_bank u_stimulus_bank (
|
|
|
+ .clk(clk), .rst_n(rst_n),
|
|
|
+ .write_enable(stimulus_wr_en),
|
|
|
+ .write_address(stimulus_wr_addr),
|
|
|
+ .write_data(stimulus_wr_data),
|
|
|
+ .stimulus_commit(stimulus_commit),
|
|
|
+ .commit_applied(bank_commit_applied),
|
|
|
+ .active_bank(stimulus_bank_active),
|
|
|
+ .read_bank(stimulus_bank_active),
|
|
|
+ .read_address(formal_bank_address),
|
|
|
+ .read_data(formal_active_stimulus_data)
|
|
|
+ );
|
|
|
+
|
|
|
+ wire command_accept = frame_valid && frame_ready && frame_accept_enable;
|
|
|
+ wire stimulus_shape = frame_type == 8'h03 && frame_length == 8'd33;
|
|
|
+ wire legal_stimulus_accept = command_accept && stimulus_shape && payload_case == 0;
|
|
|
+ wire invalid_payload_accept = command_accept && stimulus_shape && payload_case != 0;
|
|
|
+ wire supported_shape =
|
|
|
+ (frame_type == 8'h01 && frame_length == 8'd1) ||
|
|
|
+ (frame_type == 8'h02 && frame_length == 8'd0) || stimulus_shape;
|
|
|
+ wire invalid_shape_accept = command_accept && !supported_shape;
|
|
|
+ wire invalid_stimulus_length_accept = command_accept &&
|
|
|
+ frame_type == 8'h03 && frame_length != 8'd33;
|
|
|
+ wire unknown_type_accept = command_accept &&
|
|
|
+ frame_type != 8'h01 && frame_type != 8'h02 && frame_type != 8'h03;
|
|
|
+
|
|
|
+ reg [1:0] reset_cycles = 0;
|
|
|
+ reg formal_past_valid = 0;
|
|
|
+ reg legal_pending;
|
|
|
+ reg invalid_pending;
|
|
|
+ reg [5:0] pending_age;
|
|
|
+ reg [31:0] writes_seen;
|
|
|
+ reg completed_legal;
|
|
|
+ reg repeat_pending;
|
|
|
+ reg repeated_ack_seen;
|
|
|
+ reg invalid_duration_silent_seen;
|
|
|
+ reg invalid_duty_silent_seen;
|
|
|
+ reg invalid_entry_bank;
|
|
|
+
|
|
|
+ always @(posedge clk) begin
|
|
|
+ formal_past_valid <= 1'b1;
|
|
|
+ if (reset_cycles < 2) begin
|
|
|
+ assume(!rst_n);
|
|
|
+ reset_cycles <= reset_cycles + 1'b1;
|
|
|
+ end else begin
|
|
|
+ assume(rst_n);
|
|
|
+ end
|
|
|
+
|
|
|
+ if (!rst_n) begin
|
|
|
+ legal_pending <= 1'b0;
|
|
|
+ invalid_pending <= 1'b0;
|
|
|
+ pending_age <= 0;
|
|
|
+ writes_seen <= 0;
|
|
|
+ completed_legal <= 1'b0;
|
|
|
+ repeat_pending <= 1'b0;
|
|
|
+ repeated_ack_seen <= 1'b0;
|
|
|
+ invalid_duration_silent_seen <= 1'b0;
|
|
|
+ invalid_duty_silent_seen <= 1'b0;
|
|
|
+ invalid_entry_bank <= 1'b0;
|
|
|
+ end else begin
|
|
|
+ assume(formal_bank_address < 32);
|
|
|
+ if (legal_stimulus_accept || invalid_payload_accept) begin
|
|
|
+ assert(!legal_pending && !invalid_pending);
|
|
|
+ legal_pending <= legal_stimulus_accept;
|
|
|
+ invalid_pending <= invalid_payload_accept;
|
|
|
+ pending_age <= 0;
|
|
|
+ writes_seen <= 0;
|
|
|
+ repeat_pending <= legal_stimulus_accept && completed_legal;
|
|
|
+ if (invalid_payload_accept)
|
|
|
+ invalid_entry_bank <= stimulus_bank_active;
|
|
|
+ end else if (legal_pending || invalid_pending) begin
|
|
|
+ pending_age <= pending_age + 1'b1;
|
|
|
+ end
|
|
|
+
|
|
|
+ if (stimulus_wr_en) begin
|
|
|
+ assert(legal_pending || invalid_pending);
|
|
|
+ assert(stimulus_wr_data <= 100);
|
|
|
+ writes_seen[stimulus_wr_addr] <= 1'b1;
|
|
|
+ assert(!stimulus_commit);
|
|
|
+ end
|
|
|
+
|
|
|
+ // The monitor age is an exact image of the deterministic command
|
|
|
+ // pipeline. These invariants turn the bounded completion claim
|
|
|
+ // into an inductive proof rather than a simulation-like timeout.
|
|
|
+ if (legal_pending || invalid_pending) begin
|
|
|
+ assert(pending_age <= 34);
|
|
|
+ if (formal_state == 4'd3)
|
|
|
+ assert(pending_age == 0);
|
|
|
+ if (formal_state == 4'd4)
|
|
|
+ assert(pending_age == formal_index);
|
|
|
+ if (formal_state == 4'd5)
|
|
|
+ assert(pending_age == 33);
|
|
|
+ end
|
|
|
+ if (legal_pending) begin
|
|
|
+ assert(!formal_stimulus_bad);
|
|
|
+ assert(formal_state == 4'd3 || formal_state == 4'd4 ||
|
|
|
+ formal_state == 4'd5 || formal_state == 4'd6);
|
|
|
+ if (formal_state == 4'd6) begin
|
|
|
+ assert(pending_age == 34);
|
|
|
+ assert(stimulus_commit);
|
|
|
+ assert(tx_start && tx_frame_type == 8'h83 && tx_payload_length == 0);
|
|
|
+ end
|
|
|
+ end
|
|
|
+ if (invalid_pending) begin
|
|
|
+ assert(formal_state == 4'd3 || formal_state == 4'd4 ||
|
|
|
+ formal_state == 4'd5 || formal_state == 4'd7);
|
|
|
+ assert(!stimulus_commit);
|
|
|
+ assert(!(tx_start && tx_frame_type == 8'h83));
|
|
|
+ assert(stimulus_bank_active == invalid_entry_bank);
|
|
|
+ if (formal_state == 4'd7) begin
|
|
|
+ assert(pending_age == 34);
|
|
|
+ assert(transaction_done);
|
|
|
+ end
|
|
|
+ end
|
|
|
+
|
|
|
+ // A legal request becomes visible atomically only after all 32
|
|
|
+ // duty bytes have been admitted. The independent ACK starts from
|
|
|
+ // that same commit edge and always has zero payload length.
|
|
|
+ if (stimulus_commit || (tx_start && tx_frame_type == 8'h83)) begin
|
|
|
+ assert(legal_pending);
|
|
|
+ assert(writes_seen == 32'hFFFF_FFFF);
|
|
|
+ assert(stimulus_duration_seconds == 2);
|
|
|
+ assert(stimulus_commit);
|
|
|
+ assert(bank_commit_applied);
|
|
|
+ assert(tx_start && tx_frame_type == 8'h83 && tx_payload_length == 0);
|
|
|
+ legal_pending <= 1'b0;
|
|
|
+ completed_legal <= 1'b1;
|
|
|
+ if (repeat_pending)
|
|
|
+ repeated_ack_seen <= 1'b1;
|
|
|
+ repeat_pending <= 1'b0;
|
|
|
+ end
|
|
|
+ if (repeat_pending)
|
|
|
+ assert(legal_pending);
|
|
|
+
|
|
|
+ if (formal_past_valid && $past(rst_n)) begin
|
|
|
+ if ($past(stimulus_wr_en)) begin
|
|
|
+ assert(stimulus_bank_active == $past(stimulus_bank_active));
|
|
|
+ assert(formal_active_stimulus_data ==
|
|
|
+ $past(formal_active_stimulus_data));
|
|
|
+ end
|
|
|
+ if ($past(bank_commit_applied)) begin
|
|
|
+ assert(stimulus_bank_active != $past(stimulus_bank_active));
|
|
|
+ end
|
|
|
+ if (!$past(bank_commit_applied))
|
|
|
+ assert(stimulus_bank_active == $past(stimulus_bank_active));
|
|
|
+ end
|
|
|
+
|
|
|
+ if (invalid_pending && transaction_done) begin
|
|
|
+ invalid_pending <= 1'b0;
|
|
|
+ if (payload_case == 1)
|
|
|
+ invalid_duration_silent_seen <= 1'b1;
|
|
|
+ if (payload_case[1])
|
|
|
+ invalid_duty_silent_seen <= 1'b1;
|
|
|
+ end
|
|
|
+
|
|
|
+ // Wrong lengths and unknown request types retire immediately and
|
|
|
+ // silently. Bad CRC remains proved through frame_rx in the
|
|
|
+ // unchanged Production transport harness.
|
|
|
+ if (formal_past_valid && $past(rst_n) &&
|
|
|
+ $past(invalid_shape_accept)) begin
|
|
|
+ assert(transaction_done);
|
|
|
+ assert(!tx_start);
|
|
|
+ assert(!stimulus_commit);
|
|
|
+ end
|
|
|
+
|
|
|
+ cover(repeated_ack_seen);
|
|
|
+ cover(formal_past_valid && $past(bank_commit_applied) &&
|
|
|
+ stimulus_bank_active != $past(stimulus_bank_active) &&
|
|
|
+ formal_active_stimulus_data == 8'd50);
|
|
|
+ cover(invalid_duration_silent_seen);
|
|
|
+ cover(invalid_duty_silent_seen);
|
|
|
+ cover(formal_past_valid && $past(invalid_stimulus_length_accept) &&
|
|
|
+ transaction_done && !tx_start);
|
|
|
+ cover(formal_past_valid && $past(unknown_type_accept) &&
|
|
|
+ transaction_done && !tx_start);
|
|
|
+ end
|
|
|
+ end
|
|
|
+endmodule
|