Make a CPU - Page 1
Forum section: electronics / beginners

author: THATguy
author_rank: Regular Contributor
timestamp: February 03, 2017, 04:51:15 am
content: So I guess the most basic would be a calculator - addition, multiplication, subtraction, division.Then do more complicated maths functions; square root, powers. Even increase the number lengths.And that is aCoprocessor- which can be placed outside of my CPU.Then I'd perhaps want a bios ROM, to start all systems up, perhaps make some alterations (load sequence of solid state memory).A chunk ofRAMoff the CPUBUSbetween CPU and external components (RAM, coprocessor etc)Solid state memory(SD card)Floating point calculatorin the CPUObviously someInternal RAM Cachefor each part of the CPUControl Unit (CU)directs the operation of the other units by providing timing and control signals. Most computer resources are managed by the CU. It directs the flow of data between the CPU and the other devices.Status Register, Flag Register, or Condition Code RegisterHardware register that contains information about the state of the processor. Individual bits are implicitly or explicitly read and/or written by the machine code instructions executing on the processor. The status register lets an instruction take action contingent on the outcome of a previous instruction.Arithmetic Logic Unit (ALU)A small coprocessor in the CPU for very basic tasks.Not too concerned about display, input, or anyother input/outputs - that could all come later, slowly.Primarily concerned with what parts I'd require for the main CPU, and some other very basic features such as BUS between CPU, coprocessor, RAM, and solid state memory. Not worried about multi cores either.Have I missed anything?

author: helius
author_rank: Super Contributor
timestamp: February 03, 2017, 05:08:21 am
content: A calculator doesn't need a co-processor. Every processor includes an ALU and it is used to calculate.Most calculators do not use binary floating-point, however. Most use BCD (binary-coded decimal), at least for the mantissa. This helps with rounding errors. BCD operations are a standard part of the Zilog Z80, Intel 8086 and Motorola 68K processors (which the majority of calculators used), and should be considered for any calculator design.Today, with the high speed and low price of commodity ARM MCUs, a better approach might be to define a virtual machine (vm) for calculator operations, and then emulate the vm using the ARM. That approach is also used by major calculators in the marketplace.I would suggest that nobody in the world, ever, should design any processor before reading Hennessy and Paterson's "Computer Architecture: A Quantitative Approach".

author: 97hilfel
author_rank: Regular Contributor
timestamp: February 03, 2017, 06:43:36 am
content: I dont quiet get it but if you got it right, you want to build a calculatur only using "descrete" components, so no MCU?Could be fun to build but be aware:A Coporcessor is a completly independed calculating core that can perform all operations itself.A Floating point unit is not neccessary (I was surpised when I learned that and that only a few high end ARM Cotex MCUs start having one)If you want to go as deep as the register sit, it may be a good idea to build it with a FPGA which you can reprogramm if you screw something up, but thats just an idea that would save cost and money.Using an sd card as memory may be a bit complicated since that memory type is already formatted and organized in an other way most typical memories are and you NEED a serial bus to dive it instead of a parallel one which should be easier to drive if you build everything yourself.

author: danadak
author_rank: Super Contributor
timestamp: February 03, 2017, 11:39:34 am
content: You can always consider using verilog and building a 4 bit cpu, the firstcpu by intel was for a calculator customer.Regards, Dana.

author: slicendice
author_rank: Frequent Contributor
timestamp: February 03, 2017, 11:57:25 am
content: Go watchthesevideos. Maybe this info could help you build your calculator. :-)

author: rfeecs
author_rank: Frequent Contributor
timestamp: February 03, 2017, 05:50:40 pm
content: This is a fun site with a lot of pages about the development of the HP 9100 calculator:http://www.hp9825.com/html/the_9100_project.htmlIn 1964 Tom Osborne designed and built the prototype in his apartment. 10 digit, floating point. Discrete diode transistor logic.

