Flash file system for BASIC, with bitstream write protection

BASIC gets SAVE, LOAD, RUN "NAME", DIR and DEL, storing program listings
in the configuration flash from 240000h (448 x 4 KB blocks, 64 files,
32 KB each). The directory is kept in two alternating blocks with a
sequence number and checksum, new data is written before the directory
switches to it, and every page is verified after programming.

rtl/flash_spi.v drives the flash through STARTUPE2 on ports 40h/41h. It
only passes read, status, WREN/WRDI, RDID, page program and 4 KB erase,
and abandons any program or erase below 240000h before the address
reaches the chip. Tested on the board: an erase at 0 and a write at
200000h were refused and left the flash unchanged.

With SW14 up, the Z-80's output is also copied to the PC's serial port,
and tools/get-bas.py uses that to LIST a program into a file or run
commands and print the replies.

Also fixes port 10h returning the previous millisecond latch (the first
read after reset was undefined). Simulation adds a model flash and a
save/load/run/protection test. Manual and README updated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
brad ArantandClaude Opus 5.5 committed 2026-11-28 08:33:52 -08:00
1 parent dc7c7c22c5
commit 29a15bf7c7
15 files changed
+6907 -6056

No files matched your search

+10
View File
@@ -86,6 +86,16 @@ set_property -dict { PACKAGE_PIN B17 IOSTANDARD LVCMOS33 PULLUP true } [get_por
## Asynchronous / human-speed I/O
set_false_path -from [get_ports {btnC btnU btnD sw[*] RsRx PS2Clk PS2Data}]
# Configuration flash, used by the Z-80 for files (its clock goes through STARTUPE2)
set_property -dict { PACKAGE_PIN K19 IOSTANDARD LVCMOS33 } [get_ports QspiCSn]
set_property -dict { PACKAGE_PIN D18 IOSTANDARD LVCMOS33 } [get_ports {QspiDB[0]}]
set_property -dict { PACKAGE_PIN D19 IOSTANDARD LVCMOS33 } [get_ports {QspiDB[1]}]
set_property -dict { PACKAGE_PIN G18 IOSTANDARD LVCMOS33 } [get_ports {QspiDB[2]}]
set_property -dict { PACKAGE_PIN F18 IOSTANDARD LVCMOS33 } [get_ports {QspiDB[3]}]
# the SPI clock is slow (clk/4) and sampled mid-bit, so the pins need no timing
set_false_path -to [get_ports {QspiCSn QspiDB[*]}]
set_false_path -from [get_ports {QspiDB[*]}]
# The Z-80 clock is only crossed through synchronisers and toggle handshakes.
set_clock_groups -asynchronous -group [get_clocks sys_clk_pin] \
-group [get_clocks -of_objects [get_pins cpu_mmcm/CLKOUT0]]