sourceextensions/blender/demos/HexBuild.xtl

1⍝│ HexBuild.xtl -- the HEX1000-UART 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: "hb:" u_se< "HexBuild" 7 8"vd:" u̲se< "Video" 9 10⍝│ title: public name of the Tang Nano 9K UART video family 11ˡtitle ← "HEX1000-UART" 12 13⍝│ subtitle: the build video 14ˡsubtitle ← "from source to a configured Tang Nano 9K" 15 16⍝│ length: seconds, including the title and the closing board 17ˡlength ← 24.0 18 19⍝│ cueTable: start and end of the six scenes, in seconds 20ˡcueTable ← 6 2 r̲eshape 0.0 3.0 3.0 7.0 7.0 11.0 11.0 16.0 16.0 20.0 20.0 24.0 21 22⍝│ hb:c_ues stats: captions with this build's LUT, flip-flop and byte 23⍝│ counts; the source-to-XIR lowering is explicitly hand-written 24ˡc̲ues ← { stats → 25 ˡtitle c̲at ": " c̲at ˡsubtitle c̲at "|Hex1000.xtl: hx:s_tep. Hand-lowered XIR emits hex1000.v; add the board and UART.|Yosys maps the board to " c̲at (f̲ormat 1 s̲elect stats) c̲at " LUTs and " c̲at (f̲ormat 2 s̲elect stats) c̲at " flip-flops, plus memory and carry logic.|nextpnr: the logic flies to its assigned BELs. Blue: LUTs. Orange: flip-flops.|Routing: green marks the tiles occupied by routed wires, from nextpnr.|gowin_pack: " c̲at (f̲ormat 6 s̲elect stats) c̲at " bytes of bitstream. Configuration enters a schematic Tang Nano 9K." 26} 27 28⍝ a nextpnr coordinate to the scene's tile plane (x, depth, z) 29ʰp̲laces ← { (cells, y, center, scale) z → 30 x ← scale × (1 s̲elect₂ cells) − 1 s̲elect center 31 zz ← scale × (2 s̲elect center) − 2 s̲elect₂ cells 32 n ← t̲ally x 33 2 1 t̲ranspose (3 c̲at n) r̲eshape x c̲at (n r̲eshape y) c̲at zz 34} 35 36⍝│ (size, cells, routes, stats) hb:s_cene 0: the Python scene, before 37⍝│ stills or video. cells: x y BEL-slot is-flip-flop (n by 4); routes: 38⍝│ unique occupied wire tiles (m by 2); stats: the export's six counts. 39⍝│ LUTs/flip-flops keep their actual BEL assignments, offset within a 40⍝│ tile by their slots so several cells at one tile remain visible. 41ˡs̲cene ← { (size, cells, routes, stats) z → 42 w ← 1 s̲elect size 43 h ← 2 s̲elect size 44 n ← t̲ally cells 45 nr ← t̲ally routes 46 ff ← 4 s̲elect₂ cells 47 slots ← 3 s̲elect₂ cells 48 coords ← (2 t̲ake₂ cells) c̲at routes 49 xs ← 1 s̲elect₂ coords 50 ys ← 2 s̲elect₂ coords 51 center ← ((('m̲in r̲/ xs) + 'm̲ax r̲/ xs) ÷ 2.0) c̲at ((('m̲in r̲/ ys) + 'm̲ax r̲/ ys) ÷ 2.0) 52 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 53 placed ← (cells, 0.0, center, scale) ʰp̲laces 0 54 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 × ff 55 ⍝ A readable unplaced cloud, with each cell retaining its identity. 56 ids ← (r̲ange n) − 1 57 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 58 dims ← (n c̲at 3) r̲eshape 0.065 0.07 0.065 59 rgb ← 2 1 t̲ranspose (3 c̲at n) r̲eshape (70 + 185 × ff) c̲at (155 + 15 × ff) c̲at 250 − 180 × ff 60 boxes ← cloud c̲at₂ dims c̲at₂ rgb c̲at₂ (n c̲at 1) r̲eshape 1.0 61 keys ← (n c̲at 2 c̲at 6) r̲eshape r̲avel ((cloud c̲at₂ dims) c̲at₂ spaced c̲at₂ dims) 62 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 63 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 64 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 65 ⍝ Board silhouette, package, USB connector and two rows of headers: 66 ⍝ intentionally schematic, with no claim of measured geometry. 67 board ← 3 10 r̲eshape 0 0 0 3.0 0.25 7.0 20 105 70 1 0 -0.3 0 1.8 0.3 1.8 25 28 40 1 0 -0.2 3.0 1.5 0.6 1.2 180 185 200 1 68 ⍝ Headers worked out as an array, 14 contacts on each side. 69 pinx ← (14 r̲eshape -1.3) c̲at 14 r̲eshape 1.3 70 pinz ← 2 14 r̲eshape -2.8 + 0.42 × (f̲loat r̲ange 14) − 1.0 71 pins ← (2 1 t̲ranspose 3 28 r̲eshape pinx c̲at (28 r̲eshape -0.2) c̲at r̲avel pinz) c̲at₂ 28 7 r̲eshape 0.2 0.3 0.2 220 180 65 1 72 packet ← 1 10 r̲eshape -5.0 -0.5 3.0 0.8 0.2 0.4 100 240 180 2 73 d ← (w, h, 35, 13.0, 12.0) ᵛᵈf̲it 0 74 t ← ((ᵛᵈhead c̲at ((w, h, 30, ˡlength, 8 10 18, 35) ᵛᵈs̲tage 0)) c̲at 75 ((("source", source) ᵛᵈb̲oxes 0) c̲at ("source", 3 2 r̲eshape 3 7) ᵛᵈs̲hown 0) c̲at 76 ((("source labels", "hx:s_tep|hand-lowered XIR|hex1000.v + UART", words) ᵛᵈl̲abels 0) c̲at ("source labels", 3 2 r̲eshape 3 7) ᵛᵈs̲hown 0) c̲at 77 ((("logic", boxes) ᵛᵈb̲oxes 0) c̲at (("logic", 11.0 15.5, keys) ᵛᵈm̲oves 0)) c̲at 78 (("logic", (n c̲at 2) r̲eshape 7.0 20.0) ᵛᵈs̲hown 0) c̲at 79 ((("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 80 (("die", 1 2 r̲eshape 3 20) ᵛᵈs̲hown 0) c̲at 81 ((("routes", routeBoxes) ᵛᵈb̲oxes 0) c̲at ("routes", (nr c̲at 2) r̲eshape 16.0 20.0) ᵛᵈs̲hown 0) c̲at 82 ((("board", board) ᵛᵈb̲oxes 0) c̲at ("board", 3 2 r̲eshape 20 24 20 24 20 24) ᵛᵈs̲hown 0) c̲at 83 ((("headers", pins) ᵛᵈb̲oxes 0) c̲at ("headers", 28 2 r̲eshape 20 24) ᵛᵈs̲hown 0) c̲at 84 ((("bitstream", packet) ᵛᵈb̲oxes 0) c̲at (("bitstream", 20.0 22.5, 1 2 6 r̲eshape -5 -0.5 3 0.8 0.2 0.4 0 -0.5 0 0.1 0.1 0.1) ᵛᵈm̲oves 0)) c̲at 85 (("bitstream", 1 2 r̲eshape 20 22.6) ᵛᵈs̲hown 0) c̲at 86 ((0.0 24.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 87 ((ˡtitle, ˡsubtitle, 1 8 r̲eshape 0 3 255 255 255 18 22 44) ᵛᵈc̲ards 0)) 88 captions ← ˡcueTable c̲at₂ 6 3 r̲eshape 255 255 255 89 t c̲at ((ˡc̲ues stats, captions) ᵛᵈc̲aptions 0) 90}