author: rstofer
author_rank: Super Contributor
timestamp: February 03, 2017, 08:26:30 pm
content: There's an old book by Caxton C Foster that describes what would be called a minicomputer circa '69. The machine is named BLUE for no other reason that the box is blue and it executes 16 instructions and has 4k of RAM. Every bit of the design of this simple machine is presented. There are a few things we would probably change like the glitch generating control signals but the machine will work.It doesn't do floating point, very few machines of that era and of that type did. Even the IBM 1130 (released in '65) didn't do hardware floating point. It was also available in a 4K version with paper tape. I don't think the disk operating system would work in 4K and have room for user programs. The machine at my workplace had 8K and was definitely useable. My FPGA version has 32K and runs at 125 times the speed.As to BLUE, it's worth study as is Indigo, the upgraded processor in the next chapter. These machines are trivial compared to a modern processor. But they will work!There's a lot of education for $0.99 plus shipping:http://www.alibris.com/booksearch?keyword=caxton+c+foster&mtype=B&hs.x=0&hs.y=0&hs=Submit

author: eugenenine
author_rank: Frequent Contributor
timestamp: February 03, 2017, 08:46:33 pm
content: Its a good exercise. The instruction decoder can be done via shift register, other registers done via a simple octal latch (8 flip flips). I did one years ago with digital logic gates. Made up a few simple block components from gates then duplicated those components as needed. When I started college I simulated it in logic works on the Amiga.

author: THATguy
author_rank: Regular Contributor
timestamp: February 03, 2017, 09:01:22 pm
content: Well not wanting to make a calculator as such.But yes, that's where I supposed I'd start, as computer is at the very base level a calculator.Then I'd scale it up, my fancy calculator would be come a specialised Coprocessor chip off to the side.Then I'd begin again on the proper CPU, with a simple calculator inside, then FPU....Thanks for all the info, so much to read now.I seem to have confused the Coprocessor with the FPU. The specialised Coprocessor carries out large Floating Point operations. Well that's one less thing.Oh, and as for the SD card - I'll have to design that all myself, I'm doing a custom job. Just wanting to know what basic components I'll need to have &research how they function.

author: rstofer
author_rank: Super Contributor
timestamp: February 03, 2017, 10:00:57 pm
content: Do your homework and then buy the AM9511 Arithmetic Processor. Design the CPU around the chip's requirements.http://www.ebay.com/itm/AMD-AM9511ADC-CDIP-24-Arithmetic-Processor-/401212173445?hash=item5d6a1bec85:g:sLUAAOSwcLxYDO4cETA: Or this Intel Coprocessorhttp://www.ebay.com/itm/INTEL-D8087-1-CDIP-40-Arithmetic-Processor/401212778959?

author: rstofer
author_rank: Super Contributor
timestamp: February 03, 2017, 10:31:38 pm
content: Or, you can start your project on an FPGA. Building a CPU is a substantial project but there are MANY documented projects around. You can even use one of the cores provided by the vendors. There are other CPU cores on OpenCores.org and there is also an FPU project:http://opencores.org/project,fpu100There s a learning curve to using FPGAs but, in the end, it's a lot faster than using wirewrap. Over the years, I have done a lot of wirewrap and I don't intend to go there again. Besides, I have a self-imposed limit of about 100 ICs for wirewrapping and I don't think I could get a decent computer done with so few chips. I have no idea how many chips are in a PDP/11 but I suspect it is a great deal more than 100.You can build a much smaller CPU on a CPLD (Complex Programmable Logic Device) which is a lot like an FPGA but without all the bells and whistles. I suspect that BLUE would fit in most CPLDs and the memory/IO would be external. One CPLD, one 16K RAM and one 16K ROM could be hung off the CPLD with 12 address lines, 16 data lines and a few chip select signals

author: rrinker
author_rank: Super Contributor
timestamp: February 04, 2017, 06:05:51 am
content: Back in the day, the Netronics Elf II had an add-on board with BASIC in ROM and also a National Semi MM57109 "Number Oriented Processor" which was RPN. The BASIC had no math routines, all math was pushed off to this chip. So you couldn't just enter in PR 3+4 and get 7, you had to enter it as PR 3#4+You can find the data sheet online, but I haven't seen any source of these old chips yet.

