
Z80 Explorer – a Zilog Z80 netlist-level simulator - segfaultbuserr
https://baltazarstudios.com/z80explorer/
======
doctor_eval
This is nuts. I learned Z80 as a kid and wrote tens of thousands of lines of
code in it.

This isn’t just emulating the ISA, but the actual transistors. I could
basically load the schematics of the Z80 on my computer and run it. That blows
my mind. If Moore’s law keeps going, the simulation will be running at 2MHz in
a few years and I guess I could play Meteor Mission II on it.

For some reason this really makes me feel very strongly that this is a
simulator... _within a simulator_.

~~~
segfaultbuserr
See also: Full simulation of MOS 6502 [0] by the Visual6502 team. The same
team also did works on the Z80 [1], and it's actually the basis of the Z80
simulator presented in this article.

[0]
[http://visual6502.org/JSSim/index.html](http://visual6502.org/JSSim/index.html)

[1]
[http://visual6502.org/JSSim/expert-z80.html](http://visual6502.org/JSSim/expert-z80.html)

~~~
flohofwoe
Shameless plug: I did a WASM "visual6502 remix" a little while ago with an
integrated assembler and "execution history" (mostly for fun, but also because
I found the original UI a bit hard to use for my emulator experiments, so I
guess it was the same motivation as the Z80 Explorer project):

[https://floooh.github.io/visual6502remix/](https://floooh.github.io/visual6502remix/)

Eventually I want to do a version using the Z80 netlist of the visual6502
project as well (the actual transistor simulation code should remain the same,
I used a C port of the visual6502 Javascript code called 'perfect6502'):

[https://github.com/mist64/perfect6502](https://github.com/mist64/perfect6502)

...I heard though that not all 'trap transistors' which should protect the Z80
from reverse engineering had been found and 'neutralized' in that netlist, so
even though the ZEX test is running I'm not entirely sure whether the
simulation still contains hidden problems (neither ZEXDOC nor ZEXALL have
complete "coverage" of the Z80).

------
tech-historian
Small factoid. Microsoft's first foray into hardware was the Z80 Softcard for
Apple ][, which was a plug in card that introduced Z80 and 6502 functionality.
This was in 1980 and cost $365. A premium version also added 16k of RAM to the
Apple ][ line.

[https://www.versionmuseum.com/history-of/discontinued-
micros...](https://www.versionmuseum.com/history-of/discontinued-microsoft-
hardware)

~~~
acqq
I've used that, a few years later, and really enjoyed it. At the time I've
used it Turbo Pascal for CP/M was also available and it was pure magic,
practically instantaneous compared to anything else. Even then, that
environment allowed me to write the program in the editor, compile it and run
all in RAM, even if the RAM was smaller than 64 KB. I'd write something new,
press just a few keys, and it either runs and writes the output or it brings
me back to the editor and the line with an error, without any additional
steps. The last time I've checked, not even the latest IDEs did the last step
so smoothly -- I'd have to click around in the output window before.

~~~
guenthert
This is getting a bit off-track now, but I did use Turbo Pascal in the mid
eighties (on an Amstrad CPC464) too. That sure was an impressive tool, but it
seems to get more impressive as more time passes (and progress in IDEs trails,
perhaps inflated, expectations).

------
stas2k
Thanks to the author for this OCD-level work. I always find it interesting
that netlists out of die images are precise enough to run hardcore test
routines.

Z80 has a special place in my heart because of Speccy.

~~~
flohofwoe
To give proper credit (I think it's also mentioned in the blog post), the Z80
netlist was actually extracted by the visual6502 project. The data files are
available in the visual6502 github repository:

[https://github.com/trebonian/visual6502](https://github.com/trebonian/visual6502)

------
siraben
I love this project, having done a fair bit of Z80 programming myself. For all
it's baroqueness, the Z80 is still in common use in high schools and
universities in the form of TI-84 calculator series. Looks like this project
has a ZX Spectrum display emulator, it would be interesting to see if other
peripherals would be possible as well.

------
jhallenworld
Why not make a Verilog extractor? Then we can simulate it with standard tools.
I'm pretty sure Verilog can simulate NMOS since it has pullups.

Another option is to extract a Spice netlist.

~~~
duskwuff
Generally speaking, Verilog simulation tools don't support the transistor-
level primitives. You have to move up to at least the gate level to get
something that'll simulate at all; even then, certain special combinations of
gates (like registers) have to be specifically recognized to break
combinational loops.

~~~
cmrdporcupine
This was done for the 6502 from the Visual 6502 netlist, I suspect it could be
done from the Z80:

[http://www.aholme.co.uk/6502/Main.htm](http://www.aholme.co.uk/6502/Main.htm)

But it does look like a lot of work, and it's not like you get especially
readable Verilog from it.

Given other people have already built cycle accurate cores for these
processors that are readable and maintained, it may not be worth it.

~~~
duskwuff
The 6502 conversion was especially difficult, as the processor made use of
some wacky analog tricks (like capacitive storage) which can't be represented
in Verilog at all. The author of that conversion had to do a great deal of
manual work to detect these features and convert them to digital logic.

