Sign in with
Sign up | Sign in
Your question

Build a basic CPU

Last response: in CPUs
Share
a b à CPUs
July 2, 2011 12:59:24 AM

Hello THG Community.

This is dogman_1234 here. I will say you guys are the best. No where on this site have people been mean in any way,( except the occasional jerk,) but none the less, good job. I am also pleased as to how knowledgeable you all are. It amazes me how well research THG is.

As you may all know, I have been on this site since Halloween of 2009, pretty short time but long. I have in that time watched and witnessed what you guys have said.


*I come with a challenge.*


Recently, I have been researching and finding out what makes a CPU work. I though, "you know, it would be cool to make one by hand." Well, possibly...I could. Issue: Tyranny of numbers. Another issue: How to build the CPU.


This is where you guys come in.

Here is my plan:

While I may research how to build it, it come out that Google is not much of your friend after all. I figured that a good looking crew like you could help me develop a simple 4 bit Very Basic Processing System,(VBPS) Central Processing Unit,(CPU). I do not ask for much on this, as I will not run software on it. It will, however, perform basic processing in the bits,( up to 4).

Here are the requirements:

*Must be made by hand
*Cannot use already made IC's
*Must be made with transistors that are reliable and can function as gates.
*Includes Light Emitting Diodes,(LED's) that will act as an output for the calculations
*Will set-up many of them together to 'grid' them for better processing,( more FLOPS)

I would appreciate your help, and also your lack of negative criticism.

Thank You, and have a nice day.

Dogman_1234

P.S. I do not have a reward system on mind, but I do not think I will have one available, sorry.

More about : build basic cpu

a b à CPUs
July 2, 2011 8:48:33 AM

There was just an article on the web at www.HardOCP.com about some relatively young guy building his own 4 bit cpu a few weeks ago....; it used one of the DIY electronic kit boards, and was strictly an all wirewrap affair on it's underside for all connections.
a b à CPUs
July 2, 2011 10:01:15 AM

Even a 4 bit CPU is a complex beast, especially if you refuse to use pre-made ICs. I suggest you break your quest into simpler pieces, and research those pieces first.

First, look into building a NAND gate from transistors - it is possible to construct any digital circuit from NAND gates, so this is a good start. A flipflop is another useful thing to construct, especially a latching flipflop.

Next, learn a little about the basic building blocks of digital circuitry - things like small adders and registers. You'll rapidly learn that the building blocks are not trivial pieces, but logical enough.

Then, look into instruction decoding, and clocking your CPU. You can't build a CPU without these.

By this point you should have something of an understanding of the level of complexity involved in your project. I'd be interested to hear what you think of it then.

I suspect your 4 bit CPU, even if it only has a few instructions (16, perhaps?), would require some thousands of transistors. Wiring those together could take quite a while...
Related resources
a c 172 à CPUs
July 2, 2011 11:41:43 AM

compulsivebuilder said:

First, look into building a NAND gate from transistors

For anything other than a single "demo" gate, this is impractical.

a c 103 à CPUs
July 2, 2011 12:35:08 PM

Sorry I can't help but wanted to say good luck and have fun. I hope to see you getting a 86 license from intel soon.
a b à CPUs
July 2, 2011 5:11:08 PM

compulsivebuilder said:
Even a 4 bit CPU is a complex beast, especially if you refuse to use pre-made ICs. I suggest you break your quest into simpler pieces, and research those pieces first.

First, look into building a NAND gate from transistors - it is possible to construct any digital circuit from NAND gates, so this is a good start. A flip-flop is another useful thing to construct, especially a latching flip-flop.

Next, learn a little about the basic building blocks of digital circuitry - things like small adders and registers. You'll rapidly learn that the building blocks are not trivial pieces, but logical enough.

Then, look into instruction decoding, and clocking your CPU. You can't build a CPU without these.

By this point you should have something of an understanding of the level of complexity involved in your project. I'd be interested to hear what you think of it then.

I suspect your 4 bit CPU, even if it only has a few instructions (16, perhaps?), would require some thousands of transistors. Wiring those together could take quite a while...


NAND would be a good start. Problem is, there needs to be a control to alter the inputs to get a desired output. Would a NAND be a good 4 bit adder/subtracter?

jsc said:
For anything other than a single "demo" gate, this is impractical.


NAND gates are pretty easy to set up, just certain CMOS linked with resistors a viola....a NAND gate. Problem is, need to create several NAND gates.

simon12 said:
Sorry I can't help but wanted to say good luck and have fun. I hope to see you getting a 86 license from Intel soon.


Thank You. I do not think an x86 would do good for me. Maybe create a new microarchitecture that is more efficient than x86/ARM.
a c 199 à CPUs
July 2, 2011 5:23:14 PM

We did this in my computer architecture class, except we designed it on the computer and uploaded it to the FPGA, but the basic parts are still the same. You will need to build some 4 bit registers(not as easy as it seems), an ALU, some control circuits, either muxes or tristates, and a control system, since you are going to be working with extra large transistors you could do the control system by hand since i dont think you will get very high frequency out of this unit.



Instead of being silly and wanting to make it out of individual transistors, find yourself either some ICs that pack 8 or more MOSFETs on a chip, or better yet, some ICs that have a few NAND gates on them. No point trying to build four fancy rolling objects for your wagon when someone else is making wheels by the millions for you that will work even better with much better performance.
a b à CPUs
July 2, 2011 5:45:19 PM

I was trying to build the CPU out of discreet parts for a hobby. You guy do say i must build the unit out of already IC's huh?
a c 199 à CPUs
July 2, 2011 5:58:21 PM

A basic 1 bit adder involves 5 gates, a 4 bit adder will involve 20 gates, with each gate having 4 transistors you are now up to 80 transistors and all it cant even remember anything yet.

Each flipflop needs 2 NOR gates per bit, 2 4 bit registers will therefore need 16 more gates, and about 32 more transistors, so you are talking around 100 discrete parts with just those two and all it can do is simple math. With NAND gates on a chip you get small transistors so its going to use a lot less power and you have far fewer individual components to deal with.
a b à CPUs
July 2, 2011 6:23:42 PM

NAND involves CMOS. Those transistors are not that small.
a b à CPUs
July 3, 2011 2:15:18 AM

At least you won't be trying to do this with 100 components:

a b à CPUs
July 3, 2011 3:46:13 AM

^ Do not understand?
a b à CPUs
July 3, 2011 3:46:41 AM

...wait...I might see the problem(s).
a b à CPUs
July 3, 2011 5:46:17 AM

^ Virtual processors may replace Hardware and Software. All one would need is firmware that has the virtual processor integrated on the firmware device.
a c 172 à CPUs
July 3, 2011 2:19:18 PM

dogman_1234 said:
NAND involves CMOS. Those transistors are not that small.

No. NAND is a logic function. CMOS is a method of construction.

A NAND gate can be built used RTL, DTL, TTL, ECL, or CMOS logic.

hunter315 said:

Each flipflop needs 2 NOR gates per bit, 2 4 bit registers will therefore need 16 more gates,

It's worse than that. You need 9 NAND gates to synthesize a J_K flip-flop. So two 4 bit registers will need 72 gates.
a c 144 à CPUs
July 5, 2011 11:50:03 PM

randomizer said:
At least you won't be trying to do this with 100 components:

http://philipgee.com/images/CU-BC108_01.jpg



Yes thats exactly what he's talking about. just multiply it by about 5000 for a 4 bit cpu. :pt1cable: 
July 16, 2011 2:59:11 PM

as far as i have learned in computer architecture class... the nand gate construction and construction of complex circuits using nand gates (jk flip-flop) etc are pretty basic. (no offense to anyone). but the real challenge starts where you need to remember the states of certain operations. that involves using the various flip-flops in conjunction with the other states. (google state diagrams in digital electronics). next stage comes choosing the construction model( ie moore model or mealy model). the moore model works independently of future results where as the next state in a mealy model is dependent on the previous result. So once this is decided you can then focus on forming the logic and choosing the number of bits. start with 4bits as suggested above. after this, using a solving method (too big to explain here, if you want ill pm you) you can form a circuit. this forms your basic circuit to remember stuff for a short time. attach this to a simple adder/subtracter circuit and you can have a basic 4bit calculator. mul/divide needs more work on the secondary circuit (think repeated addition and repeated subtraction).

optimisation: first step would be reducing the number of gates used and number of inputs used by taking the common inputs as one.( warning: this should work for all test cases). next step would be introduction of switches and tristate buffers to offer better control over the flow. third step would be to multiplex the line thereby futher decreasing the cost of building the circuit. finally include more features.

futurescope: imagine joining multiple circuits of such type in sync to perform one task and now imagine multiple such circuits to work together while performing various tasks.... its hard to imagine that the roots of such a complex circuit started from a simple NAND gate.

usage of transistors or mosfets or normal diodes all depend on personal choice. but the basic flow remains the same. hope i have given you the direction you need to look in... this is what we have learned for 4 months in my course. if anyone has any additions or difference of opinion please feel free to post.

@dogman: we'll discuss this if you want. thanks for inviting me to this topic....
a b à CPUs
July 16, 2011 9:56:03 PM

Sure.
a b à CPUs
July 19, 2011 7:15:48 AM

I need to understand the basics of a processor in general to get it up and running. Just allowing it to be a ALU/relay is not what I am after. A fully functioning CPU is what I am after.
a b à CPUs
July 20, 2011 6:00:17 PM

http://en.wikipedia.org/wiki/Intel_4004

Quote:
The Intel 4004 was a 4-bit central processing unit (CPU) released by Intel Corporation in 1971. It was the first complete CPU on one chip, and also the first commercially available microprocessor. Such a feat of integration was made possible by the use of then new silicon gate technology allowing a higher number of transistors and a faster speed than was possible before.

The first public mention of 4004 was an advertisement in the November 15, 1971 edition of Electronic News,[1] though unconfirmed reports put the date of first delivery as early as March 1971. Packaged in a 16-pin ceramic dual in-line package, the 4004 was the first commercially available computer processor designed and manufactured by chip maker Intel, which had previously made semiconductor memory chips. The chief designers of the chip were Federico Faggin and Ted Hoff of Intel, and Masatoshi Shima of Busicom (later of ZiLOG, founded by Faggin).

The 4004 was built of approximately 2,300 transistors and was followed the next year by the first ever 8-bit microprocessor, the 3,500 transistor 8008 (and the 4040, a revised 4004). It was not until the development of the 40-pin 8080 in 1974 that the address and data buses would be separated, giving faster and simpler access to memory.

The 4004 employed a 10-μm silicon-gate enhancement load pMOS technology and could execute approximately 92,000 instructions per second (that is, a single instruction cycle was 10.8 microseconds).[5] The original clock speed design goal was 1MHz, the same as the IBM 1620 Model I.

The Intel 4004 was designed by physically cutting sheets of Rubylith into thin strips to lay out the circuits to be printed, a process made virtually obsolete by current computer graphic design capabilities.


So basically Intel would design the each CPU layer using plastic sheets (Rubylith) glued to a board, then photograph it and shrink the photo down to 10 micron size to use as a photolithographic mask. In comparison, today's 32nm CPUs use transistor sizes some 312.5 time smaller and given the billion or so transistors per CPU, gluing plastic to a board ain't gonna cut it much :p ..

Anyway, Dogman - don't order 2,300 transistors at Radio Shack - you'll go broke :D .
a b à CPUs
July 20, 2011 6:29:02 PM

^ Should I order them form Fairchild?
September 12, 2011 11:42:05 PM

dogman_1234 said:
I need to understand the basics of a processor in general to get it up and running. Just allowing it to be a ALU/relay is not what I am after. A fully functioning CPU is what I am after.


Im not sure if anyone gave you a good answer or not or you may not even care by now but I'll give it a try since I done a lot of research on making CPU's to make the one I did in minecraft. I am not all that experienced in fooling with breadboards and stuff but it seems this would be a pretty simple thing to pick up if you knew how to actually make the CPU on paper so here goes.

First of all you need to have a very good understanding of basic logic gates if you dont already: http://en.wikipedia.org/wiki/Logic_gate

After that you need to research how to make a half adder from logic and once you understand that then how to make a full adder (i would stick with ripple carry if I were you): http://en.wikipedia.org/wiki/Adder_%28electronics%29

Research how to make a multiplexer and de-multiplexer from logic and understand what they are used for: http://en.wikipedia.org/wiki/Multiplexer

After that make an ALU by combining the full adder and many logic gates through a multiplexer. This allows you to give the ALU an input and change the control lines (going to the mux) and it will do the operation corresponding to the control line setting. My ALU in minecraft is able to ADD, SUBTRACT, AND, NAND, OR, NOR, XOR, XNOR for instance. I think this would honestly be a good stopping point as creating a good ALU would take quite a number of transistors in itself.

But if you want to go on, you are going to want to put comparative logic on the ALU like slt and beq (look up the MIPS instruction set, it will be a good guide) so you can effectively do if-then and looping. A recommend this youtube CE lecture for reference: http://www.youtube.com/watch?v=RkAE4zE4uSE&feature=relm...

After your ALU is completely fleshed out you want to make registers for your CPU to work with data. There are MANY register/ALU configurations but I would chose something that is simplest as your project is already going to be giant. You will want to connect the registers to the ALU in a way that the future 'control logic' will signal and read (from register to alu) or write (from alu output to register). Also, try and design all the components in a way that you have a small opcode (the code that controls all the CPU functions) as it will require more memory when you go to make your program counter. Memory reference: http://en.wikipedia.org/wiki/Flip-flop_%28electronics%2...

After that you will make control logic which is used to interpret your opcode and send it to the appropriate component (ALU or register basically). You will need to create a clock of some sort to connect to the control logic in order for it to pulse instructions around the CPU and you will need to make a PC (program counter) which adds by one word (the size of your opcode) and can be set by the control logic. The program counter signal is then used as a control line to program memory where it reads the program to the control logic then iterates to the next instruction.

All this crap put together makes for a simple (yes simple) CPU that reads the counter, fetches the instruction at counter, decodes the instruction in the control logic, executes instruction(s) and then iterates the program counter (to check the next line of code) and it all repeats. As the CPU gets more complex you have multiple ALU's which can do instructions simultaneously (parallelism) and FPU's and barrel shifters so you can do native multiplication and division and faster adders like carry-look ahead or carry-save. Good luck with the project though, and now I want to make one too :D 
a b à CPUs
September 13, 2011 2:32:01 AM

Cool. Looks like I will have to be ding a lot of reading then. Thanks!
!