sourceextensions/blender/demos/KeysBuild.xtl

1⍝│ KeysBuild.xtl -- the HEX1000-keys-leds build, from the pinned circuit's actual 2⍝│ synthesis, placement and routing artifacts. X_eTaL computes the 3⍝│ geometry, colors and timing; Video writes the Blender player. 4⍝│ The board is a schematic model; die coordinates are nextpnr tiles, 5⍝│ not physical dimensions. Routes show occupied wire tiles. 6⍝│ Import: "kb:" u_se< "KeysBuild" 7 8"vd:" u̲se< "Video" 9"pn:" u̲se< "Panel" 10 11ʰl̲it ← { (lit, _) → lit } 12 13⍝│ title: public name of the Tang Nano 1K physical-key video family 14ˡtitle ← "HEX1000-keys-leds" 15 16⍝│ subtitle: the build video 17ˡsubtitle ← "from source to a configured Tang Nano 1K" 18 19⍝│ length: seconds, including the title and the closing board 20ˡlength ← 32.0 21 22⍝│ cueTable: source, mapping, placement, routing, timing and configuration 23ˡcueTable ← 7 2 r̲eshape 0.0 3.0 3.0 8.0 8.0 12.0 12.0 17.0 17.0 21.0 21.0 26.0 26.0 32.0 24 25⍝│ kb:c_ues stats: actual packed resources and both routed clock checks. 26⍝│ Core lowering and controller RTL are hand-written, not a compiler demo. 27ˡc̲ues ← { stats → 28 ˡtitle c̲at ": " c̲at ˡsubtitle c̲at "|Hex1000 + Front specifications. Core: hand-lowered XIR. Controller and full 1K wrapper: hand-written RTL. Upstream compiler absent.|Yosys/nextpnr packed resources: " c̲at (f̲ormat 1 s̲elect stats) c̲at " LUTs, " c̲at (f̲ormat 2 s̲elect stats) c̲at " flip-flops, " c̲at (f̲ormat 7 s̲elect stats) c̲at " carry ALUs, " c̲at (f̲ormat 8 s̲elect stats) c̲at " block RAMs, " c̲at (f̲ormat 9 s̲elect stats) c̲at " pad cells (" c̲at (f̲ormat 15 s̲elect stats) c̲at " I/O buffers + " c̲at (f̲ormat 14 s̲elect stats) c̲at " tri-state rows).|nextpnr places every cell at its assigned BEL. Blue LUTs; orange flip-flops; pink carry; purple RAM; yellow I/O; gray other.|Routing: " c̲at (f̲ormat 5 s̲elect stats) c̲at " nets occupy " c̲at (f̲ormat 4 s̲elect stats) c̲at " wire tiles. Green is a tile footprint, not physical wire geometry.|Both clocks pass: input " c̲at (3 ᵛᵈf̲ixed (f̲loat 10 s̲elect stats) ÷ 1000.0) c̲at " MHz vs 27; machine " c̲at (3 ᵛᵈf̲ixed (f̲loat 11 s̲elect stats) ÷ 1000.0) c̲at " MHz vs 0.964. BUFG clock sinks; one divider-feedback routing warning.|gowin_pack: " c̲at (f̲ormat 6 s̲elect stats) c̲at " bytes. Schematic Nano 1K, keypad, operators, TXS0108E and MAX7219. Configuration animation; no hardware programmed." 29} 30 31⍝ a nextpnr coordinate to the scene's tile plane (x, depth, z) 32ʰp̲laces ← { (cells, y, center, scale) z → 33 x ← scale × (1 s̲elect₂ cells) − 1 s̲elect center 34 zz ← scale × (2 s̲elect center) − 2 s̲elect₂ cells 35 n ← t̲ally x 36 2 1 t̲ranspose (3 c̲at n) r̲eshape x c̲at (n r̲eshape y) c̲at zz 37} 38 39⍝│ (size, cells, routes, stats) kb:s_cene 0: the Python scene, before 40⍝│ stills or video. cells: x y BEL-slot resource-class (n by 4); routes: 41⍝│ unique occupied wire tiles (m by 2); stats: counts and both clock results (15 values). 42⍝│ Cells keep their actual BEL assignments, offset within a 43⍝│ tile by their slots so several cells at one tile remain visible. 44ˡs̲cene ← { (size, cells, routes, stats) z → 45 w ← 1 s̲elect size 46 h ← 2 s̲elect size 47 n ← t̲ally cells 48 nr ← t̲ally routes 49 kind ← f̲loor 4 s̲elect₂ cells 50 slots ← 3 s̲elect₂ cells 51 coords ← (2 t̲ake₂ cells) c̲at routes 52 xs ← 1 s̲elect₂ coords 53 ys ← 2 s̲elect₂ coords 54 center ← ((('m̲in r̲/ xs) + 'm̲ax r̲/ xs) ÷ 2.0) c̲at ((('m̲in r̲/ ys) + 'm̲ax r̲/ ys) ÷ 2.0) 55 scale ← 9.0 ÷ 1.0 m̲ax (('m̲ax r̲/ xs) − 'm̲in r̲/ xs) m̲ax ('m̲ax r̲/ ys) − 'm̲in r̲/ ys 56 placed ← (cells, 0.0, center, scale) ʰp̲laces 0 57 spaced ← placed + 2 1 t̲ranspose (3 c̲at n) r̲eshape (0.025 × slots) c̲at (n r̲eshape -0.1) c̲at 0.08 × f̲loat kind 58 ⍝ A readable unplaced cloud, with each cell retaining its identity. 59 ids ← (r̲ange n) − 1 60 cloud ← 2 1 t̲ranspose (3 c̲at n) r̲eshape (0.18 × (f̲loat ids m̲od 60) − 29.5) c̲at (n r̲eshape -0.5) c̲at 0.18 × 15.0 − f̲loat ids d̲iv 60 61 wide ← 0.065 + 0.15 × f̲loat kind = 3 62 dims ← 2 1 t̲ranspose (3 c̲at n) r̲eshape wide c̲at (n r̲eshape 0.07) c̲at wide 63 rgb ← 2 1 t̲ranspose (3 c̲at n) r̲eshape ((1 + kind) s̲elect 70 255 245 185 250 150) c̲at ((1 + kind) s̲elect 155 170 90 110 225 155) c̲at (1 + kind) s̲elect 250 70 170 250 70 165 64 boxes ← cloud c̲at₂ dims c̲at₂ rgb c̲at₂ (n c̲at 1) r̲eshape 1.0 65 keys ← (n c̲at 2 c̲at 6) r̲eshape r̲avel ((cloud c̲at₂ dims) c̲at₂ spaced c̲at₂ dims) 66 source ← 3 10 r̲eshape -4 0 1 3.6 0.15 1.8 35 65 105 1 0 0 1 3.6 0.15 1.8 70 55 105 1 4 0 1 3.6 0.15 1.8 35 85 80 1 67 words ← 3 7 r̲eshape -4 -0.2 1 0.3 255 255 255 0 -0.2 1 0.3 255 255 255 4 -0.2 1 0.3 255 255 255 68 routeBoxes ← ((routes, -0.25, center, scale) ʰp̲laces 0) c̲at₂ (nr c̲at 7) r̲eshape 0.14 0.03 0.14 40 220 125 1.0 69 ⍝ Scene units only. No measured board dimensions or wire geometry. 70 board ← 5 10 r̲eshape 3 0 0 2.2 0.25 4.5 20 105 70 1 3 -0.3 0 1.3 0.3 1.3 25 28 40 1 3 -0.2 1.9 1.0 0.4 0.6 180 185 200 1 -3 0 0 5.2 0.3 6.2 35 45 65 1 0.3 0 -2.7 1.0 0.2 0.8 120 85 150 1 71 xy ← ᵖⁿk̲eyAt o̲ffsets 20 72 keyAt ← 2 1 t̲ranspose 3 20 r̲eshape ((1 s̲elect₂ xy) − 3.0) c̲at (20 r̲eshape -0.3) c̲at 2 s̲elect₂ xy 73 keyBoxes ← keyAt c̲at₂ 20 7 r̲eshape 0.72 0.2 0.72 50 130 210 0.08 74 labels ← (keyAt + 20 3 r̲eshape 0.0 -0.2 0.0) c̲at₂ 20 4 r̲eshape 0.25 245 245 255 75 display ← 1 10 r̲eshape -3 -0.3 2.3 4.9 0.1 1.1 12 25 18 1 76 strokes ← ʰl̲it ᵖⁿd̲igits 8 r̲eshape 24 77 segments ← (2 1 t̲ranspose 6 56 r̲eshape ((1 s̲elect₂ strokes) − 3.0) c̲at (56 r̲eshape -0.4) c̲at (2 s̲elect₂ strokes) c̲at ((3 s̲elect₂ strokes) − 3.0) c̲at (56 r̲eshape -0.4) c̲at 4 s̲elect₂ strokes) c̲at₂ 56 4 r̲eshape 60 150 100 0.025 78 boardLabels ← 3 7 r̲eshape 3 -0.5 2.8 0.27 240 245 255 -3 -0.5 3.2 0.27 240 245 255 0.3 -0.5 -3.3 0.23 240 245 255 79 packet ← 1 10 r̲eshape 5.5 -0.5 3.0 0.8 0.2 0.4 100 240 180 2 80 d ← (w, h, 35, 13.0, 12.0) ᵛᵈf̲it 0 81 t ← ((ᵛᵈhead c̲at ((w, h, 30, ˡlength, 8 10 18, 35) ᵛᵈs̲tage 0)) c̲at 82 ((("source", source) ᵛᵈb̲oxes 0) c̲at ("source", 3 2 r̲eshape 3 8) ᵛᵈs̲hown 0) c̲at 83 ((("source labels", "Hex1000 + Front|reference RTL|full 1K wrapper", words) ᵛᵈl̲abels 0) c̲at ("source labels", 3 2 r̲eshape 3 8) ᵛᵈs̲hown 0) c̲at 84 ((("logic", boxes) ᵛᵈb̲oxes 0) c̲at (("logic", 12.0 16.8, keys) ᵛᵈm̲oves 0)) c̲at 85 (("logic", (n c̲at 2) r̲eshape 8.0 26.0) ᵛᵈs̲hown 0) c̲at 86 ((("die", 1 10 r̲eshape 0.0 0.3 0.0 10.5 0.2 10.5 65 85 140 1.0) ᵛᵈo̲utlines 0)) c̲at 87 (("die", 1 2 r̲eshape 3 26) ᵛᵈs̲hown 0) c̲at 88 ((("routes", routeBoxes) ᵛᵈb̲oxes 0) c̲at ("routes", (nr c̲at 2) r̲eshape 17.0 21.0) ᵛᵈs̲hown 0) c̲at 89 ((("board", board) ᵛᵈb̲oxes 0) c̲at ("board", 5 2 r̲eshape 26 32) ᵛᵈs̲hown 0) c̲at 90 ((("keys", keyBoxes) ᵛᵈb̲oxes 0) c̲at ("keys", 20 2 r̲eshape 26 32) ᵛᵈs̲hown 0) c̲at 91 ((("legends", "0|1|2|3|4|5|6|7|8|9|A|B|C|D|E|F|+|-|*|=", labels) ᵛᵈl̲abels 0) c̲at ("legends", 20 2 r̲eshape 26 32) ᵛᵈs̲hown 0) c̲at 92 ((("display", display) ᵛᵈb̲oxes 0) c̲at ("display", 1 2 r̲eshape 26 32) ᵛᵈs̲hown 0) c̲at 93 ((("segments", segments) ᵛᵈl̲ines 0) c̲at ("segments", 56 2 r̲eshape 26 32) ᵛᵈs̲hown 0) c̲at 94 ((("parts", "Nano 1K (schematic)|MAX7219 + keypad|TXS0108E", boardLabels) ᵛᵈl̲abels 0) c̲at ("parts", 3 2 r̲eshape 26 32) ᵛᵈs̲hown 0) c̲at 95 ((("bitstream", packet) ᵛᵈb̲oxes 0) c̲at (("bitstream", 26.0 30.5, 1 2 6 r̲eshape 5.5 -0.5 3 0.8 0.2 0.4 3 -0.5 0 0.1 0.1 0.1) ᵛᵈm̲oves 0)) c̲at 96 (("bitstream", 1 2 r̲eshape 26 30.6) ᵛᵈs̲hown 0) c̲at 97 ((0.0 32.0, 2 3 r̲eshape 0.0 c̲at (n̲eg d) c̲at 0.0, 2 3 r̲eshape 0.0) ᵛᵈc̲amera 0) c̲at 98 ((ˡtitle, ˡsubtitle, 1 8 r̲eshape 0 3 255 255 255 18 22 44) ᵛᵈc̲ards 0)) 99 captions ← ˡcueTable c̲at₂ 7 3 r̲eshape 255 255 255 100 t c̲at ((ˡc̲ues stats, captions) ᵛᵈc̲aptions 0) 101}