Hacker News new | past | comments | ask | show | jobs | submit login
32-bit homebrew CPU using 74' series logic (hackaday.io)
208 points by peter_d_sherman on Dec 19, 2016 | hide | past | favorite | 78 comments



Hackaday project owner here...

The idea of the project is the fun of playing around with electronics, something I have not done before, and trying to understand everything about a real computer. Starting with the CPU and then building it out with a simple graphics card. After that create an assembler/compiler for RISC-V and write a small OS. Yes, all of these will be relatively simple and not of a commercial standard, but building a machine and watching it run with all the hardware and software written from scratch is the longer term goal.


> building a machine and watching it run with all the hardware and software written from scratch is the longer term goal.

This is an awesome & crazy project! I'll be watching. Would love to read a little bit about how much time it's taking as you go, and how it balances against your work & life.

Ever since I was an undergrad many moons ago, I thought a 4-year CS degree that ran on this same premise would be amazing. Say, spend your first year learning hardware logic and building a CPU. Year 2 is a basic operating system & compiler. Year 3 networking & a graphics system, and year 4 maybe a game or application or research project of the student's choice. Or something like that. Wouldn't it be cool to graduate having built your own computer from the ground up?


A couple points. First you could use surface mount ICs and fit a whole lot more circuitry onto one board. Soldering is harder but it should be better in every other way.

Second. The register file could be implemented with far fewer chips if only a single output was used. The A and B register select bits would need to go through a quad 2-1 multiplexor and the output would need to be latched for either A or B and some sequencing logic added to make it work. In other words it would take 2 cycles to read from both A and B operands.

Oh, and don't forget that in RISC-V register 0 is always read as zero so no actual storage is needed for that one.


Once you get over the initial effort of switching to surface mount and get a toaster oven/griddle setup, it can actually be quite a lot faster, especially for doing stuff in quantity. Using a stencil you can quickly place paste for all components, then hand place all components and bake it. Of course finding solder bridges and debugging can become a bit tricky...


Desoldering is all much faster if you have hot air and some tweezers.


In other words it would take 2 cycles to read from both A and B operands.

Or you could read one register on the rising and the other on the falling edge of the clock, if timing permits. A lot of real microprocessors were designed with this techinque.


Did you consider using KiCAD or another open EDA tool instead of Eagle?


Have to admit I never heard of those two tools! Given I use PCBWay for cheap production of boards I can only create boards that are 100m x 100m at a max anyway. So the Eagle restriction of free use up to 100m x 80m is not bad.


It's possible to work around the restriction easily. This tool (https://github.com/p12tic/eagle-brd-merge) can move a single Eagle board around, so whenever you want to move a component outside the allowed window you simply move the board. You can panelize the boards without any board size restriction using that tool too.


This is awesome. One tiny request: please change the board dimensions text on the page to "100mm x 80mm", or "100x80 mm" or something.

I had to stop and think about this for a second or two, since I wondered what on Earth you were doing building 100-meter boards. Units matter, and the symbol for "millimeters" is "mm". Thanks.

Mods: also it would be awesome to have "RISC-V" in the title.


cool project.. I'm curious about your experience working with China PCB manufacturer. The costs seem low from my experience ($10 for 10 boards + $25 shipping). Was the quality there? How fast was the shipping? Did you attempt any homebrew PCB etching?


I'm not the author, but I've etched my own boards. My graduate thesis project contained a couple dozen homebrew boards by the time all was said and done.

I used a photo-resist process based on transparencies that I made in the department Xerox machine.

The biggest improvement in moving to real manufactured boards was plated-through holes. For that reason alone, I wouldn't go back. Not only are boards easier to route with PTH's, but they are also more robust -- it's harder to lift a pad off the board when removing a component.

Solder mask is a boon as well, especially for surface mount.


Dirtypcbs[1] did a bang up job with amazingly fast turn around. Even got 4 extra boards; we used them for our alienflight[2] builds.

[1]: http://www.dirtypcbs.com [2]: https://www.youtube.com/watch?v=6LCuZCmttIQ


I have ordered from them 3 times and each time they arrived in ~1 week to Australia. Takes 2 or 3 days for them to be made and then another 3 or 4 days to be delivered by DHL. I have not had problems with any boards so far. I have never ordered from anyone else so I have no idea how they compare to others but for a home project with simple designs they are just fine. You can combine orders for several different boards into a single postage so it becomes even better value.


