Digital Logic Display

The goal of this project was to serve as both a demonstration and an interesting way to explain how a CPU works to people who don’t have much experience in the field.

First, a breakdown of all the components. From top right, moving left, then moving down, we have the clock module. This first breadboard will generate an alternating on-off signal that will feed into the rest of the CPU to tell it when to do it’s magic. The clock signal is shown in the blue LED at the top of the display. If you would like to interact with the display, the button at the bottom will trigger the clock when the switch is in manual mode, the dial will speed up or slow down the clock, and the switch will change from allowing you to trigger the switch via the button or to allow it to run by itself. Across from the clock is the program counter. This is hardware that will store the location of the next instruction the CPU will operate on, this is fed into the memory at the start of an instruction. Moving down from the clock, the next 3 breadboards are the memory. This hardware has the ability to store 15 different 8-bit numbers. The yellow LEDs show what memory address the CPU is at and the red LEDs show what data is stored at that address. Across from the memory is the ALU, or arithmetic logic unit. It consists of 2 registers, which is hardware that can each store 1 8-bit number and the sum register between them, which calculates either the sum or the difference between the A and B registers. Down from the memory is the instruction register, which like the A and B registers will store 1 8-bit number, but this one is an encoded version of the instruction the CPU is currently working on. The blue LEDs show the current instruction’s opcode (a way of encoding the instructions) and the yellow ones are the memory address of the instruction, if the instruction needs one. Across from the instruction register is the output register. Numbers written here will be decoded from 8-bit binary to a decimal number from 0-255 and shown on the 7-segment displays. Below the instruction register is the uCode, which is hardware that controls the CPU so that the steps of each instruction are followed in order. Across from that is the control word, 16 blue LEDs that show what control signals the uCode is giving to the CPU. In order from left to right the are halt, memory address input, memory data input, memory data output, instruction register input, instruction register output, A register input, A register output, Sum register output, B register input, output register input, program counter enable, program counter output, jump, and flag input. As an example, if the sum register output was on and the A register input was on, when the clock next turned on, the number stored in the sum register will be put into the A register.

So for those of you reading this without much experience, here’s the basics behind a CPU. CPU’s work on the fetch-execute cycle. As the clock turns on and off, the CPU starts each instruction by fetching the instruction from memory. This is shown on the display by the green LEDs in the bottom left corner. For the first two clock cycles of the instruction, shown by the first and second green LEDs in the uCode Clock lighting up, the CPU is fetching the instruction stored in the memory at the location specified by the program counter and storing it in the instruction register. This instruction, when combined with the current clock cycle of the instruction, are fed into the uCode EEPROMs, which are the large chips in the bottom right of the display. These will decode the current clock and current instruction to figure out what to do next. For example, one of the instructions is LDA, which means load from memory into the A register, so when the instruction register reads from left to right 0001 1111, where 0 is unilluminated and 1 is illuminated LEDs, the uCode EEPROMs will, after reading in the instruction, tell the instruction register to output the last 4 digits (1111) to the data bus, the long lines running down the middle, and tell the memory address to input from the data bus so that the data stored at 1111 becomes available. On the next clock cycle, the uCode will tell the memory to output the data at it’s current address (1111), which is shown in the memory data LEDs, to the bus and tell the A register to input it and store it, so the data shown on the memory data LEDs will appear in the A register LEDs. For the rest of the clock cycles in the instruction nothing is done, as some instructions will require more clock cycles so there needs to be room for it.

For those interested, Here’s the instruction set and the program that the CPU is running: https://docs.google.com/spreadsheets/d/1JtoWxPIE3F-DVVIjfvi3XUpfcCEcoc6M/edit?usp=sharing&ouid=113182617185350109054&rtpof=true&sd=true

The CPU design courtesy of Ben Eater. You can find the schematics and instructions for building your own as well as other breadboard projects at his website: Eater.net

For any OSHE students who would like to continue the project, some adjustments were made to the EEPROM code to make up for some errors in wiring. The forked github repo can be found here: https://github.com/HypersonicWalrus/eeprom-programmer