Просмотр исходного кода

fix(mrdimm): make TD net and staging drivers explicit

codex 3 месяцев назад
Родитель
Сommit
2f933a90b2
2 измененных файлов с 199 добавлено и 91 удалено
  1. 12 4
      src/motor/motor_engine.v
  2. 187 87
      src/top/prod2u_mrdimm_top.v

+ 12 - 4
src/motor/motor_engine.v

@@ -131,10 +131,18 @@ module motor_engine #(
 
     // ---- batch staging ----
     reg [127:0] stage [0:7];
-    always @(posedge clk) begin
-        if (qw_byte_we)
-            stage[qw_byte_addr[6:4]][qw_byte_addr[3:0]*8 +: 8] <= qw_byte_data;
-    end
+    // Constant part-select drivers avoid TD treating a variable byte write
+    // into a variable array element as an undriven memory. Each byte still
+    // has exactly one write enable and the same asynchronous validation view.
+    genvar stage_slot,stage_byte;
+    generate for(stage_slot=0;stage_slot<8;stage_slot=stage_slot+1) begin:g_stage_slot
+        for(stage_byte=0;stage_byte<16;stage_byte=stage_byte+1) begin:g_stage_byte
+            always @(posedge clk) begin
+                if(qw_byte_we && qw_byte_addr[6:4]==stage_slot && qw_byte_addr[3:0]==stage_byte)
+                    stage[stage_slot][stage_byte*8 +:8]<=qw_byte_data;
+            end
+        end
+    end endgenerate
 
     // segment field slices — wire segment byte order (contract 10.2):
     // byte0 axis, byte1 mode, byte2 flags, byte3 reserved,

+ 187 - 87
src/top/prod2u_mrdimm_top.v