I ordered several times from shenzhen2u. I had a few questions and some issues at first with their store. I always got a friendly (and useful) answer within 24 hours. Actually better answers, than what I got in Europe (some of them very expensive in comparison). Quality for my requirements was always better than expected. E.g. I made several boards for a Raspberry Pi and the through holes were all fine (on all boards). I had zero issues to put them on top of the 2 x 20 header of the Raspberry Pi.


This is great! I remember as a teenager back in the 80s I built a 4-bit CPU (actually, not much more than an ALU really) using 74-series chips I'd salvaged in part from old mainframe boards I found at my local scrapyard.

I loved inventing the instruction set, which made me realise why opcodes are encoded the way they are. Probably one of the best learning experiences I ever had.


Fantastic. I'll follow this with great interest, I've had the same urge to make my own 'relatively simple everything' for years, but not even close to this (already) in execution.


This is neat. I'm looking forward to reading updates.


I took the MITx MOOC version of MIT's 6.004 (Computation Structures) class. In that class students design and implement in logic gate level simulator a 32-bit RISC CPU.

I was going to try to build it out of 74' series logic as a summer project last summer. Then I did a count of the gates I was using. In the following, a number after a gate type means the number of inputs. My gate count:

  295 AND2
    8 AND3
    3 NOR2
    4 OR2
   96 OR3
   20 OR4
  226 XOR2
    6 NOT
  563 MUX2
  161 MUX4
   32 D FLIP FLOPS
I'm not including memory for the registers. I would probably not have tried to make that out of 74' series logic.

In terms of chips, it is something like

  140 4xMUX2
   75 4xAND2
   81 2xMUX2
   55 4xXOR2
plus a few more.

The project pretty much died at that point.

I could cut a lot of those out by moving some functions from hardware to software. My design includes a shifter than can left or right, logical or arithmetic shift 1 to 32 bits in one cycle. 353 of the MUX2s are involved in that.

I could take that out, add a much simpler unit that can only do logical right shift by 1, add a new shift instruction that uses that simpler shifter, and make the current shift instruction into illegal instructions. They would then trap, and the illegal instruction handler could emulate the missing instructions.

Still too many chips after that, though.

I may still build it someday, but rather than making it out of real chips I'll use it as an excuse to learn about FPGAs.

If any of this seems interesting, I highly recommend 6.004 at MITx.


In that class students design and implement in logic gate level simulator a 32-bit RISC CPU.

Is that an euphemism to avoid saying "MIPS"? ;-)

One way to really cut down on hardware (and speed) is to use a bit-serial design, as found on some minicomputers in the 70s. Memory elements like registers still need the full width, but by processing only 1 bit at a time, many of the other components in the datapath can be reduced by a factor of 32. You can also get left and right shifts for "free" since that's intrinsic in the design. Another strategy is to use microcode to break down instructions even further, e.g. reuse the ALU to do address calculations and incrementing the instruction pointer.


It's an ISA called Beta. It's based off of Alpha. See specification: https://6004.mit.edu/handouts/beta.pdf.


In that class students design and implement in logic gate level simulator a 32-bit RISC CPU.

6.004 is a ton of fun. If you want to build something, I recommend a CISC-like multi-cycle design that uses micro-code (or a hardware sequencer) to dramatically reduce the HW costs (pdf warning):

http://inst.eecs.berkeley.edu/~cs152/sp13/handouts/microcode...

And it could still run a RISC ISA like Beta or RISC-V.


A group of students did build a TTL version of the Beta processor many years ago. Unfortunately, the web being what it is I can't find stuff about previous years of the 6.004 course so I can't give a proper reference.

Anyway, this project won't be the first 32 bit homebrew TTL processor. But it seems it will be able to claim to be the first still on the web :-(


I'm lucky enough to say this was my day job in the 1980's. The sad thing is that today the TTL catalog is much thinner, so it is actually harder to do today than it was then. I'm happy to see RISC-V getting so much traction with serious builders. It seems like the most viable path to hardware freedom right now.


The 74 logic family is gone, because it's been fully obsoleted by newer logic families (especially 74LS and 74HC). The vast majority of parts from the 74 family are available in these families, which generally have compatible behavior, equivalent or higher speed, and much lower power draw.

