libraryextensions/blender/demos/KeysBuild.xtl

KeysBuild.xtl -- the HEX1000-keys-leds 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: "kb:" u_se< "KeysBuild"

source · imports vd: extensions/blender/lib/Video.xtl; pn: work/hex1000/libs/Panel/src/Panel.xtl

ʰl̲it : (Any a, Any b) => (a, b) -> a

function (private) · line 11
ʰl̲it ← { (lit, _) → lit }
Used in: ˡs̲cene

ˡtitle : Char

value · line 14

title: public name of the Tang Nano 1K physical-key video family

ˡtitle ← "HEX1000-keys-leds"

ˡsubtitle : Char

value · line 17

subtitle: the build video

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

ˡlength : Float

value · line 20

length: seconds, including the title and the closing board

ˡlength ← 32.0
Used in: ˡs̲cene

ˡcueTable : Float

value · line 23

cueTable: source, mapping, placement, routing, timing and configuration

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

ˡc̲ues : Num a => a -> Char

function · line 27

kb:c_ues stats: actual packed resources and both routed clock checks. Core lowering and controller RTL are hand-written, not a compiler demo.

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

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

function (private) · line 32
ʰ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, Num b, Any c) => (a, Float, Float, b) -> c -> Char

function · line 44

(size, cells, routes, stats) kb:s_cene 0: the Python scene, before stills or video. cells: x y BEL-slot resource-class (n by 4); routes: unique occupied wire tiles (m by 2); stats: counts and both clock results (15 values). Cells 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
  kind ← f̲loor 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 × f̲loat kind
  ⍝ 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
  wide ← 0.065 + 0.15 × f̲loat kind = 3
  dims ← 2 1 t̲ranspose (3 c̲at n) r̲eshape wide c̲at (n r̲eshape 0.07) c̲at wide
  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
  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
  ⍝ Scene units only. No measured board dimensions or wire geometry.
  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
  xy ← ᵖⁿk̲eyAt o̲ffsets 20
  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
  keyBoxes ← keyAt c̲at₂ 20 7 r̲eshape 0.72 0.2 0.72 50 130 210 0.08
  labels ← (keyAt + 20 3 r̲eshape 0.0 -0.2 0.0) c̲at₂ 20 4 r̲eshape 0.25 245 245 255
  display ← 1 10 r̲eshape -3 -0.3 2.3 4.9 0.1 1.1 12 25 18 1
  strokes ← ʰl̲it ᵖⁿd̲igits 8 r̲eshape 24
  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
  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
  packet ← 1 10 r̲eshape 5.5 -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 8) ᵛᵈs̲hown 0) c̲at
    ((("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
    ((("logic", boxes) ᵛᵈb̲oxes 0) c̲at (("logic", 12.0 16.8, keys) ᵛᵈm̲oves 0)) c̲at
    (("logic", (n c̲at 2) r̲eshape 8.0 26.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 26) ᵛᵈs̲hown 0) c̲at
    ((("routes", routeBoxes) ᵛᵈb̲oxes 0) c̲at ("routes", (nr c̲at 2) r̲eshape 17.0 21.0) ᵛᵈs̲hown 0) c̲at
    ((("board", board) ᵛᵈb̲oxes 0) c̲at ("board", 5 2 r̲eshape 26 32) ᵛᵈs̲hown 0) c̲at
    ((("keys", keyBoxes) ᵛᵈb̲oxes 0) c̲at ("keys", 20 2 r̲eshape 26 32) ᵛᵈs̲hown 0) c̲at
    ((("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
    ((("display", display) ᵛᵈb̲oxes 0) c̲at ("display", 1 2 r̲eshape 26 32) ᵛᵈs̲hown 0) c̲at
    ((("segments", segments) ᵛᵈl̲ines 0) c̲at ("segments", 56 2 r̲eshape 26 32) ᵛᵈs̲hown 0) c̲at
    ((("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
    ((("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
    (("bitstream", 1 2 r̲eshape 26 30.6) ᵛᵈs̲hown 0) c̲at
    ((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
    ((ˡtitle, ˡsubtitle, 1 8 r̲eshape 0 3 255 255 255 18 22 44) ᵛᵈc̲ards 0))
  captions ← ˡcueTable c̲at₂ 7 3 r̲eshape 255 255 255
  t c̲at ((ˡc̲ues stats, captions) ᵛᵈc̲aptions 0)
}
Used in: _