@@ -1,4 +1,5 @@
 `timescale 1ns/1ps
+`default_nettype none
 `include "generated/mrdimm/prod2u_mrdimm_params.vh"
 
 // mrdimm-chamber production top (FCB V1.2, 2026 contract section 10).
@@ -37,6 +38,8 @@ module prod2u_mrdimm_top #(parameter integer HOST_I2C_ENABLED=1) (
     output wire        y_step, y_dir,
     output wire        z_step, z_dir
 );
+    // Declare every interconnect before its first use. TD must not create
+    // implicit scalar placeholders for these buses or lose net drivers.
     wire rst_n;
     wire source_i2c,core_frame_valid,core_frame_ready,core_frame_accept_enable;
     wire [7:0] core_frame_type,core_payload_data;
@@ -44,6 +47,101 @@ module prod2u_mrdimm_top #(parameter integer HOST_I2C_ENABLED=1) (
     wire i2c_request_valid,i2c_request_ready;
     wire [7:0] i2c_request_type,i2c_payload_data;
     wire [15:0] i2c_request_length;
+    wire [3:0] fan_on, ptc_on;
+    wire tick_us, tick_1s;
+    wire selected_host_rx, shared_host_tx, host_locked, host_port_sel;
+    wire host_rs232_rx_sync, host_ttl_rx_sync;
+    wire host_transaction_done;
+    wire host_rx_valid, host_rx_error;
+    wire [7:0] host_rx_data;
+    wire frame_valid, frame_ready, frame_accept_enable;
+    wire [7:0] frame_type;
+    wire [15:0] frame_length;
+    wire payload_wr_en;
+    wire [15:0] payload_wr_addr;
+    wire [7:0] payload_wr_data;
+    wire [15:0] payload_rd_addr;
+    wire [7:0] payload_rd_data;
+    wire host_crc_start, host_crc_data_valid, host_crc_data_done, host_crc_busy;
+    wire [7:0] host_crc_data;
+    wire [15:0] host_crc_value;
+    wire host_rx_crc_start, host_rx_crc_data_valid, host_tx_crc_start, host_tx_crc_data_valid;
+    wire [7:0] host_rx_crc_data, host_tx_crc_data;
+    wire thermal_wr_en, thermal_commit, thermal_commit_done, thermal_commit_ok;
+    wire [2:0] thermal_wr_addr;
+    wire [7:0] thermal_wr_data;
+    wire keepalive_reload, snapshot_capture, snapshot_ready;
+    wire qw_byte_we, qw_submit, qw_accept, ctl_valid, ctl_accept;
+    wire [6:0] qw_byte_addr;
+    wire [7:0] qw_byte_data;
+    wire [3:0] qw_count;
+    wire [7:0] qw_status, ctl_status;
+    wire [15:0] qw_detail, ctl_detail;
+    wire [2:0] ctl_op;
+    wire [15:0] ctl_axis_mask;
+    wire [7:0] ctl_flags;
+    wire [31:0] ctl_value;
+    wire [7:0] ev_rd_index, ev_count, ev_overflow, ev_clear_count;
+    wire ev_hold, ev_clear_n;
+    wire [127:0] ev_rd_data;
+    wire ev_view_ready;
+    wire [7:0] ev_view_count;
+    wire [7:0] status_byte_in;
+    wire tx_start, tx_done, frame_tx_busy, frame_tx_byte_valid;
+    wire [7:0] tx_frame_type, tx_payload_data, frame_tx_byte_data;
+    wire [15:0] tx_payload_length, frame_tx_payload_addr;
+    wire [7:0] ack_payload_data;
+    wire host_command_busy;
+    wire lease_active;
+    wire [31:0] applied_fan_w_packed;
+    wire [31:0] applied_ptc_w_packed;
+    wire [31:0] requested_fan_w_packed;
+    wire [31:0] requested_ptc_w_packed;
+    wire [7:0] applied_fan_w [0:3];
+    wire [7:0] applied_ptc_w [0:3];
+    wire [7:0] watchdog_remaining;
+    wire [7:0] requested_fan_w [0:3],requested_ptc_w [0:3];
+    wire [31:0] ev_time_us;
+    wire [`MR_AXIS_COUNT*`MR_AXIS_RECORD_BYTES*8-1:0] axis_telemetry;
+    wire [31:0] ev_time_high,event_ring_overflow,event_pending_overflow;
+    wire motor_any_limit;
+    wire motor_telemetry_ready,motor_scan_deadline_miss;
+    reg boot_seek;
+    wire snapshot_locked,bmc_locked_bank,bmc_active_bank;
+    wire [4:0] bmc_snapshot_index;
+    wire [15:0] bmc_snapshot_raw,bmc_epoch,bmc_age;
+    wire frame_tx_done, host_tx_busy, host_tx_done;
+    wire host_response_done;
+    wire bmc_rx_valid, bmc_rx_error, bmc_tx_valid, bmc_tx_busy, bmc_tx_done;
+    wire [7:0] bmc_rx_data, bmc_tx_data;
+    wire [15:0] bmc_poll_count;
+    wire ct_request_valid, ct_request_ready, ct_response_valid, ct_response_ready;
+    wire [6:0] ct_device_addr;
+    wire [7:0] ct_register_addr;
+    wire [15:0] ct_response_data;
+    wire [3:0] ct_response_error;
+    wire ct_i2c_busy, ct_scl_drive_low, ct_sda_drive_low;
+    wire ct_snapshot_commit, ct_stale, ct_active_bank, ct_locked_bank;
+    wire [15:0] ct_epoch, ct_age;
+    wire [26:0] ct_valid_mask;
+    wire [4:0] ct_snapshot_index;
+    wire [15:0] ct_snapshot_raw;
+    wire ct_snapshot_valid;
+    wire i2c_write_strobe,i2c_command_strobe,i2c_command_write_blocked,i2c_sda_drive_low;
+    wire [15:0] i2c_write_address,i2c_read_address,i2c_response_detail,i2c_response_length;
+    wire [7:0] i2c_write_data,i2c_command_data,i2c_read_data,i2c_response_status,i2c_response_command;
+    wire i2c_response_valid;
+    wire bmc_stale;
+    wire [23:0] bmc_valid_mask;
+    wire unused;
+
+
+
+
+
+
+
+
 
 
     // ---- motor / PTC8 duplication ----
@@ -51,7 +149,7 @@ module prod2u_mrdimm_top #(parameter integer HOST_I2C_ENABLED=1) (
     // channels (pairing from the V1.2 pin contract; the duplicated pair
     // is interleaved so a single FET failure halves one zone only).
     // Physical order: P0A P0B P1A P1B P2A P2B P3A P3B
-    wire [3:0] fan_on, ptc_on;
+
     assign ptc_pwm_out = {ptc_on[3], ptc_on[3], ptc_on[2], ptc_on[2],
                           ptc_on[1], ptc_on[1], ptc_on[0], ptc_on[0]};
     // V1.2 evidence: fans are active low at the ball (connector side is
@@ -60,7 +158,7 @@ module prod2u_mrdimm_top #(parameter integer HOST_I2C_ENABLED=1) (
     assign motor_en_n = 1'b1;   // NPN invert at board: constant 1 = enabled
 
     // ---- time base ----
-    wire tick_us, tick_1s;
+
     shared_500us_tick #(.CLOCK_HZ(`MR_CLOCK_HZ), .TICK_US(1)) u_tick_1us (
         .clk(sys_clk), .rst_n(rst_n), .tick(tick_us)
     );
