| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- `timescale 1ns/1ps
- // Simulation-only wrapper for the Phase 2 real-UART contract.
- // The UART clock is kept at 25 MHz (40 ns period, 217 clocks/bit) so the bit-level
- // protocol remains real. The 500 us system tick is accelerated in simulation via
- // force so the motor startup/host-movement sequences complete within the cocotb
- // timeout, without modifying production RTL.
- module prod2u_door_temp_uart_top (
- input wire host_uart_rx,
- output wire host_uart_tx,
- output wire [7:0] ptc_pwm_out,
- output wire [3:0] fan_pwm_out,
- output wire motor_en_n,
- output wire x_step,
- output wire x_dir,
- output wire y_step,
- output wire y_dir,
- input wire x_limit_raw,
- input wire y_limit_raw,
- inout wire temp_scl,
- inout wire temp_sda
- );
- reg sys_clk = 1'b0;
- always #20 sys_clk = ~sys_clk;
- // Accelerated tick: one-cycle pulse every 100 system clocks (2 us).
- reg [6:0] tick_div = 7'd0;
- reg fast_tick = 1'b0;
- always @(posedge sys_clk) begin
- if (tick_div + 1'b1 >= 7'd100) begin
- tick_div <= 7'd0;
- fast_tick <= 1'b1;
- end else begin
- tick_div <= tick_div + 1'b1;
- fast_tick <= 1'b0;
- end
- end
- prod2u_p4_normal_v3_top u_dut (
- .sys_clk(sys_clk), .host_uart_rx(host_uart_rx), .host_uart_tx(host_uart_tx),
- .ptc_pwm_out(ptc_pwm_out), .fan_pwm_out(fan_pwm_out),
- .motor_en_n(motor_en_n),
- .x_step(x_step), .x_dir(x_dir), .y_step(y_step), .y_dir(y_dir),
- .x_limit_raw(x_limit_raw),
- .y_limit_raw(y_limit_raw), .temp_scl(temp_scl), .temp_sda(temp_sda)
- );
- initial begin
- force u_dut.tick_500us = fast_tick;
- $dumpfile("cocotb_debug.vcd");
- $dumpvars(0, prod2u_door_temp_uart_top);
- end
- endmodule
|