| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- `timescale 1ns/1ps
- // Full production-top UART/control fixture. Host and BMC stay bit-serial;
- // only the CT7428 word-level response is modeled so 27-channel scans remain
- // deterministic and fast enough for integration testing.
- module prod2u_6400_v1_cocotb_top #(
- parameter [15:0] BMC_INITIAL_EPOCH = 16'd0
- ) (
- input wire host_rs232_rx,
- output wire host_rs232_tx,
- input wire host_ttl_rx,
- output wire host_ttl_tx,
- input wire bmc_rs232_rx,
- output wire bmc_rs232_tx,
- input wire tick_1s_test,
- input wire reset_test,
- input wire bmc_epoch_override_enable,
- input wire [15:0] bmc_epoch_override_value,
- output wire [23:0] ptc_pwm_out,
- output wire [3:0] front_fan_pwm_out,
- output wire [3:0] rear_fan_pwm_out,
- output wire sys_clk,
- output wire rst_n_mon,
- output wire [2:0] control_state_mon,
- output wire [15:0] bmc_epoch_mon,
- output wire [15:0] ct_epoch_mon,
- output wire [15:0] control_epoch_mon,
- output wire [23:0] bmc_valid_mask_mon,
- output wire [26:0] ct_valid_mask_mon,
- output wire [23:0] safety_mask_mon,
- output wire [3:0] lane_fault_mask_mon,
- output wire global_fault_mon,
- output wire [7:0] current_target_mon,
- output wire host_locked_mon,
- output wire host_port_sel_mon,
- output reg [15:0] target_commit_count_mon,
- output reg [15:0] host_response_count_mon,
- output wire pwm_boundary_mon,
- output wire [6:0] pwm_phase_mon,
- output wire pwm_deadline_miss_mon,
- output wire boot_init_complete_mon,
- output wire runtime_scan_complete_mon,
- output wire [31:0] logical_bitmap_mon
- );
- reg clk = 1'b0;
- always #20 clk = ~clk;
- assign sys_clk = clk;
- tri1 temp_scl;
- tri1 temp_sda;
- prod2u_6400_v1_top #(
- .BMC_INITIAL_EPOCH(BMC_INITIAL_EPOCH),
- .CT_SCAN_PERIOD_CLKS(64),
- .HOST_INTER_BYTE_TIMEOUT_CLKS(512),
- .HOST_IDLE_UNLOCK_CLKS(1024)
- ) u_dut (
- .sys_clk(clk),
- .host_rs232_rx(host_rs232_rx),
- .host_rs232_tx(host_rs232_tx),
- .host_ttl_rx(host_ttl_rx),
- .host_ttl_tx(host_ttl_tx),
- .bmc_rs232_rx(bmc_rs232_rx),
- .bmc_rs232_tx(bmc_rs232_tx),
- .ptc_pwm_out(ptc_pwm_out),
- .front_fan_pwm_out(front_fan_pwm_out),
- .rear_fan_pwm_out(rear_fan_pwm_out),
- .temp_scl(temp_scl),
- .temp_sda(temp_sda)
- );
- // The physical I2C master has its own module tests. This fixture keeps
- // the production CT scheduler/banks/mapping and supplies one valid 60 C
- // word for every requested channel.
- initial begin
- force u_dut.tick_1s = tick_1s_test;
- force u_dut.ct_request_ready = 1'b1;
- force u_dut.ct_response_valid = 1'b1;
- force u_dut.ct_response_data = 16'h3c00;
- force u_dut.ct_response_error = 4'd0;
- end
- // Simulation-only global reset/reconfiguration injection. The production
- // top intentionally has no software reset pin; forcing its common rst_n
- // models a device reset while still exercising every real state element.
- always @(reset_test) begin
- if (reset_test === 1'b1)
- force u_dut.rst_n = 1'b0;
- else
- release u_dut.rst_n;
- end
- // Simulation-only epoch admission hook. BMC data still comes from the
- // real parser/banks; this only schedules a deterministic control pass so
- // a legal Host commit can be placed in the middle of that pass.
- always @(bmc_epoch_override_enable or bmc_epoch_override_value) begin
- if (bmc_epoch_override_enable === 1'b1)
- force u_dut.u_control.bmc_epoch = bmc_epoch_override_value;
- else
- release u_dut.u_control.bmc_epoch;
- end
- assign rst_n_mon = u_dut.rst_n;
- assign control_state_mon = u_dut.control_state;
- assign bmc_epoch_mon = u_dut.bmc_epoch;
- assign ct_epoch_mon = u_dut.ct_epoch;
- assign control_epoch_mon = u_dut.control_epoch;
- assign bmc_valid_mask_mon = u_dut.bmc_valid_mask;
- assign ct_valid_mask_mon = u_dut.ct_valid_mask;
- assign safety_mask_mon = u_dut.safety_mask;
- assign lane_fault_mask_mon = u_dut.lane_fault_mask;
- assign global_fault_mon = u_dut.global_fault;
- // The current manual controller has no single scalar current_target;
- // retain the legacy monitor port as a deterministic unused zero.
- assign current_target_mon = 8'd0;
- assign host_locked_mon = u_dut.host_locked;
- assign host_port_sel_mon = u_dut.host_port_sel;
- assign pwm_boundary_mon = u_dut.pwm_boundary;
- assign pwm_phase_mon = u_dut.pwm_phase;
- assign pwm_deadline_miss_mon = u_dut.pwm_deadline_miss;
- assign boot_init_complete_mon = u_dut.boot_init_complete;
- assign runtime_scan_complete_mon = u_dut.u_pwm.runtime_scan_complete;
- assign logical_bitmap_mon = u_dut.logical_bitmap;
- always @(posedge clk or negedge u_dut.rst_n) begin
- if (!u_dut.rst_n) begin
- target_commit_count_mon <= 0;
- host_response_count_mon <= 0;
- end else begin
- if (u_dut.manual_commit_done)
- target_commit_count_mon <= target_commit_count_mon + 1'b1;
- if (u_dut.tx_start)
- host_response_count_mon <= host_response_count_mon + 1'b1;
- end
- end
- endmodule
|