@@ -71,9 +169,9 @@ module prod2u_mrdimm_top #(parameter integer HOST_I2C_ENABLED=1) (
     prod2u_por #(.POR_CYCLES(1024)) u_por (.sys_clk(sys_clk), .sys_rst_n(rst_n));
 
     // ---- host frontend (RS232 + shared TTL; TTL balls unbound) ----
-    wire selected_host_rx, shared_host_tx, host_locked, host_port_sel;
-    wire host_rs232_rx_sync, host_ttl_rx_sync;
-    wire host_transaction_done;
+
+
+
     host_port_selector #(.IDLE_UNLOCK_CLKS(1250000)) u_host_select (
         .clk(sys_clk), .rst_n(rst_n), .rs232_rx_async(host_rs232_rx),
         .ttl_rx_async(host_ttl_rx), .shared_tx(shared_host_tx),
@@ -82,8 +180,8 @@ module prod2u_mrdimm_top #(parameter integer HOST_I2C_ENABLED=1) (
         .port_sel(host_port_sel), .rs232_rx_sync(host_rs232_rx_sync),
         .ttl_rx_sync(host_ttl_rx_sync)
     );
-    wire host_rx_valid, host_rx_error;
-    wire [7:0] host_rx_data;
+
+
     uart_rx_byte #(.CLKS_PER_BIT(`MR_HOST_CLKS_PER_BIT)) u_host_rx (
         .clk(sys_clk), .rst_n(rst_n), .rx_i(selected_host_rx),
         .byte_valid(host_rx_valid), .byte_data(host_rx_data),
@@ -91,19 +189,19 @@ module prod2u_mrdimm_top #(parameter integer HOST_I2C_ENABLED=1) (
     );
 
     // ---- frame path (shared CRC) ----
-    wire frame_valid, frame_ready, frame_accept_enable;
-    wire [7:0] frame_type;
-    wire [15:0] frame_length;
-    wire payload_wr_en;
-    wire [15:0] payload_wr_addr;
-    wire [7:0] payload_wr_data;
-    wire [15:0] payload_rd_addr;
-    wire [7:0] payload_rd_data;
-    wire host_crc_start, host_crc_data_valid, host_crc_data_done, host_crc_busy;
-    wire [7:0] host_crc_data;
-    wire [15:0] host_crc_value;
-    wire host_rx_crc_start, host_rx_crc_data_valid, host_tx_crc_start, host_tx_crc_data_valid;
-    wire [7:0] host_rx_crc_data, host_tx_crc_data;
+
+
+
+
+
+
+
+
+
+
+
+
+
     assign host_crc_start = host_rx_crc_start || host_tx_crc_start;
     assign host_crc_data_valid = host_rx_crc_data_valid || host_tx_crc_data_valid;
     assign host_crc_data = host_rx_crc_data_valid ? host_rx_crc_data : host_tx_crc_data;
