ZX-Badaloc     Reloaded

Implementing the ZX-Badaloc Clone into an FPGA

Clone setup on Xilinx 3E Board

 

Prerequisites: a VGA monitor and PS/2 Keyboard attached to the proper board's connectors; a male/female 9 pin RS-232 cable with pins 2/3 straigth (not crossed) connected to a PC running Windows. The male end of the cable should be plugged in the 9-pin female connector on the board (J9).

First of all, the provided .bit file should be uploaded to the FPGA by means of the USB cable or a JTAG interface, using Xilinx Impact software (or whatever).

After this step is accomplished, a tiny bootloader embedded into the FPGA code will be executed by the Z80 (T80 core) processor and the screen will start cycling 8 colors on the "Border" (a word that should be familiar to zx-spectrum users). Also, a 24 bit counter used for color cycling will be visible on the screen, because it uses 3 video memory locations. A portion of the video memory is used to store the Z80 code.

Led LD0 will light up, indicating that the 'context switch' logic is active. The context switch is a special memory mapping introduced on the CPLD-based clone which allows fast bank switching for NMI service even when the active ROM does not provide a handler (for example, the ZX-Spectrum Basic ROM). The handler in the bootrom firmware allows snapshots and many other functions.

Every 8 cycles, the bootloader will attempt to load a 16K ROM image from the SPI Flash chip at address $0F0000 into internal FPGA blockram. If the first byte is not $F3, the boot is aborted. During this color cycling, RS-232 command can be issued.

 

Quick play with a 48K ZX-Spectrum:

Start the ZX-Com program on the PC and select "3E-500 FPGA ZX-Badaloc Reloaded" in the Hardware Type under the "Options" menu.

While the tiny bootloader is running, the only usable menu of the zx-com program is the 'Fpga' one.

The fastest way to play with a 48K Spectrum is selecting "Serial Bootload" from "Fpga" menu then uploading any 16K Sinclair ROM file, for example the image of the original 16/48K machine.

List of USEFUL BOARD BUTTONS:

NORTH: FPGA reset: will go back to the tiny bootloader
EAST: Z80 reset
SOUTH: NMI. At this time it will crash the machine as no NMI handler is provided by original sinclair rom
 

SW0: when turned ON, disables the SPI Flash boot attempt of the tiny bootloader. Useful for issuing RS-232 commands to the tiny bootloader when a ROM is already programmed into the SPI Flash.

 

Programming the project into the SPI Flash:

In order to have the project up and running at power-on, the provided .bit file should be stored into the SPI flash chip. This can be easily accomplished by ZX-Com. With the tiny bootloader running (border cycling colors) go to the "Xilinx .bit file SPI Flash Program" in the "Fpga" menu, then select the provided .bit file. It will actually program the SPI Flash, using the lower area. Note that "user rom area" used by this project starts at SPI address $0F0000, leaving enough free space for FPGA configuration in the chip even for the largest possible FPGA of the 3E family (the 1600).

If you decide to program the clone project into the SPI flash, it will be available at power-on without the need of Impact. The "SPI FLASH" should be selected by jumpers as the FPGA configuration source (see kit documentation).

 

Uploading the BootRom firmware:

The next step is uploading the provided BootRom firmware (see download section) as the serial bootload rom. It will display the main system menu and list available snapshots if a sd-card is connected (and of course at least one snapshot has been previously saved).

NOTE: At this point, the "Fpga" menu is completely useless. If you wish to use one of it's options, you should reset the FPGA (NORTH button).

On the other hand, many of the features of zx-com can now be used (but not all of them, since the porting is still at an early stage). Pressing the LOGIN button will cause an NMI to be issued and the spectrum will execute RS-232 commands, whatever it was doing, thanks to the CONTEXT SWITCH that enables the BootRom firmware and it's NMI handler. Note that the fact that context switch is active can be observed on LD0 led.

The BootRom is now running, but it should programmed into the SPI Flash in order to avoid the serial bootload step at every power-on. To do this, select the "Flash Bootrom Firmware" from the "Flash" menu. Note that this is not different from flashing any other ROM, but the destination address will be correct for sure ($0F0000 in the SPI flash chip, which corresponds to ROM bank $3C).

Since the SPI chip can only be erased on 64K blocks, the content will be saved to DDR memory in order to keep the previous content of the 48K not being changed.

After the BootRom firmware is in place, it will be started by the tiny bootloader at every power-on (provided that SW0 is in OFF position).

NOTE that after flashing a ROM, the system is still freezed (LOG-IN). To release the machine to normal operation, press the LOGIN button (which now shows as LOGOUT).

 

