Daisy VI: Computer Architecture

Compared to all the other machines around us, the most unique feature of the digital computer is its amazing versatility. How does a machine with a finite hardware perform seemingly infinite array of tasks, from games to word processing to scientific simulation?

This remarkable flexibility is the fruit of a brilliant idea called the stored program concept. The computers before the 1930s had their logic driven entirely in hardware. A change in a computer program required rebuilding of chips amongst other things. The stored program concept postulates that the program’s code be stored and manipulated in the computer memory, just like data. As such, the same hardware platform can be made to behave completely differently by simply loading a different program into it. The stored program of yore is now universally recognised as software.

The Daisy platform is a 16-bit von Neumann machine, consisting of:

  • a CPU
  • an instruction memory (ROM)
  • a data memory (RAM)
  • two memory-mapped I/O devices:
    • a screen
    • a keyboard

The computer executes programs that reside in its ROM. The CPU consists of an ALU and three registers called data register (D), address register (A) and program counter (PC). D and A are general-purpose 16-bit registers that can be manipulated by arithmetic and logical instructions following the Daisy machine language specification.

The components are wired in such a way that the output of the program counter (PC) chip is connected to the address input of the ROM chip. This way, the ROM chip always emits the word ROM[PC], namely, the contents of the instruction memory location whose address is pointed at by the PC. This value is called the current instruction.

Daisy CPU

The overall computer operation during each clock cycle is as follows:

Execute: Various bits of the current instruction are simultaneously fed to various chips in the computer. If it’s an address instruction (most significant bit 0), the A register is set to the 15-bit constant in the instruction. If it’s a compute instruction (most significant bit 1), its constituent a-, c-, d- and j- bits are treated as control bits that cause the ALU and the registers to execute the instruction.

Fetch: The next instruction to fetch is determined by the jump bits of the current instruction and by the ALU output. Taken together, these values determine whether a jump should materialise. If so, the PC is set to the value of the A register. Otherwise, the PC is incremented by 1, i.e. to the next line in the program. In the next clock cycle, the instruction that the program counter points at emerges from the ROM’s output, and the cycle continues.

This particular execute-fetch cycle implies that in the Daisy platform, elementary operations involving memory access usually require two instructions: an address instruction to set the A register to a particular address, and a subsequent compute instruction that operates on this address.

Wrap up

This video shows the computer in action. The program loaded into the ROM listen for a key press and paints the screen black as long as the key is held down. The first 20 seconds of the clip are running at ~1GHz clock. For the remainder of the video, I’ve slowed the system clock down to 1-10Hz to see the ALU and memory chips in slow-mo action.