This project is a branch from the Micro Galena.
The ultimate goal is to make a Z80 computer, with an interpreter (to be defined), video out, keyboard, and some kind of external mass storage.
There are now two versions available:
Z80SoC-DE1 for Altera DE1 Development Board. Can easily be ported to DE2.
Z80SoC-S3E for Diligent Spartan 3E Starter Kit
The whole Quartus II project for Altera DE1, can be downloaded here:
The Xilinx ISE project files for Spartan 3E can be downloaded here:
Read the README file for the arquitecture, and IO ports.
All leds, 7 segment displays (DE1), LCD (S3E), switches, keys and IO pins can be addressed from the Z80 using IO ports (except ledr9, ledr8, sw9 and sw8 on DE1).
Video and keyboard are also implemented in this version. Video are addressed by memory write operations, from adress 0x2000h.
For DE1, the GPIO is buffered, so it is possible to write all 36 signals to a buffer, 8 at a time, and then send a final command to write all 36 values in the buffer to the gpio pins.
I have written some assembly test programs. Check the ROM directory.
A full list of Z80 opcodes can be found here: http://www.shiar.org/product/z80.txt
To make a rom, use this procedure:
1. write the assembly code (I use Z80 PC Assembler by Peter Hanratty)
2. compile
3. copy the hex codes (ascii) to a file named "rom.hex" iin the ROM directory
4. convert the rom.hex to rom.vhd. I have written a bash shell script for this purpose: hex2rombin.sh
5. copy the generated rom.vhd to VHDL directory
6. compile your project
Here is examples on how to access the DE1 input/output pins.
Writing numbers to the seven segment display:
out (10h),a ; LSB of 7segdisplay
out (11h),a ; MSB of 7segdisplay
Green leds:
out (01h),a
Red leds:
out (02h),a
Switches:
in a,(20h)
Push button:
in a,(30h)
Keyboard:
in a,(80h) ;register A will have ascii code
Video:
There are now t2o ways to write text cracters to video.
You can use port or memory mapped io.
Remember, it is a 40 columns x 30 lines display.
Lines start at 0, columns start at 0.
To calculete the VRAM address to use memory mapped io:
((Line x 40) + Column) + 4000h (values here are in hexadecimal).
ld (4000h),a ; write to video in line 0, column 0
ld (4027h),a ; write to video in line 0, column 39
ld (4488h),a ; write to video in line 29, column 0
Write to video using port io:
out (91h),a ; define cursor for video X position (0 to 39)
out (92h),a ; define cursor for video Y position (0 to 29)
out (90h),a ; print character to video in position defined using ports 91h and 92h
For Spartan 3E, the rotary and LCD display can be accessed very easily. Please, take a look in the README file and the Z80_S3E.z8a reference ROM.
Back: FPGA projects