#!/bin/sh # select_de25_profile.sh — pick the DE25-Nano board build profile WITHOUT hand-editing # the QSF. Rewrites the two managed marker blocks in the board QSF: # # >>> DE25_PROFILE_FIXTURE >>> ... # <<< DE25_PROFILE_FIXTURE <<< # # >>> DE25_PROFILE_SCENE >>> ... # <<< DE25_PROFILE_SCENE <<< # Everything else in the QSF (EMIF macros GS_LPDDR4B_FB/GS_LPDDR_FB, pin/IP assignments) # is profile-independent and untouched. After switching, re-fit in Quartus as usual. # # Usage: # ./scripts/select_de25_profile.sh lpddr_tex # Ch322 LPDDR-backed texture demo (tritex) # ./scripts/select_de25_profile.sh lpddr128_scanout # Ch321 128x128 LPDDR framebuffer scanout # ./scripts/select_de25_profile.sh --list # list profiles + show the active one # # Add a profile by extending the case blocks below (fixture mems + scene VERILOG_MACROs). set -u QSF="${QSF:-synth/de25_nano/top_psmct32_raster_demo/de25_nano_psmct32_raster_demo_top.qsf}" PROFILE="${1:-}" MEMDIR="sim/data/top_psmct32_raster_demo" [ -f "$QSF" ] || { echo "QSF not found: $QSF (run from repo root, or set QSF=)"; exit 2; } mac() { printf 'set_global_assignment -name VERILOG_MACRO "%s"\n' "$1"; } fix() { # $1=bios stem $2=payload stem mac "TOP_PSMCT32_RASTER_DEMO_BIOS_IMAGE_FILE=\\\"$MEMDIR/$1.mem\\\"" mac "TOP_PSMCT32_RASTER_DEMO_PAYLOAD_IMAGE_FILE=\\\"$MEMDIR/$2.mem\\\"" } case "$PROFILE" in lpddr_tex) FIXTURE="$(fix bios_tritex payload_tritex)" SCENE="$(mac GS_LPDDR_TEX_DEMO=1) $(mac GS_LPDDR_TEX=1)" ;; lpddr128_scanout) FIXTURE="$(fix bios_tile_lpddr128 payload_tile_lpddr128)" SCENE="$(mac GS_TILE_LPDDR128_DEMO=1)" ;; tile_spill) # Ch324 — 4x4 MULTI-TILE COLOR+Z spill/reload two-batch depth proof (64x64 raster # FB in LPDDR). GS_TILE_SPILL_DEMO selects the bram-top render config (PSMCT32, # close_combined, TILE_LOCAL, TILE_COLS/ROWS=4); GS_TILE_SPILL enables the de25 # LPDDR spill writers + gs_tile_reload (per-tile reload base) + TILE_SPILL_ENABLE. # Ch325 — scaled to 8x8 / 128x128 (bios_tile_spill8x8). Ch324 4x4 fixture retired here. # Ch327b — scaled to 16x16 / 256x256 (bios_tile_spill16x16), line-buffer scanout. FIXTURE="$(fix bios_tile_spill16x16 payload_tile_spill16x16)" SCENE="$(mac GS_TILE_SPILL_DEMO=1) $(mac GS_TILE_SPILL=1)" ;; feeder) # Ch330 — runtime command-list feeder. The setup-only bootlet uploads the texture # (bios/payload_feeder_setup), the feeder draws list A, then the HPS streams list B # into the staging RAM over the bridge (0x0D8/0x0DC/0x0E4) and retriggers (0x0E8) — # the image changes with no RBF rebuild / reset. GS_FEEDER_DEMO selects the bram-top # config (FEEDER_ENABLE=1, HEARTBEAT_SPLICE_ENABLE=0, 4x4 TILE_PRIM_COUNT=4). FIXTURE="$(fix bios_feeder_setup payload_feeder_setup)" # FEEDER_STG_INIT_FILE bitstream-inits the staging RAM with list A so the first # auto-run draws a clean scene at power-up (sim never defines this; TBs $readmemh directly). SCENE="$(mac GS_FEEDER_DEMO=1) $(mac "FEEDER_STG_INIT_FILE=\\\"$MEMDIR/feeder_stg_cap4.mem\\\"")" ;; feeder_persp) # Ch342 — PERSPECTIVE-correct textured triangles through the feeder on the S1 path (tiling/ # combined OFF, PERSPECTIVE_CORRECT=1). The setup-only bootlet uploads a 16x16 checkerboard # (bios/payload_persp_feeder_setup); FEEDER_STG_INIT renders the perspective checkerboard floor # at boot (feeder_persp.mem, word0[32]=1 -> RGBAQ/ST/XYZ2). The HPS can then stream an authentic # cube_persp scene over the bridge (ps2_feeder, ABE=0). Combined-TAZ perspective is a follow-on. FIXTURE="$(fix bios_persp_feeder_setup payload_persp_feeder_setup)" SCENE="$(mac GS_FEEDER_PERSP_DEMO=1) $(mac "FEEDER_STG_INIT_FILE=\\\"$MEMDIR/feeder_persp.mem\\\"")" ;; feeder_cube) # Ch343 — the AUTHENTIC cube on silicon. Same GS_FEEDER_PERSP_DEMO bram-top config as # feeder_persp (ABE=0 S1 perspective, .RAM_SIZE_BYTES=32 KiB), but the fixtures are the real # cubes-dump content: the boot bootlet uploads the extracted 64x64 cube texture @ TBP=64 # (bios/payload_cube_setup, QWC=1030) and FEEDER_STG_INIT renders the 27 translated perspective # triangles (feeder_cube_persp.mem). All three .mem are dump-derived/LOCAL (gitignored) — generate # with `python3 tools/gs_make_cube_fixture.py`. Closes the GS dump -> extraction -> ST/Q -> pixels arc. FIXTURE="$(fix bios_cube_setup payload_cube_setup)" SCENE="$(mac GS_FEEDER_PERSP_DEMO=1) $(mac "FEEDER_STG_INIT_FILE=\\\"$MEMDIR/feeder_cube_persp.mem\\\"")" ;; texalpha) # Ch344 — TEXTURED + source-over alpha SPRITE on silicon (boot payload, no feeder). SPRITE_TEX_ALPHA=1. # bios/payload_texalpha upload an 8x8 alpha-checker texture + blue BG sprite + a textured-alpha overlay # sprite. On HDMI: a gray/blue checkerboard (opaque texels gray, transparent texels reveal the BG). FIXTURE="$(fix bios_texalpha payload_texalpha)" SCENE="$(mac GS_TEXALPHA_DEMO=1)" ;; feeder_sprite) # Ch345a — RUNTIME FEEDER textured-alpha SPRITEs (sprite_mode staging). SPRITE_TEX_ALPHA=1 + FEEDER_ENABLE=1. # bios/payload_sprite_setup uploads an 8x8 alpha texture + blue BG; FEEDER_STG_INIT=feeder_sprite streams # 3 textured-alpha sprites over it. On HDMI: 3 gray/blue alpha-checker squares on blue (runtime ingestion). FIXTURE="$(fix bios_sprite_setup payload_sprite_setup)" SCENE="$(mac GS_FEEDER_SPRITE_DEMO=1) $(mac "FEEDER_STG_INIT_FILE=\\\"$MEMDIR/feeder_sprite.mem\\\"")" ;; sh3_clut) # Ch347 — AUTHENTIC Silent Hill 3 64x64-crop PSMT8 texture + real CLUT, DECAL on silicon. The bootlet # (bios/payload_sh3_clut) BITBLT-uploads the 256-entry CLUT + 64x64 PSMT8 indices, fires the VRAM->CLUT # load (TEX0 CLD=1, CSM2-linear), draws a 64x64 DECAL sprite. HEARTBEAT_SPLICE off (set in the profile). # Fixtures are SH3-derived -> LOCAL/gitignored: run `python3 tools/gs_extract_sh3_clut.py` then # `python3 tools/gs_make_sh3_fixture.py` with the local SH3 dump BEFORE fitting. FIXTURE="$(fix bios_sh3_clut payload_sh3_clut)" SCENE="$(mac GS_SH3_CLUT_DEMO=1)" ;; sh3_persp) # Ch348 — AUTHENTIC SH3 PSMT8 texture + real CLUT through the PERSPECTIVE-triangle FEEDER path. The # setup bootlet (bios/payload_sh3_persp) uploads the 64x64 PSMT8 texture + 256-entry CLUT; the feeder # staging (feeder_sh3_persp) draws a perspective quad with TEX0(PSMT8,CLD=1) -> the feeder commit fires # the VRAM->CLUT load. Fixtures are SH3-derived -> LOCAL/gitignored: run `python3 tools/gs_extract_sh3_clut.py` # then `python3 tools/gs_make_sh3_persp_fixture.py` with the local SH3 dump BEFORE fitting. FIXTURE="$(fix bios_sh3_persp payload_sh3_persp)" SCENE="$(mac GS_SH3_PERSP_DEMO=1) $(mac "FEEDER_STG_INIT_FILE=\\\"$MEMDIR/feeder_sh3_persp.mem\\\"")" ;; sh3_real_draw) # Ch350/351/352 — the ACTUAL Ch349 SH3 draw CROP on silicon (Codex board gate). Real draw geometry # (idx89761 lamppost/bench, host-clipped to a 256x120 viewport) + the reconstructed 512x512 PSMT8 texture # in LPDDR (GS_LPDDR_TEX cache @ 0x200000) + the real CSM1 CLUT (bootlet 256x1 BITBLT to CBP, grid bytes # verbatim) + Ch351 widened perspective precision (PERSP_RECIP_IDX_BITS=11). 128 KiB crop VRAM (under the # read2 tripwire). Golden oracle: tb_top_psmct32_sh3_real_draw_demo (ALL 96.2% <=1 texel, clut_bad=0). # BOARD ORDER: (1) fit this profile, (2) HPS write-probe uploads sh3_real_tex_lpddr.mem to LPDDR @0x200000 # + checksum-verify via the read-probe, (3) feeder auto-runs the bitstream-init scene, (4) verify HDMI vs # the crop reference (captures/.../recon/sh3_real_ref.png). Fixtures SH3-derived -> LOCAL/gitignored: # run `python3 tools/gs_make_sh3_real_draw_fixture.py` FIRST. FIXTURE="$(fix bios_sh3_real payload_sh3_real)" SCENE="$(mac GS_SH3_REAL_DRAW_DEMO=1) $(mac GS_LPDDR_TEX=1) $(mac "FEEDER_STG_INIT_FILE=\\\"$MEMDIR/feeder_sh3_real.mem\\\"")" ;; --list|"") echo "Profiles: lpddr_tex (Ch322 texture) lpddr128_scanout (Ch321 scanout) tile_spill (Ch323 spill/reload) feeder (Ch330 command-list) feeder_persp (Ch342 perspective) feeder_cube (Ch343 authentic cube) texalpha (Ch344 textured-alpha sprite) feeder_sprite (Ch345a runtime sprite) sh3_clut (Ch347 authentic SH3 PSMT8+CLUT) sh3_persp (Ch348 SH3 PSMT8+CLUT perspective) sh3_real_draw (Ch350/351/352 SH3 real-draw crop, LPDDR tex + CSM1 + widened persp)" echo "Active profile:" sed -n '/DE25_PROFILE_SCENE/,/DE25_PROFILE_SCENE/p' "$QSF" | grep VERILOG_MACRO || echo " (no scene macros)" sed -n '/DE25_PROFILE_FIXTURE/,/DE25_PROFILE_FIXTURE/p' "$QSF" | grep IMAGE_FILE [ -z "$PROFILE" ] && exit 2 || exit 0 ;; *) echo "unknown profile: $PROFILE (try --list)"; exit 2 ;; esac # Replace the content between each marker pair (awk: print markers, swap the body). swap_block() { # $1=tag $2=replacement-text (reads stdin QSF, writes stdout) awk -v tag="$1" -v repl="$2" ' $0 ~ (">>> " tag " ") { print; print repl; inblk=1; next } $0 ~ ("<<< " tag " <<<") { inblk=0 } !inblk { print } ' } tmp="$(mktemp)" swap_block DE25_PROFILE_FIXTURE "$FIXTURE" < "$QSF" \ | swap_block DE25_PROFILE_SCENE "$SCENE" > "$tmp" # sanity: both marker pairs must still be present (don't clobber the QSF on a bad run) for tag in DE25_PROFILE_FIXTURE DE25_PROFILE_SCENE; do [ "$(grep -c "$tag" "$tmp")" -eq 2 ] || { echo "ERROR: marker '$tag' missing after edit — QSF unchanged"; rm -f "$tmp"; exit 1; } done mv "$tmp" "$QSF" echo "Selected profile: $PROFILE" echo " fixture: $(echo "$FIXTURE" | grep -o '[a-z0-9_]*\.mem' | tr '\n' ' ')" echo " scene : $(echo "$SCENE" | grep -o 'GS_[A-Z0-9_]*=1' | tr '\n' ' ')" echo "Now re-fit in Quartus."