Computer Architecture
What is an accumulator in a CPU?
An accumulator is a register that keeps a running total. An adder sits in front of it: one input is the register's own output, the other is the new number. On each clock tick with ADD switched on, the register loads the sum, so the total accumulates. Early computers did nearly all their arithmetic this way, and the name survives as register A in chips like the 6502.
An adder fed back on itself
Each column of the adder works like a full adder. In the lowest bit the sum is Q0 XOR IN0, and the carry is Q0 AND IN0: 1 only when both bits are 1. The next column adds its own two bits and that carry, (Q1 XOR IN1) XOR carry, and passes its own carry on. Chain more columns and the accumulator is as wide as you like.
ADD makes it a command
In front of each flip-flop's D sits a picker that chooses between the new sum and the register's own value:
With ADD at 1, the sum gets through. With ADD at 0, each flip-flop reloads its own Q and the total holds, however many ticks go by. Leave the picker out and wire the sum straight to D, and the register adds on every tick whether it was asked to or not.
Live experiment
Add on every tick
A two-bit accumulator: the switches are the number to add, ADD is the command. Add 1 three times, then add 2 and watch 3 + 2 wrap to 1, then set ADD to 0 and see it hold. Take the carry away, or make it an OR, and see which sums go wrong.
“Add on command” is lesson 5 of 6 in Fetch Fjord, Computer Architecture World 2. Free with an account. Lessons unlock in order, so you’ll do the 11 before it first.
A worked run
Start a two-bit accumulator at 0 and add 1 three times: 1, 2, 3. The second add, 1 + 1, is where the carry earns its place: the 1s column gives 0, the carry sets the 2s bit, and 01 + 01 = 10. Now add 2. 3 + 2 is 5, which is 101 in binary, and two bits can't hold the 4s place. That bit falls off the top and the register shows 01, which is 1. This is overflow: an n-bit accumulator counts modulo 2ⁿ.
Break the carry and the maths breaks with it. Tie it to 0 and 1 + 1 gives 0. Make it an OR and 0 + 1 gives 3, because an OR carries when either bit is 1 instead of when both are.
Accumulators in real machines
EDSAC ran its first program in 1949 with a single accumulator. The 6502 in the Apple II and the NES, and Intel's 8080, are accumulator machines: an add instruction adds a byte to A and leaves the result in A. Modern processors have many general-purpose registers instead, but each addition still comes down to the same three parts: an adder, a register, and a choice about whether to load. Signal-processing chips keep wide multiply-accumulate registers for their filters, adding product after product into one total.
Free lesson
Now build it yourself
Each lesson comes in three short parts: see the idea, try it on a live board, then build it yourself, with quick checks as you go.
“Add on command” is lesson 5 of 6 in Fetch Fjord, Computer Architecture World 2. Free with an account. Lessons unlock in order, so you’ll do the 11 before it first.
Or start from the very first lesson, no account neededPractice questions
Three quick questions from the lessons. Pick an answer to check it.
Show the answer
Answer: Whether the next addition will carry: 1 when ACC and IN are both 1. It's combinational, not stored: it reads the current ACC and IN. Chain it into the next bit's sum and the accumulator grows.
- Why not “The stored value”? The stored value is Q itself. CARRY is a gate output that is 1 only when Q and IN are both 1.
- Why not “ADD”? ADD is the command input. CARRY doesn't involve it: it's worked out from Q and IN alone.
- Why not “The clock”? CARRY doesn't follow the clock. It changes as soon as Q or IN changes.
Show the answer
Answer: A AND B. Only 1 + 1 carries.
- Why not “A XOR B”? A XOR B is the sum bit. The carry is 1 only when both inputs are 1, which is an AND.
- Why not “A OR B”? An OR would carry when either input is 1, so 0 + 1 would wrongly carry.
- Why not “NOT A”? The carry depends on both inputs. NOT A ignores B entirely.
Show the answer
Answer: 10: sum 0, carry 1. Two is written 10 in binary. The sum bit is 0 and a 1 carries to the next column, just like 5 + 5 carries in decimal.
- Why not “1”? That's only the sum bit, the XOR. It drops the carry, the 1 that moves into the next column.
- Why not “2”? 2 is the right amount, but written in decimal. Binary has only the digits 0 and 1, so two is written 10.
- Why not “11”? 11 in binary is three. One plus one carries into the 2s column and leaves 0 in the 1s.
“Add on command” is lesson 5 of 6 in Fetch Fjord, Computer Architecture World 2. Free with an account. Lessons unlock in order, so you’ll do the 11 before it first.
Questions people ask
What does the accumulator do in a CPU?
It holds one number of a calculation and receives the result. An instruction like ADD 5 adds 5 to whatever the accumulator holds and leaves the sum in the accumulator, ready for the next instruction.
Is an accumulator just a register?
Yes, a register with a special job. What makes it an accumulator is the wiring around it: an adder whose inputs are the register's own output and the new number, feeding the sum back in on command.
What happens when an accumulator overflows?
The bit that won't fit falls off the top and the value wraps round: an 8-bit accumulator holding 255 plus 1 shows 0. Real processors keep that lost bit in a carry flag, so software can notice it, or add wider numbers one piece at a time.
Related topics
- Half adder vs full adderA half adder adds two bits; a full adder adds the carry too, so they chain.
- What is an ALU, and how does it work?Work out every answer at once, then let the opcode pick one: the heart of a CPU.
- The fetch-decode-execute cycle explainedFetch an instruction, decode it, carry it out, repeat: how every CPU runs.
- What does the program counter do in a CPU?The register that says which instruction comes next, and how jumps make loops.