author: george.b
author_rank: Frequent Contributor
timestamp: February 04, 2017, 11:16:31 am
content: QuoteMultiplication and division aren't as basic as you might think. You might wish to reduce complexity by implementing simpler logical/arithmetic operations (namely, for multiplying, adding and shifting) and using those to multiply by software.Some logical/arithmetic operations, control flow and data transfer instructions are pretty much all you need, instruction-set-wise, for a fairly functional CPU. Probably not one that will win any awards for speed or features, but one that is useful as a learning exercise. You could build on it later, anyways.My two cents.

author: Ammar
author_rank: Regular Contributor
timestamp: February 04, 2017, 12:23:22 pm
content: Agree with those suggesting FPGA. Dave even has his own dev board that you can get.

author: radiogeek381
author_rank: Regular Contributor
timestamp: February 04, 2017, 04:38:25 pm
content: I would suggest that your "first" CPU design not be all that ambitious. If it goes well, you'll learn so muchthat you'll have a completely different approach at the end of the project than you did at the beginning.I've worked on a bunch of processor designs over the last 30 years (radio is a hobby, computerengineering is a job) ranging from microcontrollers to high-end processors, and each one was influencedby the mistakes and successes from the ones before.For years, I've used the PDP-8 as the simplest example of a processor that is still interesting.It has a very small instruction set (7 fundamental instruction, then one really oddball catch-allinstruction). The datapath is 12 bits wide. It has one internal register. There is code out therefor it, and even a few emulators and simulators.The PDP-8 dates back to the mid 60's. There were a number of models, implemented inDTL (diode-transistor logic with discrete transistors), TTL (small integrated circuits), andeven later models in the late 70's and early 80's implemented in a CMOS LSIprocess.Some find the IOT (I/O transfer) instruction a little odd, but it introduces a big chunkof the notions behind IO in a simple way.The OPR instruction is, by modern standards, really odd, but it introduces some conceptsthat are absolutely fundamental to designing any processor that is microcoded.If you were my student, I'd suggest strongly building a PDP-8 in a simulator like Verilatoror some other free verilog solution.Implementing with small scale integration is an interesting challenge. If I were to do it,I'd keep my parts list to whatever I could get in a 2-input NAND, an inverter, and a D flip flop.That's three different parts. A 2 input XOR would make building an adder easier, but ifone wasn't available, you can implement it with 4 NAND gates. The absolute minimumset of basic building blocks is a 2 input NAND and a D flop. (Implementing a D-flop withNAND gates is possible, but always unsatisfying and expensive.)If you haven't done logic design before, but want to do logic design with SSI (like 7400series TTL) you really should read "An Engineering Approach to Digital Design" byWilliam Fletcher. It is very very dated, but spot on when it comes to designing with1970's and 1980's technology. It got me through the first 10 years of my career.neat project.

author: Alex Eisenhut
author_rank: Super Contributor
timestamp: February 04, 2017, 05:22:38 pm
content: https://en.wikipedia.org/wiki/74181

author: radiogeek381
author_rank: Regular Contributor
timestamp: February 04, 2017, 11:53:25 pm
content: Quote from: Alex Eisenhut on February 04, 2017, 05:22:38 pmYes. The 74181 arithmetic logic unit was a boon to folks building processorsin the 1970's. It provided Add/Subtract and a bunch of logical ops all inone package. If you were building a simple processor, this would save a lotof individual gates.Another chip from just a little later that provided big hunks of a processorwas the AM2901 from AMD (this was the ALU part) and the AM2910sequencer chip (think program counter part). I've seen 2901's on Ebay forless than $10.To complete the stuff around the processor, you'll need a RAM. The simplestapproach would be to use a static RAM from the late 80's like the 2114 1Kx4SRAM -- easy to interface to, though small and in DIP packages. Way back then,I used some variant of the 6264 8Kx8 SRAM in a few designs.

