Z80 FPGA Project

I have written a model of a Z80 computer system in Verilog and implemented it on an FPGA development board (a Terasic DE10). It features a Z80 CPU, 64K of RAM, a UART, and a timer. I also wrote a ROM monitor program for it that is loosely based on the Xerox 820/Bigboard monitor. It has been a fun project and a great way to learn more about the Z80 CPU architecture.

Here’s a picture of the DE10 FPGA development board:

And Here’s a picture of it running Conway’s Game of Life:

7 Likes

That’s great - well done! Is that a new Z80 model, and if so did you try running one of the test suites?

It’s a new z80 model. I wrote the Verilog code based solely on published information from Zilog data books. During development, I used the YAZE preliminary instruction test. I have not yet run any of the more extensive YAZE test suites, mostly because they have very long run times which made them impractical to run in Verilog simulations. Now that I have the ROM monitor running in hardware, I have the ability to run longer tests, and I can try some of the longer-running YAZE tests, but I have not done so yet. I made no effort to match the instruction cycle times, so programs that depend on that won’t work, but since I’m running at a 50 MHz clock speed, those programs wouldn’t work anyway. At the system level, I included a 1msec-resolution timer, so for programs that need time-delay loops, I have just replaced the time-delay loops with a call to the timer. I also have not made any efforts to implement the undocumented z80 instructions.

2 Likes

Splendid work! I was thinking of ZXDOC, and it seems that does come with YAZE.

The assembler that I’m using cannot decode the macros in the zexdoc.asm (part of the YAZE test suite). Does anyone know of an assembler (Win10 or Linux) that can assemble zexdoc.asm?

EDIT: I have found a workaround. I wrote a Perl script to expand the macros.

1 Like

The good, old pocket knife of computing!
(Is Larry Wall Swiss? :wink: )

I have created a repo on github for this project here: GitHub - scottlbaker/x820: A Z80 computer system on an FPGA

1 Like

That’s good to see! I do encourage you to release your HDL source too.

1 Like

Today I ported a Tiny Basic to the x820.

TinyBasic

1 Like

Here’s a Pi calculation benchmark running on the x820 :slight_smile:

The 90 seconds is misleading because it includes all the serial I/O time.

Edit: I did a test and the I/O takes less than a second, so I can’t blame I/O…
The Pi algorithm does lots of 32-bit divisions which is pretty slow on an 8-bit CPU.

2 Likes

Nicely done! One of my favourite numbers. I like this bit especially:
image

1 Like

Really really close :slight_smile: … With 32-bit integer arithmetic, this algorithm can accurately compute up to 9674 digits of Pi. I haven’t tried that though. My main purpose for porting and running this calculation is as another z80 compatibility test.

Are you familiar with the work on this page - source for a Z80 pi spigot can be found within, which might contain some interesting ideas.

More fun. I wrote a Lunar Lander.

1 Like

Congratulations indeed! I don’t think I’ve ever managed to touch down safely in one of these! (The graphical ones, I have.)

Speaking of “retro” lunar lander.

My friend used to play this game.

It was written in Fortran. And it was a card deck. You’d run it and just keep adding burn cards to it and run it again.

Thankfully, the college paid for the computer paper.

Hi Everyone,

The most challenging part of this project has been testing and validation. I have written or ported several test and demo programs, and I am overall happy with the current level of functionality and compatibility but the project could still use more testing and validation. If anyone wants to help/collaborate on writing or porting tests or demo programs, please let me know.

Thanks,

I’d be kind of interested in what bugs remain after passing ZXDOC - I dare say there could be some, and yet, what might they be?

I mostly use 6502, myself. I do run z80 in an Acorn second processor context, where I’m most likely to run BBC Basic - that might be worth porting - and then there’s CP/M, for which I have a small collection of games and applications but no great familiarity with them.

Are you running CP/M, or loading programs directly from your monitor?

Hi Ed,

At this point I have not run the full zexdoc test. That’s one area I could use some help with. I made a number of hacks to the zexdoc source (mainly I expanded the macros using a Perl script pre-processor) so it would assemble with my assembler. A set of CRC-based tests have been run (and passed) as well as other tests that I have written or ported. I also have written or ported several demo programs including Palo Alto Basic. I have not tried porting BBC Basic. I have also not tried getting CP/M to run, mainly because I do not have a convenient way to attach mass storage. I load all programs via a monitor program-load command which reads hex files over the serial/console connection.

1 Like

I have all of the zexdoc tests passing except for the daa test. I have done extensive testing of the daa instruction with other test suites and they all pass, so I don’t know what zexdoc is doing differently. (Note: zexdoc bundles daa with cpl,scf, and ccf but those are very simple instructions so I’m assuming the problem is in daa. I don’t currently have an assembler that will assemble zexdoc, so I can’t modify it to test that assumption.)