Skip to main content
Department of Information Technology

Computer Architecture, First Course

Microprogramming of simulated processor

Purpose

The aim of this lab is to understand how microcode can be used for executing machine instructions within a processor.

Background

In chapter 4 in the course literature (Structured Computer Organization, 4ed) an example microarchitecture is described. The described processor can execute programs written in a subset of the JAVA virtual machine (IJVM). A simulator, mic-1, is used for running the code. We will use the simulator in this lab. The simulator can easily be run on the Sun workstations by typing the following in your home directory:

> mkdir mic1
> cd mic1
> tar xvfz /stud/kurs/dark/MN1-HT03/mic1.tar.gz
> export CLASSPATH=$PWD/classes.zip

or

> setenv CLASSPATH ${PATH}:$PWD/classes.zip

It is necessary to read chapter 4.1 - 4.3 carefully before you start the lab.

Exercises

The lab contains two parts:

Part 1

Write a small program in IJVM (edit a *.jas file) that lets the user write a sentence in the simulator input window and counts the number of letters typed. Spaces should not be counted. This is similar to part 5 and 6 in the mic1 user guide.

Hints: Look at echo.jas that is part of the mic1 distribution... If you want to print the result in the simulator (instead of just looking in a register), you can borrow/steal the print function provided in the add.jas file in the distribution and call it using INVOKEVIRTUAL. It prints the result in hexadecimal form.

Part 2

Implement and test a new macro instruction that multiplies two unsigned integers between 0 and 65535 (16 bit). The new instruction, called IMUL, should multiply the two top values of the stack, remove them, and return the result on top of the stack. You should ask the user for two numbers, receive them, multiply them and print the output. You can use the methods getnum and print in the file add.jas for input and output. For the implementation of IMUL, one can add "x" to itself "y-1" times to compute "x * y". However that is unefficient for large numbers. Instead you should use the classic method:

       110 (6)
       101 (5)
     -----
       110
      000
     110
    ------
     11110 (30)

This method requires that you are able to add and shift numbers. The problem is that the provided micro instructions can only shift by 8 to the left or 1 to the right. We would like to shift by 1 to the left. This can be done by adding the number to itself, for example: 110+110=1100 (6+6=12). If you want to shift a given number of bits to the left, let say n steps, you can put n in MDR and perform:

  imul1	.......
  imul2	MDR = MDR - 1
  imul3	OPC = H = H + OPC
  imul4	Z = MDR; if (Z) goto imul5; else goto imul2
  imul5	.......

You should insert your micro code in the file mic1ijvm.mal with 0x78 as the control store address. Compile mic1ijvm.mal with mic1asm and update the ijvm.conf file.
To implement this in micro code, you have to access the memory via the stack. Try to use the memory as little as possible; use the registers instead.

Presentation

The presentation will be oral. However, it is important that you bring printouts of all code and answers you have written to the presentation.

Updated  2003-12-05 11:21:27 by Dan Wallin.