author: JoeN
author_rank: Frequent Contributor
timestamp: February 06, 2017, 09:23:20 am
content: Actually quite a few people have done this recently as what I would call passion projects. One guy did it with relays, another with transistors, many with TTL circuits, a fewwith the bit-slice circuits orwith a real CPU and just designing their own boards around it (more or less what Woz did). There is at least one webring with links to a bunch of these projects:http://members.iinet.net.au/~daveb/simplex/ringhome.htmlThe most notable examples, IMHO:http://www.homebrewcpu.com/- TTL, 16 bit, operating system, full featured, so much so you can TELNET to it!http://web.cecs.pdx.edu/~harry/Relay/index.html- Relay computer!http://www.megaprocessor.com/index.html- Transistorized computer!http://apollo181.wixsite.com/apollo181- TTL, 4-bit, actually approachable.A more modern home-brew system and one guy's implementation of it:https://retrobrewcomputers.orghttps://www.youtube.com/user/willsowerbutts/videosI can't find any amateur bit-slice designs. Anyone know of one? Neither I nor the ring knows of any amateur electron tube designs. Anyone know of one of these? That would gain you ultimate street cred.

author: LaurentR
author_rank: Frequent Contributor
timestamp: February 07, 2017, 07:27:48 am
content: I have taught a practical digital design course for a few years (part of an engineering school, high-school + 3 yr level, high quality student population) and the best students would manage to code a basic 8b microcontroller with VGA frame buffer and keyboard input, write a small assembler and program a simple game on it in about 10x4hrs with minor guidance.This was all done on FPGA boards in Verilog/VHDL from scratch.if this is a learning exercise, I don't believe that using discrete components (74xx) a la Apple I is useful. Writing Verliog/VHDL from scratch provides all the learning in a simpler environment that is much closer to how things are actually done today. You can write your own adders and multipliers instead of using the + and * operators if you want to learn the intricacies of designing fast arithmetic operations.Of course, as a "retro" project, you can always use discrete logic, but be prepared for a 10x time multiplier, lots of ugly debugging and the frustration of not being able to make even minor updates easily. Still, that would give you a good idea of "how things were done in the 70s/80s" and will leave you with a nice-looking artifact vs. an off-the-shelf FPGA board.

author: JoeN
author_rank: Frequent Contributor
timestamp: February 07, 2017, 08:23:37 am
content: Quote from: LaurentR on February 07, 2017, 07:27:48 amThere are ways to cheat now that were not available to an average home hobbyist from the 70's that could help you out immensely. You could simulate our your design with Logisim, for example, which you can get a huge number of 7400 parts for and design any 7400 parts that are missing. It wouldn't resolve all timing issues at all speeds, but I think you could be assured your design would work at some reasonable speed at least. Also, since certain PCB manufacturers like PCBWay are so extremely cheap, you could save a *lot* of time ordering the board rather than wire-wrapping or breadboarding if you know your design is going to work. Some people just get more out of working this way, they aren't doing it to try to pass a course in 15 weeks and go on to be a professional engineer. In the end, if you do everything OK, software should probably take more time than hardware. So design it with a known instruction set you can get software and especially a compiler for.I still can't find an amateur design made of bit-slice parts. Anyone know of one?

