CPR E 210 - Lab 12

Instruction Memory Design

12.0 Objectives

Instruction Memory (IMEM) is where a computer stores the set of instructions that is to be performed during execution. The IMEM only provides read access to the computer to retrieve the correct instruction for execution depending on the address generated from the PC. Most instruction consists of Opcode, DestREG, REGA, REGB, and DataIN. IMEM normally loads the program data before each execution. In this lab, however, we will be simplifying this behavior and design an IMEM that is preprogrammed. (No write access).

12.1 Instruction Memory (IMEM)

When we compile a program written in a certain programming language, the compiler normally translates the codes into some low level machine languages. These machine languages are also known as Assembly languages and can be interpreted by a computer. These instructions are then stored in an IMEM of a computer. The addresses for these instructions are provided by PC, which ensures the execution of the program is in order.

12.1.1 Transferring Neccessary Files

Before we go any further, let’s copy all the files saved in Lab10 and Lab11 to the folder C:\CprE210\Lab12Step1\. We will first test this circuit before discussing the use of Instruction Memory. The following table lists the files to be copied from each lab.

Saved Files from Lab 10 / Saved Files from Lab 11
3x8Decoder.tdf / 1bADDER.gdf
3x8Decoder.sym / 1bADDER.sym
4b4x1MUX.tdf / 4bAND.gdf
4b4x1MUX.sym / 4bAND.sym
4bAddONE.tdf ❶ / 4bOR.gdf
4bAddONE.sym ❶ / 4bOR.sym
DualPortREG.gdf
/ 4bADDER.gdf
DualPortREG.sym / 4bADDER.sym
PC.gdf ❶ /
ALU.gdf
PC.sym / ALU.sym
REG.gdf / ONE.tdf
REG.sym / ONE.sym
RegFile.gdf
RegFile.sym
TRI_BUFFER.tdf
TRI_BUFFER.sym

❶Corrections for these are mentioned in the last page of Lab 11.

Once finished transferring the necessary files into Lab12Step1, create a new design file COMPUTER.gdf in the correct directory, and set the project to current file. From the library, insert the RegFile symbols. Note that a new ALU is created for you. It is named 4bALU. This ALU can only perform A + B or A – B operations. However, it still accepts 3-bit Opcodes. Insert the 4bALU and connect it with RegFile. Inspect the 4bALU circuit and understand how it functions. (The main reason why this 4bALU is replacing the ALU from Lab 10 is because of the limited device space available). Then add the symbol 4b2x1MUX. This MUX will be selecting whether we are to perform an external data loading into RegFile, or storing the computation result back to RegFile depending on an input named Store. Nine input pins and one output pin will be needed for this file. Connect the circuit as accordingly. Please refer back to Lab 10 for connection guide.

When the connections are done, Save & Compile this file. Then run a waveform simulation to test the behavior of both the ALU and RegFile. In the waveform editor perform the following test. You can use R7 as a temporary register. Set the end time of your waveform to 2.0us and the grid size at 50ns. Upon completion of the following operations, loop through all register and show the final content of the register on the waveform. Indicate these results on your answer sheet.

LDI R0 5; % R0 = 5 %

LDI R1 6; % R1 = 6 %

LDI R2 3; % R2 = 3 %

ADD R3 R1 R2; % R3 = R1 + R2 %

SUB R4 R0 R2; % R4 = R0 – R2 %

CLR R2; % R2 = 0 %

ADD R5 R2 R4; % R5 = R2 + R4 %

SUB R6 R3 R4; % R6 = R3 – R4 %

SWAP R6 R3; % R6 = R3; R3 = R6 %

MOVE R2 R6; % R2 = R6 %

SWAP R0 R4; % R0 = R4; R4 = R0 %

Check that the results are right before demonstrating the simulation results to your lab instructor.

12.1.2 Designing Instruction Memory (IMEM)

In general, most fundamental arithmetic operation can be done within one cycle. If we want to perform only one single arithmetic operation, supplying all information manually is not a difficult task. Supplying data manually for one whole program to execute, however, will be something beyond our abilities. Hence, IMEM serves the purpose of storing these instructions and supplying the needed data when the time is right.

Note that from the block diagram in Lab 10, IMEM only supply the register addresses and data to RegFile. It does not provide the control signals. An external controller will be used to maintain the control signals for every corresponding state. IMEM merely stores all the registers’ addresses, data, and the corresponding opcodes in the sequence we desire. Some examples of the IMEM entries are given in the next page.

First create a new text design file, named IMEM.tdf, and set project to current file. The only input for IMEM is Addr[3..0], and the outputs are DIN[3..0], RA[2..0], RB[2..0], DREG[2..0], and OP[2..0]. It is more advisable to use a table in implementing the IMEM. The following examples are the first three lines of your table for the loading operation. Proceed and complete implementing the IMEM.

Addr => DIN, RA, RB, DREG, OP;

0 => 5, X, X, 0, X; % R0 = 5 %

1 => 6, X, X, 1, X; % R1 = 6 %

2 => 3, X, X, 2, X; % R2 = 3 %

When the IMEM is completed, create a default symbol and insert it to COMPUTER.gdf. Remove the input pins for DataIN, REGA, REGB, DestREG, and OP, and make the connections to IMEM. There should be only four input pins, and one output pin for your COMPUTER design.

Upon completion, simulate a waveform for this circuit again and named it differently. Compare the results to section 12.1.1. Demonstrate the result to your lab instructor.

12.2 Saving Important Files

Upon completion of section 12.1, you need to store your design for the use in next lab. Since we already have a big list of files, we will archive these files before making the transfer. First set the current project to COMPUTER.gdf. Then select File | Project | Archive…, and in the dialog box, type any preferred folder name, and click OK. All your design files will be duplicated into this folder.

When this is done, open the explorer and direct to your archive folder. Right-click on the Start button and select Explore to open the Explorer. At your archive folder, right-click and select Add to Zip. When the WinZip dialog box popped up, select I Agree. Then from the Add dialog box, make a note where the zip files will be saved, and click on Add. This will zip the whole directory into a file. This will be the file you need to transfer either to your own disk or FTP to your Vincent account.

12.3 Finishing Off

Close MAX+PLUS II Software, delete the folder C:\CprE210\Lab12\ completely and empty the recycle bin. Then, extract the file C:\Download\CprE210\210Lab12.ZIP to the folder C:\CprE210\ for the next lab use. Sign and turn in the answer sheet for Lab 12. This completes the lab session.

57