Research-Stack/4-Infrastructure/hardware/build_research_stack.sh
Brandon Schneider ba203ca971 feat: spatial hash grid — GPU-style particle physics (Python + FPGA)
Ported from ScaleSpaceSynth (WebGPU particle simulator):
- 64×64×64 spatial hash, 32 particles/cell, lock-free insertion
- Curl noise: divergence-free 3D turbulence
- Pairwise forces: attractive (ratio>0.15) + repulsive (ratio<=0.15)
- Trilinear density interpolation
- HalfLife particle lifecycle
- Q16_16 encode/decode for VCN transport

Python (spatial_hash_grid.py): 6/6 tests pass
  10K particles, neighbor query, forces, 100 sim steps, curl noise verified

FPGA (spatial_hash_bram.v):
  16×16×16 grid, dual-port BRAM, 27-cycle neighbor scan
  Density → voltage mode selector (STORE/COMPUTE/APPROX/MORPHIC)
  Integrated into research_stack_top.v

Same pattern as ScaleSpaceSynth GPU:
  GPU: atomicAdd for lock-free cell assignment
  FPGA: BRAM read-modify-write for cell assignment
  Ray: content-addressed ObjectRef for lock-free reads
  All: partition space → compute density → find structure at multiple scales
2026-05-30 01:25:19 -05:00

45 lines
1 KiB
Bash

#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "$0")"
TOP="research_stack_top"
CST="research_stack_tangnano9k.cst"
JSON="research_stack_top.json"
PNR="research_stack_top_pnr.json"
FS="research_stack_top.fs"
DEVICE="GW1NR-LV9QN88PC6/I5"
FAMILY="GW1N-9C"
FREQ=27
Q16_V="../../5-Applications/out/verilog/q16_lut_core.v"
echo "=== Synthesis ==="
yosys -p "
read_verilog -sv \
${Q16_V} \
blitter_memory_map.v \
voltage_mode_controller.v \
scale_space_bram.v \
highs_pivot_accelerator.v \
fractal_box_counter.v \
fractal_fd_selector.v \
spatial_hash_bram.v \
spatial_hash_selector.v \
Blitter6502OISC_small.v \
research_stack_top.v;
synth_gowin -top ${TOP} -json ${JSON};
stat
"
echo ""
echo "=== Place & Route ==="
nextpnr-himbaechel --device "${DEVICE}" --json "${JSON}" --write "${PNR}" \
--freq "${FREQ}" --vopt "family=${FAMILY}" --vopt "cst=${CST}"
echo ""
echo "=== Bitstream ==="
gowin_pack -d "${FAMILY}" -o "${FS}" "${PNR}"
echo ""
echo "=== Done: ${FS} ==="
ls -lh "${FS}"