author: brucehoult
author_rank: Super Contributor
timestamp: February 07, 2017, 02:01:04 pm
content: If you want to make a calculator that's pretty easy. Probably one of the smallest AVR chips will do -- you don't need any RAM at all, the registers are enough. Use two serial-to-parallel shift registers (e.g. 595) chained to drive 8 digits of 7 segment display -- one to select one of 7 segments plus dot, one to select the current digit. That will use three digital pins. One 8 bit parallel to serial shift register will do to scan keys in a 4x4 matrix. Three more pins used. (You could try to share pins, but then you need chip select, so it doesn't help much). So you need an 8 (or more) pin package. Maybe 2 KB of flash and you're done.If you want to make the whole CPU yourself .. well .. at what level? Do you want to make the ALU, or you're happy to use an off the shelf chip (available since the 70s)?People have mentioned the PDP8. Yeah, it's small and simple, and the PDP8s is even bit-serial, so only needs a 1-bit ALU. But it's just awful to program!

author: rstofer
author_rank: Super Contributor
timestamp: February 07, 2017, 03:47:18 pm
content: Before FPGAs, indeed before the 2102 Static RAM, I designed another version of the IBM 1130 using TTL including the 74181 ALU. But this design used microcode contained in blown link ROMs. I liked the design process a lot more than using discrete logic. Changing the microcode wasn't easy but it could be faster than ripping out a lot of wire. I never got to run this version because there wasn't any RAM at the hobby level. Right about that time (1975) the Altair 8800 came out and there was no point in building a computer from scratch (if having a computer was the goal).It was another 30 years before I built the FPGA version.I think if the goal is to use discrete components, I would recommend studying how to design with microcode. Perhaps Bit-slice Microprocessor Design by Mick and Brick could be useful even though I doubt that the original logic circuits are still available. Note also the related books like Bit Slice Design Microcontrollers and ALUs by Whitehttps://www.amazon.com/Bit-slice-Microprocessor-Design-John-Mick/dp/0070417814https://www.amazon.com/Bit-Slice-Design-Controllers-Donnamaie-White/dp/0824071034I think I would use some version of Flash RAM, perhaps something that could be socketed. Word widths for microcode get to be pretty large so count on having several in series to get the required width.The cool thing about microcode is the ability to extend or completely redefine the CPU. Floating point, for example, would just take more microcode (and an instruction set that had room for floating point instructions). This could be added later. In fact, microcode promotes the idea of "stepwise refinement" (Niklaus Worth).I would spend quite a bit of time coming up with the microcode memory. In particular, I would want a simple way to program it including the vagaries of the extended word width. Maybe a little Python code to create a microcode assemler (pretty well shown in Mick and Brick).

author: djnz
author_rank: Regular Contributor
timestamp: February 07, 2017, 04:16:52 pm
content: You might like the labs from this:MIT 6.004 Computation Structures ->https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-004-computation-structures-spring-2009/index.htmStarts with design of CMOS gates, progresses through adders, ALU, a pipelined processor, kernel, ...

author: JoeN
author_rank: Frequent Contributor
timestamp: February 07, 2017, 06:02:18 pm
content: Quote from: rstofer on February 07, 2017, 03:47:18 pmIt appears that 7 of these are available online for free. This Amazon link above claims there were 9.http://buzbee.net/bitslice/AMD_CH1.pdfhttp://buzbee.net/bitslice/AMD_CH2.pdfhttp://buzbee.net/bitslice/AMD_CH3.pdfhttp://buzbee.net/bitslice/AMD_CH4.pdfhttp://buzbee.net/bitslice/AMD_CH5.pdfhttp://buzbee.net/bitslice/AMD_CH6.pdfhttp://buzbee.net/bitslice/AMD_CH7.pdfIf you search eBay for Am2901, Am2902, Am2903, Am2904, etc., you will find a lot of these ICs are available in used condition.Other links, from which I found the above:http://www.homebrewcpu.com/links.htm

author: rstofer
author_rank: Super Contributor
timestamp: February 07, 2017, 06:20:33 pm
content: Quote from: JoeN on February 07, 2017, 06:02:18 pmOutstanding! I took a post grad course in using these devices way back when and we designed an 8086. I'm pretty sure we left out a lot of the fine points, like interrupts, DMA, etc. but the idea was to get the instruction set to work including all the microcode. Yes, the real 8086 was better... But it wasn't designed in one person-semester (I hope).Still, these are magnificent chips for designing CPUs. And 'Mick and Brick' is the definitive text!

author: Mephitus
author_rank: Regular Contributor
timestamp: February 07, 2017, 07:04:38 pm
content: I am rather surprised that no one has brought up the "Megaprocessor"http://www.megaprocessor.comhttps://www.youtube.com/channel/UCB_Zl-VNSH5DLAtG40riCCgI love watching this thing in operation.

author: Back2Volts
author_rank: Unknown
timestamp: February 07, 2017, 09:36:09 pm
content: Quote from: rfeecs on February 03, 2017, 05:50:40 pmI actually used the HP9100B to process tests results and statistical analysis. It had a nice plotter and (IIRC) a paper tape reader. At that time I was the techie at the Nuclear Medicine department of a very large hospital in Spain.

author: rfeecs
author_rank: Frequent Contributor
timestamp: February 07, 2017, 10:19:32 pm
content: Quote from: djnz on February 07, 2017, 04:16:52 pmWow. I took this same class almost 40 years ago! It had three first time instructors, taking turns and making things up as they went along. It looks like it still covers basically the same thing. Starting with digital logic, they designed (on paper) a 32 bit computer with pipelining, virtual memory management, cache memory. It was based on using a bitslice ALU. It seemed like a disorganized mess at the time. But looking back, actually it was a great overview class.

author: JoeN
author_rank: Frequent Contributor
timestamp: February 08, 2017, 04:45:19 am
content: Quote from: Mephitus on February 07, 2017, 07:04:38 pmI did in Reply #17, Reply #25.

author: MrAl
author_rank: Super Contributor
timestamp: February 08, 2017, 09:57:18 am
content: Quote from: THATguy on February 03, 2017, 04:51:15 amHi there,Are you saying that you want to build the CPU out of discrete components like gates and binary counters and perhaps a ROM and static RAM?I come from a time when we actually had to do this. There were CPU's just coming onto the market but we built our own in house version. It did not have to be too super sophisticated but had to go through a bunch of routines on the fly like most CPU's do.Since then though i've dealt with the 8080 for example and the Z80 which allowed more functionality with less ground work.The basics of the simplest computer are:1. Clock.2. Address Counter.3. Memory, RAM, ROM.4. Instruction decoder.5. I/O port decoding (may include an upload port).6. ALU which does all the computing.The clock obviously clocks the address counter.The ROM comes first in the address range, so say from 0x0000 to 0x8000.The RAM comes next, so say from 0x8001 to 0xFFFF.Some of that range in this simple example would be reserved for the I/O port decoder, which would decode part of the address range for use for input and output to the CPU.As each clock addresses ROM the instruction is decoded and the action is performed based on how the instruction decoder is designed. For example a memory word of 0x01 may mean to take the data input bus input and send it to the ALU as the first argument in a calculation. After some more input we may see a 0x0F 0x0001 which could mean perform an addition and put the result into RAM address 0x0001. We may see an instruction like 0x10 0x04 which might mean put the result on the data bus for transfer to the outside world through port 4.The first instruction set in ROM could be just to upload code from a host terminal. That would allow sending code from say your PC to your new CPU board which would then load it into RAM for later execution.You can also include a calculator chip that does all the math calculations. Just have instructions that send data to the chip and can get the result back into memory or to an output port.So there are a lot of variables here but the basics are not too complicated. In our in house design back then there was a calculator chip available so we used that. It was a little slow though but that was the state of things back then.

author: ebastler
author_rank: Super Contributor
timestamp: February 08, 2017, 11:21:54 am
content: The Kenbak-1 may be worth a look, if you are into retro-computing and CPUs built from TTL chips:http://kenbak-1.net/. The Boston Computer Museum has deemed this the first personal computer, in a contest held in 1986.Sold from 1971, it pre-dates the availability of microprocessors, and contains a bit-serial CPU made out of TTL chips. The website above is published by the original designer, John Blankenbaker, and includes the original technical manual with full schematics as a PDF.(Edit: "first personal computer" attribution corrected.)