Accumulator circuit: a register that adds, live
An accumulator is a register wired to an adder so that it can add a number to itself: on each clock edge this 4-bit accumulator becomes 0 if CLR is 1, loads IN if LD is 1, becomes ACC + IN if ADD is 1, and otherwise holds. It is the working register of a simple CPU, where most results collect.
Adding a column of numbers by hand, you keep a running total and add each new number to it. The accumulator does the same in hardware: a 4-bit ripple-carry adder always adds the input to the current value, and a three-way choice in front of each flip-flop decides what to store on the next edge: the input (load), the adder's sum (add) or the old value (hold), with clear overriding everything. Load wins over add, so LD and ADD together just load. The adder works in 4 bits, so totals wrap around past 15 (12 + 6 = 18 is stored as 2), and C shows the adder's carry out of ACC + IN, the bit a CPU keeps as its carry flag. Early computers and many simple CPUs, including the small one in digiwleea's course, are accumulator machines: an instruction like ADD 5 means ACC = ACC + the value at address 5. The live circuit opens with CLR on, because flip-flops start in an unknown state: turn CLR off and it adds IN (1) on every clock.
Open this circuit in the lab →
What you need
- 4× D flip-flop: the accumulator bits, all on one clock
- 7× XOR: the adder's sums (a half adder for bit 0, full adders above)
- 7× AND: the adder's carries
- 3× OR: the full adders' carry outputs
- 16× AND: the per-bit choice: IN AND LD, sum AND add-select, ACC AND hold-select, and the clear
- 2× AND: add-select = ADD AND NOT LD, hold-select = NOT ADD AND NOT LD
- 8× OR: joining the three choices for each bit
- 3× NOT: NOT CLR, NOT LD and NOT ADD
Step by step
- Place a clock
CLK, inputsCLR,LD,ADDandIN3toIN0, four D flip-flops on CLK, and probesACC3toACC0andC. - Build a 4-bit adder whose inputs are the flip-flops' outputs and IN3 to IN0; probe its final carry as C.
- For each bit, OR together three ANDs: IN with LD, the adder's sum with (ADD AND NOT LD), and the flip-flop's own Q with (NOT ADD AND NOT LD).
- AND that with NOT CLR and feed it to the flip-flop's D. Clear, load a number, then add to it a few times and watch the total grow and wrap.
Clear, load, add and hold
| Clock edge | CLR | LD | ADD | IN | Action | ACC | ACC3..ACC0 | C |
|---|---|---|---|---|---|---|---|---|
| 1 | 1 | 0 | 0 | 0 | clear | 0 | 0000 | 0 |
| 2 | 0 | 1 | 0 | 3 | load | 3 | 0011 | 0 |
| 3 | 0 | 0 | 1 | 4 | add | 7 | 0111 | 0 |
| 4 | 0 | 0 | 1 | 5 | add | 12 | 1100 | 1 |
| 5 | 0 | 0 | 1 | 6 | add | 2 | 0010 | 0 |
| 6 | 0 | 0 | 0 | 15 | hold | 2 | 0010 | 1 |
| 7 | 0 | 0 | 0 | 1 | hold | 2 | 0010 | 0 |
| 8 | 0 | 1 | 0 | 9 | load | 9 | 1001 | 1 |
| 9 | 0 | 0 | 1 | 9 | add | 2 | 0010 | 0 |
| 10 | 0 | 1 | 1 | 7 | load | 7 | 0111 | 0 |
| 11 | 1 | 0 | 1 | 7 | clear | 0 | 0000 | 0 |
This is the exact run checked before the page is built, on all four ACC bits and C after each of the 11 clocks. 12 + 6 = 18 wraps to 2, and so does 9 + 9; C is the adder's carry for the value now in ACC plus the current IN, so it shows whether the next add would overflow.
You can also read the full theory in the lesson on the accumulator. Prefer to build it yourself from scratch? Open the digiwleea lab and place the gates on the canvas, or start from the logic gate simulator.
More builds: Registers and counters
All 246 build guides, by topic
Each of these is one step from a transistor to a working CPU. Build every gate from CMOS transistors and work all the way up in the free digiwleea lab, with the free theory reference alongside.
Open the 4-bit accumulator in the lab →Frequently asked
What is an accumulator in a CPU?
A register that holds the running result of arithmetic. In an accumulator machine most instructions use it implicitly: ADD x means ACC = ACC + x, and STORE x copies ACC to memory.
How is an accumulator built?
From a register (one flip-flop per bit) and an adder whose inputs are the register's own output and the incoming number, with a multiplexer in front of the register choosing between loading, adding and holding.
What happens when the accumulator overflows?
The sum wraps around: with 4 bits, 12 + 6 = 18 is stored as 2, and the adder's carry out is 1. CPUs keep that carry as a flag so programs can detect overflow or add numbers wider than the register.
What is the difference between an accumulator and a general-purpose register?
An accumulator is the one register that arithmetic always uses as an operand and a destination. General-purpose register machines let an instruction choose among several registers instead.