Homemade 8bit CPU & computer from scratch project - Page 1
Forum section: electronics / projects

author: PauloConstantino
author_rank: Regular Contributor
timestamp: May 31, 2017, 12:09:16 am
content: Hi friends.I just wanted to share my project with you guys. Maybe give out some inspiration like I was inspired to do this before.Some time ago I decided to build a CPU from scratch, using only the 74HC series of IC's: gates, counters, flip flops and so on.It took me some time to get the design to the point I wanted. It would be built on breadboards at first for testing, and then probably transferred into wirewrap boards. I decided for an 8bit CPU because a 16bit one would require just too much wiring. The first CPU I designed was pretty much an 8085, with interrupts and DMA and most of the 8085 instruction set.However, it would take a good while to build, so I decided to design a simpler CPU, that I could build in a few days, with just basic instructions for arithmetic and logic, data transfer between registers and memories and so on. No stack, or calls. This CPU is microcoded, meaning the control word that controls the CPU is stored in ROMS (4 ROMS in this case).There are 2 8bit registers A and B, an 8bit ALU, 256 bytes of RAM (), a programming mode whereby you can enter programs into the RAM for execution, and that's basically it. There are only 256 bytes of RAM because this simplified the microcode for me, so I could finish it faster, but it's easy to expand the memory system and I will do this later.I built everything in about a week, and designed a program in C to compile the microcode so I could store it in the 4 ROMS. Basically all instructions in this CPU are customizable, and one can create new instructions up with to 64 clock cycles. One only needs to give the instruction a number from 0x00 to 0xFF, and declare the control words for each clock cycle for the nstruction.I still have some work to do. I still need to add a few input/output ports, an HEX keypad for input, and a few LCD's for output.But here is a photo of the result so far.If you are interested, I can send you the schematics.Thanks a lot!

author: mariush
author_rank: Super Contributor
timestamp: May 31, 2017, 12:23:15 am
content: That thing SCREAMS to be moved over to prototyping boards, at least for the parts that you won't change often.Here's a suggestion :http://uk.farnell.com/roth-elektronik/re520-hp/pcb-prototyp-fr2-stripes-2-54mm/dp/1172154Good quality, very easy to separate chunks of strips just by cutting or by enlarging the hole with a drill, and very easy to add solder to strips to increase the current and lower track resistance.And you could also use potentially more reliable 2.54mm spaced connectors and ribbon cable.. here's some suggestions :http://uk.farnell.com/w/c/cable-wire-cable-assemblies/cable-assemblies/ribbon-cable-flat-cable-assemblies?connector-pitch=2.54mm

author: PauloConstantino
author_rank: Regular Contributor
timestamp: May 31, 2017, 12:35:32 am
content: Quote from: mariush on May 31, 2017, 12:23:15 amHello Mariush,Thanks for your comment. I am looking forwards to transferring the design into permanent boards once the testing is completed. I have around 8 high quality wirewrap boards here ready. The only annoying thing for me is that these wirewrap boards are not that friendly for making buses because the pins are all spread out, so it requires connecting the pins together to form buses.Here's a photo:

author: MK14
author_rank: Super Contributor
timestamp: May 31, 2017, 01:48:44 am
content: Has it got a shift RIGHT instruction (now, as what I think was your earlier one, seemed to be missing it) ?Hence divide by 2.Although it may not have a direct shift left, something on the lines of (your) ADD A,A is effectively a shift left instruction.

author: mariush
author_rank: Super Contributor
timestamp: May 31, 2017, 02:59:45 am
content: Quote from: PauloConstantino on May 31, 2017, 12:35:32 amThose cards are nice but I think you should save them for other projects.These prototyping boards with continuous strips would be far more suitable and i don't think your project would takeadvantage of some of the benefits of wirewrap vs soldered connections. The strips of copper would also allow to quicklyrearrange wires (traces) just by using tiny pieces of solid core wires (jumper wires) on the top side and the 0.1" spacingallows you to use cheap connectors.you could also use right angle connectors at each pcb edge to make a sort of backplane/bus (to use a flat ribbon cable to connectmultiple such cards together.You could also stack the easier with regular spacers (by enlarging some holes in corners)The wirewrap pins would still make your boards hard to follow (look like a forest of wires and pins)// m key acts up on my laptop. apologies for missing letters.

author: PauloConstantino
author_rank: Regular Contributor
timestamp: May 31, 2017, 03:09:01 am
content: It doesn't have Shift instructions, but they can be implemented easily in hardware or even software. Why ?

author: PauloConstantino
author_rank: Regular Contributor
timestamp: May 31, 2017, 03:13:55 am
content: Quote from: mariush on May 31, 2017, 02:59:45 amWhat do you mean my project wouldnt take advantage of wirewrap boards ?

