EE 333 Fall 2006

Project 6 Lillevik

Project 6

Microprogramming

Purpose

The purpose of this assignment is to microprogram an instruction set for our MDP16 computer. Specifically, we will implement twelve instructions and use the MicroAsm assembler to generate the microROM for our controller. Finally, we will run the complete design on a small user program to verify that the entire computer functions correctly.

For extra credit, you may implement an additional instruction provided you 1) write a test program (run.txt) that illustrates its use, 2) simulate the instruction with the program and generate a trace file (run.bmp), and 3) submit a new microprogram (new.upg) file and microROM (new.txt).You will receive an additional 10% for each added instruction that you microprogram.

Due Date

Friday, December 1, at 5:00 PM. Late assignments will not receive full credit.

Background

You do not need to design the controller, it is found in the file CTL.CKT. Also, the following shows the state diagram for the instructions we are implementing.

State Diagram

Instruction Formats

The following diagrams define the instruction formats and include the R-type, I-type, and J-type.

R-type

I-type

J-type

Op Codes

The following table defines the operation codes. An example is provided for each operation code.

Name / Op / Format / Func / Example / Meaning
add
sub
addi
subi
and
or
andi
ori
sll
srl / 1
1
A
B
1
1
C
D
2
3 / R
R
I
I
R
R
I
I
I
I / 0
1
0
1
2
3
2
3
8
9 / add $0, $0, $1
sub $0, $0, $1
addi $0, $1, 20
subi $0, $1, 20
and $0, $0, $1
or $0, $0, $1
andi $0, $1, 1f
ori $0, $1, 1f
sll $0, $1
sr l$0, $1 / $0 = $0 + $1
$0 = $0 - $1
$0 = $1 + 20
$0 = $1 - 20
$0 = $0 & $1
$0 = $0 || $1
$0 = $1 & 1f
$0 = $1 || 1f
$0 = $1 < 1 bit
$0 = $1 > 1 bit
nop
lw
sw
beq
j
resv / 0
4
5
6
7
8-9, E-F / J
I
I
I
J
Resv / NA / nop
lw $0, c3 ($1)
sw $0, c3 ($1)
beq $0, $1, 2a
j 23
NA / No operation
$0 = mem [$1 + c3]
mem [$1 + c3] = $0
If ($0 = = $1) go to (PC + 1) + 2a
PC = PC [11- 8] || 23
NA

MicroAsm

The micro assembler is a Java program that runs under the BlueJ programming environment. It can be run on the DOS command line with the right invocation. There are two class files as shown below.

To execute the program, right click on the MicroAsm class and execute method main. Pass it the name of your input file by entering it on the popup window. For example, the following shows the file uCode.upg being passed to method main. MicroAsm assumes the extension on the source code is file.upg but do not include it. Also, it assumes all your files are in the same directory.

Then, the assembler reads your file.upg input file and creates a file.txt output file. If the input file assembles correctly, you will see the following success statement on the console.

Directives

There are two directives which you may wish to use.

org: nbr

Sets uPC to value of nbr, used with Branch token

// comment

Everthing after // ignored

Tokens

The following tables define the micro assembler tokens.

Token / Value / Function
Branch / 0000 0100 / Branch the uPgm to the opcode (default is next address)
Rwr / 0000 0400 / Write to the REG file
Imm / 0000 0800 / uPgm controls ALU function (default is IR[3:0])
PCinc / 0000 1000 / Increment the PC
PCwr / 0000 2000 / Write to the PC
PCwrcond / 0000 4000 / Write to the PC if EQ is asserted
IoD / 0001 0000 / Select RALU for memory address (default is PC)
MEMwr / 0002 0000 / Write to the memory (default is to read)
IRwr / 0004 0000 / Write to the IR
MDRwr / 0008 0000 / Write to the MDR
Token / Value / Function
PCsrc / 0020 0000 / PC write data is branch address (default is jump address)
ALUa_R0
ALUa_PC / 0040 0000
0000 0000 / First ALU argument is R0
First ALU argument is PC (default is PC)
ALUb_R1
ALUb_Ext
ALUb_Trnc / 0000 0000
0080 0000
0100 0000 / Second ALU argument is R1
Second ALU argument is Sign Extended offset
Second ALU argument is Truncated offset
REG_RALU
REG_MDR / 0000 0000
0200 0000 / REG write data is the RALU
REG write data is the MDR
Token / Value / Function
REGfmt / 0800 0000 / Selects IR[10] for the REG destination (default is IR[9])
ALUOpadd
ALUOpsub
ALUOpand
ALUOpor
ALUOpsll
ALUOpsrl / 0000 0000
1000 0000
2000 0000
3000 0000
8000 0000
9000 0000 / ALU function is add
ALU function is subtract
ALU function is logical AND
ALU function is logical OR
ALU function is shift left logically
ALU function is shift right logically
Next
Return / uPC+1
00 / Inserts uPC+1 into uPgm next address (default)
Inserts 00 into uPgm next address

MicroROM contents

If you successfully microcode the instruction set, the output of MicroAsm should look as follows.

Requirements

·  Create your microprogram file.upg using a text editor. You must include comments in your file.

·  Run MicroAsm and successfully translate the microcode into file.txt.

·  Run the B2Logic simulator with the complete MDP16 computer using 1) your individual designs for the glue logic, ALU, PC, register file, and memory, 2) file.txt as the ROM for the controller section, and 3) pgm.txt as the ROM for the memory section.

·  If you are not sure of your individual design files, you may request a working design from your instructor.

·  Be sure to turn in all files (CKT, TXT, BMP, etc.) for your design including those provided for you by your instructor.

·  For those design teams handing in extra credit, be sure to include your run.txt, run.bmp, new.upg, and new.txt files.

Description of Trace

The test program is listed below.

The program begins by loading 0x20 into $0 and shifting it left three times so that 0x100 is now in $0. This points to the first address of the RAM in your memory design. Next, it stores 0x25, 0x35, and 0x45 in memory locations 0x100, 0x101, and 0x102, respectively. Lastly, it loads the stored values back into $0 to verify that they were written properly.

The following table identifies the time that each instruction enters the instruction register.

Instruction / Time (ns)
addi / 250
sll / 1100
sll / 1900
sll / 2700
addi / 3500
sw / 4300
addi / 5100
sw / 5900
addi / 6700
sw / 7500
lw / 8300
lw / 9300
lw / 10300

Hints

Remember that each token for MicroAsm maps to a signal in the controller and that each line represents one clock tick.

You do not require a command file for this project. Instead, use the B2Logic menu Simulate Þ Reset Time (F1) or Step (F2) to simulate the design. Its easier just to use F1 and F2.

It is possible to de-assemble the microROM contents. If you get stuck, you can do this in a pinch.

Remember, do not leave any inputs undefined. Even if you do not use an input, it must be tied high or low. In a real circuit, open inputs can result in undefined outputs or can sometimes damage the logic circuit.

University of Portland