Programming a Sinclair ROM into the Flash Chip:

The BootRom firmware has a few options to start a 48K, 128K or +3E ZX-Spectrum. For these options to work, proper ROMS should be programmed in the SPI Flash.

For compatibility reason with the original zx-badaloc clone, the ROM layout should be as follows:

BANK 0 = 128K Spectrum ROM 0
BANK 1 = 128K Spectrum ROM 1
BANK 2 = 48K Spectrum ROM
BANK 3   was the BootRom bank in the original clone. Unused by now.

BANKS 4-7 = 4 ROM for +2A / +3 ZX-Spectrum. The +3E ROMs by Garry Lancaster (who made a custom release for this clone) is the best choice. Download the latest version from the +3E home, then program the file "baden3eE.rom" (64K) into bank 4 (it will automatically span to banks 5,6,7) or download the 1.37 version here.

BANK 8 = BBC Basic rom 0
BANK 9 = BBC Basic rom 1

 

The first bank (0) is located at absolute SPI Flash offset $100000 (+1MB). The zx-com program takes care of properly addressing the SPI chip. Just select the "Flash Rom" from the "Flash" menu, select the desired ROM file then the bank number from the dialog box.

NOTE: All SPI ROMS are copied to proper DDR banks at system startup. A newly programmed ROM will be available only after restarting the BootRom firmware.

After this step has been accomplished, pressing 'C' on the PS/2 keyboard (see the on-screen menu) will load the 16/48K rom from proper SPI address and jump in it.

Pressing 'V' will switch the machine to +3 mode and activate the +3E ROMs

 

Taking RS-232 snapshots:

This step is only meaningful if you built the TAPE Interface, so that you can load programs (many places on the internet provides Spectrum software in the form of playable files on a PC).

Anyway, the entire state of the machine can be freezed into a PC file (by RS-232) or on the SD-CARD.

Select the "48K Snapshot" from the "Snap" menu: the Spectrum will be halted and the entire memory along with Z80 registers will be uploaded to the PC via RS-232. Finally, a file will be saved on your computer.

To reload a previously saved snapshot, use the "Upload Snapshot" option of the "File" menu.

The zx-com package provides a few snapshots in the /zx-data subdirectory. You can immediately upload and run them on the clone. You can also modify snapshot parameters (see the "Snap" menu) to see how they behaves (higher processor frequency, etc).

This is the ResiDOS 2.08 installer in the form of snapshot. Press ENTER after upload.

 

SD-CARD usage for snapshot purpose:

The zx-com package provides a few sd-card snapshot backups in the /mmc-backup subdirectory. You can write them to your card using the "Restore" feature from the 'SnapShot Backup/Verify/Restore' option in the "SD-MMC" menu. The snapshots will be positioned into the sd-card using the number in square brackets in the filename (see the /mmc-backup directory content to understand this point). Before uploading the backup, you should initialize your card (keep reading).

The SD-CARD uses a nonstandard RAW format which is the same used by the original clone and the zxmmc+ interface. When a new SD-CARD is found, the bootrom firmware displays an options (on the Q key) to initialize it for snapshot use. The initialization consists in a simple header written at a certain position in the card. In the earlier version, this could only be done at the beginning of the card. The current bootrom allows initializing the snapshot area at a given offset, so that the same card might be used with other filesystems (that could be placed at the beginning of the card itself) such as IDEDOS or even FAT16.

Further information on the RAW format can be found in the provided bootrom source code.

Anyway, after an sd-card has been prepared for snapshot and the system is running a software we want to save, press the NMI (SOUTH) button on the board. The border will turn BLUE and the machine will enter CONTEXT SWITCH state (see LD0 led). From this, you can press Q or W or E to save a 16K, 48K or 128K snapshot. A flashing green attribute on the upper left corner will tell the operation was completed. If the border turns MAGENTA, it means that IM2 interrupt mode has been detected. If it turns RED, it means that a requested 16K snapshot has been turned into a 48K one because the stack pointer has been found to point to a memory region outside the first 16K.

The next time the machine is started, there should be a new snapshot in the list. The flashing cursor can be moved by O, P keys. When highlighed, snapshot parameters such as name and Z80 settings can be changed. By pressing ENTER the snapshot will be reloaded and executed. The same can be achieved by pressing the key with the same number in the list.

System speed adjustment:

Turn the encoder knob to adjust Z80 clock between 3.5 and 42MHz. Below 3.5MHz the system will enter the 'prescaler mode', which allows slowing down enough to be able to see single instruction execution address/data on the LCD display. See the controls page for further information.

 

 

Back to Index