author: MK14
author_rank: Super Contributor
timestamp: May 31, 2017, 03:24:53 am
content: Quote from: PauloConstantino on May 31, 2017, 03:09:01 amWHY?:Part1 of 2Because you need them, to perform things like multiply/divide and other functions.It CAN be done in software. But that could end up being considerably slower than having them as built in instructions.WHY?:Part2 of 2I noticed they seemed to be missing, when I read through your list of instructions (from maybe an older version).If your intention is just to have something which is educational and a bare minimum, to get an 8 bit processor to work. I can see why you are missing them.But if your intention is to have a reasonably complete set of instructions, then they would be best included with it.

author: PauloConstantino
author_rank: Regular Contributor
timestamp: May 31, 2017, 03:33:16 am
content: Where did you read about my work before? I don't remember posting it in here before.I know it can be done by software, that's why I omitted it from this simple CPU. The point of this CPU was that it would be quick to build. The other CPU I designed does have shift instructions.

author: MK14
author_rank: Super Contributor
timestamp: May 31, 2017, 03:53:53 am
content: Quote from: PauloConstantino on May 31, 2017, 03:33:16 amI did NOT link to where, as I presumed you wanted to keep quiet about other stuff, you may or may not have published on the internet (not on this forum). (It is NOT for me, to decide what you want to reveal or not, on this forum).The list of instructions, are the one included at the bottom, just after the big schematic of the whole thing.It has many instructions, but does not seem to mention any bit shifting ones. (It could be the list changed in time by you, but was not updated, online).It does mention arithmetic, compare, various conditional branches, subroutine, move, stack and maybe others, in the list.If you are going 100% minimalistic, totally bare bones, then I can understand why some things are missing from it. No problem.

author: PauloConstantino
author_rank: Regular Contributor
timestamp: May 31, 2017, 04:02:44 am
content: Ah so you saw it on my website! Cool. That's nice. That CPU was actually the very first I designed, and it's outdated and actually not a good one. I just haven't updated the website yet!

author: MK14
author_rank: Super Contributor
timestamp: May 31, 2017, 04:29:11 am
content: Quote from: PauloConstantino on May 31, 2017, 04:02:44 amYes, that is where I got the extra details from.At least one person, who designed an early, homebrew all TTL computer (and now works for Google as a result). Actually powers his entire website, via that same computer. He even allows random users (us lot), to log onto it for free, and play around with his minimalistic, Unix (like) environment.I've had great fun (in the past), both reading, watching (youtube) and even logging in and playing with his homebrew TTL computer. It is really cool!"Google engineer builds PC from scratch"

author: PauloConstantino
author_rank: Regular Contributor
timestamp: May 31, 2017, 06:23:26 am
content: I know Bill Buzbee and his Magic-1. He's an online friend of mine, and his work has inspired me a lot. I've exchanged many e-mails with him!He's a very cool guy and a lovely person. Very friendly and helpful. Thanks for sharing anyhow. I love his videos!

author: MK14
author_rank: Super Contributor
timestamp: May 31, 2017, 06:28:23 am
content: Quote from: PauloConstantino on May 31, 2017, 06:23:26 amI can imagine, he is a very nice and extremely interesting/knowledgeable/inspiring person to know. Congratulations!It was interesting to find out, how he used a reconfigurable compiler (C) to make a compiler available for his one of a kind computer (instruction set). Then compiling a minimalistic operation system for it (Unix like), is just magic! (excuse the pun with the computers name). Hence making his computer, rather useable, even by people anywhere on the planet.I would love to do something like that. But there is limited time (24/7, 52 weeks and 0..200+ years left), and so many other projects I can/could do ...But maybe one day, I might.

author: PauloConstantino
author_rank: Regular Contributor
timestamp: May 31, 2017, 06:48:44 am
content: It's simpler than it seems. He is a compiler guy, so retargetting the compiler was easy for him. The most suttle part of all the design is handling interrupts and DMA, but that's not so difficult either. The computer I designed is very similar to his (not this one I posted, this is the simplified version), except that it is 8bits rather than his 16bit one. 16bit requires double the amount of wiring so it's terrible to build with breadboards or even wirewrap. However, designing a pcb kinda takes the magic away from doing it by hand. It took him 4 years or so to complete his computer!If you want to build a simple one I can send you my schematics so you can have a look what it is about in case you don't know.

author: MK14
author_rank: Super Contributor
timestamp: May 31, 2017, 07:12:23 am
content: There are so many different ways of doing things like that. I can be torn by all the different possibilities. I will give you some actual examples:==>>Doing it all on an FPGA (or CPLD). It means that even quite big and complex designs can be experimented with. With little worries about costs, it getting too big physically or how long it will take to physically build etc.It also will probably run at a much higher clock speed, than something built out of transistors or TTL.==>>Going all (or mostly) discrete transistor. But one has to be extremely careful, to avoid such a project going out of control. Because it can soon become impractically big (and hence very expensive and power hungry). Which someone else demonstrated here:Quotehttps://www.theregister.co.uk/2015/06/23/brit_mega_processor/==>>TTL like you and others. But the older TTL (such as LS) are getting harder, and harder to obtain, and even HC types are not necessarily fully available, especially in through hole.==>>Doing a retro like, Microprocessor, build. E.g. Motorola/Hitachi 68000 or Z80/6502/6800 etc. These are probably old enough now, to count as retro (vintage like).I think you can buy, Motherboard kits. Which allow you to build (as a kit), a complete, vintage 8086, working PC motherboard. I am very tempted by these. They are something like $150+ or so. Hence you can make an entire vintage PC (8086), yourself, with the kits.==>>Don't get me started talking about an all valve/tube, retro cpu/computer design, with core memory. If you think that is a totally crazy idea, then look through this forum. Because at least one of the posters, has wound his own core memory devices, and put youtube videos, of his experiments with them. Which were then used to make a useful project for him.--------------------------------------------------------------------------------------------------------------------------------Currently, I favor starting with the FPGA route. Because learning more about FPGA's, is a useful/fun skill, anyway. It is a relatively cheap way, as well. With the FPGA obtainable, ready assembled in developer board format.If you get it dramatically wrong, it is real quick and easy to correct. Unlike large/complicated physical builds.Thanks for the kind offer of the schematics. But a big part of the fun element for me, would be designing it, completely by myself.

