Authority: AGENTS.md at the repository root. This file only pins the module-level
interfaces so parallel work cannot drift. If this file and AGENTS.md disagree,
AGENTS.md wins and this file is corrected.
sys_clk = 25 MHz, single domain. rst_n comes from src/rtl/prod2u_por.v.
No PLL, no derived or gated clock, no clock used as data.A5 5A | TYPE:u8 | LENGTH:u8 | PAYLOAD | CRC_L | CRC_H.
Total bytes = LENGTH + 6. CRC-16/CCITT-FALSE (poly 0x1021, init 0xFFFF,
refin/refout false, xorout 0) covers TYPE, LENGTH and PAYLOAD; not the header.
Low CRC byte first.crc16_serial instance. A single
accumulator switched by UART busy is forbidden.| TYPE | Meaning | Payload |
|---|---|---|
| 0x01 | SET_ALL | 6400 = 32, MRDIMM = 68 |
| 0x02 | GET_ALL | 0 |
| 0x81 | SET_ACK | 0 |
| 0x82 | GET_ACK | 0 |
| 0x42 | GET_DATA | 6400 = 83, MRDIMM = 63 |
| 0x50 | MOTOR_DONE | 4 (MRDIMM only) |
| 0xC0 | NACK | 2 = {request TYPE, reason} |
NACK reasons: 01 UNSUPPORTED, 02 BAD_LENGTH, 03 BAD_VALUE, 04 QUEUE_FULL, 05 BUSY.
| Owner | Files |
|---|---|
| core (lead) | src/top/*final*, src/control/output_bank.v, src/control/watchdog_30s.v, src/transport/reply_ram.v, src/transport/reply_arbiter.v, src/telemetry/get_data_6400.v, src/motor/* |
| protocol worker | src/common/frame_rx.v, src/common/frame_tx.v, src/transport/host_uart_endpoint.v, tests/sim/frame_rx_*, tests/sim/frame_tx_*, tests/sim/host_uart_endpoint_* |
| temperature worker | src/acquisition/temp_ram.v, src/acquisition/bmc_ascii_poll.v, src/acquisition/ct7428_scan.v, tests/sim/bmc_*, tests/sim/ct7428_*, tests/sim/temp_ram_* |
| contracts worker | contracts/*, tools/generate_*.py, generated/*, products/*/source-closure.json, projects/registry.json, config/current-product-tests.json |
| SDK worker | /workspace/hth-platform/** |
Rules: one writer per file. Do not edit a file another owner holds. Do not modify
AGENTS.md. New files go through git add <path> only (never git add -A).
src/common/frame_rx.vAdd parameter LENGTH_BYTES (1 or 2, default 2). With LENGTH_BYTES = 1:
frame_length is {8'h00, length_byte}; the CRC input sees exactly two bytes
(TYPE then LENGTH).MAX_PAYLOAD
are CRC-consumed and dropped (sink), never written past the RAM and never treated
as a new frame.A5 5A inside a payload never restarts a frame.INTER_BYTE_TIMEOUT_CYCLES gap expiry returns the parser to hunting.src/common/frame_tx.vAdd parameter LENGTH_BYTES (1 or 2, default 2). With LENGTH_BYTES = 1: emit only
payload_length[7:0] as the LENGTH byte and feed TYPE, LENGTH, PAYLOAD into CRC.
src/transport/host_uart_endpoint.vmodule host_uart_endpoint #(
parameter integer CLKS_PER_BIT = 27,
parameter integer INTER_BYTE_TIMEOUT_CYCLES = 250000,
parameter integer MAX_PAYLOAD = 128,
parameter integer ADDR_WIDTH = 8
) (
input wire clk,
input wire rst_n,
input wire rs232_rx, // CON78
output wire rs232_tx,
input wire ttl_rx, // CON30
output wire ttl_tx, // broadcast copy of the same TX stream
// parsed request (one outstanding ordinary transaction)
output reg req_valid,
input wire req_ready,
output reg [7:0] req_type,
output reg [7:0] req_length,
// request RAM write port (parser owns it)
output wire req_ram_wr_en,
output wire [ADDR_WIDTH-1:0] req_ram_wr_addr,
output wire [7:0] req_ram_wr_data,
// request RAM read port for validation/commit
output wire [ADDR_WIDTH-1:0] req_ram_rd_addr,
input wire [7:0] req_ram_rd_data,
// reply transmission
input wire tx_start, // one-cycle request; only when !tx_busy
input wire [7:0] tx_type,
input wire [7:0] tx_length,
output wire tx_busy,
output reg tx_done, // final stop bit on the wire
output wire [ADDR_WIDTH-1:0] tx_ram_rd_addr,
input wire [7:0] tx_ram_rd_data
);
Behaviour:
tx_done marks the real last stop bit, not "handed to the UART".rs232_tx and ttl_tx carry the same byte stream.src/transport/reply_ram.vmodule reply_ram #(
parameter integer DEPTH = 128,
parameter integer ADDR_WIDTH = 8
) (
input wire clk,
input wire wr_en,
input wire [ADDR_WIDTH-1:0] wr_addr,
input wire [7:0] wr_data,
input wire [ADDR_WIDTH-1:0] rd_addr,
output wire [7:0] rd_data // synchronous read, 1 clock
);
The response builder fills this RAM before tx_start. frame_tx is instantiated with
PAYLOAD_READ_LATENCY = 1.
src/transport/reply_arbiter.vmodule reply_arbiter (
input wire clk,
input wire rst_n,
// normal reply group (SET_ACK / GET_ACK + GET_DATA / NACK); held until complete
input wire group_valid, // a complete group is ready in reply_ram
output reg group_start, // one-cycle launch
input wire group_done, // last stop bit of the last frame of the group
input wire [7:0] group_type,
input wire [7:0] group_length,
input wire group_second, // group has a second frame (GET_ACK then GET_DATA)
input wire [7:0] second_type,
input wire [7:0] second_length,
input wire [ADDR_WIDTH-1:0] second_base, // reply_ram offset of the second payload
// DONE queue
input wire [15:0] done_pending,
output reg [3:0] done_axis_grant,
input wire done_ack, // DONE accepted for transmission
// wire side
output reg tx_start,
output reg [7:0] tx_type,
output reg [7:0] tx_length,
output reg [31:0] tx_base, // reply_ram offset of the current frame payload
input wire tx_busy,
input wire tx_done // final stop bit of one frame
);
Rules the arbiter enforces: a started frame is never truncated; GET_ACK + GET_DATA
is one contiguous group with no DONE inserted; a legal SET's ACK precedes that new
segment's DONE; DONEs are not starved forever (a group window is bounded by one group).
src/control/output_bank.vmodule output_bank #(
parameter integer CHANNEL_COUNT = 32,
parameter integer ADDR_WIDTH = 5
) (
input wire clk,
// PWM read side (active bank)
input wire [ADDR_WIDTH-1:0] pwm_addr,
output wire [7:0] pwm_duty,
// staging write side (inactive bank, driven from request RAM during commit)
input wire stage_we,
input wire [ADDR_WIDTH-1:0] stage_addr,
input wire [7:0] stage_data,
input wire commit, // flip active bank after a complete stage pass
// default override
input wire present_default,
input wire [7:0] default_ptc, // 0
input wire [7:0] default_fan // 20
);
pwm_duty presents the active bank unless present_default is high, in which case
PTC channels read default_ptc and fan channels read default_fan. The bitmap source
is fixed for a whole PWM period; it never changes midway through a scan.
src/control/watchdog_30s.vmodule watchdog_30s #(
parameter integer CLOCK_HZ = 25000000,
parameter integer TIMEOUT_SECONDS = 30
) (
input wire clk,
input wire rst_n,
input wire arm, // first successful SET_ACCEPT or GET_ACCEPT
input wire reload, // SET_ACCEPT / GET_ACCEPT
output reg expired, // one-cycle pulse at expiry
output reg counting
);
Bad requests, NACKs and DONEs never feed it. A coincidence of expiry with a valid admission resolves in favour of the admission.
src/acquisition/temp_ram.vmodule temp_ram #(
parameter integer DEPTH = 64,
parameter integer ADDR_WIDTH = 6
) (
input wire clk,
input wire wr_en,
input wire [ADDR_WIDTH-1:0] wr_addr,
input wire [7:0] wr_data,
input wire [ADDR_WIDTH-1:0] rd_addr,
output wire [7:0] rd_data, // synchronous, 1 clock
output wire rd_valid // registered address-in-range flag
);
BMC channels live at 0..23, CT channels at 32..58. A value of 0xFF means invalid.
src/telemetry/get_data_6400.vSequentially fills reply_ram with 83 bytes: PTC 0..23, Front 0..3, Rear 0..3 from
the active output bank; then 24 BMC bytes; then 27 CT bytes.
module get_data_6400 (
input wire clk,
input wire rst_n,
input wire start,
output reg ready, // one-cycle pulse, 83 bytes present
// output bank read
output reg [4:0] bank_addr,
input wire [7:0] bank_duty,
// temperature read
output reg [5:0] temp_addr,
input wire [7:0] temp_data,
input wire temp_valid,
// reply staging
output reg reply_we,
output reg [7:0] reply_addr,
output reg [7:0] reply_data
);
Every fetched byte is held until the staging write is accepted; temp_valid gates the
temperature reads so a slow synchronous RAM never commits a mixed channel.
src/motor/* (MRDIMM)axis_queue_ram.v: 12 axes x 32 slots x 8 bytes = 3072 bytes in one RAM
(ef2_bram_32k, 2048x16 -> use two 16-bit words per slot or a 8-byte aligned
layout documented in the module header).motor_scheduler12.v: head/tail/count per axis; finite segment
{action:u8, steps:u16, half_period_us:u16}; STEP/DIR generation; limit gating;
final-pin edge counting; one DONE slot per axis.done_mailbox.v: per-axis {axis, reason, steps_done} plus a pending flag.generated/6400/prod2u_6400_v1_params.vh must define exactly these names, and the
new 6400 RTL includes this header:
FB_CLOCK_HZ FB_PTC_COUNT FB_FRONT_FAN_COUNT FB_REAR_FAN_COUNT FB_OUTPUT_COUNT
FB_BMC_COUNT FB_CT_COUNT FB_HOST_BAUD FB_BMC_BAUD FB_HOST_CLKS_PER_BIT
FB_BMC_CLKS_PER_BIT FB_PWM_PHASES FB_PTC_PWM_HZ FB_FAN_PWM_HZ FB_PWM_PHASE_CLKS
FB_PWM_PERIOD_CLKS FAN_BOARD_INVERT_MASK CONTROL_WATCHDOG_SECONDS
FB_FRAME_LENGTH_WIDTH FB_CMD_SET_ALL FB_CMD_GET_ALL FB_RSP_SET_ACK FB_RSP_GET_ACK
FB_RSP_GET_DATA FB_RSP_NACK FB_NACK_UNSUPPORTED FB_NACK_BAD_LENGTH FB_NACK_BAD_VALUE
FB_NACK_QUEUE_FULL FB_NACK_BUSY FB_SET_ALL_BYTES FB_GET_DATA_BYTES
FB_HOST_INTER_BYTE_TIMEOUT_CLKS FB_HOST_BAUD_DIV FB_HOST_BAUD_MUL
FB_FRAME_LENGTH_WIDTH is 8. FB_PWM_PHASE_CLKS x FB_PWM_PHASES = 50000.
The 76/77 C clamp macros, PID macros and every epoch/age/lease macro are deleted.
generated/mrdimm/prod2u_mrdimm_params.vh must define exactly:
MR_CLOCK_HZ MR_HOST_BAUD MR_HOST_CLKS_PER_BIT MR_BMC_BAUD MR_BMC_CLKS_PER_BIT
MR_FRAME_LENGTH_WIDTH MR_CMD_SET_ALL MR_CMD_GET_ALL MR_RSP_SET_ACK MR_RSP_GET_ACK
MR_RSP_GET_DATA MR_RSP_MOTOR_DONE MR_RSP_NACK MR_NACK_UNSUPPORTED MR_NACK_BAD_LENGTH
MR_NACK_BAD_VALUE MR_NACK_QUEUE_FULL MR_NACK_BUSY MR_SET_ALL_BYTES MR_GET_DATA_BYTES
MR_MOTOR_DONE_BYTES MR_AXIS_COUNT MR_SLOTS_PER_AXIS MR_SLOT_BYTES MR_AXIS_SLOT_BASE
MR_FAN_COUNT MR_PTC_COUNT MR_PTC_PHYSICAL MR_PWM_HZ MR_PWM_PHASES MR_PWM_PHASE_CLKS
MR_PWM_PERIOD_CLKS MR_LIMIT_ACTIVE_HIGH MR_BOOT_FAN_PERCENT MR_BOOT_PTC_PERCENT
MR_HOST_INTER_BYTE_TIMEOUT_CLKS
MR_AXIS_SLOT_BASE = 8, MR_SLOT_BYTES = 5, MR_SLOTS_PER_AXIS = 32.
Unit/pytest (repo root):
/opt/prod2u/venv/bin/python -m pytest -q tests/unit -x
Icarus testbench:
iverilog -g2012 -Wall -I. -s <tb_module> -o /tmp/<tb>.vvp <sources...> tests/sim/<tb>.v
vvp /tmp/<tb>.vvp +ARTIFACT_DIR=<dir>
A testbench prints <tb_module> PASS on success and exits non-zero on failure.
Every testbench must fail on a deliberately injected defect in the behaviour it
claims to check.