Cube-view: draw all attached components as separate blocks

All router-attached components (PE, M_CPU, SRAM, UCIe) rendered as
labeled blocks with explicit connector lines to their router.
UCIe blocks positioned at cube edges matching port direction.
Router→HBM_CTRL lines shown for all 32 routers.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-04 22:09:08 -07:00
parent e94f1de078
commit 109c9b4483
2 changed files with 308 additions and 209 deletions
+182 -120
View File
@@ -124,126 +124,188 @@
<line x1="435" y1="685" x2="585" y2="685" stroke="#475569" stroke-width="1" opacity="0.4"/>
<line x1="585" y1="685" x2="685" y2="685" stroke="#475569" stroke-width="1" opacity="0.4"/>
<line x1="685" y1="685" x2="835" y2="685" stroke="#475569" stroke-width="1" opacity="0.4"/>
<circle cx="135" cy="135" r="10" fill="#3b82f6" stroke="#1d4ed8" stroke-width="1.5"/>
<text x="135" y="138" text-anchor="middle" font-family="monospace" font-size="7" font-weight="bold" fill="white">r0c0</text>
<text x="135" y="155" text-anchor="middle" font-family="monospace" font-size="6" fill="#94a3b8">PE0, UCIe×2</text>
<line x1="135" y1="145" x2="135" y2="285" stroke="#10b981" stroke-width="1.5" opacity="0.5" stroke-dasharray="4,3"/>
<text x="147" y="215" font-family="monospace" font-size="6" fill="#10b98188">256GB/s</text>
<circle cx="285" cy="135" r="10" fill="#3b82f6" stroke="#1d4ed8" stroke-width="1.5"/>
<text x="285" y="138" text-anchor="middle" font-family="monospace" font-size="7" font-weight="bold" fill="white">r0c1</text>
<text x="285" y="155" text-anchor="middle" font-family="monospace" font-size="6" fill="#94a3b8">PE1, UCIe×1</text>
<line x1="285" y1="145" x2="285" y2="285" stroke="#10b981" stroke-width="1.5" opacity="0.5" stroke-dasharray="4,3"/>
<text x="297" y="215" font-family="monospace" font-size="6" fill="#10b98188">256GB/s</text>
<circle cx="435" cy="135" r="10" fill="#334155" stroke="#475569" stroke-width="1.5"/>
<text x="435" y="138" text-anchor="middle" font-family="monospace" font-size="7" font-weight="bold" fill="white">r0c2</text>
<circle cx="585" cy="135" r="10" fill="#334155" stroke="#475569" stroke-width="1.5"/>
<text x="585" y="138" text-anchor="middle" font-family="monospace" font-size="7" font-weight="bold" fill="white">r0c3</text>
<circle cx="685" cy="135" r="10" fill="#8b5cf6" stroke="#6d28d9" stroke-width="1.5"/>
<text x="685" y="138" text-anchor="middle" font-family="monospace" font-size="7" font-weight="bold" fill="white">r0c4</text>
<text x="685" y="155" text-anchor="middle" font-family="monospace" font-size="6" fill="#94a3b8">UCIe×1</text>
<circle cx="835" cy="135" r="10" fill="#8b5cf6" stroke="#6d28d9" stroke-width="1.5"/>
<text x="835" y="138" text-anchor="middle" font-family="monospace" font-size="7" font-weight="bold" fill="white">r0c5</text>
<text x="835" y="155" text-anchor="middle" font-family="monospace" font-size="6" fill="#94a3b8">UCIe×2</text>
<circle cx="135" cy="260" r="10" fill="#8b5cf6" stroke="#6d28d9" stroke-width="1.5"/>
<text x="135" y="263" text-anchor="middle" font-family="monospace" font-size="7" font-weight="bold" fill="white">r1c0</text>
<text x="135" y="280" text-anchor="middle" font-family="monospace" font-size="6" fill="#94a3b8">UCIe×1</text>
<circle cx="285" cy="260" r="10" fill="#334155" stroke="#475569" stroke-width="1.5"/>
<text x="285" y="263" text-anchor="middle" font-family="monospace" font-size="7" font-weight="bold" fill="white">r1c1</text>
<circle cx="435" cy="260" r="10" fill="#334155" stroke="#475569" stroke-width="1.5"/>
<text x="435" y="263" text-anchor="middle" font-family="monospace" font-size="7" font-weight="bold" fill="white">r1c2</text>
<circle cx="585" cy="260" r="10" fill="#334155" stroke="#475569" stroke-width="1.5"/>
<text x="585" y="263" text-anchor="middle" font-family="monospace" font-size="7" font-weight="bold" fill="white">r1c3</text>
<circle cx="685" cy="260" r="10" fill="#3b82f6" stroke="#1d4ed8" stroke-width="1.5"/>
<text x="685" y="263" text-anchor="middle" font-family="monospace" font-size="7" font-weight="bold" fill="white">r1c4</text>
<text x="685" y="280" text-anchor="middle" font-family="monospace" font-size="6" fill="#94a3b8">PE2</text>
<line x1="685" y1="270" x2="685" y2="285" stroke="#10b981" stroke-width="1.5" opacity="0.5" stroke-dasharray="4,3"/>
<text x="697" y="278" font-family="monospace" font-size="6" fill="#10b98188">256GB/s</text>
<circle cx="835" cy="260" r="10" fill="#3b82f6" stroke="#1d4ed8" stroke-width="1.5"/>
<text x="835" y="263" text-anchor="middle" font-family="monospace" font-size="7" font-weight="bold" fill="white">r1c5</text>
<text x="835" y="280" text-anchor="middle" font-family="monospace" font-size="6" fill="#94a3b8">PE3, UCIe×1</text>
<line x1="835" y1="270" x2="835" y2="285" stroke="#10b981" stroke-width="1.5" opacity="0.5" stroke-dasharray="4,3"/>
<text x="847" y="278" font-family="monospace" font-size="6" fill="#10b98188">256GB/s</text>
<circle cx="135" cy="335" r="10" fill="#f59e0b" stroke="#d97706" stroke-width="1.5"/>
<text x="135" y="338" text-anchor="middle" font-family="monospace" font-size="7" font-weight="bold" fill="white">r2c0</text>
<text x="135" y="355" text-anchor="middle" font-family="monospace" font-size="6" fill="#94a3b8">M_CPU</text>
<circle cx="285" cy="335" r="10" fill="#334155" stroke="#475569" stroke-width="1.5"/>
<text x="285" y="338" text-anchor="middle" font-family="monospace" font-size="7" font-weight="bold" fill="white">r2c1</text>
<circle cx="685" cy="335" r="10" fill="#334155" stroke="#475569" stroke-width="1.5"/>
<text x="685" y="338" text-anchor="middle" font-family="monospace" font-size="7" font-weight="bold" fill="white">r2c4</text>
<circle cx="835" cy="335" r="10" fill="#334155" stroke="#475569" stroke-width="1.5"/>
<text x="835" y="338" text-anchor="middle" font-family="monospace" font-size="7" font-weight="bold" fill="white">r2c5</text>
<circle cx="135" cy="485" r="10" fill="#f59e0b" stroke="#d97706" stroke-width="1.5"/>
<text x="135" y="488" text-anchor="middle" font-family="monospace" font-size="7" font-weight="bold" fill="white">r3c0</text>
<text x="135" y="505" text-anchor="middle" font-family="monospace" font-size="6" fill="#94a3b8">SRAM</text>
<circle cx="285" cy="485" r="10" fill="#334155" stroke="#475569" stroke-width="1.5"/>
<text x="285" y="488" text-anchor="middle" font-family="monospace" font-size="7" font-weight="bold" fill="white">r3c1</text>
<circle cx="685" cy="485" r="10" fill="#334155" stroke="#475569" stroke-width="1.5"/>
<text x="685" y="488" text-anchor="middle" font-family="monospace" font-size="7" font-weight="bold" fill="white">r3c4</text>
<circle cx="835" cy="485" r="10" fill="#334155" stroke="#475569" stroke-width="1.5"/>
<text x="835" y="488" text-anchor="middle" font-family="monospace" font-size="7" font-weight="bold" fill="white">r3c5</text>
<circle cx="135" cy="560" r="10" fill="#3b82f6" stroke="#1d4ed8" stroke-width="1.5"/>
<text x="135" y="563" text-anchor="middle" font-family="monospace" font-size="7" font-weight="bold" fill="white">r4c0</text>
<text x="135" y="580" text-anchor="middle" font-family="monospace" font-size="6" fill="#94a3b8">PE4, UCIe×1</text>
<line x1="135" y1="570" x2="135" y2="535" stroke="#10b981" stroke-width="1.5" opacity="0.5" stroke-dasharray="4,3"/>
<text x="147" y="552" font-family="monospace" font-size="6" fill="#10b98188">256GB/s</text>
<circle cx="285" cy="560" r="10" fill="#3b82f6" stroke="#1d4ed8" stroke-width="1.5"/>
<text x="285" y="563" text-anchor="middle" font-family="monospace" font-size="7" font-weight="bold" fill="white">r4c1</text>
<text x="285" y="580" text-anchor="middle" font-family="monospace" font-size="6" fill="#94a3b8">PE5</text>
<line x1="285" y1="570" x2="285" y2="535" stroke="#10b981" stroke-width="1.5" opacity="0.5" stroke-dasharray="4,3"/>
<text x="297" y="552" font-family="monospace" font-size="6" fill="#10b98188">256GB/s</text>
<circle cx="435" cy="560" r="10" fill="#334155" stroke="#475569" stroke-width="1.5"/>
<text x="435" y="563" text-anchor="middle" font-family="monospace" font-size="7" font-weight="bold" fill="white">r4c2</text>
<circle cx="585" cy="560" r="10" fill="#334155" stroke="#475569" stroke-width="1.5"/>
<text x="585" y="563" text-anchor="middle" font-family="monospace" font-size="7" font-weight="bold" fill="white">r4c3</text>
<circle cx="685" cy="560" r="10" fill="#334155" stroke="#475569" stroke-width="1.5"/>
<text x="685" y="563" text-anchor="middle" font-family="monospace" font-size="7" font-weight="bold" fill="white">r4c4</text>
<circle cx="835" cy="560" r="10" fill="#8b5cf6" stroke="#6d28d9" stroke-width="1.5"/>
<text x="835" y="563" text-anchor="middle" font-family="monospace" font-size="7" font-weight="bold" fill="white">r4c5</text>
<text x="835" y="580" text-anchor="middle" font-family="monospace" font-size="6" fill="#94a3b8">UCIe×1</text>
<circle cx="135" cy="685" r="10" fill="#8b5cf6" stroke="#6d28d9" stroke-width="1.5"/>
<text x="135" y="688" text-anchor="middle" font-family="monospace" font-size="7" font-weight="bold" fill="white">r5c0</text>
<text x="135" y="705" text-anchor="middle" font-family="monospace" font-size="6" fill="#94a3b8">UCIe×2</text>
<circle cx="285" cy="685" r="10" fill="#8b5cf6" stroke="#6d28d9" stroke-width="1.5"/>
<text x="285" y="688" text-anchor="middle" font-family="monospace" font-size="7" font-weight="bold" fill="white">r5c1</text>
<text x="285" y="705" text-anchor="middle" font-family="monospace" font-size="6" fill="#94a3b8">UCIe×1</text>
<circle cx="435" cy="685" r="10" fill="#334155" stroke="#475569" stroke-width="1.5"/>
<text x="435" y="688" text-anchor="middle" font-family="monospace" font-size="7" font-weight="bold" fill="white">r5c2</text>
<circle cx="585" cy="685" r="10" fill="#334155" stroke="#475569" stroke-width="1.5"/>
<text x="585" y="688" text-anchor="middle" font-family="monospace" font-size="7" font-weight="bold" fill="white">r5c3</text>
<circle cx="685" cy="685" r="10" fill="#3b82f6" stroke="#1d4ed8" stroke-width="1.5"/>
<text x="685" y="688" text-anchor="middle" font-family="monospace" font-size="7" font-weight="bold" fill="white">r5c4</text>
<text x="685" y="705" text-anchor="middle" font-family="monospace" font-size="6" fill="#94a3b8">PE6, UCIe×1</text>
<line x1="685" y1="695" x2="685" y2="535" stroke="#10b981" stroke-width="1.5" opacity="0.5" stroke-dasharray="4,3"/>
<text x="697" y="615" font-family="monospace" font-size="6" fill="#10b98188">256GB/s</text>
<circle cx="835" cy="685" r="10" fill="#3b82f6" stroke="#1d4ed8" stroke-width="1.5"/>
<text x="835" y="688" text-anchor="middle" font-family="monospace" font-size="7" font-weight="bold" fill="white">r5c5</text>
<text x="835" y="705" text-anchor="middle" font-family="monospace" font-size="6" fill="#94a3b8">PE7, UCIe×2</text>
<line x1="835" y1="695" x2="835" y2="535" stroke="#10b981" stroke-width="1.5" opacity="0.5" stroke-dasharray="4,3"/>
<text x="847" y="615" font-family="monospace" font-size="6" fill="#10b98188">256GB/s</text>
<rect x="120" y="103" width="30" height="18" rx="3" fill="#2d1f3d" stroke="#a855f7" stroke-width="1"/>
<text x="135" y="116" text-anchor="middle" font-family="monospace" font-size="8" font-weight="bold" fill="#a855f7">PE0</text>
<line x1="135" y1="121" x2="135" y2="125" stroke="#a855f7" stroke-width="1.5" opacity="0.7"/>
<rect x="270" y="103" width="30" height="18" rx="3" fill="#2d1f3d" stroke="#a855f7" stroke-width="1"/>
<text x="285" y="116" text-anchor="middle" font-family="monospace" font-size="8" font-weight="bold" fill="#a855f7">PE1</text>
<line x1="285" y1="121" x2="285" y2="125" stroke="#a855f7" stroke-width="1.5" opacity="0.7"/>
<rect x="670" y="228" width="30" height="18" rx="3" fill="#2d1f3d" stroke="#a855f7" stroke-width="1"/>
<text x="685" y="241" text-anchor="middle" font-family="monospace" font-size="8" font-weight="bold" fill="#a855f7">PE2</text>
<line x1="685" y1="246" x2="685" y2="250" stroke="#a855f7" stroke-width="1.5" opacity="0.7"/>
<rect x="820" y="228" width="30" height="18" rx="3" fill="#2d1f3d" stroke="#a855f7" stroke-width="1"/>
<text x="835" y="241" text-anchor="middle" font-family="monospace" font-size="8" font-weight="bold" fill="#a855f7">PE3</text>
<line x1="835" y1="246" x2="835" y2="250" stroke="#a855f7" stroke-width="1.5" opacity="0.7"/>
<rect x="120" y="574" width="30" height="18" rx="3" fill="#2d1f3d" stroke="#a855f7" stroke-width="1"/>
<text x="135" y="587" text-anchor="middle" font-family="monospace" font-size="8" font-weight="bold" fill="#a855f7">PE4</text>
<line x1="135" y1="574" x2="135" y2="570" stroke="#a855f7" stroke-width="1.5" opacity="0.7"/>
<rect x="270" y="574" width="30" height="18" rx="3" fill="#2d1f3d" stroke="#a855f7" stroke-width="1"/>
<text x="285" y="587" text-anchor="middle" font-family="monospace" font-size="8" font-weight="bold" fill="#a855f7">PE5</text>
<line x1="285" y1="574" x2="285" y2="570" stroke="#a855f7" stroke-width="1.5" opacity="0.7"/>
<rect x="670" y="699" width="30" height="18" rx="3" fill="#2d1f3d" stroke="#a855f7" stroke-width="1"/>
<text x="685" y="712" text-anchor="middle" font-family="monospace" font-size="8" font-weight="bold" fill="#a855f7">PE6</text>
<line x1="685" y1="699" x2="685" y2="695" stroke="#a855f7" stroke-width="1.5" opacity="0.7"/>
<rect x="820" y="699" width="30" height="18" rx="3" fill="#2d1f3d" stroke="#a855f7" stroke-width="1"/>
<text x="835" y="712" text-anchor="middle" font-family="monospace" font-size="8" font-weight="bold" fill="#a855f7">PE7</text>
<line x1="835" y1="699" x2="835" y2="695" stroke="#a855f7" stroke-width="1.5" opacity="0.7"/>
<circle cx="135" cy="135" r="8" fill="#475569" stroke="#64748b" stroke-width="1"/>
<text x="135" y="138" text-anchor="middle" font-family="monospace" font-size="6" fill="white">r0c0</text>
<line x1="135" y1="143" x2="135" y2="285" stroke="#10b981" stroke-width="0.8" opacity="0.25"/>
<rect x="83" y="107" width="32" height="16" rx="3" fill="#2d1f3d" stroke="#a855f7" stroke-width="1"/>
<text x="99" y="118" text-anchor="middle" font-family="monospace" font-size="7" font-weight="bold" fill="#a855f7">PE0</text>
<line x1="99" y1="123" x2="135" y2="127" stroke="#a855f7" stroke-width="1" opacity="0.6"/>
<rect x="24" y="127" width="32" height="16" rx="3" fill="#1e1b4b" stroke="#8b5cf6" stroke-width="1"/>
<text x="40" y="138" text-anchor="middle" font-family="monospace" font-size="6" font-weight="bold" fill="#8b5cf6">UCIe-W.c0</text>
<line x1="56" y1="135" x2="127" y2="135" stroke="#8b5cf6" stroke-width="1" opacity="0.6"/>
<rect x="155" y="40" width="32" height="16" rx="3" fill="#1e1b4b" stroke="#8b5cf6" stroke-width="1"/>
<text x="171" y="51" text-anchor="middle" font-family="monospace" font-size="6" font-weight="bold" fill="#8b5cf6">UCIe-N.c0</text>
<line x1="171" y1="56" x2="135" y2="127" stroke="#8b5cf6" stroke-width="1" opacity="0.6"/>
<text x="149" y="214" font-family="monospace" font-size="6" fill="#10b98188">256GB/s</text>
<circle cx="285" cy="135" r="8" fill="#475569" stroke="#64748b" stroke-width="1"/>
<text x="285" y="138" text-anchor="middle" font-family="monospace" font-size="6" fill="white">r0c1</text>
<line x1="285" y1="143" x2="285" y2="285" stroke="#10b981" stroke-width="0.8" opacity="0.25"/>
<rect x="251" y="107" width="32" height="16" rx="3" fill="#2d1f3d" stroke="#a855f7" stroke-width="1"/>
<text x="267" y="118" text-anchor="middle" font-family="monospace" font-size="7" font-weight="bold" fill="#a855f7">PE1</text>
<line x1="267" y1="123" x2="285" y2="127" stroke="#a855f7" stroke-width="1" opacity="0.6"/>
<rect x="287" y="40" width="32" height="16" rx="3" fill="#1e1b4b" stroke="#8b5cf6" stroke-width="1"/>
<text x="303" y="51" text-anchor="middle" font-family="monospace" font-size="6" font-weight="bold" fill="#8b5cf6">UCIe-N.c1</text>
<line x1="303" y1="56" x2="285" y2="127" stroke="#8b5cf6" stroke-width="1" opacity="0.6"/>
<text x="299" y="214" font-family="monospace" font-size="6" fill="#10b98188">256GB/s</text>
<circle cx="435" cy="135" r="8" fill="#334155" stroke="#475569" stroke-width="1"/>
<text x="435" y="138" text-anchor="middle" font-family="monospace" font-size="6" fill="white">r0c2</text>
<line x1="435" y1="143" x2="435" y2="285" stroke="#10b981" stroke-width="0.8" opacity="0.25"/>
<circle cx="585" cy="135" r="8" fill="#334155" stroke="#475569" stroke-width="1"/>
<text x="585" y="138" text-anchor="middle" font-family="monospace" font-size="6" fill="white">r0c3</text>
<line x1="585" y1="143" x2="585" y2="285" stroke="#10b981" stroke-width="0.8" opacity="0.25"/>
<circle cx="685" cy="135" r="8" fill="#475569" stroke="#64748b" stroke-width="1"/>
<text x="685" y="138" text-anchor="middle" font-family="monospace" font-size="6" fill="white">r0c4</text>
<line x1="685" y1="143" x2="685" y2="285" stroke="#10b981" stroke-width="0.8" opacity="0.25"/>
<rect x="669" y="40" width="32" height="16" rx="3" fill="#1e1b4b" stroke="#8b5cf6" stroke-width="1"/>
<text x="685" y="51" text-anchor="middle" font-family="monospace" font-size="6" font-weight="bold" fill="#8b5cf6">UCIe-N.c2</text>
<line x1="685" y1="56" x2="685" y2="127" stroke="#8b5cf6" stroke-width="1" opacity="0.6"/>
<circle cx="835" cy="135" r="8" fill="#475569" stroke="#64748b" stroke-width="1"/>
<text x="835" y="138" text-anchor="middle" font-family="monospace" font-size="6" fill="white">r0c5</text>
<line x1="835" y1="143" x2="835" y2="285" stroke="#10b981" stroke-width="0.8" opacity="0.25"/>
<rect x="914" y="109" width="32" height="16" rx="3" fill="#1e1b4b" stroke="#8b5cf6" stroke-width="1"/>
<text x="930" y="120" text-anchor="middle" font-family="monospace" font-size="6" font-weight="bold" fill="#8b5cf6">UCIe-E.c0</text>
<line x1="914" y1="117" x2="843" y2="135" stroke="#8b5cf6" stroke-width="1" opacity="0.6"/>
<rect x="837" y="40" width="32" height="16" rx="3" fill="#1e1b4b" stroke="#8b5cf6" stroke-width="1"/>
<text x="853" y="51" text-anchor="middle" font-family="monospace" font-size="6" font-weight="bold" fill="#8b5cf6">UCIe-N.c3</text>
<line x1="853" y1="56" x2="835" y2="127" stroke="#8b5cf6" stroke-width="1" opacity="0.6"/>
<circle cx="135" cy="260" r="8" fill="#475569" stroke="#64748b" stroke-width="1"/>
<text x="135" y="263" text-anchor="middle" font-family="monospace" font-size="6" fill="white">r1c0</text>
<line x1="135" y1="268" x2="135" y2="285" stroke="#10b981" stroke-width="0.8" opacity="0.25"/>
<rect x="24" y="252" width="32" height="16" rx="3" fill="#1e1b4b" stroke="#8b5cf6" stroke-width="1"/>
<text x="40" y="263" text-anchor="middle" font-family="monospace" font-size="6" font-weight="bold" fill="#8b5cf6">UCIe-W.c1</text>
<line x1="56" y1="260" x2="127" y2="260" stroke="#8b5cf6" stroke-width="1" opacity="0.6"/>
<circle cx="285" cy="260" r="8" fill="#334155" stroke="#475569" stroke-width="1"/>
<text x="285" y="263" text-anchor="middle" font-family="monospace" font-size="6" fill="white">r1c1</text>
<line x1="285" y1="268" x2="285" y2="285" stroke="#10b981" stroke-width="0.8" opacity="0.25"/>
<circle cx="435" cy="260" r="8" fill="#334155" stroke="#475569" stroke-width="1"/>
<text x="435" y="263" text-anchor="middle" font-family="monospace" font-size="6" fill="white">r1c2</text>
<line x1="435" y1="268" x2="435" y2="285" stroke="#10b981" stroke-width="0.8" opacity="0.25"/>
<circle cx="585" cy="260" r="8" fill="#334155" stroke="#475569" stroke-width="1"/>
<text x="585" y="263" text-anchor="middle" font-family="monospace" font-size="6" fill="white">r1c3</text>
<line x1="585" y1="268" x2="585" y2="285" stroke="#10b981" stroke-width="0.8" opacity="0.25"/>
<circle cx="685" cy="260" r="8" fill="#475569" stroke="#64748b" stroke-width="1"/>
<text x="685" y="263" text-anchor="middle" font-family="monospace" font-size="6" fill="white">r1c4</text>
<line x1="685" y1="268" x2="685" y2="285" stroke="#10b981" stroke-width="0.8" opacity="0.25"/>
<rect x="669" y="232" width="32" height="16" rx="3" fill="#2d1f3d" stroke="#a855f7" stroke-width="1"/>
<text x="685" y="243" text-anchor="middle" font-family="monospace" font-size="7" font-weight="bold" fill="#a855f7">PE2</text>
<line x1="685" y1="248" x2="685" y2="252" stroke="#a855f7" stroke-width="1" opacity="0.6"/>
<text x="699" y="276" font-family="monospace" font-size="6" fill="#10b98188">256GB/s</text>
<circle cx="835" cy="260" r="8" fill="#475569" stroke="#64748b" stroke-width="1"/>
<text x="835" y="263" text-anchor="middle" font-family="monospace" font-size="6" fill="white">r1c5</text>
<line x1="835" y1="268" x2="835" y2="285" stroke="#10b981" stroke-width="0.8" opacity="0.25"/>
<rect x="801" y="232" width="32" height="16" rx="3" fill="#2d1f3d" stroke="#a855f7" stroke-width="1"/>
<text x="817" y="243" text-anchor="middle" font-family="monospace" font-size="7" font-weight="bold" fill="#a855f7">PE3</text>
<line x1="817" y1="248" x2="835" y2="252" stroke="#a855f7" stroke-width="1" opacity="0.6"/>
<rect x="914" y="270" width="32" height="16" rx="3" fill="#1e1b4b" stroke="#8b5cf6" stroke-width="1"/>
<text x="930" y="281" text-anchor="middle" font-family="monospace" font-size="6" font-weight="bold" fill="#8b5cf6">UCIe-E.c1</text>
<line x1="914" y1="278" x2="843" y2="260" stroke="#8b5cf6" stroke-width="1" opacity="0.6"/>
<text x="849" y="276" font-family="monospace" font-size="6" fill="#10b98188">256GB/s</text>
<circle cx="135" cy="335" r="8" fill="#475569" stroke="#64748b" stroke-width="1"/>
<text x="135" y="338" text-anchor="middle" font-family="monospace" font-size="6" fill="white">r2c0</text>
<line x1="135" y1="327" x2="135" y2="535" stroke="#10b981" stroke-width="0.8" opacity="0.25"/>
<rect x="119" y="307" width="32" height="16" rx="3" fill="#451a03" stroke="#f59e0b" stroke-width="1"/>
<text x="135" y="318" text-anchor="middle" font-family="monospace" font-size="7" font-weight="bold" fill="#f59e0b">M_CPU</text>
<line x1="135" y1="323" x2="135" y2="327" stroke="#f59e0b" stroke-width="1" opacity="0.6"/>
<circle cx="285" cy="335" r="8" fill="#334155" stroke="#475569" stroke-width="1"/>
<text x="285" y="338" text-anchor="middle" font-family="monospace" font-size="6" fill="white">r2c1</text>
<line x1="285" y1="327" x2="285" y2="535" stroke="#10b981" stroke-width="0.8" opacity="0.25"/>
<circle cx="685" cy="335" r="8" fill="#334155" stroke="#475569" stroke-width="1"/>
<text x="685" y="338" text-anchor="middle" font-family="monospace" font-size="6" fill="white">r2c4</text>
<line x1="685" y1="327" x2="685" y2="535" stroke="#10b981" stroke-width="0.8" opacity="0.25"/>
<circle cx="835" cy="335" r="8" fill="#334155" stroke="#475569" stroke-width="1"/>
<text x="835" y="338" text-anchor="middle" font-family="monospace" font-size="6" fill="white">r2c5</text>
<line x1="835" y1="327" x2="835" y2="535" stroke="#10b981" stroke-width="0.8" opacity="0.25"/>
<circle cx="135" cy="485" r="8" fill="#475569" stroke="#64748b" stroke-width="1"/>
<text x="135" y="488" text-anchor="middle" font-family="monospace" font-size="6" fill="white">r3c0</text>
<line x1="135" y1="477" x2="135" y2="535" stroke="#10b981" stroke-width="0.8" opacity="0.25"/>
<rect x="119" y="497" width="32" height="16" rx="3" fill="#1c1917" stroke="#d97706" stroke-width="1"/>
<text x="135" y="508" text-anchor="middle" font-family="monospace" font-size="7" font-weight="bold" fill="#d97706">SRAM</text>
<line x1="135" y1="497" x2="135" y2="493" stroke="#d97706" stroke-width="1" opacity="0.6"/>
<circle cx="285" cy="485" r="8" fill="#334155" stroke="#475569" stroke-width="1"/>
<text x="285" y="488" text-anchor="middle" font-family="monospace" font-size="6" fill="white">r3c1</text>
<line x1="285" y1="477" x2="285" y2="535" stroke="#10b981" stroke-width="0.8" opacity="0.25"/>
<circle cx="685" cy="485" r="8" fill="#334155" stroke="#475569" stroke-width="1"/>
<text x="685" y="488" text-anchor="middle" font-family="monospace" font-size="6" fill="white">r3c4</text>
<line x1="685" y1="477" x2="685" y2="535" stroke="#10b981" stroke-width="0.8" opacity="0.25"/>
<circle cx="835" cy="485" r="8" fill="#334155" stroke="#475569" stroke-width="1"/>
<text x="835" y="488" text-anchor="middle" font-family="monospace" font-size="6" fill="white">r3c5</text>
<line x1="835" y1="477" x2="835" y2="535" stroke="#10b981" stroke-width="0.8" opacity="0.25"/>
<circle cx="135" cy="560" r="8" fill="#475569" stroke="#64748b" stroke-width="1"/>
<text x="135" y="563" text-anchor="middle" font-family="monospace" font-size="6" fill="white">r4c0</text>
<line x1="135" y1="552" x2="135" y2="535" stroke="#10b981" stroke-width="0.8" opacity="0.25"/>
<rect x="101" y="572" width="32" height="16" rx="3" fill="#2d1f3d" stroke="#a855f7" stroke-width="1"/>
<text x="117" y="583" text-anchor="middle" font-family="monospace" font-size="7" font-weight="bold" fill="#a855f7">PE4</text>
<line x1="117" y1="572" x2="135" y2="568" stroke="#a855f7" stroke-width="1" opacity="0.6"/>
<rect x="24" y="570" width="32" height="16" rx="3" fill="#1e1b4b" stroke="#8b5cf6" stroke-width="1"/>
<text x="40" y="581" text-anchor="middle" font-family="monospace" font-size="6" font-weight="bold" fill="#8b5cf6">UCIe-W.c2</text>
<line x1="56" y1="578" x2="127" y2="560" stroke="#8b5cf6" stroke-width="1" opacity="0.6"/>
<text x="149" y="544" font-family="monospace" font-size="6" fill="#10b98188">256GB/s</text>
<circle cx="285" cy="560" r="8" fill="#475569" stroke="#64748b" stroke-width="1"/>
<text x="285" y="563" text-anchor="middle" font-family="monospace" font-size="6" fill="white">r4c1</text>
<line x1="285" y1="552" x2="285" y2="535" stroke="#10b981" stroke-width="0.8" opacity="0.25"/>
<rect x="269" y="572" width="32" height="16" rx="3" fill="#2d1f3d" stroke="#a855f7" stroke-width="1"/>
<text x="285" y="583" text-anchor="middle" font-family="monospace" font-size="7" font-weight="bold" fill="#a855f7">PE5</text>
<line x1="285" y1="572" x2="285" y2="568" stroke="#a855f7" stroke-width="1" opacity="0.6"/>
<text x="299" y="544" font-family="monospace" font-size="6" fill="#10b98188">256GB/s</text>
<circle cx="435" cy="560" r="8" fill="#334155" stroke="#475569" stroke-width="1"/>
<text x="435" y="563" text-anchor="middle" font-family="monospace" font-size="6" fill="white">r4c2</text>
<line x1="435" y1="552" x2="435" y2="535" stroke="#10b981" stroke-width="0.8" opacity="0.25"/>
<circle cx="585" cy="560" r="8" fill="#334155" stroke="#475569" stroke-width="1"/>
<text x="585" y="563" text-anchor="middle" font-family="monospace" font-size="6" fill="white">r4c3</text>
<line x1="585" y1="552" x2="585" y2="535" stroke="#10b981" stroke-width="0.8" opacity="0.25"/>
<circle cx="685" cy="560" r="8" fill="#334155" stroke="#475569" stroke-width="1"/>
<text x="685" y="563" text-anchor="middle" font-family="monospace" font-size="6" fill="white">r4c4</text>
<line x1="685" y1="552" x2="685" y2="535" stroke="#10b981" stroke-width="0.8" opacity="0.25"/>
<circle cx="835" cy="560" r="8" fill="#475569" stroke="#64748b" stroke-width="1"/>
<text x="835" y="563" text-anchor="middle" font-family="monospace" font-size="6" fill="white">r4c5</text>
<line x1="835" y1="552" x2="835" y2="535" stroke="#10b981" stroke-width="0.8" opacity="0.25"/>
<rect x="914" y="552" width="32" height="16" rx="3" fill="#1e1b4b" stroke="#8b5cf6" stroke-width="1"/>
<text x="930" y="563" text-anchor="middle" font-family="monospace" font-size="6" font-weight="bold" fill="#8b5cf6">UCIe-E.c2</text>
<line x1="914" y1="560" x2="843" y2="560" stroke="#8b5cf6" stroke-width="1" opacity="0.6"/>
<circle cx="135" cy="685" r="8" fill="#475569" stroke="#64748b" stroke-width="1"/>
<text x="135" y="688" text-anchor="middle" font-family="monospace" font-size="6" fill="white">r5c0</text>
<line x1="135" y1="677" x2="135" y2="535" stroke="#10b981" stroke-width="0.8" opacity="0.25"/>
<rect x="24" y="659" width="32" height="16" rx="3" fill="#1e1b4b" stroke="#8b5cf6" stroke-width="1"/>
<text x="40" y="670" text-anchor="middle" font-family="monospace" font-size="6" font-weight="bold" fill="#8b5cf6">UCIe-W.c3</text>
<line x1="56" y1="667" x2="127" y2="685" stroke="#8b5cf6" stroke-width="1" opacity="0.6"/>
<rect x="137" y="764" width="32" height="16" rx="3" fill="#1e1b4b" stroke="#8b5cf6" stroke-width="1"/>
<text x="153" y="775" text-anchor="middle" font-family="monospace" font-size="6" font-weight="bold" fill="#8b5cf6">UCIe-S.c0</text>
<line x1="153" y1="764" x2="135" y2="693" stroke="#8b5cf6" stroke-width="1" opacity="0.6"/>
<circle cx="285" cy="685" r="8" fill="#475569" stroke="#64748b" stroke-width="1"/>
<text x="285" y="688" text-anchor="middle" font-family="monospace" font-size="6" fill="white">r5c1</text>
<line x1="285" y1="677" x2="285" y2="535" stroke="#10b981" stroke-width="0.8" opacity="0.25"/>
<rect x="269" y="764" width="32" height="16" rx="3" fill="#1e1b4b" stroke="#8b5cf6" stroke-width="1"/>
<text x="285" y="775" text-anchor="middle" font-family="monospace" font-size="6" font-weight="bold" fill="#8b5cf6">UCIe-S.c1</text>
<line x1="285" y1="764" x2="285" y2="693" stroke="#8b5cf6" stroke-width="1" opacity="0.6"/>
<circle cx="435" cy="685" r="8" fill="#334155" stroke="#475569" stroke-width="1"/>
<text x="435" y="688" text-anchor="middle" font-family="monospace" font-size="6" fill="white">r5c2</text>
<line x1="435" y1="677" x2="435" y2="535" stroke="#10b981" stroke-width="0.8" opacity="0.25"/>
<circle cx="585" cy="685" r="8" fill="#334155" stroke="#475569" stroke-width="1"/>
<text x="585" y="688" text-anchor="middle" font-family="monospace" font-size="6" fill="white">r5c3</text>
<line x1="585" y1="677" x2="585" y2="535" stroke="#10b981" stroke-width="0.8" opacity="0.25"/>
<circle cx="685" cy="685" r="8" fill="#475569" stroke="#64748b" stroke-width="1"/>
<text x="685" y="688" text-anchor="middle" font-family="monospace" font-size="6" fill="white">r5c4</text>
<line x1="685" y1="677" x2="685" y2="535" stroke="#10b981" stroke-width="0.8" opacity="0.25"/>
<rect x="651" y="697" width="32" height="16" rx="3" fill="#2d1f3d" stroke="#a855f7" stroke-width="1"/>
<text x="667" y="708" text-anchor="middle" font-family="monospace" font-size="7" font-weight="bold" fill="#a855f7">PE6</text>
<line x1="667" y1="697" x2="685" y2="693" stroke="#a855f7" stroke-width="1" opacity="0.6"/>
<rect x="687" y="764" width="32" height="16" rx="3" fill="#1e1b4b" stroke="#8b5cf6" stroke-width="1"/>
<text x="703" y="775" text-anchor="middle" font-family="monospace" font-size="6" font-weight="bold" fill="#8b5cf6">UCIe-S.c2</text>
<line x1="703" y1="764" x2="685" y2="693" stroke="#8b5cf6" stroke-width="1" opacity="0.6"/>
<text x="699" y="606" font-family="monospace" font-size="6" fill="#10b98188">256GB/s</text>
<circle cx="835" cy="685" r="8" fill="#475569" stroke="#64748b" stroke-width="1"/>
<text x="835" y="688" text-anchor="middle" font-family="monospace" font-size="6" fill="white">r5c5</text>
<line x1="835" y1="677" x2="835" y2="535" stroke="#10b981" stroke-width="0.8" opacity="0.25"/>
<rect x="783" y="697" width="32" height="16" rx="3" fill="#2d1f3d" stroke="#a855f7" stroke-width="1"/>
<text x="799" y="708" text-anchor="middle" font-family="monospace" font-size="7" font-weight="bold" fill="#a855f7">PE7</text>
<line x1="799" y1="697" x2="835" y2="693" stroke="#a855f7" stroke-width="1" opacity="0.6"/>
<rect x="914" y="677" width="32" height="16" rx="3" fill="#1e1b4b" stroke="#8b5cf6" stroke-width="1"/>
<text x="930" y="688" text-anchor="middle" font-family="monospace" font-size="6" font-weight="bold" fill="#8b5cf6">UCIe-E.c3</text>
<line x1="914" y1="685" x2="843" y2="685" stroke="#8b5cf6" stroke-width="1" opacity="0.6"/>
<rect x="855" y="764" width="32" height="16" rx="3" fill="#1e1b4b" stroke="#8b5cf6" stroke-width="1"/>
<text x="871" y="775" text-anchor="middle" font-family="monospace" font-size="6" font-weight="bold" fill="#8b5cf6">UCIe-S.c3</text>
<line x1="871" y1="764" x2="835" y2="693" stroke="#8b5cf6" stroke-width="1" opacity="0.6"/>
<text x="849" y="606" font-family="monospace" font-size="6" fill="#10b98188">256GB/s</text>
<rect x="60" y="865" width="10" height="10" rx="2" fill="#3b82f6" stroke="#475569" stroke-width="0.5"/>
<text x="74" y="874" font-family="monospace" font-size="8" fill="#94a3b8">PE Router</text>
<rect x="147" y="865" width="10" height="10" rx="2" fill="#f59e0b" stroke="#475569" stroke-width="0.5"/>

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 30 KiB