author: PauloConstantino
author_rank: Regular Contributor
timestamp: May 31, 2017, 07:17:27 am
content: I know the megaprocessor too. That guy is brave. I think FPGA's also take the magic away. Hardware design is fun for hardware engineers. Coding FPGA's is halfway between software and hardware. Anyway, the fun for me is designing it by hand using logic gates.Yes I agree about the schems. But if you're starting out, you need to have an idea of how it is done, because it's not very obvious how to start.

author: MK14
author_rank: Super Contributor
timestamp: May 31, 2017, 07:32:35 am
content: Quote from: PauloConstantino on May 31, 2017, 07:17:27 amTo me it is fairly obvious how to do it. (Probably because of other digital/computer stuff, I have learnt about, experienced or been involved with in some way, such as building in kit form or something). Or even reading about how such things are done, over the years. So maybe I'm claiming it is "obvious", but it was partly taught, really.Until you start talking about super fast floating point multipliers/dividers, such as what the Cray1 super computer had. But maybe it is not that hard to do, in practice.I understand what you mean, as regards the FPGA. But they do allow you to have many millions or even 10+ millions of custom gates. Which would probably be impracticable, to build physically. Hence allowing sophisticated 64 bit, pipelined cpus to be implemented.It can also compute things, VERY quickly. Because of reasonable clock frequencies (e.g. > 100 MHz) and mass parallelable/pipelined circuits.But I agree, building it out of raw parts, such as Valves/tubes, Transistors, TTL, ECL, Relays etc. Is going to be a lot more fun.Projects/career wise. FPGAs are a useful skill, to have/improve. So you sort of get two birds with one stone, by doing it with FPGAs.

author: fourtytwo42
author_rank: Super Contributor
timestamp: May 31, 2017, 08:16:10 am
content: Quote from: mariush on May 31, 2017, 12:23:15 amHi PauloWhat a wonderful project, reminds me very much of life in the 70's surrounded by these things, I used to both repair them and fix design faults, later still design my own, mostly 74S & H (HOT). Out of interest what clock speed re you able to obtain with that construction ?

author: PauloConstantino
author_rank: Regular Contributor
timestamp: May 31, 2017, 08:52:51 am
content: Quote from: fourtytwo42 on May 31, 2017, 08:16:10 amHi there and thanks. I'm still using the manual clock for testing but I predict it will reach 4MHz or so. Glad you like it! The point of it is being vintage indeed:)

author: fourtytwo42
author_rank: Super Contributor
timestamp: May 31, 2017, 09:13:01 am
content: Hi Paulo I got the wrong quote! ALU's we used to use were 74S181 4 bit in big package, they were called MSI (Medium Scale Integration) vs SSI (Small Scale Integration) for gates etc. I still have the schematics (somewhere) for a 16 bit 0.8MIP CPU with no PALS circa 1972 that I used to do a lot of work on

author: MK14
author_rank: Super Contributor
timestamp: May 31, 2017, 09:28:34 am
content: Quote from: fourtytwo42 on May 31, 2017, 09:13:01 amWas it an ICL 1904S, with a 500ns semiconductor store ?https://en.wikipedia.org/wiki/ICT_1900_series

author: fourtytwo42
author_rank: Super Contributor
timestamp: May 31, 2017, 09:38:30 am
content: Quote from: MK14 on May 31, 2017, 09:28:34 amNope it was a Computek 200 intelligent terminal used to spoof mainframe remote batch terminals and the like, loads of synchronous comms softwarememory was silicon, high voltage drive 1103's I recall using MH0026 clock drivers that would regularly burn. At that time I preferred working on core stores in the likes of Data General Nova's but I am drifting off thread here....sorry Paulo

author: PauloConstantino
author_rank: Regular Contributor
timestamp: May 31, 2017, 01:04:27 pm
content: Quote from: fourtytwo42 on May 31, 2017, 09:38:30 amI'm using the 74HC181 ALU in this project.

author: PauloConstantino
author_rank: Regular Contributor
timestamp: May 31, 2017, 01:07:16 pm
content: I've attached the schematics here as an Image for those interested.