Building your own CPU

Page 2 - Seeking answers? Join the AnandTech community: where nearly half-a-million members share solutions and discuss the latest tech.

Cogman

Lifer
Sep 19, 2000
10,277
125
106
I mean, you can do it, but why? What's the point of actually wiring everything together?

I guess whatever floats your boat. But I would suggest first starting off modeling the CPU using a HDL (Verilog, VHDL, etc). Then push it out to an FPGA to prove whether or not it works. Doing that will set you back around $400, but is certainly attainable. I've done VGA output and a rudimentary CPU for my undergrad doing just this, so definitely something you could do.

That is, honestly, the point I would quit at. But you want to do more, so at that point I would decide what the lowest level of hardware is you want to use. A Transistor? A logic gate? Whole components? Suffice it to say, you can basically choose whatever level of abstract you want to go at and there will be parts that exist which will fulfill that role. I would NOT do the transistor level (or really anything beyond an FPGA, you'll just make something slower, more power hungry, and more buggy).

Once you do that, a lot of the HDL software you can get for free will spit out schematic for you. I would take those and work with them to bust down to the lowest level you want to go to. Do note, however, that even FPGAs cheat. They have dedicated circuits for common tasks, it isn't all gate wiring.

And then, if you are really set on doing this, buckle up for the next year, because you are in for a treat of figuring out why the voltage isn't high enough in sector 40 of your CPU.

So yeah, design it first, test it on an FPGA, then work on laying out the actual circuits.

If you go the transistor route, I would highly suggest not buying 10000 individual transitors, at very least save yourself some headaches and use chips that expose 10/20 transistors per chip. Ditto for gates.
 
  • Like
Reactions: Aser

DigDog

Lifer
Jun 3, 2011
13,472
2,106
126
I want to try building my own CPU.

I'm not going to build a chip.
Chip-ee-uh.
central processing unit.

i've seen sooo many threads like this one. new guy registers on a forum, "i want to do IMPOSSIBLE THING, how do i do it".
then experienced people tell him "you cannot do it, it's stupid to even think of doing this, here is some non-stupid alternatives"
newguy: "I OWN THIS THREAD, I BAN YOU, YOU ARE A NOOB".

i probably did a few of these myself. i think at some point i wanted to custombuild a case with zero pc customization experience.

anyway, back to the thread.

Hi Gregow; i see you are new. Could you please be so kind as to answer a few questions about yourself?
1. how old are you?
2. what profession do you do?
(these are just so that we can make an educated guess as to the resources in budget, tools, workspace, and so on, that you might have)
3. what experience in this field do you have?
4. what do you need to complete this project for?
5. are you open to finding alternatives if this project proves to be not feasible?
 

sao123

Lifer
May 27, 2002
12,648
201
106
So here is my opinion, if the OP is serious about making his own CPU.
Designing a CPU can be a laborious task. What will your instruction set be? What will your register configurations be? What will your caching scheme be (if any)?
you should start by making a software emulator of how that cpu is going to function in order to test it out. It can be a proof of concept.
We did this for a college level design class, and it took about 3 months to complete just this aspect of it for a very rudimentary fake 16 bit CPU with only 6 registers and 14 instructions. (Load, Store, Add, Subtract, Multiply, Divide, NOT, AND, OR, XOR, Compare, Branch, BranchConditional, and Call.)

We planned it out, and fully built it in C++. then we coded and ran several machine language level programs through it just to test that all the instructions worked ass designed.
once you know all the bit patterns for all your instructions, then I guess you could begin making gate layouts to perform the operations etc.
but you need to start with the planning before you ever get to hardware.
 
Last edited:
  • Like
Reactions: Thebobo and Cogman

Red Squirrel

No Lifer
May 24, 2003
67,333
12,098
126
www.anyf.ca
That sounds like a fun project actually, I wish we had done stuff like that in my computer science course. We did touch on assembly though, but only the very basics.
 

LightningZ71

Golden Member
Mar 10, 2017
1,627
1,898
136
To echo Sao123 and Cogman, you need to sit down and decide some fundamentals of what you want to accomplish with the processor: How many bits is the data bus, address bus, I/O setup, instruction set type, number of registers, desired functional units, etc. Then, begin to describe it in a formal language or design platform. When I was in my computer engineering under-grad, we used Verilog to do our logical level prototyping and ran test programs against the logical design. We then translated that into something that could be burned to an FPGA and tested that. With a good FPGA, that may be all that you need to do to give you a functional "CPU" for most hobby projects. If you really want to go farther, you need to start researching the steps needed to convert the verilog into an actual layout, find a custom foundary that can do small batches of custom chips and is willing to do one off prototyping (it'll be expensive) and can help you with the conversion to their preferred design libraries. None of that last sentence is trivial and simplifies a lot of the process. I STRONGLY suggest against throwing money at that unless you REALLY need higher performance than a high quality FPGA can provide.

I'm not saying that it can't be done, as unlimited funds can make almost anything happen. I'm saying that it becomes prohibitively expensive in time and money when you move beyond an FPGA.
 
  • Like
Reactions: Thebobo

MrDoritos

Junior Member
Nov 25, 2017
2
0
6
Finding information is a very interesting task when looking for detailed information on a homebrew computer built at an IC level, not to mention at a BJT level. I've been interested in computer architecture myself, but before breaking out the soldering iron- I would prototype in a program. I've tried many things but I found that minecraft helps the best, it has everything you would need with redstone, you can make a 1:1 representation of the circuits itself. I would recommend building logic gates first in a program with transistors, then try 1 bit flip flops. Before going ahead, you should at least question your current knowledge of computer science itself. Like do you understand addressing, logic gates, electronics themselves? It would take some time to become proficient with electronics. The best part about creating your own standards and protocols, is that you don't have to take months of pain trying to lean back and understand them.

Harry Porter explains the basics really well in his video,
http://web.cecs.pdx.edu/~harry/Relay/
It may be an hour long but you will learn a lot.
 

Red Squirrel

No Lifer
May 24, 2003
67,333
12,098
126
www.anyf.ca
Some people have made some pretty crazy computers in Minecraft actually. One thing I always found annoying is how you can't have vertical redstone paths though. That would make things so much less tedious if you could go up a wall with redstone.
 

AMDisTheBEST

Senior member
Dec 17, 2015
682
90
61
I had done it before using bunch of light bulbs. It freaking works even if I can only manage a peak clock of 1 hertz per second because there is limit to how how fast my hand can turn on and off a switch in a minute without tiring. The “cpu” can add 2 bit integers. Isn’t that freaking impressive? Lol
 

AMDisTheBEST

Senior member
Dec 17, 2015
682
90
61
Now to be serious, if you wanna build cpu, you better be familiar with logic circuits.

Do you know all the elementary stuffs? like gates(and, nand, not ect), combinational circuits(Inverter, adder, decoder, encoder, multiplexer, ect) and sequential circuits(Flip flops, including jk, d, and such; finite state machines, including Moore, meleay and such) ?

You may also need to be familiar with a bit of math like binary conversion, one hot encoding, hexdecimals, Boolean algebras ect to understand the underlying theory.

At least that’s how my computer engineering course at my college teaches the stuff
 

Aser

Junior Member
Apr 10, 2016
2
1
6
There are a lot of people in this thread who really don't know anything and are trying to put you down. Don't listen to them. As long as your goal is realistic (building a basic 8-bit cpu, not an Intel rival), and you have some amount of intelligence and sticktoitiveness, then it is definitely doable.

Yes, it will definitely be a waste of time in the sense that you won't build anything really useful. However, you will learn a lot from it and it will be something that you can show off to colleges/employers in future.

Start out by looking at other homebrew cpu projects, and reading about computer architecture. Then follow Cogman's suggestions and start modelling stuff in HDL. I'd start with just building an ALU, and once you've done that, build up from there. If you make it to having a working CPU designed in HDL, try running it on an FPGA. Then look at adding peripherals like keyboard and a simple display.

Again, I agree with Cogman, I'd probably stop at FPGA, but you could go further and build it physically using discrete logic chips. Someone has even built a computer using discrete transistors (http://www.megaprocessor.com/).

An alternate path that might be easier to start on is to get a CPU like the Z80 and try and build a working computer around that. There have been a few homebrew projects like that, and I'm sure you'll learn a lot from that as well. Again, search around for existing projects. Hackaday.com is a good source for some of these.
 
  • Like
Reactions: Charlie22911

Ichinisan

Lifer
Oct 9, 2002
28,298
1,234
136
There are a lot of people in this thread who really don't know anything and are trying to put you down. Don't listen to them. As long as your goal is realistic (building a basic 8-bit cpu, not an Intel rival), and you have some amount of intelligence and sticktoitiveness, then it is definitely doable.

Yes, it will definitely be a waste of time in the sense that you won't build anything really useful. However, you will learn a lot from it and it will be something that you can show off to colleges/employers in future.

Start out by looking at other homebrew cpu projects, and reading about computer architecture. Then follow Cogman's suggestions and start modelling stuff in HDL. I'd start with just building an ALU, and once you've done that, build up from there. If you make it to having a working CPU designed in HDL, try running it on an FPGA. Then look at adding peripherals like keyboard and a simple display.

Again, I agree with Cogman, I'd probably stop at FPGA, but you could go further and build it physically using discrete logic chips. Someone has even built a computer using discrete transistors (http://www.megaprocessor.com/).

An alternate path that might be easier to start on is to get a CPU like the Z80 and try and build a working computer around that. There have been a few homebrew projects like that, and I'm sure you'll learn a lot from that as well. Again, search around for existing projects. Hackaday.com is a good source for some of these.
Yes. The video I linked is from the megaprocessor.com guy.

Maybe some discouraging advice warning of the difficulty is appropriate, but I really don't understand the hostility of many in this thread toward the OP. It definitely sounds like the type of interesting discussion we should have in the "highly technical" subforum. When I saw the topic, I immediately thought of the megaprocessor.com guy and thought "it's difficult, but it definitely can be done and has been done."
 
May 11, 2008
19,469
1,159
126
I want to try building my own CPU. Has anyone here done this?

The idea is to build something that can be programmed, with proper keyboard input and display output. I basically want to take this project from circuit to rudimentary OS that can execute simple programs. Instead of going nuts hooking wires to a breadboard I would like to make the design in software and transfer it to a printed circuit board (seems fairly cheap if you can make do with a simple PCB).

Anyhow, my first question is if you can recommend any good resources (sites/videos/books/etc) and if you know of any good designs that would be suitable for my purposes?

And second, can you recommend any good software for designing the CPU and transferring the circuitry to a PCB? I've looked at LogiSim which seems like just the kind of software I want, but I'm unsure as to how the designs can be converted to schematics for a PCB.

You might want to have a look at FPGA design.

Xilinx has a nice ide that even allows you to simulate your design before you actually implement it in an fpga.
It is free, after registration , you get a license file for student alike use.
https://www.xilinx.com/products/design-tools/ise-design-suite/ise-webpack.html
ISE® WebPACK™ design software is the industry´s only FREE, fully featured front-to-back FPGA design solution for Linux, Windows XP, and Windows 7. ISE WebPACK is the ideal downloadable solution for FPGA and CPLD design offering HDL synthesis and simulation, implementation, device fitting, and JTAG programming. ISE WebPACK delivers a complete, front-to-back design flow providing instant access to the ISE features and functionality at no cost. Xilinx has created a solution that allows convenient productivity by providing a design solution that is always up to date with error-free downloading and single file installation.

Here is a nice starters page :
http://www.fpga4fun.com/
https://embeddedmicro.com/tutorials/lucid/basic-cpu

edit:
A better link for a product family and ide (suited for windows 10 as well):
https://www.xilinx.com/products/silicon-devices/fpga/spartan-6.html

another edit:
Just use the ise webpack.
I just checked with the older version ise webpack i have (13.3) and it supports spartan 6 as well and a whole lot of older models.
 
Last edited:

Ankur Saxena

Junior Member
May 8, 2018
17
0
1
First collect your needs like RAM, Hardisk, graphics and then try building your own CPU according to your needs
 

hasu

Senior member
Apr 5, 2001
993
10
81
There are a lot of people in this thread who really don't know anything and are trying to put you down. Don't listen to them. As long as your goal is realistic (building a basic 8-bit cpu, not an Intel rival), and you have some amount of intelligence and sticktoitiveness, then it is definitely doable.

Yes, it will definitely be a waste of time in the sense that you won't build anything really useful. However, you will learn a lot from it and it will be something that you can show off to colleges/employers in future.

Start out by looking at other homebrew cpu projects, and reading about computer architecture. Then follow Cogman's suggestions and start modelling stuff in HDL. I'd start with just building an ALU, and once you've done that, build up from there. If you make it to having a working CPU designed in HDL, try running it on an FPGA. Then look at adding peripherals like keyboard and a simple display.

Again, I agree with Cogman, I'd probably stop at FPGA, but you could go further and build it physically using discrete logic chips. Someone has even built a computer using discrete transistors (http://www.megaprocessor.com/).

An alternate path that might be easier to start on is to get a CPU like the Z80 and try and build a working computer around that. There have been a few homebrew projects like that, and I'm sure you'll learn a lot from that as well. Again, search around for existing projects. Hackaday.com is a good source for some of these.

Here is another CPU built using basic TTL logic ICs: https://gigatron.io/
Pretty cool project and it should be very valuable for an EE student/enthusiast.
 

lakedude

Platinum Member
Mar 14, 2009
2,549
262
126
I've got an engineering background. For a number of years I did not own my own computer which coworkers found curious. The simple reason was that until computers and software became significantly complex they just were not fun. If I had to work on a non-fun system I was going to get paid or it wasn't happening. I found early computers tedious. I could write better code myself and I often did "tune up" the software to make it more to my liking.

At some point both the hardware and the software became very complex. Entire teams of very smart and creative people labor to make the modern experience happen. For me the game Mech Warrior marks the point at which I found computers amazing rather than tedious. Mech Warrior was far beyond what my own skills could have ever created.

Making your own CPU is going to fall into the first category. It is going to be expensive, tedious and what you have when you are done is going to be nothing compared to even a Raspberry Pi. The only reasons I can think of for doing any of this is just to learn or if someone is paying you.

A software simulator seems like the way to go on this.
 

legolas_tk

Member
Apr 16, 2008
90
7
71
I advise to find out what specifications you want for your processor? Processor requires registered, ALU, Combination logic, control unit.
What frequency does you want to achieve? How much cache L2/L3? How deep pipeline? 3Ghz CPU? Is it low power chip, than 1Ghz?
DDR4 controller or what kind of RAM?
I recommend using FPGA and program using VHDL/Verilog.