There are some old parts from the 74 family which were never brought over (like the 7447 seven-segment decoder), but all of the basic logic parts are still around.


Most specialty (in the higher up numbers there are quite a lot of these) parts only existed in a single family anyway. But basic stuff, muxes, dividers, registers/drivers etc. all made it to HCMOS :)


This is one of my old favorites. I never used it, but it had some of the most speciality logic out there:

4-Bit Arithmetic Logic Unit http://ee-classes.usc.edu/ee459/library/datasheets/DM74LS181...


The 74181 was a really cool classic part, and was used in a lot of discrete CPUs.

Unfortunately, it's one of the parts that never made it past the 74LS family. :(


But... on a purely philosophical note, are you really building a CPU from gates if you use a '181?

With that said, the capstone project for my college electronics course was to build a 4-bit computer from 74LS chips, and we used the '181. The instructor explained that it was a necessary simplification, in order to get the project into the space and time available. We were provided with the schematic, but were expected to get it working with little or no help, and to demonstrate operation of a program. I wrote a dice game.


Not true...Philips did at least a 74F and 74HCT version, and TI did a 74AS181. Weirdly, Hitachi did a 74AC182 (lookahead carry generator for '181), but AFAIK only the 74HC181. Never figured that one out. There's also an ECL version (MC10181).

If you jumped to the 74381 you could get nifty things like the IDT7381 or L4C381, which are the equivalent of 4 '381s in a PLCC package that ran at a 25ns cycle (faster, I think, as well).


RISC-V isn't about hardware freedom, but about an open ISA that anyone can implement, including those who will make proprietary implementations.


The fact that RISC-V is not motivated by hardware freedom is not in conflict with my statement that it is a beacon of light on the road to hardware freedom. Both can be simultaneously true.

Hardware freedom will become increasingly important in the future, and I predict it will be harder to achieve that software freedom.


That sounds like it would have been very interesting! Back in the 70's it wasn't an uncommon "hobby project" to build a very simple "CPU" using TTL parts. While the computational utility was obviously limited it was a great learning exercise.

I remember working out the logic of "JK" flip-flops and the like. At one time I'd acquired some ancient vacuum tube versions of said flip-flops. Wish I'd kept them, they'd be a great curiosity today, a collector's item of sorts.

Should evoke some good memories looking through the catalogs of current versions of those venerable products. Won't be surprising if they'll be around for a long time into the future.


What do you mean by the TTL catalog is much thinner?


TTL = transistor transistor logic

This is the technology in the common 74' series integrated circuits that became popular in the late 1960's and 1970's. You can get basic IC's that perform AND, NOT, XOR operations but also more complex IC's that perform as multiplexors, buffers, registers and so forth. You can find these in computers like the PDP or VAX series machines.

They are not used as much today and so less of them are still manufactured.


Although when we say TTL/74 today, usually HCMOS is meant. Real TTL 7400 series parts are, I think, all EOL and have been for many years.


TI still makes a lot of them, but you have to mix and match series if you want broad coverage of the device family. This document is a very helpful overview of their range and how they interoperate: http://www.ti.com/lit/sg/sdyu001aa/sdyu001aa.pdf

(fwiw it sounds like you know what you're talking about; I just wanted to share this info for anyone else who might be interested)


Looks like 'F' is still available:

http://www.nxp.com/documents/data_sheet/74F74.pdf


Ah ok, you were referring to the catalog of actually being able to order these types of first generation ICs I see. Yeah I would imagine it would be nice market - basically the hobbyist if that. Cheers.


Many, many of my favorite 74' parts from the old days are no longer made. The MSI parts that were bread-and-butter of this kind of design back then make less-than-zero economic sense any more. Nobody would design them in, so nobody makes them.

Today you can get the basic logic, of course, because a little bit of glue and duct tape is still necessary. And the super basic shift registers and I/O buffers are still useful. But all computation has moved into much more highly integrated chips or FPGAs.


Fewer chips.


This is important as any 32 bit design is already going to be a big project, so lets not make it impossible by going for something like the CISC of the 80386!

From a practical standpoint, going with 32-bit over 16-bit means not much more than making the datapath twice as wide --- which increases area but not actual complexity per se. And seeing a discrete i386 would actually be pretty interesting, especially if implemented on top of this one as an x86-to-RISCV uop-based decoder like the original P5.

Here's another well-known one, although it's 16-bit and uses a custom ISA (but its creator ported a whole OS to it):

http://www.homebrewcpu.com/


> From a practical standpoint, going with 32-bit over 16-bit means not much more than making the datapath twice as wide

Actually, that is more true from a theoretical standpoint.

From a practical standpoint you have twice as many traces to fit on your board and route, you have more chips, higher power requirement, etc.


So very true. I have an ongoing 32-bit computer project using a simple MPU and RAM/ROM/peripherals attached via a standard bus, and oh my god is that ever a lot of signals. It's not as bad if you use big device packages, but at higher speeds and with now-common BGA parts, it is damn hard to route all those signals with the processes that are easily available to hobbyists (like OSH Park's four layer board service).


It's unfortunate that hobbyist PCB processes haven't increased much in layer count vs, price even after several decades; the original IBM PC (8-bit data/16-bit address, multiplexed), if my sources are accurate, used a 4-layer motherboard. 386/486-era motherboards with real 32-bit busses, already had 6-8 layers. It seems cost goes up more than the multiple of the layer count --- a 10-layer board costs more than 5x a 2-layer one.


I feel like there has been considerable improvement in the hobbyist PCB scene... Prices, process size, and turnaround time for low layer count boards have come way down. But still, like you say, >4 layer stuff gets crazy expensive fast. Maybe easy access to higher layer counts will be the next milestone.


Last time I was playing with 74 series chips I kept wishing there was a Verilog or VHDL library with impementations of all the common 74 series chips (complete with the proper pinouts and timings etc), so one could do a full working simulation of the circuit before going ahead and breadboarding it or laying out a PCB.


It's not VHDL or Verilog, but SPICE tools are what you are looking for.

LTSpice is free, and quite good: http://www.linear.com/designtools/software/#LTspice

A good tutorial page: http://www.simonbramble.co.uk/lt_spice/ltspice_lt_spice.htm

LTWiki page on component libraries, Bordodynov's library in particular contains lots of 74HC and 74HCT series chips: http://ltwiki.org/?title=Components_Library


Wow. No, what he wants is a logic similator, not a circuit simulator. Spice is a circuit simulator.

In any case, it is libraries where the rubber meets the road. A logic simulator is a programming homework assignment. Enough libraries to simulate a CPU is months of effort.


Actually, he does need Spice if he wants to do layout, and worries about timings.


Gah! Who uses Spice for pcb layout? Logic timing anslysis is done with topology tracing tools and pcb simulation is done with transmission line analysis tools.


What are those tools and are they free?


Appraise for the effort. But I do not know why anybody did this kind of tedious job. Isn't it enough to do with Verilog / VHDL to fully understand basic architecture of CPU?


In my view, it depends on what you get your pleasure from. Taking something from model to metal invokes a certain crazy satisfaction that's hard to describe. I've built things that didn't really need to be built, for this reason.


Seems similar to ship-in-a-bottle in the age of 3d modeling/painting/printing :)


