Lab 10 - The Microcode

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

Instruction Address Microcode Operation
Fetch 0 00080000 Fetch and dispatch instruction
  1    
ADD 8 000001c2 MAR ⇐ Mem[0-7]
  9 00000530 ACC ⇐ Memory+ACC+Cin
  A 00002004 (PC) ++
  B 00080000 Fetch
  C    
  80 00001010 (ACC) ⇐ 0
  81 00002004 (PC) ++
  82 00080000 Fetch
  83    
Halt F8 00020000 Halt
  F9    

Machine language test program:

Address Code Assembler Code
0 F00 Clear ACC
1 105 Add mem(5) to the ACC
2 105 Add mem(6) to the ACC
3 F0F Halt

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:

Opcode Hex Mnemonic Meaning Address
0010aaaaaaaa 2aa LOAD add ACC <- mem( add ) 0x10
0011aaaaaaaa 3aa STORE add Mem( add ) <- ACC 0x18
0111dddddddd 7dd BR add Branch to Address 0x38
1000aaaaaaaa 8aa BEQ add Branch to Address if Z=1 0x40
111100000000 F00 CLR Clear ACC 0x80
111100000100 F04 DEC ACC = ACC - 1 0xA0

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

Instruction Address Microcode Operation
LOAD 10    
  11    
  . . .    
STORE 18    
  19    
  . . .    
BR 38    
  39    
  . . .    
BEQ 40    
  41    
  . . .    
CLR 80    
  80    
  . . .    
DEC A0    
  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]
Address Code Assembler Code
0 F00 CLR
1 312 STORE 12
2 210 LOAD 10
3 310 STORE 10
4 80b BEQ b
5 211 LOAD 11
6 112 ADD 12
7 312 STORE 12
8 210 LOAD 10
9 F04 DEC
a 703 BR 3
b F0F HALT
     
10 03 Data
11 05 Data
12 00 Data

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 5

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

Opcode Hex Mnemonic Meaning Address
0100dddddddd 4nn SUB add ACC <- ACC - mem( add) 0x20
1001aaaaaaaa 9aa BLT add Branch to Address if N=1 0x48
111100000001 F01 NOT Not ACC 0x88
111100000010 F02 NEG Negate ACC 0x90
111100000011 F03 INC ACC = ACC + 1 0x98
111100000101 F05 SWAP ACC <=> B 0xA8
111100000110 F0E NOP Do Nothing 0xF0
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.
*
Topic revision: r4 - 2014-11-12 - JimSkon
 
This site is powered by the TWiki collaboration platformCopyright &© by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback