prod2u_door_temp_uart_top.v 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. `timescale 1ns/1ps
  2. // Simulation-only wrapper for the Phase 2 real-UART contract.
  3. // The UART clock is kept at 25 MHz (40 ns period, 217 clocks/bit) so the bit-level
  4. // protocol remains real. The 500 us system tick is accelerated in simulation via
  5. // force so the motor startup/host-movement sequences complete within the cocotb
  6. // timeout, without modifying production RTL.
  7. module prod2u_door_temp_uart_top (
  8. input wire host_uart_rx,
  9. output wire host_uart_tx,
  10. output wire [7:0] ptc_pwm_out,
  11. output wire [3:0] fan_pwm_out,
  12. output wire motor_en_n,
  13. output wire x_step,
  14. output wire x_dir,
  15. output wire y_step,
  16. output wire y_dir,
  17. input wire x_limit_raw,
  18. input wire y_limit_raw,
  19. inout wire temp_scl,
  20. inout wire temp_sda
  21. );
  22. reg sys_clk = 1'b0;
  23. always #20 sys_clk = ~sys_clk;
  24. // Accelerated tick: one-cycle pulse every 100 system clocks (2 us).
  25. reg [6:0] tick_div = 7'd0;
  26. reg fast_tick = 1'b0;
  27. always @(posedge sys_clk) begin
  28. if (tick_div + 1'b1 >= 7'd100) begin
  29. tick_div <= 7'd0;
  30. fast_tick <= 1'b1;
  31. end else begin
  32. tick_div <= tick_div + 1'b1;
  33. fast_tick <= 1'b0;
  34. end
  35. end
  36. prod2u_p4_normal_v3_top u_dut (
  37. .sys_clk(sys_clk), .host_uart_rx(host_uart_rx), .host_uart_tx(host_uart_tx),
  38. .ptc_pwm_out(ptc_pwm_out), .fan_pwm_out(fan_pwm_out),
  39. .motor_en_n(motor_en_n),
  40. .x_step(x_step), .x_dir(x_dir), .y_step(y_step), .y_dir(y_dir),
  41. .x_limit_raw(x_limit_raw),
  42. .y_limit_raw(y_limit_raw), .temp_scl(temp_scl), .temp_sda(temp_sda)
  43. );
  44. initial begin
  45. force u_dut.tick_500us = fast_tick;
  46. $dumpfile("cocotb_debug.vcd");
  47. $dumpvars(0, prod2u_door_temp_uart_top);
  48. end
  49. endmodule