Jump to content
IGNORED

Building a z80 or 6502 computer?


mehguy

Recommended Posts

Hello everyone,

 

I've taken interest in building a computer from scratch for a few months now. But I think it's come down to 2 processors. A z80 or a 6502 processor. Which one shall I go with? Is one easier than the other? Just as a little perspective, I'm currently learning HTML in a course and know basic electrical theory. The goal of this is to be able to have a computer with a composite output to have it displayed on a tv running microsoft basic or cp/m. Where should I even start with this?

Edited by mehguy
Link to comment
Share on other sites

I'd say go with the 6502. Slightly newer architecture (by what, 2 years?) but in that time they came up with some neat features. Slower clock speed, but you can do more things per tick due to having a richer instruction set. Probably more support out there for the 6502, too--tons of books for the Apple, Commodore, Atari and BBC machines for programming. The Z80 was used in a lot of CP/M builds, the early TRS-80 computers, the Coleco ADAM, and the Nintendo Gameboy (ok, it was a brother of the Z80), so not as much programming happening there, so less information.

 

If you wanted to ever put faster chips in your build, then the 6502 wins again. If you can find it, a WDC 65C02 chip is a drop-in replacement (plus a change in crystals). If you can find them. They went up to 14MHz, I believe.

Link to comment
Share on other sites

