libraryextensions/blender/demos/HexBuild.xtl

HexBuild.xtl -- the HEX1000-UART build, from the pinned circuit's actual synthesis, placement and routing artifacts. X_eTaL computes the geometry, colors and timing; Video writes the Blender player. The board is a schematic model; die coordinates are nextpnr tiles, not physical dimensions. Routes show occupied wire tiles. Import: "hb:" u_se< "HexBuild"

source · imports vd: extensions/blender/lib/Video.xtl

ˡtitle : Char

value · line 11

title: public name of the Tang Nano 9K UART video family

ˡtitle ← "HEX1000-UART"

ˡsubtitle : Char

value · line 14

subtitle: the build video

ˡsubtitle ← "from source to a configured Tang Nano 9K"

ˡlength : Float

value · line 17

length: seconds, including the title and the closing board

ˡlength ← 24.0
Used in: ˡs̲cene

ˡcueTable : Float

value · line 20

cueTable: start and end of the six scenes, in seconds

ˡ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
Used in: ˡs̲cene, _

ˡc̲ues : a -> Char

function · line 24

hb:c_ues stats: captions with this build's LUT, flip-flop and byte counts; the source-to-XIR lowering is explicitly hand-written

ˡc̲ues ← { stats →
  ˡ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."
}
Used in: ˡs̲cene, _

ʰp̲laces : (Num a, Any b) => (a, a, a, a) -> b -> a

function (private) · line 29
ʰp̲laces ← { (cells, y, center, scale) z →
  x ← scale × (1 s̲elect₂ cells) − 1 s̲elect center
  zz ← scale × (2 s̲elect center) − 2 s̲elect₂ cells
  n ← t̲ally x
  2 1 t̲ranspose (3 c̲at n) r̲eshape x c̲at (n r̲eshape y) c̲at zz
}
Used in: ˡs̲cene

ˡs̲cene : (Num a, Any c) => (a, Float, Float, b) -> c -> Char

function · line 41

(size, cells, routes, stats) hb:s_cene 0: the Python scene, before stills or video. cells: x y BEL-slot is-flip-flop (n by 4); routes: unique occupied wire tiles (m by 2); stats: the export's six counts. LUTs/flip-flops keep their actual BEL assignments, offset within a tile by their slots so several cells at one tile remain visible.

ˡs̲cene ← { (size, cells, routes, stats) z →
  w ← 1 s̲elect size
  h ← 2 s̲elect size
  n ← t̲ally cells
  nr ← t̲ally routes
  ff ← 4 s̲elect₂ cells
  slots ← 3 s̲elect₂ cells
  coords ← (2 t̲ake₂ cells) c̲at routes
  xs ← 1 s̲elect₂ coords
  ys ← 2 s̲elect₂ coords
  center ← ((('m̲in r̲/ xs) + 'm̲ax r̲/ xs) ÷ 2.0) c̲at ((('m̲in r̲/ ys) + 'm̲ax r̲/ ys) ÷ 2.0)
  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
  placed ← (cells, 0.0, center, scale) ʰp̲laces 0
  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
  ⍝ A readable unplaced cloud, with each cell retaining its identity.
  ids ← (r̲ange n) − 1
  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
  dims ← (n c̲at 3) r̲eshape 0.065 0.07 0.065
  rgb ← 2 1 t̲ranspose (3 c̲at n) r̲eshape (70 + 185 × ff) c̲at (155 + 15 × ff) c̲at 250 − 180 × ff
  boxes ← cloud c̲at₂ dims c̲at₂ rgb c̲at₂ (n c̲at 1) r̲eshape 1.0
  keys ← (n c̲at 2 c̲at 6) r̲eshape r̲avel ((cloud c̲at₂ dims) c̲at₂ spaced c̲at₂ dims)
  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
  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
  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
  ⍝ Board silhouette, package, USB connector and two rows of headers:
  ⍝ intentionally schematic, with no claim of measured geometry.
  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
  ⍝ Headers worked out as an array, 14 contacts on each side.
  pinx ← (14 r̲eshape -1.3) c̲at 14 r̲eshape 1.3
  pinz ← 2 14 r̲eshape -2.8 + 0.42 × (f̲loat r̲ange 14) − 1.0
  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
  packet ← 1 10 r̲eshape -5.0 -0.5 3.0 0.8 0.2 0.4 100 240 180 2
  d ← (w, h, 35, 13.0, 12.0) ᵛᵈf̲it 0
  t ← ((ᵛᵈhead c̲at ((w, h, 30, ˡlength, 8 10 18, 35) ᵛᵈs̲tage 0)) c̲at
    ((("source", source) ᵛᵈb̲oxes 0) c̲at ("source", 3 2 r̲eshape 3 7) ᵛᵈs̲hown 0) c̲at
    ((("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
    ((("logic", boxes) ᵛᵈb̲oxes 0) c̲at (("logic", 11.0 15.5, keys) ᵛᵈm̲oves 0)) c̲at
    (("logic", (n c̲at 2) r̲eshape 7.0 20.0) ᵛᵈs̲hown 0) c̲at
    ((("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
    (("die", 1 2 r̲eshape 3 20) ᵛᵈs̲hown 0) c̲at
    ((("routes", routeBoxes) ᵛᵈb̲oxes 0) c̲at ("routes", (nr c̲at 2) r̲eshape 16.0 20.0) ᵛᵈs̲hown 0) c̲at
    ((("board", board) ᵛᵈb̲oxes 0) c̲at ("board", 3 2 r̲eshape 20 24 20 24 20 24) ᵛᵈs̲hown 0) c̲at
    ((("headers", pins) ᵛᵈb̲oxes 0) c̲at ("headers", 28 2 r̲eshape 20 24) ᵛᵈs̲hown 0) c̲at
    ((("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
    (("bitstream", 1 2 r̲eshape 20 22.6) ᵛᵈs̲hown 0) c̲at
    ((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
    ((ˡtitle, ˡsubtitle, 1 8 r̲eshape 0 3 255 255 255 18 22 44) ᵛᵈc̲ards 0))
  captions ← ˡcueTable c̲at₂ 6 3 r̲eshape 255 255 255
  t c̲at ((ˡc̲ues stats, captions) ᵛᵈc̲aptions 0)
}
Used in: _