Lab 4: Fetch Unit Components

In this lab, you have two new components to build.

Program Counter Register

In this component, no processing goes on. There is a single input signal, and a single output signal. When the tick method os caled, you simply copy the input signal to the output signal pin and you are done.

Instruction Memory

This unit is a bit more complicated.

First, the component has a single input pin named PCin. It has three output pins labeled PCout, ``opcode, and opcode2

First, you need to set up an array of uint16_t data items. The size of this array should be provided as a second parameter to a new constructor for this component. That constructor needs to allocate the memory block when an object is created, using the C++ new operator. You do not need to initialize this array, but we will need to provide a load method>

Add a new method to the class named load. This method should receive a string parameter with the file name for the data file to load into memory. When called, this method should open up the named file and read the data items, one value per line (text). Copy the data into the allocated memory array as needed.

The memory unit tick method is pretty simple. When this method is called, read the PCin signal on the input pin, and use that value to index into your data array. Note that you will need to do this twice, once for the data at the indicated index, and once more for the next data item. Place these two values on the two output pins. Pass the input pin PC``value on the outgoing ``PCout pin as well.


As usual, you should add tests for these new components. Once we have all of this in place, we can begin assembling out machine. That wll be your next lab!