prod2u_6400_v1_cocotb_top.v 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. `timescale 1ns/1ps
  2. // Full production-top UART/control fixture. Host and BMC stay bit-serial;
  3. // only the CT7428 word-level response is modeled so 27-channel scans remain
  4. // deterministic and fast enough for integration testing.
  5. module prod2u_6400_v1_cocotb_top #(
  6. parameter [15:0] BMC_INITIAL_EPOCH = 16'd0
  7. ) (
  8. input wire host_rs232_rx,
  9. output wire host_rs232_tx,
  10. input wire host_ttl_rx,
  11. output wire host_ttl_tx,
  12. input wire bmc_rs232_rx,
  13. output wire bmc_rs232_tx,
  14. input wire tick_1s_test,
  15. input wire reset_test,
  16. input wire bmc_epoch_override_enable,
  17. input wire [15:0] bmc_epoch_override_value,
  18. output wire [23:0] ptc_pwm_out,
  19. output wire [3:0] front_fan_pwm_out,
  20. output wire [3:0] rear_fan_pwm_out,
  21. output wire sys_clk,
  22. output wire rst_n_mon,
  23. output wire [2:0] control_state_mon,
  24. output wire [15:0] bmc_epoch_mon,
  25. output wire [15:0] ct_epoch_mon,
  26. output wire [15:0] control_epoch_mon,
  27. output wire [23:0] bmc_valid_mask_mon,
  28. output wire [26:0] ct_valid_mask_mon,
  29. output wire [23:0] safety_mask_mon,
  30. output wire [3:0] lane_fault_mask_mon,
  31. output wire global_fault_mon,
  32. output wire [7:0] current_target_mon,
  33. output wire host_locked_mon,
  34. output wire host_port_sel_mon,
  35. output reg [15:0] target_commit_count_mon,
  36. output reg [15:0] host_response_count_mon,
  37. output wire pwm_boundary_mon,
  38. output wire [6:0] pwm_phase_mon,
  39. output wire pwm_deadline_miss_mon,
  40. output wire boot_init_complete_mon,
  41. output wire runtime_scan_complete_mon,
  42. output wire [31:0] logical_bitmap_mon
  43. );
  44. reg clk = 1'b0;
  45. always #20 clk = ~clk;
  46. assign sys_clk = clk;
  47. tri1 temp_scl;
  48. tri1 temp_sda;
  49. prod2u_6400_v1_top #(
  50. .BMC_INITIAL_EPOCH(BMC_INITIAL_EPOCH),
  51. .CT_SCAN_PERIOD_CLKS(64),
  52. .HOST_INTER_BYTE_TIMEOUT_CLKS(512),
  53. .HOST_IDLE_UNLOCK_CLKS(1024)
  54. ) u_dut (
  55. .sys_clk(clk),
  56. .host_rs232_rx(host_rs232_rx),
  57. .host_rs232_tx(host_rs232_tx),
  58. .host_ttl_rx(host_ttl_rx),
  59. .host_ttl_tx(host_ttl_tx),
  60. .bmc_rs232_rx(bmc_rs232_rx),
  61. .bmc_rs232_tx(bmc_rs232_tx),
  62. .ptc_pwm_out(ptc_pwm_out),
  63. .front_fan_pwm_out(front_fan_pwm_out),
  64. .rear_fan_pwm_out(rear_fan_pwm_out),
  65. .temp_scl(temp_scl),
  66. .temp_sda(temp_sda)
  67. );
  68. // The physical I2C master has its own module tests. This fixture keeps
  69. // the production CT scheduler/banks/mapping and supplies one valid 60 C
  70. // word for every requested channel.
  71. initial begin
  72. force u_dut.tick_1s = tick_1s_test;
  73. force u_dut.ct_request_ready = 1'b1;
  74. force u_dut.ct_response_valid = 1'b1;
  75. force u_dut.ct_response_data = 16'h3c00;
  76. force u_dut.ct_response_error = 4'd0;
  77. end
  78. // Simulation-only global reset/reconfiguration injection. The production
  79. // top intentionally has no software reset pin; forcing its common rst_n
  80. // models a device reset while still exercising every real state element.
  81. always @(reset_test) begin
  82. if (reset_test === 1'b1)
  83. force u_dut.rst_n = 1'b0;
  84. else
  85. release u_dut.rst_n;
  86. end
  87. // Simulation-only epoch admission hook. BMC data still comes from the
  88. // real parser/banks; this only schedules a deterministic control pass so
  89. // a legal Host commit can be placed in the middle of that pass.
  90. always @(bmc_epoch_override_enable or bmc_epoch_override_value) begin
  91. if (bmc_epoch_override_enable === 1'b1)
  92. force u_dut.u_control.bmc_epoch = bmc_epoch_override_value;
  93. else
  94. release u_dut.u_control.bmc_epoch;
  95. end
  96. assign rst_n_mon = u_dut.rst_n;
  97. assign control_state_mon = u_dut.control_state;
  98. assign bmc_epoch_mon = u_dut.bmc_epoch;
  99. assign ct_epoch_mon = u_dut.ct_epoch;
  100. assign control_epoch_mon = u_dut.control_epoch;
  101. assign bmc_valid_mask_mon = u_dut.bmc_valid_mask;
  102. assign ct_valid_mask_mon = u_dut.ct_valid_mask;
  103. assign safety_mask_mon = u_dut.safety_mask;
  104. assign lane_fault_mask_mon = u_dut.lane_fault_mask;
  105. assign global_fault_mon = u_dut.global_fault;
  106. // The current manual controller has no single scalar current_target;
  107. // retain the legacy monitor port as a deterministic unused zero.
  108. assign current_target_mon = 8'd0;
  109. assign host_locked_mon = u_dut.host_locked;
  110. assign host_port_sel_mon = u_dut.host_port_sel;
  111. assign pwm_boundary_mon = u_dut.pwm_boundary;
  112. assign pwm_phase_mon = u_dut.pwm_phase;
  113. assign pwm_deadline_miss_mon = u_dut.pwm_deadline_miss;
  114. assign boot_init_complete_mon = u_dut.boot_init_complete;
  115. assign runtime_scan_complete_mon = u_dut.u_pwm.runtime_scan_complete;
  116. assign logical_bitmap_mon = u_dut.logical_bitmap;
  117. always @(posedge clk or negedge u_dut.rst_n) begin
  118. if (!u_dut.rst_n) begin
  119. target_commit_count_mon <= 0;
  120. host_response_count_mon <= 0;
  121. end else begin
  122. if (u_dut.manual_commit_done)
  123. target_commit_count_mon <= target_commit_count_mon + 1'b1;
  124. if (u_dut.tx_start)
  125. host_response_count_mon <= host_response_count_mon + 1'b1;
  126. end
  127. end
  128. endmodule