SCMP 391 – Lab 10

A basic microprogrammed computer

Goal

The Goal of this lab is to write and test the complete microcode for the processor as build in Lab 9.

Step one – Where we left off

Lets recap where we are. we have a (hopefully) working machine. in the last lab we wrote the following microcode, and the follow simple machine language program to test it.

Micro code for Fetch, ADD and Halt

InstructionAddressMicrocodeOperation
Fetch000080000Fetch and dispatch instruction
 1  
ADD8000001c2MAR ⇐ Mem[0-7]
 900000530ACC ⇐ Memory+ACC+Cin
 A00002004(PC) ++
 B00080000Fetch
 C  
 8000001010(ACC) ⇐ 0
 8100002004(PC) ++
 8200080000Fetch
 83  
HaltF800020000Halt
 F9  

Machine language test program

AddressCodeAssembler Code
0F00Clear ACC
1105Add mem(5) to the ACC
2105Add mem(6) to the ACC
3F0FHalt

Step two – Writing your own microcode

What we want to do net is to write and test some more microcode Lets start out with a few easy ones:

  • LOAD
  • STORE
  • BR
  • BEQ
  • CLR
  • DEC

The instructions, and location the mapper will map to, are below:

OpcodeHexMnemonicMeaningAddress
0010aaaaaaaa2aaLOAD addACC <- mem( add )0x10
0011aaaaaaaa3aaSTORE addMem( add ) <- ACC0x18
0111dddddddd7ddBR addBranch to Address0x38
1000aaaaaaaa8aaBEQ addBranch to Address if Z=10x40
111100000000F00CLRClear ACC0x80
111100000100F04DECACC = ACC – 10xA0

The Instructions can be coded using this template (you can add yourown sections for CLR and DEC):

InstructionAddressMicrocodeOperation
LOAD10  
 11  
 . . .  
STORE18  
 19  
 . . .  
BR38  
 39  
 . . .  
BEQ40  
 41  
 . . .  
CLR80  
 80  
 . . .  
DECA0  
 A1  
 . . .  

Once you get the code build, combine it with the microcode from above. You will need to use the microcode generator to build the code. Then generate a ROM image, and load it into the microcode ROM.

Now try it out with the following ISA program:

Code to multiply using ADD: Mem[12]<-Mem[10]*Mem[11]

AddressCodeAssembler Code
0F00CLR
1312STORE 12
2210LOAD 10
3310STORE 10
480bBEQ b
5211LOAD 11
6112ADD 12
7312STORE 12
8210LOAD 10
9F04DEC
a703BR 3
bF0FHALT
   
1003Data
1105Data
1200Data

What we see above is the assembly language code. Below is the resulting machine code in a form ready to be imported into the logisim memory chip.

v2.0 raw
F00 312 210 310 80b 211 112 312 
210 F04 703 F0F 4*0 3 5Code language: CSS (css)

Test out the program and use it to make sure your new microcode works. If it doesn;t work, you will need to step through the operations one processor cycle at a time, and watch what is happening. Please see the instructor if you get stuck.

To Do

  1. Write the microcode with the microcode generator, save it to a file, and load it into the machines RAM.
  2. Test it out an get it running.
  3. Turn in the code as generated in the “Micro-program” panel in the code generator.
  4. Discuss how the process went. What proved hardest? What lessons did you learn?

Step Three – Add more instructions

Now add microcode for the following instructions:

  • SUB
  • BLT
  • NOT
  • NEG
  • INC
  • SWAP
  • NOP
OpcodeHexMnemonicMeaningAddress
0100dddddddd4nnSUB addACC <- ACC – mem( add)0x20
1001aaaaaaaa9aaBLT addBranch to Address if N=10x48
111100000001F01NOTNot ACC0x88
111100000010F02NEGNegate ACC0x90
111100000011F03INCACC = ACC + 10x98
111100000101F05SWAPACC <=> B0xA8
111100000110F0ENOPDo Nothing0xF0

To do

  1. Write the microcode as before.
  2. Write a simple program that test all the new instructions
  3. Convert the source code into machine code, create a RAM image file, and write to RAM. (The memory image is like that above. “v2.0 raw” on the first line, then 8 values per line (HEX). Repeated values (like 0) can be coded as 4*0 for four zeros in a row.)
  4. Debug your code and get it working.
  5. Turn in your newer more complete code as displayed in the “Micro-program” panel in the code generator.
  6. Turn in your test program both as source an machine code.

Step Three – Write another machine code program to test your microcode

To do

  1. Write a assembly language program to do the following operation:
    Mem[12]<-Mem[10]/Mem[11], Mem[13] <- MOD(Mem[10],Mem[11])
    Thus Mem[12] is the quotient of Mem[10]/Mem[11], and Mem[13] is the remainder of Mem[10]/Mem[11].
  2. Convert the program into machine code for logisim.
  3. Get the program to work
  4. Turn in your assemble and machine code. Show the memory after the program has executed. Try it for at least 5 different pairs, some with a remainder, and some without.

Scroll to Top