소스 검색

test(6400): expose sensor lease and lane protection gaps at production clock

codex 2 달 전
부모
커밋
8db8239b08
3개의 변경된 파일과 59개의 추가작업 그리고 2개의 파일을 삭제
  1. 2 1
      tests/sim/pwm_bitmap_engine_tb.v
  2. 56 0
      tests/sim/thermal_safety_contract_tb.v
  3. 1 1
      tools/fw_cli.py

+ 2 - 1
tests/sim/pwm_bitmap_engine_tb.v

@@ -32,7 +32,7 @@ module pwm_bitmap_engine_tb;
     reg previous_valid;
     reg idle_seen;
 
-    always #5 clk = ~clk;
+    always #20 clk = ~clk;
     always @(posedge clk) duty_data <= duty[addr];
 
     pwm_bitmap_engine dut (
@@ -244,6 +244,7 @@ module pwm_bitmap_engine_tb;
         if (miss) $fatal(1, "scan deadline miss after safety transition");
 
         $display("PASS: PWM reset 3 periods FAN20 plus 0/20/50/100 connector polarity");
+        $display("pwm_bitmap_engine_tb PASS");
         $finish;
     end
 endmodule

+ 56 - 0
tests/sim/thermal_safety_contract_tb.v

@@ -0,0 +1,56 @@
+`timescale 1ns/1ps
+module thermal_safety_contract_tb;
+ reg clk=0;always #20 clk=~clk;
+ reg rst_n=0,tick=0,wr=0,commit=0,keepalive=0;
+ reg [4:0] addr=0,read_addr=0;
+ reg [7:0] value=0;
+ reg [15:0] epoch=0;
+ reg stale=1;
+ reg [7:0] temps[0:23];
+ wire [4:0] bi;reg[15:0] braw;
+ wire done,ok,active_bank,ready,manual,wd,hard;
+ wire [7:0] remaining,requested,applied;
+ wire [23:0] safety;wire[3:0] lanes;
+ always @(posedge clk)braw<={temps[bi],8'd0};
+ thermal_control_core dut(.clk(clk),.rst_n(rst_n),.tick_1s(tick),.manual_wr_en(wr),.manual_wr_addr(addr),
+  .manual_wr_data(value),.manual_commit(commit),.manual_commit_done(done),.manual_commit_ok(ok),
+  .watchdog_keepalive(keepalive),.bmc_epoch(epoch),.bmc_stale(stale),.bmc_valid_mask(24'hFFFFFF),
+  .bmc_rd_index(bi),.bmc_rd_raw(braw),.bmc_rd_valid(1'b1),.ct_epoch(16'd0),.ct_stale(1'b1),.ct_valid_mask(27'd0),
+  .snapshot_lock(1'b0),.snapshot_lock_bank(1'b0),.pwm_rd_addr(5'd0),.pwm_rd_data(),
+  .snapshot_output_bank(active_bank),.snapshot_rd_addr(read_addr),.snapshot_requested_data(requested),
+  .snapshot_applied_data(applied),.active_output_bank(active_bank),.control_state(),.current_target_celsius(),
+  .control_epoch(),.safety_override_mask(safety),.lane_fault_mask(lanes),.global_fault(),.output_commit(),
+  .watchdog_active(wd),.watchdog_remaining(remaining),.manual_mode(manual),.hard_protect(hard),
+  .pwm_phase_boundary(1'b1),.pwm_scan_idle(1'b1),.boot_init_complete(ready));
+ integer i;
+ task set_all;
+  begin
+   for(i=0;i<32;i=i+1)begin @(negedge clk);wr=1;addr=i;value=i<24 ? 40 : 30;end
+   @(negedge clk);wr=0;commit=1;@(negedge clk);commit=0;
+   wait(done);if(!ok)$fatal(1,"SET_ALL rejected");@(negedge clk);
+  end
+ endtask
+ task expect_output(input integer a,input integer req,input integer app);
+  begin read_addr=a;repeat(3)@(negedge clk);
+   if(requested!==req || applied!==app)$fatal(1,"channel %0d request/applied=%0d/%0d expected%0d/%0d",a,requested,applied,req,app);
+  end
+ endtask
+ initial begin
+  for(i=0;i<24;i=i+1)temps[i]=50;
+  repeat(4)@(negedge clk);rst_n=1;wait(ready);repeat(5)@(negedge clk);
+  set_all();if(!manual || remaining!=30)$fatal(1,"manual without BMC");
+  stale=0;epoch=1;repeat(300)@(negedge clk);
+  if(!manual || !wd || remaining!=30)$fatal(1,"sensor scan cancelled manual lease");
+  expect_output(0,40,40);expect_output(24,30,30);
+  temps[7]=76;epoch=2;repeat(300)@(negedge clk);
+  expect_output(7,40,0);expect_output(6,40,40);expect_output(25,30,30);
+  temps[7]=77;epoch=3;repeat(300)@(negedge clk);
+  if(lanes!==4'b0010)$fatal(1,"77C lane mapping");
+  for(i=0;i<24;i=i+1)expect_output(i,40,(i>=6&&i<12)?0:40);
+  expect_output(25,30,100);expect_output(29,30,100);expect_output(24,30,30);
+  for(i=0;i<30;i=i+1)begin tick=1;@(negedge clk);tick=0;@(negedge clk);end
+  repeat(300)@(negedge clk);expect_output(0,0,0);expect_output(24,20,20);
+  $display("thermal_safety_contract_tb PASS");$finish;
+ end
+ initial begin #1000000;$fatal(1,"thermal test deadline");end
+endmodule

+ 1 - 1
tools/fw_cli.py

@@ -240,7 +240,7 @@ def cmd_diagnose(args: argparse.Namespace) -> int:
     out.mkdir(parents=True, exist_ok=False)
     products = ("6400-front-rear", "mrdimm-chamber") if args.target == "all" else (args.target,)
     tests = {
-        "6400-front-rear": ("frame_rx_tb", "prod2u_6400_uart_e2e_tb", "thermal_snapshot_contract_tb", "host_i2c_slave_contract_tb", "prod2u_6400_host_e2e_tb"),
+        "6400-front-rear": ("frame_rx_tb", "prod2u_6400_uart_e2e_tb", "thermal_snapshot_contract_tb", "host_i2c_slave_contract_tb", "prod2u_6400_host_e2e_tb", "thermal_safety_contract_tb", "pwm_bitmap_engine_tb"),
         "mrdimm-chamber": ("motor_axis_contract_tb", "motor_engine_tb", "motor_event_ring_tb", "mrdimm_snapshot_contract_tb", "prod2u_mrdimm_uart_e2e_tb", "prod2u_mrdimm_i2c_e2e_tb"),
     }
     receipt = {"scope": "migration-diagnostic-only", "run_id": out.name,