With the Z80 still being made today and having been used in tons of computers(you can add the MSX computers, the Amstrad CPC and PCW, the Bally Astrocade, the Master System (I can add the Megadrive and Neo Geo where it's used as a sound processor) and some consoles, I think there is at least as much infos on Z80 tricks and programming than there is on the 6502.

 

If you wannna have a sample of what you could do, check out the ZX80 and 81 - they are barebone computers, sold as DIY kits, with nothing but a Z80 and RAM on it, even the video display is made of gates (at least it's how some Soviet Spectrum clones did it).

 

I guess that the choice will be mostly personnal for you - what do you feel more comfortable with and what the people that can help you know best.

Link to comment
Share on other sites

I'd say go with the 6502. Slightly newer architecture (by what, 2 years?) but in that time they came up with some neat features. Slower clock speed, but you can do more things per tick due to having a richer instruction set. Probably more support out there for the 6502, too--tons of books for the Apple, Commodore, Atari and BBC machines for programming. The Z80 was used in a lot of CP/M builds, the early TRS-80 computers, the Coleco ADAM, and the Nintendo Gameboy (ok, it was a brother of the Z80), so not as much programming happening there, so less information.

 

If you wanted to ever put faster chips in your build, then the 6502 wins again. If you can find it, a WDC 65C02 chip is a drop-in replacement (plus a change in crystals). If you can find them. They went up to 14MHz, I believe.

?

The 6502 came out the year before the Z80.

The 8080 came out before the 6502 and was in the first CP/M machines.

The Z80 can run 8080 code but it has more registers and instructions.

 

The 6502 has no 16 bit support unless you chose the 65816, but it requires switching between 8 and 16 bit modes for registers since it doesn't add separate instructions for it.

The Z80 has 16 bit support and can alternate between 8 and 16 bit use of registers from one instruction to the next.

 

The Z80 has a larger instruction set than the 6502, due in part to the greater number of registers and separate 8 and 16 bit instructions.

 

Compiled languages usually pass parameters and allocate temporary variables, etc... on the stack.

Neither CPU supports stack relative addressing which makes both CPUs use index registers to access variables on the stack.

That makes variable access slower.

The 6502 only has a 256 byte hardware stack located at a fixed address.

That is really small for compiled languages and makes multitasking more complex since you can't have a different stack for each task.

6502 compilers often manage a larger stack in software to compensate for the small stack, which is slower than using normal stack instructions.

The 65816 has a 16 bit stack pointer in native mode so it can be placed anywhere in the first 64K and it supports stack relative addressing making compiler support much better.

The Z80 has a 16 bit stack pointer, making it easy to put the stack anywhere in memory or to switch between different stacks for multitasking.

While the 6502 requires fewer clock cycles per instruction, the Z80 doesn't have to access RAM every clock cycle.

The Z80 basically breaks each instruction into smaller steps that are executed internally.

The result is that a 4MHz Z80 uses about the same speed RAM as a 2MHz 6502.

Newer Z80 variants like the HD64180/Z180 or later use a larger ALU and an instruction prefetch to reduce the number of clock cycles required per instruction.

A Z180 also has a multiply instruction, MMU, DMA, etc...

A 6 MHz Z180 is supposedly twice as fast as a 4 MHz Z80 and some Z180s can be clocked at 33 MHz.

There are now pipelined Z80 derivatives that are even faster.

 

I/O is handled through memory mapped hardware on the 6502.

The Z80 has I/O ports which can simplify address decoding of hardware.

 

If I were to build a new system, I'd use a 65816, Z180 or some other Z80 derivative.

The Z180 has the advantage of having some built in hardware (serial ports, etc...) so you don't need as many chips to build a complete computer.

 

BYTE magazine had some articles on building an HD64180 based system in 1985, the SB180.

http://www.miredespa.com/sb180/

Add a Yamaha VDP plus video RAM and you have a pretty decent system.

Link to comment
Share on other sites

Is it particularly hard to build one? Also I have a timex sinclair 1000 which is based on the zx81. That would be a good reference on how its made.

I guess it would depend on how much you know about circuits and the complexity of the project.

If you are just copying someone else's project, using a pre-printed circuit board, it's a bit like putting together tinker toys.

If you want to wire wrap a computer on perf board with your own design... you should know what you are doing.

 

The SB-180 design is nice because it only needs serial ports. It's basically a CP/M system that communicates through a serial port to a terminal.

No keyboard, no video... easy.

 

I suggested the Yamaha VDP because it's just a few ports to address and you don't have to worry about memory mapped video conflicts.

 

I'm not sure what I'd use for a keyboard controller.

Link to comment
Share on other sites

I'd say go with the 6502. Slightly newer architecture (by what, 2 years?) but in that time they came up with some neat features. Slower clock speed, but you can do more things per tick due to having a richer instruction set. Probably more support out there for the 6502, too--tons of books for the Apple, Commodore, Atari and BBC machines for programming. The Z80 was used in a lot of CP/M builds, the early TRS-80 computers, the Coleco ADAM, and the Nintendo Gameboy (ok, it was a brother of the Z80), so not as much programming happening there, so less information.

 

If you wanted to ever put faster chips in your build, then the 6502 wins again. If you can find it, a WDC 65C02 chip is a drop-in replacement (plus a change in crystals). If you can find them. They went up to 14MHz, I believe.

This is a whole pile of nonsense, as James pointed out.

 

Generally speaking, the z80 seems to be the easier of the two to interface to a variety of other chipsets. I typically get away with a single IC being used for decoder logic, that is both memory and I/O.

 

How hard it is can be said to be totallly dependent on what you want to do with it, what features you want it to have, and how thorough your design is. Simplistic machines, Like Grant Searle's 7-chip design are comparatively easy when you put it against any of the more complex designs. That said, I have built Grant's z80 computer, and personally believe it has stability issues. Mine works, with the exception of the serial port that I'm still trying to debug.

 

Currently, as in this very moment, i'm working on a board layout for a 'non-Grant' design, with dual UART, RAM, ROM, 8-bit input port, 8-bit output port, and a USB interface for serial communication. It uses 8-chips as follows:

 

Z80 20mhz

32k EEPROM

32k SRAM

Z80 DART (Z8470)

FT232RL

74HCT245

74HCT373

GAL16V8 (decoding logic)

And a handful of passives and a Oscillator.

 

It's a design that I'm doing as I lay the board out. So it's not guaranteed to work, but based on my previous builds just changing the I/O, which is straight foreword. Here is an idea of where I'm at in the process. Basically I'm down to designing the USB.

Link to comment
Share on other sites

How hard it is can be said to be totallly dependent on what you want to do with it, what features you want it to have, and how thorough your design is. Simplistic machines, Like Grant Searle's 7-chip design are comparatively easy when you put it against any of the more complex designs. That said, I have built Grant's z80 computer, and personally believe it has stability issues. Mine works, with the exception of the serial port that I'm still trying to debug.

 

I made one too, my serial ports work fine, but you really gotta watch the clock, the oscillator setup is very dependent on capacitance and distance (read wire length) and will start to echo, which wont mess with the z80 as much as it will the SIO

Link to comment
Share on other sites

I made one too, my serial ports work fine, but you really gotta watch the clock, the oscillator setup is very dependent on capacitance and distance (read wire length) and will start to echo, which wont mess with the z80 as much as it will the SIO

I think it has more to do with with the 6850 itself in my case. These are not the 68B50s, just the plain Jane 1mhz versions. If I boot it up I get Garbage, unless I am using the Arduino serial terminal, then it displays correctly. However, it doesn't respond to input.

 

I built it about a year ago. Just got around to digging it out and trying to mess with it. Tried out 5-6 different UARTs, all had the same problem. The only difference between my build and Grants is that I patched his ROM to work with a 1.8432mhz XO oscillator instead of the 7.something Mhz. When checking with my Saleae logic analyzer it show the z80 is running and executing code. However, I do not show any activity on the RX line, or the handshaking lines. So I suspect there that there is a bug somewhere that is preventing the 6850 from shifting the polarity of the handshaking signals, and as a result, it's not receiving anything from the terminal. I ordered some 68B50s to see if it fixes the problem. But considering they are old and of unknown origin, there is no way to tell if they are working or not.

 

My experience is many old chipsets were pulled from working systems for a reason....they were faulty. It's a little hard to find new chips of that make in this day and age.

Link to comment
Share on other sites

What are some good resources to read?

Well, if you're looking at doing a z80, then http://z80.info is the place to go. It has most of the information that you will need. Another is Grant Searle's website, found here: http://searle.hostei.com. Obviously reading the datasheet for the z80 family is a must: http://www.z80.info/zip/z80cpu_um.pdf. As well as the actual datasheets for the devices, along with any third party devices you decide to use (as mentioned above, Grant's z80 uses the Motorola 6850 UART).

 

What it comes down to, is you have a lot of reading and research to do. And if you're going to design your own, you'll need to do it.

Link to comment
Share on other sites

Well, if you're looking at doing a z80, then http://z80.info is the place to go. It has most of the information that you will need. Another is Grant Searle's website, found here: http://searle.hostei.com. Obviously reading the datasheet for the z80 family is a must: http://www.z80.info/zip/z80cpu_um.pdf. As well as the actual datasheets for the devices, along with any third party devices you decide to use (as mentioned above, Grant's z80 uses the Motorola 6850 UART).

 

What it comes down to, is you have a lot of reading and research to do. And if you're going to design your own, you'll need to do it

 

what version of the z80 should I use?

Link to comment
Share on other sites

Generally speaking, it depends on two things. How fast you want it to run, and how much power you need it to use. The low current 20mhz models that are sold cheaply on various auction sites will be more than enough for most applications. If you want to simplify things, like James suggested, you can use one of the various flavors of the z180. Again, it depends on what you're trying to do.

Edited by jdgabbard
Link to comment
Share on other sites

Generally speaking, it depends on two things. How fast you want it to run, and how much power you need it to use. The low current 20mhz models that are sold cheaply on various auction sites will be more than enough for most applications. If you want to simplify things, like James suggested, you can use one of the various flavors of the z180. Again, it depends on what you're trying to do.

Where on that z80.info site should I start reading?

Link to comment
Share on other sites

You could implement a driver in MESS, which has now been combined into MAME. It has support for virtually every chip out there used in arcades and also computer systems.

 

This will definitely help once you start writing/testing the operating system as MAME comes with an excellent debugger.

  • Like 1
Link to comment
Share on other sites

A little on topic...not entirely... But I thought I'd share a video since I got one of my projects running today. It still needs a little work to get the expansion port working (planned for serial I/O and storage), but it is operational. I haven't written the assembly code yet. It is currently examining locations in RAM and displaying the default garbage. I need to write a Memory Clearing routine... But hey, it's been a fun weekend getting this thing going.

 

  • Like 3
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...