Register8

Inputs

PinTypeDescription
Databus8Input value to store (8 bits)
ClockbitClock signal
WEbitWrite Enable: 1 = write Data on Clock edge

Outputs

PinTypeDescription
Qbus8Stored value (current contents)

How It Works

If a D flip-flop is a single cell in a notebook, a register is a whole row of eight such cells. Inside Register8 hide eight DFFs wired to the same Clock: each one stores its bit of the byte, and all eight update at the very same moment.

The key property: the byte is written only on the Clock edge and only when WE = 1. Between ticks the Q output repeats the stored value, no matter what happens on the Data input. Example: Data = 00001111 (15), WE = 1, an edge — Q = 15; on the next tick WE = 0 and Data = 11111111 (255) — Q is still 15: writing is disabled.

A nuance: an unconnected WE pin counts as 1 — the register will be rewritten on every tick. In the processor the Decoder fixes this: the RegLoad signal drives WE, so the accumulator changes only on ticks of commands like LDA, ADD and SUB.

Examples (clock sequence)

TickWEDataQ after the edge
1100001111 (15)00001111 (15) — written
2011111111 (255)00001111 (15) — WE = 0, writing disabled
3111111111 (255)11111111 (255) — written
4100000000 (0)00000000 (0) — written

Tick 2 is the key one: the input data changed, but without WE nothing got inside.

Usage

Level 12 introduces the register, and from level 16 it lives in the heart of the processor as the accumulator: every ALU result and every byte fetched from RAM by an LDA lands here. Together with the program counter and the index register it forms all the working memory of the course CPU.

A concrete use is the stepping stone between memory and arithmetic: LDA puts a number from RAM into the accumulator, ADD adds the operand, STA writes the result back to memory. Each of these commands spends ticks in which the WE signal permits a write on exactly the right edge.

Build it yourself →

Related components

Related articles

Frequently Asked Questions

What is a register for?

Storing a byte between ticks. In the course CPU it is the accumulator — the main working value.

What happens to the data when the circuit stops?

The register resets: it holds a value only while the circuit is running.

Can you read from a register and write into it at the same time?

Yes. Q always reflects the current contents, while a write happens only on the edge: for the whole tick the ALU can compute based on the old value, and only at the edge does the result take its place.

What happens if you forget to connect WE?

The register assumes WE = 1 and accepts Data on every tick. If Data is left dangling, garbage enters the accumulator — that is why WE is always wired to the Decoder's RegLoad signal.