فهرست منبع

fix: force accelerated tick in cocotb wrapper to keep real UART bit timing while completing motor sequences in simulation.

Codex Resource Selftest 4 ماه پیش
والد
کامیت
d84dc38a18
1فایلهای تغییر یافته به همراه21 افزوده شده و 0 حذف شده
  1. 21 0
      tests/cocotb/prod2u_door_temp_uart_top.v

+ 21 - 0
tests/cocotb/prod2u_door_temp_uart_top.v

@@ -1,6 +1,10 @@
 `timescale 1ns/1ps
 `timescale 1ns/1ps
 
 
 // Simulation-only wrapper for the Phase 2 real-UART contract.
 // 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 (
 module prod2u_door_temp_uart_top (
     input  wire       host_uart_rx,
     input  wire       host_uart_rx,
     output wire       host_uart_tx,
     output wire       host_uart_tx,
@@ -19,6 +23,19 @@ module prod2u_door_temp_uart_top (
     reg sys_clk = 1'b0;
     reg sys_clk = 1'b0;
     always #20 sys_clk = ~sys_clk;
     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 (
     prod2u_p4_normal_v3_top u_dut (
         .sys_clk(sys_clk), .host_uart_rx(host_uart_rx), .host_uart_tx(host_uart_tx),
         .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),
         .ptc_pwm_out(ptc_pwm_out), .fan_pwm_out(fan_pwm_out),
@@ -28,4 +45,8 @@ module prod2u_door_temp_uart_top (
         .y_limit_raw(y_limit_raw), .temp_scl(temp_scl), .temp_sda(temp_sda)
         .y_limit_raw(y_limit_raw), .temp_scl(temp_scl), .temp_sda(temp_sda)
     );
     );
 
 
+    initial begin
+        force u_dut.tick_500us = fast_tick;
+    end
+
 endmodule
 endmodule