M7 · canonical twins on the dieM7 · 晶粒上的正規化孿生
Same structure, same fate相同結構,相同命運
This is the real 2C02 silicon layout — the same segment polygons the switch-level engine simulates — rendered live in your browser. On top of it, M7's canonical key colours every node by its structural-twin tier. The big green blocks are the chip's replicated cell arrays — sprite OAM, palette RAM, the shift registers — that the key folds into a handful of large canonical groups (590, 582, 360, 360, 298, 288… cells). Drag to pan, wheel to zoom, hover any cell for its name and tier. The census numbers (3,824 nodes in 16 big arrays, 3,299 smaller twins, 1,642 structurally unique) stop being numbers and become places. 這是真實的 2C02 矽佈局 —— 開關級引擎模擬的同一批 segment 多邊形 —— 在你瀏覽器裡即時渲染。上面疊著 M7 正規化鍵,把每一個節點依「結構孿生層級」著色。那幾團綠色大區塊,是晶片的複製 cell 陣列 —— 精靈 OAM、調色盤 RAM、位移暫存器 —— 正規化鍵把它們摺疊進少數幾個大型正規化群組(590、582、360、360、298、288… 個 cell)。拖曳平移、滾輪縮放、停在任一 cell 上看名字與層級。那些普查數字(3,824 個節點落在 16 個大陣列、3,299 個較小孿生、1,642 個結構唯一)不再是數字,而是位置。
Faint background = the die's layers (diffusion / poly / metal). Green = nodes in the big replicated arrays; purple = smaller structural twins; blue = structurally unique nodes the key already individuates. M7 assigns a key to every node, so the whole die is coloured — click a legend chip to toggle a tier off and isolate the arrays.暗色背景 = 晶粒各層(擴散 / 多晶矽 / 金屬)。綠色 = 大型複製陣列裡的節點;紫色 = 較小的結構孿生;藍色 = 正規化鍵已能單獨識別的結構唯一節點。M7 給每一個節點一把鍵,所以整顆晶粒都上了色 —— 點圖例色塊可關掉某一層,單獨看那些陣列。
How the detection works偵測演算法怎麼運作
The engine breaks ties by node number, and a node's number is just its load order — a file-order accident. When two events land in the same settle wave, or a floating group is a dead heat, whoever got the smaller id wins. That is the D-class lottery: identical twin circuits (u7/u8) where one twin passed a test and its structurally-identical sibling broke on the same test. M7 replaces "id = load order" with "id = a deterministic canonical key from physics + structure", so identical circuits get identical keys, hence identical fates. This is what m7_canonical_key.py computes; the highlights above are its key projected onto the layout.
引擎用節點編號來打破平手,而節點編號只是它的載入順序 —— 一個檔案順序的意外。當兩個事件落在同一波 settle,或一個浮動群組平手時,誰的 id 較小誰就贏。這就是 D 類抽籤:一模一樣的孿生電路(u7/u8),其中一個通過測試,而結構完全相同的兄弟卻在同一測試上壞掉。M7 把「id = 載入順序」換成「id = 一把由物理 + 結構決定的正規化鍵」,於是相同電路拿到相同鍵、因而有相同命運。這就是 m7_canonical_key.py 算的東西;上面的亮點就是它的鍵投影到佈局上。
| Key dimension鍵的維度 | The rule規則 | What it does作用 |
|---|---|---|
| 1 · class1 · 類別 | the node's prune / locality class, kept as the leading key field節點的 prune / locality 類別,放在鍵的最前面 | preserves the +3.56% class-major locality win — the canonical order only reorders within a class, never across保住 +3.56% class-major locality 的成果 —— 正規化順序只在同一類別內重排,不跨類 |
| 2 · layeredArea2 · 分層面積 | the M2 capacitance proxy: segdefs polygon area × layer weight, log-bucketedM2 電容代理量:segdefs 多邊形面積 × 層權重,取對數分桶 | a physical, load-order-independent magnitude — near-equal capacitances collide, different scales separate一個與載入順序無關的物理量 —— 相近電容碰撞、不同量級分開 |
| 3 · structHash (Weisfeiler-Lehman)3 · 結構雜湊(Weisfeiler-Lehman) | start each node labelled by its degree; each round, relabel it by hash(own label, sorted neighbour labels); iterate twice每個節點先以其度數(degree)為標籤;每一輪用 hash(自身標籤, 已排序的鄰居標籤) 重新貼標;疊代兩輪 | the twin-finder — after two rounds, nodes with the same local neighbourhood collapse to the same hash, and any structural difference within two hops splits them apart孿生偵測器 —— 兩輪之後,鄰域相同的節點塌縮到同一雜湊,而兩跳之內的任何結構差異都會把它們分開 |
| 4 · degree4 · 度數 | the node's transistor gate + channel fan-in/out節點的電晶體閘極 + 通道扇入/扇出 | the final cheap tiebreak最後一道廉價的打破平手 |
Add structHash and layeredArea on top of degree and 18.3% of the degree-order ties resolve — 8,723 nodes tied by degree fall to 7,123 that still share a key. The ones that still share a key are the point, not a failure: they are the structural twins, and giving them one key is exactly the goal — same structure, same fate. They cluster into 497 canonical groups, and the 16 largest (each ≥ 96 cells, with a clean gap to the next tier at 60) are the replicated arrays lit green above.
在度數之上再加 structHash 與 layeredArea,就有 18.3% 的度數順序平手被解開 —— 原本 8,723 個依度數平手的節點,降到 7,123 個仍共用一把鍵。仍共用鍵的那些不是失敗,而是重點:它們就是結構孿生,而給它們同一把鍵正是目標 —— 同結構、同命運。它們聚成 497 個正規化群組,其中最大的 16 個(每個 ≥ 96 個 cell,與下一層級的 60 之間有明顯斷層)就是上面點亮成綠色的複製陣列。
Full write-up with the key construction, the tie-reduction stages, and the name-vs-structure audit: M7 · The canonical key that ends the lottery →完整說明含鍵的建構、平手削減各階段、以及「名字 vs 結構」稽核:M7 · 終結抽籤的正規化鍵 →
Live layout rendering adapted from Visual6502's wires.js (Brian & Barry Silverman, MIT). Layout data derived from the Visual 2C02 netlist (CC-BY-NC-SA) — the corrected data/system-def/. Detection: WebSite/s1a/py/m7_canonical_key.py --dump-nodes.
即時佈局渲染改編自 Visual6502 的 wires.js(Brian & Barry Silverman,MIT)。佈局資料衍生自 Visual 2C02 網表(CC-BY-NC-SA)—— 修正版 data/system-def/。偵測:WebSite/s1a/py/m7_canonical_key.py --dump-nodes。