M_CPU/SRAM placement via pos_mm in topology.yaml (nearest router)

Component placement uses mm coordinates in topology.yaml, mesh_gen
finds the nearest router automatically. M_CPU moved to pos_mm=[7.5,2.0]
(→ r0c2), SRAM at pos_mm=[1.5,9.0] (→ r3c0).

No hardcoded router references in topology config.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-05 00:48:20 -07:00
parent 3ea4fa90f8
commit 7640635f90
4 changed files with 38 additions and 16 deletions
+22 -5
View File
@@ -53,6 +53,7 @@ def _compute_source_hash(cube_spec: dict) -> str:
"hbm_mapping_mode": cube_spec.get("memory_map", {}).get(
"hbm_mapping_mode", "n_to_one"
),
"placement": cube_spec.get("placement", {}),
}
raw = yaml.dump(relevant, sort_keys=True)
return hashlib.sha256(raw.encode()).hexdigest()[:16]
@@ -221,13 +222,29 @@ def _generate_mesh(cube_spec: dict, source_hash: str) -> dict:
pe_idx += 1
# M_CPU and SRAM attachments (HBM row, leftmost available)
mcpu_key = f"r{hbm_row_start}c0"
if routers.get(mcpu_key) is not None:
# M_CPU and SRAM attachments: find nearest router to configured position
placement = cube_spec.get("placement", {})
def _nearest_router(target_mm: list[float]) -> str | None:
best_key, best_dist = None, float("inf")
for rk, rv in routers.items():
if rv is None:
continue
rx, ry = rv["pos_mm"]
dist = math.sqrt((rx - target_mm[0]) ** 2 + (ry - target_mm[1]) ** 2)
if dist < best_dist:
best_dist = dist
best_key = rk
return best_key
mcpu_pos = placement.get("m_cpu", {}).get("pos_mm", [1.5, 5.5])
mcpu_key = _nearest_router(mcpu_pos)
if mcpu_key and routers.get(mcpu_key) is not None:
routers[mcpu_key]["attach"].append("m_cpu")
sram_key = f"r{hbm_row_end}c0"
if routers.get(sram_key) is not None:
sram_pos = placement.get("sram", {}).get("pos_mm", [1.5, 8.5])
sram_key = _nearest_router(sram_pos)
if sram_key and routers.get(sram_key) is not None:
routers[sram_key]["attach"].append("sram")
# UCIe PE rows: top-half rows + bottom-half rows (1 per PE row)