You can still do it old-style with no custom-made PC boards ... I actually have quite a few protoboards made with a wiring pencil. No CPU/computer though. Most complex thing is probably a serial-to-NATO (alphabet/language) board :)


The toolchain for a 7400 series project is very different from an FPGA. That's a bit obvious of course, but compare them... With an FPGA you have a giant proprietary software package, with some incredibly powerful tools at your disposal. They're damn useful, and they're fast, but the focus is on learning how to describe your design to Xilinx ISE or whatever, and you have to learn the software so you can use its testbench facilities to validate your design, etc.

With discrete logic, the design can be done on paper and with standard EDA tools, and you can prototype it and test and build it on your workbench, and all the signals are exposed so you can inject and probe signals with standard test equipment.

I like the discrete logic approach because it feels more tangible and it's fun from an electronics tinkering perspective. But the FPGA method is for sure gonna be faster and smaller and cheaper, you just have to do all the work in software.

Depends on the experience you want in your hobby project, I guess. :)


> So creating it as a big breadboard project is out the window. No. We need to create some actual proper PCB designs that can then be connected together in a modular fashion.

Before you write off prototyping large sections on breadboards, I highly recommend you take a look at the Vulcan-74:

http://forum.6502.org/viewtopic.php?f=4&t=3329


I've followed that thread for a long time. He keeps changing direction, which is unfortunate. His breadboarding technique is quite amazing -- I tried copying his approach and my fingers just can't do it :-)


