Let’s build the machine from the stored programs post with the parts we’ve made. So far, a person had to change the circuit’s inputs by hand at every step.
Let’s start with the simplest case. The only part is a register file, and the job is to write 0 or 1 into one register at each step. The inputs a person used to set are four: the write address WA1·WA0, Write, and IN. Try it yourself. The value in each register is shown inside the box.
Each step takes three or four switch changes by hand. Let’s hand this work to the machine.
Each input is either 0 or 1, so the inputs for one step can be written as a few
bits. One job for the machine written as bits is called an instruction. The
machine in this post only ever writes, so we fix Write at 1 and write down only
the address and IN, which change from step to step. “Write 1 into register 1”
has the address WA1·WA0 = 01 and IN = 1, so it’s 01 1.
01 1: write 1 to register 1
Tap the bits to change them. The three bits tell which register to write and what to write.
We put these instructions into memory in order, starting at slot 0. Then at each step, we just read that step’s slot. Which slot to read is decided by a counter. Feeding the counter value into the memory address gives that slot’s instruction, and wiring those bits to the register file’s address and IN lets the memory give the inputs instead of a person. The counter goes up with every clock, so the machine moves to the next instruction by itself.
Press Next to start reading from slot 0.
Now a person only has to write instructions into memory. These instructions written in memory are the program we saw in stored programs.
Now let’s wire this machine as a circuit. The counter value goes into the memory’s address, and the memory outputs that slot’s three bits at once. This 3-bit signal is drawn as a single line. The faint number next to the slash (/) on the line is the number of bits, and next to it is the current value. The narrow bar on the right (SPLIT) splits the 3-bit signal into three lines: WA1, WA0, and IN.
Change CLK to 1 and back to 0, four times over. The highlighted slot in memory moves down one at a time: R1 and R3 become 1, R1 goes back to 0, and then R0 becomes 1.
With the counter counting steps and the memory giving that step’s instruction, the machine works on its own without human hands. But for now, this machine can only put preset values into registers. How should we write instructions to give it jobs that need other parts, like adding? Let’s find out in the next post.
The post's instruction is 3 bits: a 2-bit address and a 1-bit IN. If we grow to 16 registers and make the value to write (IN) 8 bits, how many bits is one instruction? Answer with a number.