|
@@ -106,6 +106,19 @@ def validate_wire(wire: dict[str, Any], snapshot_size: int) -> None:
|
|
|
raise ValueError("UART baud drift")
|
|
raise ValueError("UART baud drift")
|
|
|
if wire["commands"]["SET_TARGET"]["payload_length"] != 1:
|
|
if wire["commands"]["SET_TARGET"]["payload_length"] != 1:
|
|
|
raise ValueError("SET_TARGET length drift")
|
|
raise ValueError("SET_TARGET length drift")
|
|
|
|
|
+ stimulus_fields = wire["commands"]["SET_STIMULUS"].get("payload_fields", [])
|
|
|
|
|
+ expected_stimulus_fields = [
|
|
|
|
|
+ {"name": "duration_seconds", "offset": 0, "count": 1, "minimum": 1, "maximum": 255, "unit": "seconds"},
|
|
|
|
|
+ {"name": "ptc_duty_percent", "offset": 1, "count": 24, "minimum": 0, "maximum": 100, "unit": "percent"},
|
|
|
|
|
+ {"name": "front_fan_duty_percent", "offset": 25, "count": 4, "minimum": 0, "maximum": 100, "unit": "percent"},
|
|
|
|
|
+ {"name": "rear_fan_duty_percent", "offset": 29, "count": 4, "minimum": 0, "maximum": 100, "unit": "percent"},
|
|
|
|
|
+ ]
|
|
|
|
|
+ if stimulus_fields != expected_stimulus_fields:
|
|
|
|
|
+ raise ValueError("SET_STIMULUS payload layout drift")
|
|
|
|
|
+ if wire["responses"]["GET_SNAPSHOT_ACK"] != {"type": 0x82, "payload_length": 0}:
|
|
|
|
|
+ raise ValueError("GET_SNAPSHOT independent ACK drift")
|
|
|
|
|
+ if wire["responses"]["SNAPSHOT_DATA"].get("type") != 0x42:
|
|
|
|
|
+ raise ValueError("SNAPSHOT_DATA must be request type OR 0x40")
|
|
|
if wire["responses"]["SNAPSHOT_DATA"].get("payload_length", snapshot_size) != snapshot_size:
|
|
if wire["responses"]["SNAPSHOT_DATA"].get("payload_length", snapshot_size) != snapshot_size:
|
|
|
raise ValueError("snapshot length drift")
|
|
raise ValueError("snapshot length drift")
|
|
|
forbidden = set(wire.get("forbidden_fields", []))
|
|
forbidden = set(wire.get("forbidden_fields", []))
|
|
@@ -113,6 +126,47 @@ def validate_wire(wire: dict[str, Any], snapshot_size: int) -> None:
|
|
|
raise ValueError("forbidden field list incomplete")
|
|
raise ValueError("forbidden field list incomplete")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+def validate_fans(mapping: dict[str, Any], fan: dict[str, Any]) -> None:
|
|
|
|
|
+ if mapping.get("fan_output_vector_order") != [
|
|
|
|
|
+ "front0", "front1", "front2", "front3",
|
|
|
|
|
+ "rear0", "rear1", "rear2", "rear3",
|
|
|
|
|
+ ]:
|
|
|
|
|
+ raise ValueError("fan physical vector order drift")
|
|
|
|
|
+ expected_front = (
|
|
|
|
|
+ (24, 0, "CON25", 7, "FAN_PWM3", "Q101", "B1", True),
|
|
|
|
|
+ (25, 1, "CON8", 7, "FAN_PWM1", "Q99", "C4", True),
|
|
|
|
|
+ (26, 2, "CON24", 7, "FAN_PWM2", "Q100", "B5", True),
|
|
|
|
|
+ (27, 3, "CON26", 7, "FAN_PWM4", "Q102", "A14", True),
|
|
|
|
|
+ )
|
|
|
|
|
+ expected_rear = (
|
|
|
|
|
+ (28, 0, "CON64", 4, "FAN_GPIO44", "R704_0R_DIRECT", "P15", False),
|
|
|
|
|
+ (29, 1, "CON66", 4, "FAN_GPIO46", "R706_0R_DIRECT", "N15", False),
|
|
|
|
|
+ (30, 2, "CON62", 4, "FAN_GPIO42", "R702_0R_DIRECT", "M14", False),
|
|
|
|
|
+ (31, 3, "CON60", 4, "FAN_GPIO40", "R700_0R_DIRECT", "P5", False),
|
|
|
|
|
+ )
|
|
|
|
|
+ rows = mapping.get("fan_outputs", [])
|
|
|
|
|
+ for name, expected in (("front", expected_front), ("rear", expected_rear)):
|
|
|
|
|
+ actual = tuple(
|
|
|
|
|
+ (int(row["output_index"]), int(row["lane"]), row["connector"], int(row["pin"]),
|
|
|
|
|
+ row["net"], row["board_stage"], row["fpga_ball"], bool(row["board_inverts"]))
|
|
|
|
|
+ for row in rows if row.get("group") == name
|
|
|
|
|
+ )
|
|
|
|
|
+ if actual != expected:
|
|
|
|
|
+ raise ValueError(f"{name} fan physical mapping drift")
|
|
|
|
|
+ invert_mask = sum(1 << (int(row["output_index"]) - 24) for row in rows if row["board_inverts"])
|
|
|
|
|
+ if invert_mask != 0x0F:
|
|
|
|
|
+ raise ValueError("fan board invert mask must be 0x0F for grouped front/rear vector")
|
|
|
|
|
+ pwm = fan.get("pwm", {})
|
|
|
|
|
+ if pwm.get("ptc_hz") != 500 or pwm.get("fan_hz") != 500:
|
|
|
|
|
+ raise ValueError("current PTC/FAN PWM frequencies must independently equal 500 Hz")
|
|
|
|
|
+ if pwm.get("ptc_phase_clks") != 500 or pwm.get("fan_phase_clks") != 500:
|
|
|
|
|
+ raise ValueError("current PTC/FAN phase clocks must independently equal 500")
|
|
|
|
|
+ if pwm.get("carrier_backend") != "shared_equal_frequency_v1":
|
|
|
|
|
+ raise ValueError("current equal-frequency carrier backend drift")
|
|
|
|
|
+ if fan["duty"].get("reset") != 10 or fan["duty"].get("stopped") != 10:
|
|
|
|
|
+ raise ValueError("reset and STOPPED fan standby duty must remain 10")
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
def crc16(data: bytes) -> int:
|
|
def crc16(data: bytes) -> int:
|
|
|
crc = 0xFFFF
|
|
crc = 0xFFFF
|
|
|
for value in data:
|
|
for value in data:
|
|
@@ -132,12 +186,16 @@ def json_bytes(value: Any) -> bytes:
|
|
|
return (json.dumps(value, indent=2, sort_keys=True, ensure_ascii=False) + "\n").encode()
|
|
return (json.dumps(value, indent=2, sort_keys=True, ensure_ascii=False) + "\n").encode()
|
|
|
|
|
|
|
|
|
|
|
|
|
-def verilog_header(layout_rows: list[dict[str, Any]], snapshot_size: int, wire: dict[str, Any], coeff: dict[str, Any], fan: dict[str, Any], contract_sha: str) -> bytes:
|
|
|
|
|
|
|
+def verilog_header(layout_rows: list[dict[str, Any]], snapshot_size: int, wire: dict[str, Any], coeff: dict[str, Any], fan: dict[str, Any], mapping: dict[str, Any], contract_sha: str) -> bytes:
|
|
|
command = wire["commands"]
|
|
command = wire["commands"]
|
|
|
response = wire["responses"]
|
|
response = wire["responses"]
|
|
|
limits = coeff["limits_centi_degC"]
|
|
limits = coeff["limits_centi_degC"]
|
|
|
target = coeff["targets_centi_degC"]
|
|
target = coeff["targets_centi_degC"]
|
|
|
classes = coeff["classes"]
|
|
classes = coeff["classes"]
|
|
|
|
|
+ fan_invert_mask = sum(
|
|
|
|
|
+ 1 << (int(row["output_index"]) - 24)
|
|
|
|
|
+ for row in mapping["fan_outputs"] if row["board_inverts"]
|
|
|
|
|
+ )
|
|
|
lines = [
|
|
lines = [
|
|
|
"`ifndef PROD2U_6400_V1_PARAMS_VH",
|
|
"`ifndef PROD2U_6400_V1_PARAMS_VH",
|
|
|
"`define PROD2U_6400_V1_PARAMS_VH",
|
|
"`define PROD2U_6400_V1_PARAMS_VH",
|
|
@@ -155,14 +213,24 @@ def verilog_header(layout_rows: list[dict[str, Any]], snapshot_size: int, wire:
|
|
|
"`define FB_BMC_BAUD 115200",
|
|
"`define FB_BMC_BAUD 115200",
|
|
|
"`define FB_HOST_FIXED_CLKS_PER_BIT 27",
|
|
"`define FB_HOST_FIXED_CLKS_PER_BIT 27",
|
|
|
"`define FB_BMC_CLKS_PER_BIT 217",
|
|
"`define FB_BMC_CLKS_PER_BIT 217",
|
|
|
- "`define FB_PWM_PHASES 100",
|
|
|
|
|
- "`define FB_PWM_PHASE_CLKS 500",
|
|
|
|
|
- "`define FB_PWM_PERIOD_CLKS 50000",
|
|
|
|
|
|
|
+ f"`define FB_PWM_PHASES {int(fan['pwm']['phases'])}",
|
|
|
|
|
+ f"`define FB_PTC_PWM_HZ {int(fan['pwm']['ptc_hz'])}",
|
|
|
|
|
+ f"`define FB_FAN_PWM_HZ {int(fan['pwm']['fan_hz'])}",
|
|
|
|
|
+ f"`define FB_PTC_PWM_PHASE_CLKS {int(fan['pwm']['ptc_phase_clks'])}",
|
|
|
|
|
+ f"`define FB_FAN_PWM_PHASE_CLKS {int(fan['pwm']['fan_phase_clks'])}",
|
|
|
|
|
+ f"`define FB_PTC_PWM_PERIOD_CLKS {int(fan['pwm']['ptc_phase_clks']) * int(fan['pwm']['phases'])}",
|
|
|
|
|
+ f"`define FB_FAN_PWM_PERIOD_CLKS {int(fan['pwm']['fan_phase_clks']) * int(fan['pwm']['phases'])}",
|
|
|
|
|
+ f"`define FAN_BOARD_INVERT_MASK 8'h{fan_invert_mask:02X}",
|
|
|
|
|
+ "`define FRONT_FAN_CONNECTOR_MAP \"CON25.7,CON8.7,CON24.7,CON26.7\"",
|
|
|
|
|
+ "`define FRONT_FAN_FPGA_BALL_MAP \"B1,C4,B5,A14\"",
|
|
|
|
|
+ "`define REAR_FAN_CONNECTOR_MAP \"CON64.4,CON66.4,CON62.4,CON60.4\"",
|
|
|
|
|
+ "`define REAR_FAN_FPGA_BALL_MAP \"P15,N15,M14,P5\"",
|
|
|
f"`define FB_CMD_SET_TARGET 8'h{int(command['SET_TARGET']['type']):02X}",
|
|
f"`define FB_CMD_SET_TARGET 8'h{int(command['SET_TARGET']['type']):02X}",
|
|
|
f"`define FB_CMD_GET_SNAPSHOT 8'h{int(command['GET_SNAPSHOT']['type']):02X}",
|
|
f"`define FB_CMD_GET_SNAPSHOT 8'h{int(command['GET_SNAPSHOT']['type']):02X}",
|
|
|
f"`define FB_CMD_SET_STIMULUS 8'h{int(command['SET_STIMULUS']['type']):02X}",
|
|
f"`define FB_CMD_SET_STIMULUS 8'h{int(command['SET_STIMULUS']['type']):02X}",
|
|
|
f"`define FB_RSP_SET_TARGET_ACK 8'h{int(response['SET_TARGET_ACK']['type']):02X}",
|
|
f"`define FB_RSP_SET_TARGET_ACK 8'h{int(response['SET_TARGET_ACK']['type']):02X}",
|
|
|
- f"`define FB_RSP_SNAPSHOT 8'h{int(response['SNAPSHOT_DATA']['type']):02X}",
|
|
|
|
|
|
|
+ f"`define FB_RSP_GET_SNAPSHOT_ACK 8'h{int(response['GET_SNAPSHOT_ACK']['type']):02X}",
|
|
|
|
|
+ f"`define FB_RSP_SNAPSHOT_DATA 8'h{int(response['SNAPSHOT_DATA']['type']):02X}",
|
|
|
f"`define FB_RSP_STIMULUS_ACK 8'h{int(response['SET_STIMULUS_ACK']['type']):02X}",
|
|
f"`define FB_RSP_STIMULUS_ACK 8'h{int(response['SET_STIMULUS_ACK']['type']):02X}",
|
|
|
f"`define FB_SNAPSHOT_LENGTH {snapshot_size}",
|
|
f"`define FB_SNAPSHOT_LENGTH {snapshot_size}",
|
|
|
f"`define FB_TEMP_SOFT {int(limits['soft'])}",
|
|
f"`define FB_TEMP_SOFT {int(limits['soft'])}",
|
|
@@ -211,6 +279,7 @@ def generate(output: Path) -> dict[Path, bytes]:
|
|
|
coeff = load_yaml("controller-coefficients.yaml")
|
|
coeff = load_yaml("controller-coefficients.yaml")
|
|
|
fan = load_yaml("fan-control-parameters.yaml")
|
|
fan = load_yaml("fan-control-parameters.yaml")
|
|
|
validate_channels(mapping)
|
|
validate_channels(mapping)
|
|
|
|
|
+ validate_fans(mapping, fan)
|
|
|
layout_rows, snapshot_size = layout(snapshot)
|
|
layout_rows, snapshot_size = layout(snapshot)
|
|
|
validate_wire(wire, snapshot_size)
|
|
validate_wire(wire, snapshot_size)
|
|
|
contract_sha = source_hash()
|
|
contract_sha = source_hash()
|
|
@@ -224,13 +293,35 @@ def generate(output: Path) -> dict[Path, bytes]:
|
|
|
"set_target_70": frame(0x01, bytes((70,))),
|
|
"set_target_70": frame(0x01, bytes((70,))),
|
|
|
"get_snapshot": frame(0x02, b""),
|
|
"get_snapshot": frame(0x02, b""),
|
|
|
"set_target_ack": frame(0x81, b""),
|
|
"set_target_ack": frame(0x81, b""),
|
|
|
|
|
+ "get_snapshot_ack": frame(0x82, b""),
|
|
|
"stimulus_all_zero_one_second": frame(0x03, bytes((1,)) + bytes(32)),
|
|
"stimulus_all_zero_one_second": frame(0x03, bytes((1,)) + bytes(32)),
|
|
|
"stimulus_ack": frame(0x83, b""),
|
|
"stimulus_ack": frame(0x83, b""),
|
|
|
},
|
|
},
|
|
|
}
|
|
}
|
|
|
|
|
+ canonical_profiles = {
|
|
|
|
|
+ "6400-control": {
|
|
|
|
|
+ "allowed_commands": ["SET_TARGET", "GET_SNAPSHOT"],
|
|
|
|
|
+ "production": True,
|
|
|
|
|
+ "stimulus": False,
|
|
|
|
|
+ "simulation_only": False,
|
|
|
|
|
+ },
|
|
|
|
|
+ "6400-identification": {
|
|
|
|
|
+ "allowed_commands": ["SET_TARGET", "GET_SNAPSHOT", "SET_STIMULUS"],
|
|
|
|
|
+ "production": False,
|
|
|
|
|
+ "stimulus": True,
|
|
|
|
|
+ "simulation_only": False,
|
|
|
|
|
+ },
|
|
|
|
|
+ "6400-sim-debug": {
|
|
|
|
|
+ "allowed_commands": ["SET_TARGET", "GET_SNAPSHOT", "SET_STIMULUS"],
|
|
|
|
|
+ "production": False,
|
|
|
|
|
+ "stimulus": True,
|
|
|
|
|
+ "simulation_only": True,
|
|
|
|
|
+ },
|
|
|
|
|
+ }
|
|
|
host = {
|
|
host = {
|
|
|
- "schema": "prod2u-6400-host-contract-v1",
|
|
|
|
|
|
|
+ "schema": "prod2u-6400-host-contract-v2",
|
|
|
"contract_sha256": contract_sha,
|
|
"contract_sha256": contract_sha,
|
|
|
|
|
+ "canonical_profiles": canonical_profiles,
|
|
|
"wire": wire,
|
|
"wire": wire,
|
|
|
"snapshot": snapshot_layout,
|
|
"snapshot": snapshot_layout,
|
|
|
"channel_map": mapping,
|
|
"channel_map": mapping,
|
|
@@ -247,7 +338,7 @@ def generate(output: Path) -> dict[Path, bytes]:
|
|
|
output / "fan-control-parameters.json": json_bytes({**fan, "contract_sha256": contract_sha}),
|
|
output / "fan-control-parameters.json": json_bytes({**fan, "contract_sha256": contract_sha}),
|
|
|
output / "golden-vectors.json": json_bytes(golden),
|
|
output / "golden-vectors.json": json_bytes(golden),
|
|
|
output / "host-contract.json": json_bytes(host),
|
|
output / "host-contract.json": json_bytes(host),
|
|
|
- output / "prod2u_6400_v1_params.vh": verilog_header(layout_rows, snapshot_size, wire, coeff, fan, contract_sha),
|
|
|
|
|
|
|
+ output / "prod2u_6400_v1_params.vh": verilog_header(layout_rows, snapshot_size, wire, coeff, fan, mapping, contract_sha),
|
|
|
output / "contract-sha256.txt": (contract_sha + "\n").encode(),
|
|
output / "contract-sha256.txt": (contract_sha + "\n").encode(),
|
|
|
ROOT / "docs/generated/6400-channel-map.md": channel_markdown(mapping, contract_sha),
|
|
ROOT / "docs/generated/6400-channel-map.md": channel_markdown(mapping, contract_sha),
|
|
|
}
|
|
}
|