Building a cpu using 74 series logic was a required project in our undergraduate micro-architecture course. It was a fun time debugging the bread boards! First time we learnt the fact that voltage at one end of bread board to the other drops due to resistance so 5V gates do not work if power supply is not connected close enough.


I know a startup that wasted $10mm (and precious time to market) because of a similar issue. They wish they'd learned this lesson much earlier!


Would it be worth faking parts you haven't gotten to yet? Have boards with the correct connectors for higher level components and simulate using off the shelf microcontrollers.

This would allow system level testing, and get to a working device sooner. Over time migrate everything to TTL


Quinn Dunki did something like that when building her "Veronica" 68k computer. IIRC the VGA output remains AVR-based. Seems like a good way to go, provided you don't get bogged down in timing constraints.

If you just need to test a unit (and don't need full functionality), a nice logic analyzer works well... I have an HP 16700A with pattern generator, which I can use to simulate just about anything (more or less.. sometimes it's a bit cumbersome to use.)


Timing could be difficult, might not end up actually saving any (calendar) time.


I am not part of the FSF, but this probably would qualify for the FSF's certified device program if the full blue prints were made available.


Unlikely, since the designs are only editable in the proprietary Eagle EDA tool.


What's the best free alternative to Eagle?


Kicad: http://kicad-pcb.org/

There's a bit of a learning curve, but it's a highly capable EDA suite.


Everyone mentions the learning curve... I just learned it myself and pretty much was up and running after an amazing and fast paced intro tutorial of about 20 mins. Maybe it used to be hard to learn because now it seems to me very logical. Just dont bother without watching a video first.

I wish more people would use it so more footprints would be available, although making them from a datasheet is trivial. And fun...

I dont wish bad luck on the good folk who make eagle but long live free software.


It is hard to learn when you come from Eagle or expect it to behave like "normal" Windows drawing application. But that holds for mostly any EDA package or even general purpose CADs.

Biggest problem with KiCad's UI is that while it's UI is actually highly consistent when it comes to drawing itself, it's GUI is a mess (things that are only on toolbar or only in main menu, no correlation between icons in menu and on toolbars, crucial functions buried in random non-related dialog boxes, behavior and feature set changing depending on graphics backend etc.).

But in comparison with various other EDA packages (including Eagle) I find the overall experience mostly consistent and logical. In comparison with one very expensive EDA package at least snap to grid works in a way that is actually usable and all KiCad windows use same GUI toolkit.


Eagle is free as long as your boards are limited to a maximum of 100m x 80m.


That's not free as in freedom 0: http://fsfe.org/about/basics/freesoftware.en.html


You mean mm.

And also, as long as you use only two layers, which given how cheap are 4-layer boards from china is pretty significant limitation, especially for project of this kind.


Makes me wanna see a 100m x 80m board in real life. What would that be? Maybe a Core i3 in TTL? :)


More, I think.

This: http://www.embedded.com/electronics-blogs/break-points/44311... shows a TTL era computer board, which seems to cram in about 300 packages in 15x15 inches.

Assuming each package is at most 500 gate (medium-scale integration) with 5 transistors/gate, that's 2,500 transistors per package.

So in 225 square inches we'd get 300*2500 = 750,000 transistors.

The Core i7 "only" has 731 million, which converts to 975 of those giant boards. But each such board is just 0.15 square meters, and in 100x50 meters we can fit more than 33,000 of them, for billions of transistors.

Of course, the max clock would not be very impressive at this scale. :)


I actually just started breadboarding an 8-bit CPU inspired by Ben Eater's project of the same nature [0]. The book he makes reference to "Digital Computer Electronics" by Malvino provides plans for a complete 'Simple As Possible' CPU using 74LS chips.

[0] https://www.youtube.com/playlist?list=PLowKtXNTBypGqImE405J2...


Can anybody estimate roughly how big can this end up physically, and how fast it can get in clock Hz or (better?) ops Hz? Also, how many discrete components it might take?


I find myself wondering if the final result will be anything like the Xerox Alto.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: