13

There is a wonderful project called Visual6502, and I've used it from time to time to figure things out, like exactly the difference between rti and rts. It is good to see which control lines were fired in each cycle from the Control ROM.

But Z80 is a whole other thing. It's not microcoded like the 6502 is, but instead apparently contains some finite state machines and things. I am not sure I understand why that design choice was made, especially considering the relatively more complex ISA, including variable-length instruction codes. But I really have no idea about that.

So I am interested in finding out more about how the Z80 worked. Has this chip been reverse-engineered and had its internal mechanisms explained, such that it can be understood by laypeople?

  • I am especially interested in the parts which decode instructions. My guess is that prefixes modify some kind of internal state, and all other instructions reset that state, but it would be interesting to find out more. – Wilson May 23 at 13:48
  • 4
    (Not enough for an answer) You may want do browse thru Ken Shirriff's Blog as he describes quite some internals for 8080/8085/Z80. (I think he's as well on RC.SE) – Raffzahn May 23 at 14:12
  • 1
    More specific link: posts tagged "Z-80" on Ken's blog – Toby Speight May 23 at 18:42
  • The 6502 is not microcoded - it uses a PLA to decode and execute instructions. – Eight-Bit Guru Jun 25 at 15:20
  • @Eight-BitGuru What do you call the data on the PLA then? Microcode is as good a term as any. – Wilson Jun 25 at 15:24
7

Z80 has been implemented in the Visual6502 way too. However looks like the site http://www.micrologo.net/z80x is no longer operational. It was Z80 die simulation in Javascript When I searched matching stuff from mine off-line copy I found this repository:

So if you want to run the Z80 simulation download the repo and open expert-z80.html file from it in your browser.

Yes a lot has been reversed especially the 4bit ALU of Z80. See Ken Shirriff's blog sites are really good and I used them while perfected my Z80 emulator:

I ended up with this ISET configuration:

Which breaks down all the instructions into their machine cycles ... Once you done that many things start to be obvious.

3

The best I've seen is Goran Devic's implementation for an FPGA. He's taken the existing bits of Z-80 reverse engineering and filled in the missing pieces and connected them all together. Read through the blog and you'll find a large PNG functional diagram and a link to a bitbucket repo of all the code.

Although I haven't done a deep dive into the details, it does seem to be similar to the 6502 in that a PLA is used to decode instructions and drive various sub-circuits. It does differ at the low level in a lot of ways in how the register files and ALUs are implemented.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.