@@ -128,31 +226,31 @@ module prod2u_mrdimm_top #(parameter integer HOST_I2C_ENABLED=1) (
     );
 
     // ---- command core ----
-    wire thermal_wr_en, thermal_commit, thermal_commit_done, thermal_commit_ok;
-    wire [2:0] thermal_wr_addr;
-    wire [7:0] thermal_wr_data;
-    wire keepalive_reload, snapshot_capture, snapshot_ready;
-    wire qw_byte_we, qw_submit, qw_accept, ctl_valid, ctl_accept;
-    wire [6:0] qw_byte_addr;
-    wire [7:0] qw_byte_data;
-    wire [3:0] qw_count;
-    wire [7:0] qw_status, ctl_status;
-    wire [15:0] qw_detail, ctl_detail;
-    wire [2:0] ctl_op;
-    wire [15:0] ctl_axis_mask;
-    wire [7:0] ctl_flags;
-    wire [31:0] ctl_value;
-    wire [7:0] ev_rd_index, ev_count, ev_overflow, ev_clear_count;
-    wire ev_hold, ev_clear_n;
-    wire [127:0] ev_rd_data;
-    wire ev_view_ready;
-    wire [7:0] ev_view_count;
-    wire [7:0] status_byte_in;
-    wire tx_start, tx_done, frame_tx_busy, frame_tx_byte_valid;
-    wire [7:0] tx_frame_type, tx_payload_data, frame_tx_byte_data;
-    wire [15:0] tx_payload_length, frame_tx_payload_addr;
-    wire [7:0] ack_payload_data;
-    wire host_command_busy;
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
 
     mrdimm_host_command #(.SNAPSHOT_LENGTH(`MR_SNAPSHOT_LENGTH)) u_command (
         .clk(sys_clk), .rst_n(rst_n),
@@ -183,23 +281,23 @@ module prod2u_mrdimm_top #(parameter integer HOST_I2C_ENABLED=1) (
         .transaction_done(host_transaction_done), .busy(host_command_busy)
     );
 
-    wire lease_active;
-    wire [31:0] applied_fan_w_packed;
+
+
 assign applied_fan_w[0]=applied_fan_w_packed[0*8 +:8];
 assign applied_fan_w[1]=applied_fan_w_packed[1*8 +:8];
 assign applied_fan_w[2]=applied_fan_w_packed[2*8 +:8];
 assign applied_fan_w[3]=applied_fan_w_packed[3*8 +:8];
-wire [31:0] applied_ptc_w_packed;
+
 assign applied_ptc_w[0]=applied_ptc_w_packed[0*8 +:8];
 assign applied_ptc_w[1]=applied_ptc_w_packed[1*8 +:8];
 assign applied_ptc_w[2]=applied_ptc_w_packed[2*8 +:8];
 assign applied_ptc_w[3]=applied_ptc_w_packed[3*8 +:8];
-wire [31:0] requested_fan_w_packed;
+
 assign requested_fan_w[0]=requested_fan_w_packed[0*8 +:8];
 assign requested_fan_w[1]=requested_fan_w_packed[1*8 +:8];
 assign requested_fan_w[2]=requested_fan_w_packed[2*8 +:8];
 assign requested_fan_w[3]=requested_fan_w_packed[3*8 +:8];
