This was a class project for my Digital Design course that was the culmination of a semester’s worth of labs. The “computer” is a single-cycle, simplified MIPS processor designed with Verilog in Xilinx Vivado and uplaoded to a Xilinx Pynq-Z2 board’s FPGA. The processor is capable of running assembly code. The multiplication of two numbers is demonstrated in the video above; the display shows the contents of Register 2, which eventually contains the final answer.
The basic organization of the processor is shown in the block diagram below.
Block diagram of MIPS processor
In layman’s terms, the processor takes two numbers, does some math on them, remembers them, and repeats with different numbers and different math.
To get more technical, the schematic of the processor in Vivado is below. It may help to open the image in a new tab and zoom in. Each component of the processor is broken down in the following section.
Full schematic of MIPS processor
Debounce component in schematic
The pushbutton is used to advance the clock by one cycle. The debounce is used to prevent unintentional advances from prolonged presses or the sporadic make-break pattern of the button contacts.
Program Counter (PC) and Instruction Memory
Program counter and instruction memory
The program counter keeps track of which instruction the processor is working on. After completion of an instruction, it either iterates by one instruction, or branches to a different instruction as specified by the offset input. The program counter passes its value into the instruction memory, which outputs the instruction at that address. This instruction eventually goes into the instruction decoder.
The instruction memory is an IP module in Vivado. The PC code is shown below.
Instruction decoder schematic
The instruction decoder is a critical component. It takes the instruction, analyzes what type it is (R-type, I-type, J-type), and controls the data path in the processor. For example, if two numbers need to be added, it directs those numbers into the ALU (arithmetic logic unit, covered later) where it tells the ALU to add; it then directs the result either into memory or back into the register.
Register file and write mux
The register file contains 4 registers; each register stores a value that is meant to be operated on soon. It accepts two addresses to decide which registers to pass to its outputs. It also accepts an address on which register to write to and data to write to that specified register. It accepts a control bit from the decoder on whether or not to write in that cycle.
Arithmetic Logic Unit (ALU)
Arithmetic logic unit
The ALU does the math in the processor. It can add, subtract, compare numbers, perform NOT, AND, and OR operations, and perform arithmetic and logical shifts. It accepts two data inputs and outputs data and a take_branch bit that goes back to the PC.
This module contains 3 multiplexers. The first two decide what data to pass into the ALU. For the first, either register data or a zero register; the second, either register data or an immediate input. The third decides whether the data going back to the register comes directly from the ALU or comes from the data memory.
This memory is intended for longer term storage of data. It accepts an 8-bit input for the address and outputs the data at that address. This data is written back to the regfile. It is a Vivado IP module.
Adaptor display and Virtual Input/Output (VIO)
Adaptor display and VIO
The adaptor display is a module that displays the value in register 2 on a 7-segment display attached to the board. It was university provided.
The VIO is a debugging tool that shows the value of critical datapaths in the processor. As the processor is running entirely from instructions, it has no outputs.
The processor was given a program that multiplies two numbers: 5 and -5, with an expected output of -25. The documented assembly code is shown below. It repeatedly adds the absolute value of the first number to the absolute value of the second, and performs logic to determine the final sign.
These two videos show the execution of the code on the actual board. The first is a video of the board itself and the second shows the VIO monitor.