macro_pin_side
暂无简介
- License 许可
- Apache-2.0
- 所属仓库
- FeSens/openTPU
- 最近更新
- 2026-11-12
- Stars
- ★ 971
- Forks
- 96
02 资源文件 1
- 脚本macro_pin_side.py15.2 KB
03 SKILL.md 正文
Skill: Macro pin-side highlight
Detect the signal-pin side(s) of every macro from OpenROAD DB geometry and draw a thick highlight line on every pin-bearing edge in a whole-die PNG. A macro may have pins on more than one side (e.g. an SRAM with pins on both L and R) — each real pin side is highlighted, not just the single dominant one.
Key idea: never infer the pin side visually from a screenshot. The side comes
from iterm getBBox, which already reflects the macro's current placed
orientation (R0/R90/MX/MY…). The screenshot is only the canvas we annotate.
What it does
-
OpenROAD loads the placement (
--odb, or--def+ LEFs). -
For every BLOCK instance:
- take the placed bbox (
inst getBBox), - iterate
inst getITerms, keep onlygetSigType == SIGNAL, - compute each pin center from
iterm getBBox, - measure its distance to the macro L/R/T/B edges and count it toward the nearest edge,
- dominant side = edge with the most pins (
NONEif no signal pins).
- take the placed bbox (
-
Writes structured text, one line per macro (the per-edge
countsare the source of truth; pin side(s) are derived from them in Python — see step 5):MACRO_PIN_SIDE name=<inst> orient=<orient> side=<L/R/T/B/NONE> dominant=<n> \ counts=L:<n>,R:<n>,T:<n>,B:<n> bbox=(x0,y0,x1,y1)(bbox in microns.
side= the single dominant edge;countscarry all four so a multi-side macro can be recovered without re-running OpenROAD.) -
save_imageof the whole die, following the whole-die-with-pins convention ofskills_Nangate45/image_snapshot: the save area is the union of the die box and the top-level IO-pin (bterm) boxes, padded bymargin, and the signal/clock bterm boxes are recorded so they can be redrawn (OpenROAD rasterizes thin pins to near-invisibility at die zoom). -
Python derives each macro's pin side(s) from the per-edge counts with
pin_sides(counts, min_pins): an edge is a pin side when it carries at least--min-pinssignal pins (default 1 = every edge with any pins). Each pin is already binned to its geometrically nearest edge, so this reports all real pin sides — a macro with address/data on L+R and control on T+B shows four bars (e.g.L:40 R:38 T:10 B:10→L,R,T,B). Then it maps each macro/pin bbox micron→pixel (with Y-flip) and draws:- the IO pins as small cyan boxes (so the die-edge pins stay visible), then
- a black-shadow + bright-red bar on each pin side of every macro, drawn just inside that macro, hugging the pin edge and inset to ~70% of the edge length. Keeping it inside (not in the channel) means the bar is never confused with the neighbouring macro across an abutting edge,
- a numbered label (yellow-on-black) drawn once per macro, on the dominant
pin side. The number is the macro's index in the printed summary /
MACRO_PIN_SIDEorder, so you can read bar → macro name. Disable with--no-label.
The stdout summary prints
sides=<comma list>and aside_comboshistogram (e.g.{'LR': 12}) so multi-side macros are obvious without opening the image.
Usage
conda activate coder
python skills/skills_Nangate45/macro_pin_side/macro_pin_side.py \
--def Benchmark/PlaceReasoner-Bench/bp_fe/def/u65_placed.def \
--lef-dir Benchmark/PlaceReasoner-Bench/bp_fe/lef \
--out-dir /…/OpenLayout_macro/work_images \
--design bp_fe_u65
From a checkpoint ODB instead (one read_db restores tech + LEF + placement):
python macro_pin_side.py --odb run/floorplan.odb --out-dir work_images --design foo
Options
--lef LEF1 LEF2 …— explicit LEFs (tech first) instead of--lef-dirglob.--lef-dirglobs*.lefand reads any name containingtechfirst.--width(default 1600) —save_imagepixel width; height keeps aspect.--margin(default 0.03) — pad fraction on the die∪pins union,pad = max(w,h) * margin.--min-pins(default 1) — an edge is highlighted as a pin side when it carries at least this many signal pins. Default 1 shows every edge that has any pins (a four-side macro gets four bars). Raise it (e.g.3) to suppress edges with only a stray pin or two.--no-pins— skip the IO-pin overlay (pins on by default, matchingimage_snapshot).--no-label— skip the numbered macro labels next to each bar.--openroad(default/usr/bin/openroad).
Outputs (in --out-dir, prefixed <design>_)
<design>_pin_side.txt— theMACRO_PIN_SIDElines (machine-readable).<design>_iopins.txt—IO_PIN sig=… box=(…)lines for the bterm overlay.<design>_pin_side.png— annotated whole-die-with-pins image.<design>_raw.png— un-annotated OpenROAD render.<design>_pin_side.tcl— the generated TCL (re-runnable / inspectable).
The driver also prints a per-macro summary and the side distribution.
Notes / gotchas
- Headless render needs
xvfb-runin this repo (offscreen/xcbboth fail — see memoryfeedback_openroad_save_image). The driver already wraps OpenROAD inxvfb-run -a. parse_sides()anddraw_overlay()are importable if you want to reuse the highlight on an image you rendered elsewhere — pass the same micronareathatsave_image -areaused (the driver reads it from theIMAGE_AREAstdout line).- Verified on bp_fe
u65_placed.def: 11 BLOCK macros, 8×R / 3×L; red line lands on the correct geometric edge (right edge present, left edge clean) under the Y-flip.
04 同仓库更多 Skills
openroad-image-snapshot
Whole-die layout snapshot for any checkpoint: the executable template reads an ODB, expands the die box by a margin so boundary pins stay visible, and saves a PNG. The Worker runs it after every stage; it can also be run standalone on any saved checkpoint.
image_snapshot
暂无简介
get_macro_current_location
暂无简介
get_die_core_info
暂无简介
5.optimizer
暂无简介
post-route-timing-check
Check post-route static timing (TNS/WNS) in OpenROAD to decide whether a macro placement exploration iteration is done. Use this skill whenever the user is running macro placement exploration, sweeping floorplans, or asking whether a placement run is "good enough to stop" — anytime post-route timing in OpenROAD needs to be read and compared against a goal, even if the user doesn't explicitly say "TNS" or "WNS".