-wire [31:0] requested_ptc_w_packed;
+
 assign requested_ptc_w[0]=requested_ptc_w_packed[0*8 +:8];
 assign requested_ptc_w[1]=requested_ptc_w_packed[1*8 +:8];
 assign requested_ptc_w[2]=requested_ptc_w_packed[2*8 +:8];
@@ -220,10 +318,10 @@ assign requested_ptc_w[3]=requested_ptc_w_packed[3*8 +:8];
         .watchdog_remaining(watchdog_remaining),
         .fan_pwm_on(fan_on), .ptc_pwm_on(ptc_on)
     );
-    wire [7:0] applied_fan_w [0:3];
-    wire [7:0] applied_ptc_w [0:3];
-    wire [7:0] watchdog_remaining;
-    wire [7:0] requested_fan_w [0:3],requested_ptc_w [0:3];
+
+
+
+
 
     // ---- motor engine ----
     motor_engine #(
@@ -253,21 +351,21 @@ assign requested_ptc_w[3]=requested_ptc_w_packed[3*8 +:8];
         .axis_telemetry(axis_telemetry),
         .step_out({z_step, y_step, x_step}), .dir_out({z_dir, y_dir, x_dir})
     );
-    wire [31:0] ev_time_us;
-    wire [`MR_AXIS_COUNT*`MR_AXIS_RECORD_BYTES*8-1:0] axis_telemetry;
-    wire [31:0] ev_time_high,event_ring_overflow,event_pending_overflow;
-    wire motor_any_limit;
-    wire motor_telemetry_ready,motor_scan_deadline_miss;
-    reg boot_seek;
+
+
+
+
+
+
     always @(posedge sys_clk or negedge rst_n) begin
         if (!rst_n) boot_seek <= 1'b1;      // power-on SEEK_LOWER x3
         else boot_seek <= 1'b0;
     end
 
     // ---- Complete schema-derived status and bounded sensor-bank copy ----
-    wire snapshot_locked,bmc_locked_bank,bmc_active_bank;
-    wire [4:0] bmc_snapshot_index;
-    wire [15:0] bmc_snapshot_raw,bmc_epoch,bmc_age;
+
+
+
     mrdimm_snapshot_mux u_snapshot (
         .clk(sys_clk),.rst_n(rst_n),.capture(snapshot_capture),.source_ready(motor_telemetry_ready),.ready(snapshot_ready),.locked(snapshot_locked),
         .bmc_locked_bank(bmc_locked_bank),.ct_locked_bank(ct_locked_bank),
@@ -288,7 +386,7 @@ assign requested_ptc_w[3]=requested_ptc_w_packed[3*8 +:8];
     );
 
     // ---- frame_tx + uart ----
-    wire frame_tx_done, host_tx_busy, host_tx_done;
+
     frame_tx #(.PAYLOAD_IDX_BITS(10), .EXTERNAL_CRC(1), .PAYLOAD_READ_LATENCY(1)) u_frame_tx (
         .clk(sys_clk), .rst_n(rst_n), .start(tx_start), .frame_type(tx_frame_type),
         .payload_length(tx_payload_length), .busy(frame_tx_busy),
@@ -310,16 +408,16 @@ assign requested_ptc_w[3]=requested_ptc_w_packed[3*8 +:8];
         .byte_data(frame_tx_byte_data), .tx_o(shared_host_tx),
         .busy(host_tx_busy), .byte_done(host_tx_done)
     );
-    wire host_response_done = source_i2c ? frame_tx_done : (host_tx_done && !frame_tx_busy);
+    assign host_response_done = source_i2c ? frame_tx_done : (host_tx_done && !frame_tx_busy);
 
     // ---- BMC (optional telemetry) ----
-    wire bmc_rx_valid, bmc_rx_error, bmc_tx_valid, bmc_tx_busy, bmc_tx_done;
-    wire [7:0] bmc_rx_data, bmc_tx_data;
+
+
     uart_rx_byte #(.CLKS_PER_BIT(`MR_BMC_CLKS_PER_BIT)) u_bmc_rx (
         .clk(sys_clk), .rst_n(rst_n), .rx_i(bmc_rs232_rx),
         .byte_valid(bmc_rx_valid), .byte_data(bmc_rx_data), .framing_error(bmc_rx_error)
     );
