Building a 4-bit CPU with integrated circuits and breadboards
How I built a 4-bit CPU from scratch with integrated circuits and breadboards, covering the clock, ALU, registers, and RAM.
A few weeks ago, while packing for a move, I stumbled upon an old 4-bit CPU that a friend and I built during our first year of college. For our âComputer System Architectureâ class, they didnât give us specific instructionsâjust that it had to relate to the course topics. My friend and I were fascinated by the inner workings of a CPU and eager to understand how it actually functions. We were learning about Boolean logic, the architecture of a 4x3 RAM chip, and the simplified instruction set of an Intel Pentium chip, but none of this really explained how transistors and logic gates come together to create such a complex piece of engineering like a CPU.
Around that time, electronics engineer and YouTuber Ben Eater posted his first couple of videos on building an 8-bit CPU with integrated circuits and breadboards. The initial videos only covered building a proper clock, but that was enough to hook us. We decided to build our own CPU for the assignment, even though we knew Ben Eaterâs series wouldnât be finished before our deadline.
Hereâs a quick video of what the end result looked like:
The Arduino only serves as a 5V power source
Building the CPU
We started by ordering a bunch of integrated circuits from Texas Instruments, since we couldnât find any in Uruguay. These circuits were supposed to help us build the clock. To our surprise, the integrated circuits didnât fit in the breadboardâthey were five times smaller than the ones we needed (yeah, and five times smaller than what they showed in the pictures đ).
After visiting every electronics shop in Uruguay, we finally found a small, old shop that sold the type of chips we needed.
Clock
You might think it would have been smooth sailing from there, but unsurprisingly, they didnât have the exact models we needed. đ€Šââïž The interesting part is, this actually led to our first big lesson: you donât need to copy every step and use the exact materials; you can use what you have and think your way through it. The integrated circuits we bought served the same purpose, but since they were a different model, each pin had a different function. This forced us to read through each chipâs documentation instead of blindly following Benâs videos (which we did try at first).
A couple of days in, and we had our clock working! Iâm not going to dive into the implementation details for the clock because, first of all, I donât remember everything about it đ, and more importantly, knowing the internals doesnât contribute much to fully understanding how a CPU works. As long as you know that the clock provides regular energy pulses to the rest of the CPU every few milliseconds (each pulse being a clock cycle), and that an operation is executed in each cycle, you should be fine.
Weâll dive into the âoperationsâ that the CPU executes later in the post. Meanwhile if youâre curious about the internals of a CPU clock, you can watch this video from Ben Eater.
ALU, Registers and a simple BUS
After building the clock, we moved on to the ALU and the registers. The ALU (Arithmetic Logic Unit) is the part of the CPU that performs arithmetic and logical operations, while the registers are memory units that store the data the ALU operates on.
This is where we decided to make our CPU a 4-bit CPU. The old store had limited chip options, and we couldnât afford to order new ones from Texas Instruments without knowing if they would be suitable. We could have chained 4-bit registers and ALUs to create an 8-bit CPU, but we opted to keep things simple and start small, knowing we could always expand later.
Here are some key insights we gained while building the ALU and the registers:
Register Control: You can control when to load data into a register by changing the voltage of a pin. This was our first glimpse into how you can actively manage the flow of data in a CPU, demonstrating that loading data from the BUS isnât just some magical, automatic process.
ALU Operations: For the ALU, you can dictate the operation it performs by altering the voltage of a specific pin. Our simple 4-bit ALU could only handle addition and subtraction, controlled by the voltage at a single pin. If it supported more operations, additional pins would be involved.
BUS Functionality: Data can also be output from the registers and ALU to the BUS. Here, we realized that the BUS acts like the CPUâs highway, connecting various components that can read from and output data to it.
After assembling the ALU and the registers, we set them up so that the ALU would output results to the BUS, and register A would read the data from it, enabling us to perform multiplication tables!
RAM
The last component we managed to assemble, which isnât featured in the video, was the RAM. It comprised several small RAM chips, each capable of holding 4 bits of data. We manually loaded data into these chips using DIP switches.
While the RAM itself might not seem particularly exciting, itâs important to understand its function in a CPU system. RAM is used to store the results of operations performed by the ALU as well as the instructions that the CPU executes. This makes it a critical component, serving as the storage and retrieval point for both data and operational commands.
CU, where the magic happens
The last piece of the puzzle was the CU (Control Unit). Although we attempted to build it, we ran out of time and didnât have a detailed guide or tutorial to follow, as Benâs series was only beginning to explore the ALU when we reached this stage.
The CU is where terms like âInstructions,â âMachine Code,â and âAssemblyâ transition from abstract concepts into practical components of computing. Recall our earlier discussion about the Registers, ALU, and BUS? The CU is responsible for controlling the voltage of specific pins to manage the loading and outputting of data to and from the BUS. This central role in coordinating how the CPU processes instructions makes the CU a fundamental element where much of the computational âmagicâ occurs.
But how does it do it?
The CU connects to every âcontrolâ pin, thus controlling the operations of the ALU, including whether registers should load data from the BUS. This is where you define your CPUâs instruction set. For example, â0001â might be set to instruct the CPU to âload data from the BUS into Register A,â triggering the appropriate voltage change in the registerâs control pin to perform the operation. Similarly, â0010â or another binary code could be assigned for different instructions.
This variability is why there are many different Assembly languages, as their instruction sets are defined arbitrarily based on each CPUâs architecture.
By encoding your instruction set in an EEPROM, the CU is programmed to deliver specific control signals to other components based on the instruction codes it receives (â0000â, â0001â, etc.). This is crucial for directing the precise behavior of the CPU during each operation.
Now, the CU receives instructions from the same BUS that supplies data to other components. In a 4-bit CPU, the limited number of bits presents a challenge: ideally, you use all bits for data or instructions at different times, rather than permanently dividing the bus. Implementing a strict division (2 bits for data, 2 for instructions) severely restricts operational flexibility, limiting you to just 4 distinct operations.
At this point, we decided to conclude our project. While most of our peers had only built simple systems using Arduinos and sensors, we believed our project would earn a good grade. More importantly, we had gained a deep understanding of how a CPU works, satisfying our curiosity.
Conclusion
If youâre an electronics engineer, you might find this post a bit basic or lacking in detailâand thatâs exactly the intention. As software engineers, we rarely get a firsthand look at the hardware we work on. Peeling back some of the âmagicâ behind a CPU is a fantastic way to spark curiosity and encourage others to explore this fascinating subject further.
I definitely recommend watching Ben Eaterâs complete series. After our assignment was done, I watched it to see how he addressed the issues with the CU that we couldnât figure out. Let me tell you, he is a genius. If youâre interested, you can check out his series here.

