|
|
@@ -29,7 +29,7 @@ module thermal_control_core #(
|
|
|
input wire [15:0] bmc_epoch,
|
|
|
input wire bmc_stale,
|
|
|
input wire [23:0] bmc_valid_mask,
|
|
|
- output reg [4:0] bmc_rd_index,
|
|
|
+ output wire [4:0] bmc_rd_index,
|
|
|
input wire [15:0] bmc_rd_raw,
|
|
|
input wire bmc_rd_valid,
|
|
|
input wire [15:0] ct_epoch,
|
|
|
@@ -38,11 +38,11 @@ module thermal_control_core #(
|
|
|
input wire snapshot_lock,
|
|
|
input wire snapshot_lock_bank,
|
|
|
input wire [4:0] pwm_rd_addr,
|
|
|
- output reg [7:0] pwm_rd_data,
|
|
|
+ output wire [7:0] pwm_rd_data,
|
|
|
input wire snapshot_output_bank,
|
|
|
input wire [4:0] snapshot_rd_addr,
|
|
|
- output reg [7:0] snapshot_requested_data,
|
|
|
- output reg [7:0] snapshot_applied_data,
|
|
|
+ output wire [7:0] snapshot_requested_data,
|
|
|
+ output wire [7:0] snapshot_applied_data,
|
|
|
output reg active_output_bank,
|
|
|
output reg [2:0] control_state,
|
|
|
output reg [7:0] current_target_celsius,
|
|
|
@@ -70,6 +70,8 @@ module thermal_control_core #(
|
|
|
localparam [3:0] W_FANS = 4'd5;
|
|
|
localparam [3:0] W_APPLY = 4'd6;
|
|
|
localparam [3:0] W_SAFE_FILL = 4'd7;
|
|
|
+ localparam [3:0] W_APPLY_PREFETCH = 4'd8;
|
|
|
+ localparam [3:0] W_INIT = 4'd9;
|
|
|
|
|
|
reg [3:0] work_state;
|
|
|
reg [4:0] work_index;
|
|
|
@@ -82,12 +84,6 @@ module thermal_control_core #(
|
|
|
reg [2:0] invalid_count2;
|
|
|
reg [2:0] invalid_count3;
|
|
|
reg [15:0] target_centi;
|
|
|
- reg [7:0] req0 [0:31];
|
|
|
- reg [7:0] req1 [0:31];
|
|
|
- reg [7:0] app0 [0:31];
|
|
|
- reg [7:0] app1 [0:31];
|
|
|
- reg signed [15:0] previous_error [0:23];
|
|
|
- reg signed [15:0] previous_output [0:23];
|
|
|
reg [7:0] stimulus_mem [0:31];
|
|
|
reg stimulus_running;
|
|
|
reg [7:0] stimulus_remaining;
|
|
|
@@ -105,6 +101,17 @@ module thermal_control_core #(
|
|
|
reg signed [31:0] ki_product;
|
|
|
integer i;
|
|
|
|
|
|
+`ifdef FORMAL
|
|
|
+ // Proof-only mirrors preserve arbitrary-index invariants without adding
|
|
|
+ // any storage to TD synthesis.
|
|
|
+ reg [7:0] formal_req0 [0:31];
|
|
|
+ reg [7:0] formal_req1 [0:31];
|
|
|
+ reg [7:0] formal_app0 [0:31];
|
|
|
+ reg [7:0] formal_app1 [0:31];
|
|
|
+ reg signed [15:0] formal_previous_error [0:23];
|
|
|
+ reg signed [15:0] formal_previous_output [0:23];
|
|
|
+`endif
|
|
|
+
|
|
|
wire [15:0] bmc_integer_scaled = ({8'd0, bmc_rd_raw[15:8]} << 6) +
|
|
|
({8'd0, bmc_rd_raw[15:8]} << 5) + ({8'd0, bmc_rd_raw[15:8]} << 2);
|
|
|
wire signed [15:0] bmc_temperature = $signed(bmc_integer_scaled + {8'd0, bmc_rd_raw[7:0]});
|
|
|
@@ -114,19 +121,36 @@ module thermal_control_core #(
|
|
|
wire signed [15:0] selected_ki = edge_channel ? EDGE_KI : CENTER_KI;
|
|
|
reg signed [15:0] mult_a;
|
|
|
reg signed [15:0] mult_b;
|
|
|
+ wire [31:0] pi_state_read;
|
|
|
+ wire signed [15:0] pi_previous_error_ram = pi_state_read[31:16];
|
|
|
+ wire signed [15:0] pi_previous_output_ram = pi_state_read[15:0];
|
|
|
+ wire [7:0] output_control_requested_ram;
|
|
|
+ wire [7:0] output_pwm_applied;
|
|
|
+ wire [31:0] pi_state_write_port_read_unused;
|
|
|
+`ifdef FORMAL
|
|
|
+ // The proof mirrors are the inductive abstraction of the synchronous RAM
|
|
|
+ // contents. Simulation and TD use the physical RAM read ports below.
|
|
|
+ wire signed [15:0] pi_previous_error = formal_previous_error[work_index];
|
|
|
+ wire signed [15:0] pi_previous_output = formal_previous_output[work_index];
|
|
|
+ wire [7:0] output_control_requested = active_output_bank ?
|
|
|
+ formal_req0[work_index] : formal_req1[work_index];
|
|
|
+`else
|
|
|
+ wire signed [15:0] pi_previous_error = pi_previous_error_ram;
|
|
|
+ wire signed [15:0] pi_previous_output = pi_previous_output_ram;
|
|
|
+ wire [7:0] output_control_requested = output_control_requested_ram;
|
|
|
+`endif
|
|
|
wire signed [31:0] mult_result = mult_a * mult_b;
|
|
|
wire signed [31:0] pi_sum = kp_product + ki_product;
|
|
|
wire signed [31:0] pi_delta = (pi_sum >= 0) ? ((pi_sum + 8) >>> 4) : -(((-pi_sum) + 8) >>> 4);
|
|
|
- wire signed [31:0] previous_output_ext = {{16{previous_output[work_index][15]}}, previous_output[work_index]};
|
|
|
+ wire signed [31:0] previous_output_ext = {{16{pi_previous_output[15]}}, pi_previous_output};
|
|
|
wire signed [31:0] pi_candidate = previous_output_ext + pi_delta;
|
|
|
wire signed [31:0] slew_low = previous_output_ext - SLEW_Q8_8;
|
|
|
wire signed [31:0] slew_high = previous_output_ext + SLEW_Q8_8;
|
|
|
wire signed [31:0] slew_candidate = (pi_candidate < slew_low) ? slew_low : ((pi_candidate > slew_high) ? slew_high : pi_candidate);
|
|
|
wire signed [15:0] clamped_output = (slew_candidate < 0) ? 16'sd0 : ((slew_candidate > 25600) ? 16'sd25600 : slew_candidate[15:0]);
|
|
|
- wire signed [15:0] reduced_output = previous_output[work_index] - 16'sd256;
|
|
|
+ wire signed [15:0] reduced_output = pi_previous_output - 16'sd256;
|
|
|
wire [7:0] clamped_duty = (clamped_output >= 16'sd25600) ? 8'd100 : q8_8_to_duty(clamped_output);
|
|
|
- wire [7:0] reduced_duty = (previous_output[work_index] > 16'sd256) ? q8_8_to_duty(reduced_output) : 8'd0;
|
|
|
- wire [7:0] inactive_request = active_output_bank ? req0[work_index] : req1[work_index];
|
|
|
+ wire [7:0] reduced_duty = (pi_previous_output > 16'sd256) ? q8_8_to_duty(reduced_output) : 8'd0;
|
|
|
wire signed [15:0] recovery_threshold = $signed(target_centi) + RECOVERY_MARGIN;
|
|
|
|
|
|
assign stimulus_active = stimulus_running;
|
|
|
@@ -200,11 +224,11 @@ module thermal_control_core #(
|
|
|
(global_fault || control_state == STOPPED ||
|
|
|
lane_fault_for_output(work_index) ||
|
|
|
lane_invalid(lane_for_channel(work_index)) ||
|
|
|
- ptc_shutdown_mask[work_index]) ? 8'd0 : inactive_request;
|
|
|
+ ptc_shutdown_mask[work_index]) ? 8'd0 : output_control_requested;
|
|
|
wire [7:0] apply_fan_value =
|
|
|
(global_fault || lane_fault_for_output(work_index) ||
|
|
|
lane_invalid(lane_for_output(work_index))) ? 8'd100 :
|
|
|
- (lane_thermal_protection(lane_for_output(work_index)) ? 8'd80 : inactive_request);
|
|
|
+ (lane_thermal_protection(lane_for_output(work_index)) ? 8'd80 : output_control_requested);
|
|
|
wire [7:0] safe_fill_value = (work_index < 24) ? 8'd0 :
|
|
|
((global_fault || lane_fault_for_output(work_index) ||
|
|
|
lane_invalid(lane_for_output(work_index))) ? 8'd100 :
|
|
|
@@ -214,24 +238,77 @@ module thermal_control_core #(
|
|
|
// must still run before BMC stability is evaluated.
|
|
|
wire bmc_stale_runtime = bmc_stale &&
|
|
|
(control_state == AUTO_BMC || control_state == SENSOR_DEGRADED);
|
|
|
+ wire update_fault_clear = work_state == W_UPDATE && sample_valid &&
|
|
|
+ ((sample_temperature >= PRETRIP_LIMIT) || global_fault ||
|
|
|
+ lane_fault_for_output(work_index));
|
|
|
+ wire update_soft = work_state == W_UPDATE && sample_valid &&
|
|
|
+ !update_fault_clear && (sample_temperature >= SOFT_LIMIT);
|
|
|
+ wire update_normal = work_state == W_UPDATE && sample_valid &&
|
|
|
+ !update_fault_clear && !update_soft && !stimulus_running;
|
|
|
+ wire pi_clear_write = (work_state == W_INIT || work_state == W_SAFE_FILL) &&
|
|
|
+ (work_index < 24);
|
|
|
+ wire pi_state_write = pi_clear_write || update_fault_clear || update_soft || update_normal;
|
|
|
+ wire [31:0] pi_state_write_data = pi_clear_write || update_fault_clear ? 32'd0 :
|
|
|
+ (update_soft ? {sample_error, (pi_previous_output > 16'sd256 ? reduced_output : 16'sd0)} :
|
|
|
+ {sample_error, clamped_output});
|
|
|
+
|
|
|
+ wire [7:0] update_request_value = !sample_valid ? 8'd0 :
|
|
|
+ ((sample_temperature >= PRETRIP_LIMIT) || global_fault ||
|
|
|
+ lane_fault_for_output(work_index)) ? 8'd0 :
|
|
|
+ (sample_temperature >= SOFT_LIMIT) ? reduced_duty :
|
|
|
+ stimulus_running ? stimulus_mem[work_index] : clamped_duty;
|
|
|
+ wire [7:0] fan_request_value = stimulus_running ? stimulus_mem[work_index] : 8'd30;
|
|
|
+ wire output_init_write = work_state == W_INIT;
|
|
|
+ wire output_control_write = work_state == W_UPDATE || work_state == W_FANS ||
|
|
|
+ work_state == W_APPLY || work_state == W_SAFE_FILL;
|
|
|
+ wire [7:0] apply_value = (work_index < 24) ? apply_ptc_value : apply_fan_value;
|
|
|
+ wire [15:0] output_control_write_data =
|
|
|
+ (work_state == W_UPDATE) ? {update_request_value, 8'd0} :
|
|
|
+ (work_state == W_FANS) ? {fan_request_value, 8'd0} :
|
|
|
+ (work_state == W_APPLY) ? {output_control_requested, apply_value} :
|
|
|
+ {safe_fill_value, safe_fill_value};
|
|
|
+ wire [4:0] output_control_read_addr =
|
|
|
+ (work_state == W_APPLY_PREFETCH) ? 5'd0 :
|
|
|
+ ((work_state == W_APPLY && work_index < 31) ? work_index + 1'b1 : work_index);
|
|
|
+ wire [7:0] init_output_value = (work_index < 24) ? 8'd0 : 8'd10;
|
|
|
+
|
|
|
+ assign bmc_rd_index = work_index;
|
|
|
+ assign pwm_rd_data = (work_state == W_INIT) ?
|
|
|
+ ((pwm_rd_addr < 24) ? 8'd0 : 8'd10) : output_pwm_applied;
|
|
|
+
|
|
|
+ ef2_bram_dp #(.DATA_WIDTH(32), .ADDR_WIDTH(5), .DATA_DEPTH(24)) u_pi_state (
|
|
|
+ .clk(clk), .a_en(1'b1), .a_we(1'b0), .a_addr(work_index),
|
|
|
+ .a_wdata(32'd0), .a_rdata(pi_state_read),
|
|
|
+ .b_en(1'b1), .b_we(pi_state_write), .b_addr(work_index),
|
|
|
+ .b_wdata(pi_state_write_data), .b_rdata(pi_state_write_port_read_unused)
|
|
|
+ );
|
|
|
+
|
|
|
+ thermal_output_banks u_output_banks (
|
|
|
+ .clk(clk), .active_bank(active_output_bank),
|
|
|
+ .init_write(output_init_write), .init_addr(work_index),
|
|
|
+ .init_data({init_output_value, init_output_value}),
|
|
|
+ .control_bank(~active_output_bank),
|
|
|
+ .control_read_addr(output_control_read_addr),
|
|
|
+ .control_write(output_control_write), .control_write_addr(work_index),
|
|
|
+ .control_write_data(output_control_write_data),
|
|
|
+ .pwm_addr(pwm_rd_addr), .pwm_applied(output_pwm_applied),
|
|
|
+ .snapshot_bank(snapshot_output_bank), .snapshot_addr(snapshot_rd_addr),
|
|
|
+ .snapshot_requested(snapshot_requested_data), .snapshot_applied(snapshot_applied_data),
|
|
|
+ .control_requested(output_control_requested_ram)
|
|
|
+ );
|
|
|
+
|
|
|
+ wire unused_pi_write_port_read = &{1'b0, pi_state_write_port_read_unused};
|
|
|
|
|
|
always @* begin
|
|
|
mult_a = 0;
|
|
|
mult_b = 0;
|
|
|
if (work_state == W_KP) begin
|
|
|
- mult_a = live_error - previous_error[work_index[4:0]];
|
|
|
+ mult_a = live_error - pi_previous_error;
|
|
|
mult_b = selected_kp;
|
|
|
end else if (work_state == W_KI) begin
|
|
|
mult_a = sample_error;
|
|
|
mult_b = selected_ki;
|
|
|
end
|
|
|
- if (snapshot_output_bank) begin
|
|
|
- snapshot_requested_data = req1[snapshot_rd_addr];
|
|
|
- snapshot_applied_data = app1[snapshot_rd_addr];
|
|
|
- end else begin
|
|
|
- snapshot_requested_data = req0[snapshot_rd_addr];
|
|
|
- snapshot_applied_data = app0[snapshot_rd_addr];
|
|
|
- end
|
|
|
end
|
|
|
|
|
|
always @(posedge clk or negedge rst_n) begin
|
|
|
@@ -248,10 +325,8 @@ module thermal_control_core #(
|
|
|
lane_fault_mask <= 0;
|
|
|
global_fault <= 0;
|
|
|
output_commit <= 0;
|
|
|
- pwm_rd_data <= 0;
|
|
|
- work_state <= W_IDLE;
|
|
|
+ work_state <= W_INIT;
|
|
|
work_index <= 0;
|
|
|
- bmc_rd_index <= 0;
|
|
|
last_bmc_epoch <= 0;
|
|
|
last_ct_epoch <= 0;
|
|
|
stable_epochs <= 0;
|
|
|
@@ -269,22 +344,42 @@ module thermal_control_core #(
|
|
|
kp_product <= 0;
|
|
|
ki_product <= 0;
|
|
|
for (i = 0; i < 32; i = i + 1) begin
|
|
|
- req0[i] <= (i < 24) ? 0 : 10;
|
|
|
- req1[i] <= (i < 24) ? 0 : 10;
|
|
|
- app0[i] <= (i < 24) ? 0 : 10;
|
|
|
- app1[i] <= (i < 24) ? 0 : 10;
|
|
|
stimulus_mem[i] <= 0;
|
|
|
+`ifdef FORMAL
|
|
|
+ formal_req0[i] <= (i < 24) ? 0 : 10;
|
|
|
+ formal_req1[i] <= (i < 24) ? 0 : 10;
|
|
|
+ formal_app0[i] <= (i < 24) ? 0 : 10;
|
|
|
+ formal_app1[i] <= (i < 24) ? 0 : 10;
|
|
|
+`endif
|
|
|
end
|
|
|
+`ifdef FORMAL
|
|
|
for (i = 0; i < 24; i = i + 1) begin
|
|
|
- previous_error[i] <= 0;
|
|
|
- previous_output[i] <= 0;
|
|
|
+ formal_previous_error[i] <= 0;
|
|
|
+ formal_previous_output[i] <= 0;
|
|
|
end
|
|
|
+`endif
|
|
|
end else begin
|
|
|
output_commit <= 0;
|
|
|
- if (active_output_bank)
|
|
|
- pwm_rd_data <= app1[pwm_rd_addr];
|
|
|
- else
|
|
|
- pwm_rd_data <= app0[pwm_rd_addr];
|
|
|
+`ifdef FORMAL
|
|
|
+ if (output_init_write) begin
|
|
|
+ formal_req0[work_index] <= init_output_value;
|
|
|
+ formal_req1[work_index] <= init_output_value;
|
|
|
+ formal_app0[work_index] <= init_output_value;
|
|
|
+ formal_app1[work_index] <= init_output_value;
|
|
|
+ end else if (output_control_write) begin
|
|
|
+ if (active_output_bank) begin
|
|
|
+ formal_req0[work_index] <= output_control_write_data[15:8];
|
|
|
+ formal_app0[work_index] <= output_control_write_data[7:0];
|
|
|
+ end else begin
|
|
|
+ formal_req1[work_index] <= output_control_write_data[15:8];
|
|
|
+ formal_app1[work_index] <= output_control_write_data[7:0];
|
|
|
+ end
|
|
|
+ end
|
|
|
+ if (pi_state_write) begin
|
|
|
+ formal_previous_error[work_index] <= pi_state_write_data[31:16];
|
|
|
+ formal_previous_output[work_index] <= pi_state_write_data[15:0];
|
|
|
+ end
|
|
|
+`endif
|
|
|
if (stimulus_wr_en && (ENABLE_STIMULUS != 0))
|
|
|
stimulus_mem[stimulus_wr_addr] <= stimulus_wr_data;
|
|
|
if (stimulus_commit && (ENABLE_STIMULUS != 0) && stimulus_duration_seconds != 0) begin
|
|
|
@@ -298,7 +393,7 @@ module thermal_control_core #(
|
|
|
end else stimulus_remaining <= stimulus_remaining - 1'b1;
|
|
|
end
|
|
|
|
|
|
- if (target_commit) begin
|
|
|
+ if (target_commit && work_state != W_INIT) begin
|
|
|
current_target_celsius <= target_celsius;
|
|
|
target_centi <= ({8'd0, target_celsius} << 6) +
|
|
|
({8'd0, target_celsius} << 5) + ({8'd0, target_celsius} << 2);
|
|
|
@@ -316,10 +411,6 @@ module thermal_control_core #(
|
|
|
control_state <= SENSOR_DEGRADED;
|
|
|
else
|
|
|
control_state <= WAIT_CT_VALID;
|
|
|
- for (i = 0; i < 24; i = i + 1) begin
|
|
|
- previous_error[i] <= 0;
|
|
|
- previous_output[i] <= 0;
|
|
|
- end
|
|
|
end else if (bmc_stale_runtime && !global_fault) begin
|
|
|
global_fault <= 1;
|
|
|
control_state <= SENSOR_DEGRADED;
|
|
|
@@ -330,6 +421,14 @@ module thermal_control_core #(
|
|
|
stimulus_running <= 0;
|
|
|
end else begin
|
|
|
case (work_state)
|
|
|
+ W_INIT: begin
|
|
|
+ if (work_index == 31) begin
|
|
|
+ work_index <= 0;
|
|
|
+ work_state <= W_IDLE;
|
|
|
+ end else begin
|
|
|
+ work_index <= work_index + 1'b1;
|
|
|
+ end
|
|
|
+ end
|
|
|
W_IDLE: begin
|
|
|
if (control_state == RESET_SAFE) begin
|
|
|
control_state <= WAIT_CT_VALID;
|
|
|
@@ -365,7 +464,6 @@ module thermal_control_core #(
|
|
|
end
|
|
|
end
|
|
|
W_PREP: begin
|
|
|
- bmc_rd_index <= work_index;
|
|
|
if (work_index == 0) begin
|
|
|
epoch_safe <= 1;
|
|
|
invalid_count0 <= 0;
|
|
|
@@ -388,7 +486,6 @@ module thermal_control_core #(
|
|
|
end
|
|
|
W_UPDATE: begin
|
|
|
if (!sample_valid) begin
|
|
|
- if (active_output_bank) begin req0[work_index] <= 0; end else begin req1[work_index] <= 0; end
|
|
|
safety_override_mask[work_index] <= 1;
|
|
|
ptc_shutdown_mask[work_index] <= 1;
|
|
|
thermal_protection_mask[work_index] <= 0;
|
|
|
@@ -406,23 +503,17 @@ module thermal_control_core #(
|
|
|
3: invalid_count3 <= invalid_count3 + 1'b1;
|
|
|
endcase
|
|
|
end else if (sample_temperature >= HARD_LIMIT) begin
|
|
|
- if (active_output_bank) req0[work_index] <= 0; else req1[work_index] <= 0;
|
|
|
safety_override_mask[work_index] <= 1;
|
|
|
ptc_shutdown_mask[work_index] <= 1;
|
|
|
thermal_protection_mask[work_index] <= 1;
|
|
|
- previous_error[work_index] <= 0;
|
|
|
- previous_output[work_index] <= 0;
|
|
|
lane_fault_mask[lane_for_channel(work_index)] <= 1;
|
|
|
epoch_safe <= 0;
|
|
|
control_state <= SENSOR_DEGRADED;
|
|
|
stimulus_running <= 0;
|
|
|
end else if (sample_temperature >= PRETRIP_LIMIT) begin
|
|
|
- if (active_output_bank) req0[work_index] <= 0; else req1[work_index] <= 0;
|
|
|
safety_override_mask[work_index] <= 1;
|
|
|
ptc_shutdown_mask[work_index] <= 1;
|
|
|
thermal_protection_mask[work_index] <= 1;
|
|
|
- previous_error[work_index] <= 0;
|
|
|
- previous_output[work_index] <= 0;
|
|
|
epoch_safe <= 0;
|
|
|
control_state <= SENSOR_DEGRADED;
|
|
|
end else if (global_fault || lane_fault_for_output(work_index)) begin
|
|
|
@@ -430,36 +521,23 @@ module thermal_control_core #(
|
|
|
// state. Otherwise recovery could expose duty that
|
|
|
// accumulated while the physical output was forced
|
|
|
// off, violating bumpless limited-duty restart.
|
|
|
- if (active_output_bank) req0[work_index] <= 0; else req1[work_index] <= 0;
|
|
|
safety_override_mask[work_index] <= 0;
|
|
|
ptc_shutdown_mask[work_index] <= 0;
|
|
|
thermal_protection_mask[work_index] <= 0;
|
|
|
- previous_error[work_index] <= 0;
|
|
|
- previous_output[work_index] <= 0;
|
|
|
end else begin
|
|
|
// Safety precedes identification stimulus. The
|
|
|
// soft limit reduces the autonomous PI state by
|
|
|
// one duty point and requests protection airflow,
|
|
|
// but deliberately does not assert PTC shutdown.
|
|
|
if (sample_temperature >= SOFT_LIMIT) begin
|
|
|
- if (active_output_bank)
|
|
|
- req0[work_index] <= reduced_duty;
|
|
|
- else
|
|
|
- req1[work_index] <= reduced_duty;
|
|
|
- if (previous_output[work_index] > 16'sd256) previous_output[work_index] <= previous_output[work_index] - 16'sd256; else previous_output[work_index] <= 0;
|
|
|
- previous_error[work_index] <= sample_error;
|
|
|
safety_override_mask[work_index] <= 1;
|
|
|
ptc_shutdown_mask[work_index] <= 0;
|
|
|
thermal_protection_mask[work_index] <= 1;
|
|
|
end else if (stimulus_running) begin
|
|
|
- if (active_output_bank) req0[work_index] <= stimulus_mem[work_index]; else req1[work_index] <= stimulus_mem[work_index];
|
|
|
safety_override_mask[work_index] <= 0;
|
|
|
ptc_shutdown_mask[work_index] <= 0;
|
|
|
thermal_protection_mask[work_index] <= 0;
|
|
|
end else begin
|
|
|
- if (active_output_bank) req0[work_index] <= clamped_duty; else req1[work_index] <= clamped_duty;
|
|
|
- previous_output[work_index] <= clamped_output;
|
|
|
- previous_error[work_index] <= sample_error;
|
|
|
safety_override_mask[work_index] <= 0;
|
|
|
ptc_shutdown_mask[work_index] <= 0;
|
|
|
thermal_protection_mask[work_index] <= 0;
|
|
|
@@ -485,25 +563,14 @@ module thermal_control_core #(
|
|
|
end
|
|
|
end
|
|
|
W_FANS: begin
|
|
|
- if (active_output_bank)
|
|
|
- req0[work_index] <= stimulus_running ? stimulus_mem[work_index] : 8'd30;
|
|
|
- else
|
|
|
- req1[work_index] <= stimulus_running ? stimulus_mem[work_index] : 8'd30;
|
|
|
- if (work_index == 31) begin work_index <= 0; work_state <= W_APPLY; end
|
|
|
+ if (work_index == 31) begin
|
|
|
+ work_index <= 0;
|
|
|
+ work_state <= W_APPLY_PREFETCH;
|
|
|
+ end
|
|
|
else work_index <= work_index + 1'b1;
|
|
|
end
|
|
|
+ W_APPLY_PREFETCH: work_state <= W_APPLY;
|
|
|
W_APPLY: begin
|
|
|
- if (active_output_bank) begin
|
|
|
- if (work_index < 24)
|
|
|
- app0[work_index] <= apply_ptc_value;
|
|
|
- else
|
|
|
- app0[work_index] <= apply_fan_value;
|
|
|
- end else begin
|
|
|
- if (work_index < 24)
|
|
|
- app1[work_index] <= apply_ptc_value;
|
|
|
- else
|
|
|
- app1[work_index] <= apply_fan_value;
|
|
|
- end
|
|
|
if (work_index == 31) begin
|
|
|
active_output_bank <= ~active_output_bank;
|
|
|
control_epoch <= control_epoch + 1'b1;
|
|
|
@@ -513,13 +580,6 @@ module thermal_control_core #(
|
|
|
end else work_index <= work_index + 1'b1;
|
|
|
end
|
|
|
W_SAFE_FILL: begin
|
|
|
- if (active_output_bank) begin
|
|
|
- req0[work_index] <= safe_fill_value;
|
|
|
- app0[work_index] <= safe_fill_value;
|
|
|
- end else begin
|
|
|
- req1[work_index] <= safe_fill_value;
|
|
|
- app1[work_index] <= safe_fill_value;
|
|
|
- end
|
|
|
if (work_index == 31) begin
|
|
|
active_output_bank <= ~active_output_bank;
|
|
|
control_epoch <= control_epoch + 1'b1;
|
|
|
@@ -540,9 +600,9 @@ module thermal_control_core #(
|
|
|
(* anyconst *) reg [4:0] formal_ptc_index;
|
|
|
|
|
|
wire [7:0] formal_active_applied = active_output_bank ?
|
|
|
- app1[formal_duty_index] : app0[formal_duty_index];
|
|
|
+ formal_app1[formal_duty_index] : formal_app0[formal_duty_index];
|
|
|
wire [7:0] formal_inactive_applied = active_output_bank ?
|
|
|
- app0[formal_duty_index] : app1[formal_duty_index];
|
|
|
+ formal_app0[formal_duty_index] : formal_app1[formal_duty_index];
|
|
|
wire [7:0] formal_safe_fill_value = (formal_duty_index < 24) ? 8'd0 :
|
|
|
((global_fault || lane_fault_for_output(formal_duty_index) ||
|
|
|
lane_invalid(lane_for_output(formal_duty_index))) ?
|
|
|
@@ -561,8 +621,10 @@ module thermal_control_core #(
|
|
|
W_KI: formal_work_rank = 8'd134 - ({3'd0, index_value} << 2);
|
|
|
W_UPDATE: formal_work_rank = 8'd133 - ({3'd0, index_value} << 2);
|
|
|
W_FANS: formal_work_rank = 8'd64 - index_value;
|
|
|
- W_APPLY: formal_work_rank = 8'd32 - index_value;
|
|
|
+ W_APPLY_PREFETCH: formal_work_rank = 8'd32;
|
|
|
+ W_APPLY: formal_work_rank = 8'd31 - index_value;
|
|
|
W_SAFE_FILL: formal_work_rank = 8'd64 - index_value;
|
|
|
+ W_INIT: formal_work_rank = 8'd32 - index_value;
|
|
|
default: formal_work_rank = 8'd0;
|
|
|
endcase
|
|
|
end
|
|
|
@@ -580,10 +642,10 @@ module thermal_control_core #(
|
|
|
assume(formal_ptc_index < 24);
|
|
|
|
|
|
// P01: every requested and applied logical duty remains in 0..100.
|
|
|
- assert(req0[formal_duty_index] <= 100);
|
|
|
- assert(req1[formal_duty_index] <= 100);
|
|
|
- assert(app0[formal_duty_index] <= 100);
|
|
|
- assert(app1[formal_duty_index] <= 100);
|
|
|
+ assert(formal_req0[formal_duty_index] <= 100);
|
|
|
+ assert(formal_req1[formal_duty_index] <= 100);
|
|
|
+ assert(formal_app0[formal_duty_index] <= 100);
|
|
|
+ assert(formal_app1[formal_duty_index] <= 100);
|
|
|
assert(stimulus_mem[formal_duty_index] <= 100);
|
|
|
assert(safe_fan_target <= 100);
|
|
|
assert(control_state <= STOPPED);
|
|
|
@@ -591,8 +653,8 @@ module thermal_control_core #(
|
|
|
(current_target_celsius >= 20 && current_target_celsius <= 70));
|
|
|
assert(target_centi <= 16'd7000);
|
|
|
if (formal_duty_index < 24) begin
|
|
|
- assert(previous_output[formal_duty_index] >= 0);
|
|
|
- assert(previous_output[formal_duty_index] <= 25600);
|
|
|
+ assert(formal_previous_output[formal_duty_index] >= 0);
|
|
|
+ assert(formal_previous_output[formal_duty_index] <= 25600);
|
|
|
end
|
|
|
|
|
|
if (!rst_n) begin
|
|
|
@@ -605,22 +667,54 @@ module thermal_control_core #(
|
|
|
assert(lane_fault_mask == 0);
|
|
|
assert(!global_fault);
|
|
|
if (formal_duty_index < 24) begin
|
|
|
- assert(app0[formal_duty_index] == 0);
|
|
|
- assert(app1[formal_duty_index] == 0);
|
|
|
+ assert(formal_app0[formal_duty_index] == 0);
|
|
|
+ assert(formal_app1[formal_duty_index] == 0);
|
|
|
end else begin
|
|
|
- assert(app0[formal_duty_index] == 10);
|
|
|
- assert(app1[formal_duty_index] == 10);
|
|
|
+ assert(formal_app0[formal_duty_index] == 10);
|
|
|
+ assert(formal_app1[formal_duty_index] == 10);
|
|
|
end
|
|
|
end else begin
|
|
|
// P10: an admitted scheduler pass has a finite rank that strictly
|
|
|
// decreases every clock unless target/stale safety preempts it.
|
|
|
assert(formal_scheduler_rank <= 136);
|
|
|
- assert(work_state <= W_SAFE_FILL);
|
|
|
+ assert(work_state <= W_INIT);
|
|
|
if (work_state == W_PREP || work_state == W_KP ||
|
|
|
work_state == W_KI || work_state == W_UPDATE)
|
|
|
assert(work_index < 24);
|
|
|
if (work_state == W_FANS)
|
|
|
assert(work_index >= 24);
|
|
|
+ if (work_state == W_APPLY_PREFETCH)
|
|
|
+ assert(work_index == 0);
|
|
|
+ // W_INIT is reachable only from reset. Its prefix invariants make
|
|
|
+ // the deterministic RAM scrub inductive even when the solver
|
|
|
+ // starts an induction window in the middle of that sweep.
|
|
|
+ if (work_state == W_INIT) begin
|
|
|
+ assert(control_state == RESET_SAFE);
|
|
|
+ assert(safety_override_mask == 0);
|
|
|
+ assert(ptc_shutdown_mask == 0);
|
|
|
+ assert(thermal_protection_mask == 0);
|
|
|
+ assert(lane_fault_mask == 0);
|
|
|
+ assert(!global_fault);
|
|
|
+ assert(invalid_count0 == 0);
|
|
|
+ assert(invalid_count1 == 0);
|
|
|
+ assert(invalid_count2 == 0);
|
|
|
+ assert(invalid_count3 == 0);
|
|
|
+ if (formal_duty_index < work_index) begin
|
|
|
+ if (formal_duty_index < 24) begin
|
|
|
+ assert(formal_req0[formal_duty_index] == 0);
|
|
|
+ assert(formal_req1[formal_duty_index] == 0);
|
|
|
+ assert(formal_app0[formal_duty_index] == 0);
|
|
|
+ assert(formal_app1[formal_duty_index] == 0);
|
|
|
+ assert(formal_previous_error[formal_duty_index] == 0);
|
|
|
+ assert(formal_previous_output[formal_duty_index] == 0);
|
|
|
+ end else begin
|
|
|
+ assert(formal_req0[formal_duty_index] == 10);
|
|
|
+ assert(formal_req1[formal_duty_index] == 10);
|
|
|
+ assert(formal_app0[formal_duty_index] == 10);
|
|
|
+ assert(formal_app1[formal_duty_index] == 10);
|
|
|
+ end
|
|
|
+ end
|
|
|
+ end
|
|
|
// Reset-age stale must not bypass CT/preheat startup sequencing.
|
|
|
if (bmc_stale && (control_state == RESET_SAFE ||
|
|
|
control_state == WAIT_CT_VALID ||
|
|
|
@@ -710,9 +804,9 @@ module thermal_control_core #(
|
|
|
assert(ptc_shutdown_mask[formal_ptc_index]);
|
|
|
assert(!thermal_protection_mask[formal_ptc_index]);
|
|
|
if ($past(active_output_bank))
|
|
|
- assert(req0[formal_ptc_index] == 0);
|
|
|
+ assert(formal_req0[formal_ptc_index] == 0);
|
|
|
else
|
|
|
- assert(req1[formal_ptc_index] == 0);
|
|
|
+ assert(formal_req1[formal_ptc_index] == 0);
|
|
|
end
|
|
|
|
|
|
// P05: a sampled hard limit latches the lane fault before the
|
|
|
@@ -758,12 +852,12 @@ module thermal_control_core #(
|
|
|
(global_fault ||
|
|
|
lane_fault_mask[lane_for_channel(formal_ptc_index)]) &&
|
|
|
!target_commit && !formal_stale_preempt)) begin
|
|
|
- assert(previous_error[formal_ptc_index] == 0);
|
|
|
- assert(previous_output[formal_ptc_index] == 0);
|
|
|
+ assert(formal_previous_error[formal_ptc_index] == 0);
|
|
|
+ assert(formal_previous_output[formal_ptc_index] == 0);
|
|
|
if ($past(active_output_bank))
|
|
|
- assert(req0[formal_ptc_index] == 0);
|
|
|
+ assert(formal_req0[formal_ptc_index] == 0);
|
|
|
else
|
|
|
- assert(req1[formal_ptc_index] == 0);
|
|
|
+ assert(formal_req1[formal_ptc_index] == 0);
|
|
|
end
|
|
|
|
|
|
// P12: absence of a Host target commit cannot create STOPPED.
|
|
|
@@ -785,19 +879,19 @@ module thermal_control_core #(
|
|
|
// tasks; they prevent the safety antecedents from being vacuous.
|
|
|
cover(global_fault && work_state == W_IDLE &&
|
|
|
formal_ptc_index < 24 &&
|
|
|
- (active_output_bank ? app1[formal_ptc_index] :
|
|
|
- app0[formal_ptc_index]) == 0);
|
|
|
+ (active_output_bank ? formal_app1[formal_ptc_index] :
|
|
|
+ formal_app0[formal_ptc_index]) == 0);
|
|
|
cover(ptc_shutdown_mask[formal_ptc_index] &&
|
|
|
work_state == W_IDLE &&
|
|
|
- (active_output_bank ? app1[formal_ptc_index] :
|
|
|
- app0[formal_ptc_index]) == 0);
|
|
|
+ (active_output_bank ? formal_app1[formal_ptc_index] :
|
|
|
+ formal_app0[formal_ptc_index]) == 0);
|
|
|
cover(lane_fault_mask[lane_for_channel(formal_ptc_index)] &&
|
|
|
work_state == W_IDLE &&
|
|
|
- (active_output_bank ? app1[formal_ptc_index] :
|
|
|
- app0[formal_ptc_index]) == 0);
|
|
|
+ (active_output_bank ? formal_app1[formal_ptc_index] :
|
|
|
+ formal_app0[formal_ptc_index]) == 0);
|
|
|
cover(control_state == STOPPED && work_state == W_IDLE &&
|
|
|
- (active_output_bank ? app1[formal_ptc_index] :
|
|
|
- app0[formal_ptc_index]) == 0);
|
|
|
+ (active_output_bank ? formal_app1[formal_ptc_index] :
|
|
|
+ formal_app0[formal_ptc_index]) == 0);
|
|
|
cover(stimulus_running && stimulus_remaining != 0);
|
|
|
cover(formal_past_valid &&
|
|
|
$past(stimulus_running && tick_1s &&
|