-    wire [15:0] bmc_poll_count;
+
     bmc_poll_engine u_bmc_poll (
         .clk(sys_clk), .rst_n(rst_n), .tx_ready(!bmc_tx_busy),
         .tx_valid(bmc_tx_valid), .tx_data(bmc_tx_data), .poll_count(bmc_poll_count)
@@ -339,18 +437,18 @@ assign requested_ptc_w[3]=requested_ptc_w_packed[3*8 +:8];
     );
 
     // ---- CT7428 acquisition (independent I2C master) ----
-    wire ct_request_valid, ct_request_ready, ct_response_valid, ct_response_ready;
-    wire [6:0] ct_device_addr;
-    wire [7:0] ct_register_addr;
-    wire [15:0] ct_response_data;
-    wire [3:0] ct_response_error;
-    wire ct_i2c_busy, ct_scl_drive_low, ct_sda_drive_low;
-    wire ct_snapshot_commit, ct_stale, ct_active_bank, ct_locked_bank;
-    wire [15:0] ct_epoch, ct_age;
-    wire [26:0] ct_valid_mask;
-    wire [4:0] ct_snapshot_index;
-    wire [15:0] ct_snapshot_raw;
-    wire ct_snapshot_valid;
+
+
+
+
+
+
+
+
+
+
+
+
     ct7428_snapshot #(.SCAN_PERIOD_CLKS(2500000)) u_ct_snapshot (
         .clk(sys_clk), .rst_n(rst_n), .tick_1s(tick_1s),
         .snapshot_lock(snapshot_locked), .snapshot_lock_bank(ct_locked_bank),
@@ -378,12 +476,12 @@ assign requested_ptc_w[3]=requested_ptc_w_packed[3*8 +:8];
     assign temp_sda = ct_sda_drive_low ? 1'b0 : 1'bz;
 
     // Independent physical I2C frontend; business logic is shared with UART.
-    wire i2c_write_strobe,i2c_command_strobe,i2c_command_write_blocked,i2c_sda_drive_low;
-    wire [15:0] i2c_write_address,i2c_read_address,i2c_response_detail,i2c_response_length;
-    wire [7:0] i2c_write_data,i2c_command_data,i2c_read_data,i2c_response_status,i2c_response_command;
-    wire i2c_response_valid;
-    wire bmc_stale;
-    wire [23:0] bmc_valid_mask;
+
+
+
+
+
+
     generate if(HOST_I2C_ENABLED)begin:g_host_i2c
     host_i2c_register_slave #(.SLAVE_ADDRESS(`MR_HOST_I2C_ADDRESS)) u_host_i2c_slave (
         .clk(sys_clk),.rst_n(rst_n),.scl_i(host_i2c_scl),.sda_io(host_i2c_sda),
@@ -419,9 +517,11 @@ assign requested_ptc_w[3]=requested_ptc_w_packed[3*8 +:8];
         .core_type(core_frame_type),.core_length(core_frame_length),.core_payload_data(core_payload_data),
         .transaction_done(host_transaction_done),.source_i2c(source_i2c)
     );
-    wire unused = &{1'b0, host_locked, host_port_sel, frame_tx_busy, frame_tx_done,
+    assign unused = &{1'b0, host_locked, host_port_sel, frame_tx_busy, frame_tx_done,
         host_tx_done, host_rs232_rx_sync, host_ttl_rx_sync, host_command_busy,
         bmc_tx_done, bmc_poll_count, ct_snapshot_commit, ct_i2c_busy, bmc_rx_error,
         ct_snapshot_valid, ct_snapshot_raw, ct_snapshot_index, host_rx_error};
 
 endmodule
+
+`default_nettype wire