Skip to content
digiwleeaTools
LearnGlossaryAboutCheat sheetHow a CPU worksBuild a CPUToolsOpen the lab →

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.

Big circuit: pinch, scroll or tap + to zoom in, then drag to move around.

Live circuit: click the inputs to toggle them and watch the outputs update. It runs the real simulator, right here on the page.

Open this circuit in the lab →

Embed or cite this circuit

Free to embed on a course page, blog or worksheet: paste this code. The circuit stays live, and the small digiwleea badge links back here.

To cite it: digiwleea, “4-bit accumulator”, https://digiwleea.wleeaf.dev/tools/build/accumulator/

What you need

Step by step

  1. Place a clock CLK, inputs CLR, LD, ADD and IN3 to IN0, four D flip-flops on CLK, and probes ACC3 to ACC0 and C.
  2. Build a 4-bit adder whose inputs are the flip-flops' outputs and IN3 to IN0; probe its final carry as C.
  3. 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).
  4. 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 edgeCLRLDADDINActionACCACC3..ACC0C
11000clear000000
20103load300110
30014add701110
40015add1211001
50016add200100
600015hold200101
70001hold200100
80109load910011
90019add200100
100117load701110
111017clear000000

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.