+126 -89
View File
@@ -529,120 +529,157 @@ def _render_cube_view_svg(view: ViewGraph, spec: dict) -> str:
)
break
# ── Router nodes ──
r_size = 10 # px radius
pe_routers: dict[str, str] = {} # rkey → pe label
# ── Router nodes + attached component blocks ──
r_size = 8 # px radius for router circle
blk_w, blk_h = 32, 16 # px for component blocks
# Component style definitions
_COMP_STYLE = {
"pe": {"fill": "#2d1f3d", "stroke": "#a855f7", "text": "#a855f7"},
"mcpu": {"fill": "#451a03", "stroke": "#f59e0b", "text": "#f59e0b"},
"sram": {"fill": "#1c1917", "stroke": "#d97706", "text": "#d97706"},
"ucie": {"fill": "#1e1b4b", "stroke": "#8b5cf6", "text": "#8b5cf6"},
}
for rkey, rval in routers.items():
if rval is None:
continue
rx, ry = rval["pos_mm"]
px, py = mm2px(rx, ry)
attach = rval.get("attach", [])
is_top = ry < cube_h / 2
# Determine router type by attachments
has_pe = any(a.endswith(".dma") for a in attach)
has_mcpu = "m_cpu" in attach
has_sram = "sram" in attach
has_ucie = any(a.startswith("ucie_") for a in attach)
if has_pe:
fill, stroke = "#3b82f6", "#1d4ed8"
pe_name = [a for a in attach if a.endswith(".dma")][0].split(".")[0]
pe_routers[rkey] = pe_name.upper()
elif has_mcpu:
fill, stroke = "#f59e0b", "#d97706"
elif has_sram:
fill, stroke = "#f59e0b", "#d97706"
elif has_ucie:
fill, stroke = "#8b5cf6", "#6d28d9"
else:
fill, stroke = "#334155", "#475569"
# ── Router circle ──
has_attach = len(attach) > 0
r_fill = "#475569" if has_attach else "#334155"
r_stroke = "#64748b" if has_attach else "#475569"
parts.append(
f' <circle cx="{px:.0f}" cy="{py:.0f}" r="{r_size}" '
f'fill="{fill}" stroke="{stroke}" stroke-width="1.5"/>'
f'fill="{r_fill}" stroke="{r_stroke}" stroke-width="1"/>'
)
# Router label
parts.append(
f' <text x="{px:.0f}" y="{py + 3:.0f}" text-anchor="middle" '
f'font-family="monospace" font-size="7" font-weight="bold" fill="white">'
f'font-family="monospace" font-size="6" fill="white">'
f'{rkey}</text>'
)
# Attachment labels below router
label_parts = []
if has_pe:
label_parts.append(pe_routers[rkey])
if has_mcpu:
label_parts.append("M_CPU")
if has_sram:
label_parts.append("SRAM")
ucie_items = [a for a in attach if a.startswith("ucie_")]
if ucie_items:
label_parts.append(f"UCIe×{len(ucie_items)}")
if label_parts:
# ── Router → HBM_CTRL line (all routers connect to HBM) ──
hbm_edge_y = hbm_y if py < hbm_y else hbm_y + hbm_h
r_edge_y = py + r_size if py < hbm_y else py - r_size
# Only draw if not inside HBM zone
if abs(r_edge_y - hbm_edge_y) > 10:
parts.append(
f' <text x="{px:.0f}" y="{py + r_size + 10:.0f}" text-anchor="middle" '
f'font-family="monospace" font-size="6" fill="#94a3b8">'
f'{", ".join(label_parts)}</text>'
f' <line x1="{px:.0f}" y1="{r_edge_y:.0f}" '
f'x2="{px:.0f}" y2="{hbm_edge_y:.0f}" '
f'stroke="#10b981" stroke-width="0.8" opacity="0.25"/>'
)
# ── PE → HBM connection line (for PE routers) ──
if has_pe:
# Draw line from router to HBM zone edge
target_y = hbm_y if py < hbm_y else hbm_y + hbm_h
# ── Attached component blocks ──
# Collect components to draw, positioned outward from router
blocks: list[tuple[str, str, dict]] = [] # (label, kind, style)
pe_items = [a for a in attach if a.endswith(".dma")]
if pe_items:
pe_name = pe_items[0].split(".")[0].upper()
blocks.append((pe_name, "pe", _COMP_STYLE["pe"]))
if "m_cpu" in attach:
blocks.append(("M_CPU", "mcpu", _COMP_STYLE["mcpu"]))
if "sram" in attach:
blocks.append(("SRAM", "sram", _COMP_STYLE["sram"]))
ucie_items = [a for a in attach if a.startswith("ucie_")]
for ui in ucie_items:
direction = ui.split(".")[0].replace("ucie_", "").upper()
conn = ui.split(".")[1] if "." in ui else ""
blocks.append((f"UCIe-{direction}.{conn}", "ucie", _COMP_STYLE["ucie"]))
# Position blocks outward from router (away from cube center)
for bi, (label, kind, style) in enumerate(blocks):
# Determine placement direction: PE/components go outward
# Use left/right offset for multiple blocks on same router
offset_x = (bi - (len(blocks) - 1) / 2) * (blk_w + 4)
if kind == "ucie":
# UCIe: place at cube edge direction
direction = label.split("-")[1].split(".")[0] if "-" in label else ""
if direction == "N":
bx, by = px + offset_x - blk_w / 2, pad - blk_h - 4
elif direction == "S":
by_base = pad + cube_h * scale
bx, by = px + offset_x - blk_w / 2, by_base + 4
elif direction == "W":
bx, by = pad - blk_w - 4, py + offset_x - blk_h / 2
elif direction == "E":
bx_base = pad + cube_w * scale
bx, by = bx_base + 4, py + offset_x - blk_h / 2
else:
bx, by = px + offset_x - blk_w / 2, py - r_size - blk_h - 4
else:
# PE/M_CPU/SRAM: place above (top half) or below (bottom half)
bx = px + offset_x - blk_w / 2
if is_top:
by = py - r_size - blk_h - 4 - bi * (blk_h + 2)
else:
by = py + r_size + 4 + bi * (blk_h + 2)
# Block rect
parts.append(
f' <line x1="{px:.0f}" y1="{py + r_size:.0f}" '
f'x2="{px:.0f}" y2="{target_y:.0f}" '
f'stroke="#10b981" stroke-width="1.5" opacity="0.5" '
f'stroke-dasharray="4,3"/>'
f' <rect x="{bx:.0f}" y="{by:.0f}" '
f'width="{blk_w}" height="{blk_h}" '
f'rx="3" fill="{style["fill"]}" stroke="{style["stroke"]}" stroke-width="1"/>'
)
# BW annotation
bw_y = (py + r_size + target_y) / 2
# Label
font_sz = 6 if len(label) > 6 else 7
parts.append(
f' <text x="{px + 12:.0f}" y="{bw_y:.0f}" '
f' <text x="{bx + blk_w / 2:.0f}" y="{by + blk_h / 2 + 3:.0f}" '
f'text-anchor="middle" font-family="monospace" font-size="{font_sz}" '
f'font-weight="bold" fill="{style["text"]}">{_escape(label)}</text>'
)
# Connector line: block → router
if kind == "ucie":
# Line from block edge toward router
if direction == "N":
parts.append(
f' <line x1="{bx + blk_w / 2:.0f}" y1="{by + blk_h:.0f}" '
f'x2="{px:.0f}" y2="{py - r_size:.0f}" '
f'stroke="{style["stroke"]}" stroke-width="1" opacity="0.6"/>'
)
elif direction == "S":
parts.append(
f' <line x1="{bx + blk_w / 2:.0f}" y1="{by:.0f}" '
f'x2="{px:.0f}" y2="{py + r_size:.0f}" '
f'stroke="{style["stroke"]}" stroke-width="1" opacity="0.6"/>'
)
elif direction == "W":
parts.append(
f' <line x1="{bx + blk_w:.0f}" y1="{by + blk_h / 2:.0f}" '
f'x2="{px - r_size:.0f}" y2="{py:.0f}" '
f'stroke="{style["stroke"]}" stroke-width="1" opacity="0.6"/>'
)
elif direction == "E":
parts.append(
f' <line x1="{bx:.0f}" y1="{by + blk_h / 2:.0f}" '
f'x2="{px + r_size:.0f}" y2="{py:.0f}" '
f'stroke="{style["stroke"]}" stroke-width="1" opacity="0.6"/>'
)
else:
# Vertical connector
ly1 = by + blk_h if is_top else by
ly2 = py - r_size if is_top else py + r_size
parts.append(
f' <line x1="{px + offset_x:.0f}" y1="{ly1:.0f}" '
f'x2="{px:.0f}" y2="{ly2:.0f}" '
f'stroke="{style["stroke"]}" stroke-width="1" opacity="0.6"/>'
)
# ── PE router → HBM BW annotation ──
if pe_items:
bw_x = px + 14
bw_y = (r_edge_y + hbm_edge_y) / 2
parts.append(
f' <text x="{bw_x:.0f}" y="{bw_y:.0f}" '
f'font-family="monospace" font-size="6" fill="#10b98188">'
f'{agg_bw:.0f}GB/s</text>'
)
# ── PE blocks (drawn next to their router) ──
pe_w, pe_h = 30, 18 # px
for rkey, rval in routers.items():
if rval is None:
continue
attach = rval.get("attach", [])
pe_dma = [a for a in attach if a.endswith(".dma")]
if not pe_dma:
continue
pe_name = pe_dma[0].split(".")[0] # "pe0"
pe_label = pe_name.upper()
rx, ry = rval["pos_mm"]
px, py = mm2px(rx, ry)
# Position PE block: top-half PEs above router, bottom-half below
is_top = ry < cube_h / 2
pe_x = px - pe_w / 2
pe_y = py - r_size - pe_h - 4 if is_top else py + r_size + 4
parts.append(
f' <rect x="{pe_x:.0f}" y="{pe_y:.0f}" '
f'width="{pe_w}" height="{pe_h}" '
f'rx="3" fill="#2d1f3d" stroke="#a855f7" stroke-width="1"/>'
)
parts.append(
f' <text x="{px:.0f}" y="{pe_y + pe_h / 2 + 4:.0f}" text-anchor="middle" '
f'font-family="monospace" font-size="8" font-weight="bold" fill="#a855f7">'
f'{pe_label}</text>'
)
# PE ↔ router link
link_y1 = pe_y + pe_h if is_top else pe_y
link_y2 = py - r_size if is_top else py + r_size
parts.append(
f' <line x1="{px:.0f}" y1="{link_y1:.0f}" '
f'x2="{px:.0f}" y2="{link_y2:.0f}" '
f'stroke="#a855f7" stroke-width="1.5" opacity="0.7"/>'
)
# ── Legend ──
ly = h_px - 35
legend_items = [