Maker Pro
Maker Pro

Building a CPU That Works

milesdavidsmith

Aug 28, 2012
7
Joined
Aug 28, 2012
Messages
7
I'm a computer programmer by trade, but I also dabble in electronics as a hobby (because it's the perfect hobby).

One project I've had in mind for a while is building a simple 8 bit CPU out ICs. I would be piecing this together with chips on the order of latches, decoders/encoders, basically just above discreet logic gates, plus a basic ROM chip with a microcoded instruction set. I have the basic architecture set up in a noodling program called LogiSim, but that's about it. So I know HOW they work and WHAT they are, that's not the issue.

I've tried once to assemble a CPU, but I'm not actually very good or experienced at real life electronics. I put together a register unit out of CMOS 8 bit latches, soldered directly to the board, with a decoupling capaciter at every chip and 1M Ohm pull down resistors at every contact.

The thing obviously didn't work.

My question is: What kind of methodologies / testing habits / tools tips techniques should I implement AT THE BEGINNING to get a circuit like this off the ground? What are some of the obvious things I should be doing that I'm not realizing initially? I thought about buying IC Sockets to protect my chips from the hot iron (I think that's what killed it last time) but they're so damned expensive for the amount of chips I need.

I'm a circuit noobie!

EDIT:

I can post pictures of the board after I get out of work.

I just need some help on assembling generally larger logic circuits.

Thank you very much in advance.
 
Last edited:

Raven Luni

Oct 15, 2011
798
Joined
Oct 15, 2011
Messages
798
Cool project! I hope you'll keep us updated or make a blog or something. I'm the same as you, programmer and electronics hobbyist. I've often wondered about building a CPU from scratch but I've got enough to keep me busy at the moment besides I still havent finished my Z80 based computer.

Anyway - one bit of advice regarding methodologies: NEVER solder ICs directly to the board (unless they're surface mount and you have the right tools). Use sockets wherever possible. That is pretty standard advice but I found out the hard way when I fried a counter in my bat detector. It was only one pin that was misbehaving but that was enough to render it useless and necessitate desoldering (almost futile with that many pins) and having to lever and rip the thing out to replace it (with a socket this time).

As for building the thing, I recommend presettable binary counters over latches for all your registers - that makes things a whole lot simpler. I use the 74HC193 alot which is a 4 bit (stackable) counter but for 8 bit you might want something like the 74F579 which I think also does tri state I/O.

The ALU will be the hard part. I cant imagine any other way of doing that than having a separate circuit for each unique instruction. It would probably be easiest with a fixed instruction length say 16 bits which includes an opcode and any register numbers (with a couple of numbers to represent a memory read or write, whether a register is being used as a pointer etc). Use demuxes for selection. Extra bytes may have to be read for addresses and operands - thats where your control bus comes in. You'll want to signal readiness for the next instruction etc.

Shift and add are the only 2 arithmetic operations you need (maybe rotate as well). The rest can be done in software (multiplication loops, 2s compliment etc). Shifting is a trade off between speed and complexity. The easiest way is to use a shift register and counter but if youre interested, here is a nice article on barrel shifters: http://www.princeton.edu/~rblee/ELE572Papers/Fall04Readings/Shifter_Schulte.pdf
 

milesdavidsmith

Aug 28, 2012
7
Joined
Aug 28, 2012
Messages
7
Wow - Great reply!

Also, I looked over your project on this website and if you have videos on youtube, I think I've seen them. If so, your Z80 project was one of those that got me inspired to do this stuff anyway, so awesome.

Anyway, I thought that it was probably the sockets that did me in. I'm going to start something like a blog and maybe load up my logisim files, someday.

The most important methodology is always just to keep trying until you get it right. I guess it's time to buy another batch of chips and boards, maybe I'll prototype this time. Do you think it's absolutely essential to have a logic analyzer? Because all I've got is a 'scope from the early 1970s...

P.S. What's a bat detector? Does it detect the flying mammals or the baseball device? I could honestly take that both ways!
 
Last edited:

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
Check out how it was done in the EDUC-8.

You could also look at how the various people who've build computers out of relays have done it.
 

milesdavidsmith

Aug 28, 2012
7
Joined
Aug 28, 2012
Messages
7
Steve, thanks for the information. Interestingly enough, Harry Porter's relay computer was the first CPU I ever spent all night reading about. I actually tried to make a relay CPU a year or so ago (so technically, the CMOS was my second attempt), but the 4 bit relay ALU cost nearly 60 dollars just by itself!

Plus I figured there was no way it would ever get over 30 hertz, so why spend all that money?

Thanks, too, for the article. I've never read this one before! This is really awesome. Sort of like the Altair, which I have always wanted to play with.
 
Last edited:

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
The Educ 8 could still be built today, although I'd use CMOS.

The boards are all laid out by hand (literally). There are some issues with getting the same edge connectors, but you could probably redesign them to use something else.

Also some of the TTL chips are hard to locate, and the alternatives have a different pinout, so you'd have to do more layout changes.

As to why you'd bother with 30Hz clock, just to show you can. An Educ 8 has an entire 256 BYTES of RAM, so dollar for dollar it's not exactly going to compete with anything.
 

BobK

Jan 5, 2010
7,682
Joined
Jan 5, 2010
Messages
7,682
If the idea is just to design a cpu at the gate level and then realize it in hardware, I would suggest that an easier approach would be to use an FPGA development board. No soldering required, and the result would be something that would perform, well, like a modern cpu.

bob
 

milesdavidsmith

Aug 28, 2012
7
Joined
Aug 28, 2012
Messages
7
@Steve, the idea was (at first) to build a 30Hz relay unit to hear beautiful rhythmic clicking. Then it just got too expensive per relay, and I knew I'd want to build a faster one someday anyway. The EDUC-8 looks like a really great option, although I'd modify the addressing system because 256 Bytes of ram is honestly completely useless for what I wanted to do. After I build a CPU, my intention was to begin to port / design something along the lines of FreeBSD (a whole new learning curve).

@Bob: The architectural design has been thought out and simulated. I was considering something along the lines of FPGA or perhaps a circuit crutched by microcontrollers, but it's not my goal to design from the gate level, anymore. I'm fine with buying latches, counters, adders, etc. for my implementation. The idea for me was more along the lines of just "hey, how the heck are you supposed to put ICs together so that they work, anyway?" and I figured the only way to actually learn this is to have people who know things just spew information of all kinds at me. I'm trying to get a feel for the non-intuitive parts of digital electronics.
 

milesdavidsmith

Aug 28, 2012
7
Joined
Aug 28, 2012
Messages
7
Do you guys think that I should go with a homemade PCB, a prototype copper laminate board, or order one from an eagle file?
 

CocaCola

Apr 7, 2012
3,635
Joined
Apr 7, 2012
Messages
3,635
Do you guys think that I should go with a homemade PCB, a prototype copper laminate board, or order one from an eagle file?

For me and the low cost of batch PC boards there isn't even a question... I would get a professional one run... But, there is the fun and challenge in making your own, I have just moved past that point and making my own has little appeal nowadays except for an immediate need board...
 

Raven Luni

Oct 15, 2011
798
Joined
Oct 15, 2011
Messages
798
No I havent made any videos. I'm sure a few people have done this though :)
 

Raven Luni

Oct 15, 2011
798
Joined
Oct 15, 2011
Messages
798
For me and the low cost of batch PC boards there isn't even a question... I would get a professional one run... But, there is the fun and challenge in making your own, I have just moved past that point and making my own has little appeal nowadays except for an immediate need board...

How much does it cost on average to get one done anyway? Among the plans for my computer project are to make a CNC machine which would enable me to move from strip board to PCB and possibly surface mount later.
 

CocaCola

Apr 7, 2012
3,635
Joined
Apr 7, 2012
Messages
3,635
How much does it cost on average to get one done anyway?

The batch service I primarily use is $5 a square inch and you get 3 copies of the board for that price, in a pretty deep purple color...

So for $5 you could get three 1x1 boards... And in the US shipping is included in that price! $5 for international shipping...

On a more practical sized board, say a 2 x 3 board, that is $30 for three or $10 a board...

http://oshpark.com/

There are many other batch PCB services out there as well, I'll list a few companies that I have experience with... There are of course many others...

Sparkfun's PCB service http://batchpcb.com
Sure Electronics http://www.wondom.com/products
Seeed Studio's http://www.seeedstudio.com/depot/fusion-pcb-service-p-835.html?cPath=185
 
Last edited:
Top