C20.0035.001 Fundamentals of Computer Systems -- Spring 2000

Lecture Notes on

The Microarchitecture Level of a Computer

How the FDE Cycle of IJVM is Executed by a Microprogram

 

  

Microarchitecture

(Notes Accompanying the Handout "Computer System Organization: the Microarchitecture Level")

Material That You Should Know

(including pages from the book):

 

  1. The data path (Section 4.1.1). Key points: how various operations are performed in ALU and the Shifter; how this is accomplished by moving the data from registers and memory through ALU/Shifter and moving the result back to one or several registers and/or memory.
  2. ALU and Shifter control signals governing these operations; Figure 4-2; Skip pages 207 - 209 (data path timing)
  3. Memory operation (p. 209; skip page 210).
  4. Microinstruction format for the IJVM machine (Section 4.1.2). Main idea: how the microinstruction completely specifies what the computer should do (what operation is performed, where the input data is coming from, where the results are stored, what next operation should be performed, etc.). Given a sequence of bits, you should be able to explain what the instruction is (i.e., what it does) and vice versa: given an English explanation of the instruction, you should be able to write the appropriate microinstruction (i.e., sequence of bits).
  5. The micro-architecture of IJVM. You should be able to understand Fig. 4-6 and explain how it works (pp. 213 - 216).

 

How the FDE Cycle of IJVM is Executed by a Microprogram

1. Java Virtual Machine. You are responsible for the following topics covered in Sections 1.4.3 (p.p. 34 - 35) and 4.2.4 (p. 226) of the book. The basics of the Java Virtual Machine (JVM) (as explained in Section 1.4.3). The concept of a virtual machine (it is specified by the computer designers "on paper" and does not have to exist as a piece of hardware). Compilation of Java programs into the Java byte code (binary programs). Three ways to execute Java byte code (binary programs): a) by interpreting them with the run-time interpreter running on the machine of your choice (e.g. Pentium, SunSparc, etc.); b) by compiling them into the machine language of your computer (e.g. Pentium, etc.) using Just-in-time compiler and executing the compiled code; c) by executing the Java byte code directly on the dedicated hardware (JVM chips, such as picoJava). Portability of Java binary programs.

2. Instruction Set for IJVM. The JVM machine is quite complicated, e.g., it contains 226 instructions in its instruction set. Therefore, the book restricts its consideration only to the subset of the integer instructions and calls the resulting machine Integer JVM or IJVM for short. The instructions of IJVM machine are presented in Figure 4-11 of the book and most of them explicitly use stack as a part of their definition. To see what the stack is and how it works, click here. For example, the "ILOAD varnum" instruction pushes the local variable varnum onto the stack, the "ISTORE varnum" instruction pops the top of the stack into variable varnum. Similarly, the IADD instruction pops the two topmost elements from the top of the stack, adds them, and pushes the sum back onto the stack. For example, if the stack has numbers 8, 4, 16, and 9 (8 being on top and 9 on the bottom), then IADD pops 8 and 4, adds them, and pushes 12 back on stack. The contents of the new stack is 12, 16, 9.

The programs written using IJVM instructions are called Java byte code (or binary) programs and, as explained before, are usually obtained by compiling Java programs (although they can also be written directly by humans). An example of such a program is presented in Figure 4-14. Column (a) shows a fragment of a Java program that adds two numbers (assigned to variables j and k), and if the result is equal to 3, variable k is assigned 0; otherwise, variable j is decremented by 1. The Java binary program, obtained by compiling the Java program from Figure (a), is presented in Figure (c), and its human-readable form (written in Java assembly language) is in Figure (b).

3. Microprogram for IJVM. We next present a microprogram that executes Java byte-code programs, such as the ones from Figure 4-14(b) (or 4-14(c)). This microprogram is located in the control-store memory unit in Fig. 4-6 and implements the FDE cycle presented in Section 2.1.2 (and in Fig. 2-3 in particular). This microprogram is written in the microinstruction language presented in Section 4.1.2 (and shown in Fig. 4-5). However, if such a program is specified as a sequence of bits, then it would be impossible for humans to understand it. Therefore, we will use a symbolic language that is equivalent to the bit-language of microinstructions presented in Section 4.1.2. This language is described in Section 4.3.1 (pages 227 - 229). Examples of the instructions in this language are SP = SP + 1; rd (increment the value of stack pointer register SP by one and issue the read instruction); and MDR = SP (copy the content of the SP register to the MDR register).

The microprogram for the IJVM is presented in Figure 4-17 and explained in Section 4.3.2 (mainly pages 232 - 236). However, before explaining how it works, we need the following preliminary explanations.

Registers in the data path. Figure 4-6 (and Figure 4-1) contains several registers in its data path. Some of them are special-purpose registers carrying the following functions:

PC - program counter; it points to the next instruction in the program to be executed; it is described on p. 40 and in Section 2.1.1 of the book in the context of the FDE cycle execution.

MAR - memory address register (contains the address of the memory location to be read/written).

MDR - memory data register (contains data to be written to the memory location pointed to by the MAR register for the write operation; also receives data from the memory location pointed to by the MAR register in the case of read operation).

The MAR and MDR registers "work" together in the cases when data is written to and read from the memory. For example assume that MAR = 3FC and MDR = 58. If the "write" request is issued, the data 58 is written from the MDR register to the memory location having address 3FC (pointed to by the MAR register). Similarly, if the memory location 3FC has the value 27 stored in it, and the "read" request is issued, the value 27 is transferred from the memory address 3FC to the MDR register.

MBR - memory buffer register; its size is only 1 byte (as opposed to 32 bits - 4 bytes - as is the case with other registers). It contains 1 byte of data fetched from the memory pointed to by the program counter PC.

SP - stack pointer; it points to the top of the stack.

TOS - top-of-stack register; contains the value of the memory location pointed to by SP (i.e., contains the item located on the top of the stack). For example, if the stack has numbers 8, 3, 6, 9, then TOS = 8.

Instruction Opcodes. As discussed before, instructions in Figure 4-11 consist of opcodes and zero, one, or two parameteres. The opcode specifies the type of an instruction (e.g. IADD vs. ILOAD vs. POP, etc.) to be executed. Opcodes are defined in the first column of Figure 4-11 (Hex) as hexadecimal offsets into the control store (of Figure 4-6) where the part of microprogram responsible for the execution of that instruction is located. For example, the opcode 0x60 for the IADD instruction means that the microcode associated with the addition operation begins at the hexadecimal address 60 in the control store.

4. Explanation of the microprogram from Figure 4-17. In order to explain how the microprogram from Figure 4-17 works, assume that the program is about to execute the IADD instruction (i.e., assume that the program counter PC points to instruction 3 in Figure 4-14(b)). As a first step, the first line of Figure 4-17 is executed, i.e.

PC = PC + 1; fetch; goto(MBR)

Initially, mictoinstruction PC = PC + 1 makes the program counter point to the next instruction of the macroprogram (instruction 4 ISTORE in Figure 4-14(b)). Simultaneously, the fetch instruction loads 1 byte of the memory location pointed to by the old value of PC into the MBR register. As a result, MBR contains the code for the IADD instruction (which has the value of 60 in hexadecimal, i.e., MBR = 60). After that, the goto(MBR) microinstruction lets the microprogram jump to the microcode located at the address 60 in the control store (by loading 60 into the MPC register of Figure 4-6). This completes the Fetch (PC = PC + 1; fetch) and the Decode (goto(MBR)) phases of the FDE cycle. Note that these two phases are the same for all the macroinstructions supported by the machine.
Now, the execute portion of the FDE cycle begins, and the next microinstruction to be executed is iadd1 (located at the address 60 in the control store). The first step of the iadd1 instruction is
MAR = SP = SP - 1
i.e., SP is decremented by 1, and this new value of SP is stored in the MAR register. After that the READ instruction is executed which loads the data immediately below the top of the stack into register MDR.
However, it takes some time to do the memory read. While this happens, the second microinstruction iadd2 (H = TOS) is executed, and the contents of the top of the stack is loaded into the register H (along the data path of Figure 4-6). At this point, the READ operation is completed and the MDR register receives the 2nd element of the stack.
After that, the third line (iadd3) of the IADD microprogram is executed. In particular, the contents of registers MDR and H (containing the two topmost elements on the stack at this point) are added in the ALU, and their sum stored in registers TOS and MDR. After that, the WRITE operation is issued. The MDR register contains the value of the sum, and the MAR register points to the top of the stack (the iadd1 instruction set it to the new value of SP). Therefore, the WRITE operation writes the sum back to the top of the stack.
Finally, the goto Main1 instruction takes us to the beginning of the microprogram and competes the execution of the IADD instruction. At this point, the microprogram is ready to execute the next macroinstruction pointed to by PC (e.g., ISTORE in the case of Figure 4-14(b)).
We considered the execution of the IADD macroinstruction. Executions of other instructions of the IJVM machine (specified in Figure 4-11) proceeds in a similar fashion by the microprogram from Figure 4-17. This completes our description of how the FDE cycle is executed by a microprogram.
The book covers the execution of the FDE cycle by the microprogram on pages 232 - 237.
 
Stacks
Stack is a data structure consisting of a list of items that can be inserted onto and deleted from the stack only from one end (i.e., the top of the stack). For example, if the "items" are integers, a possible configuration of the stack can be 8, 4, 9, 12, 5, 7, with 8 being on the top of stack and 7 on its bottom. Then we can use two major operations with the stack: PUSH new elements on top of the stack and POP old elements from the top of the stack. For example, the operation PUSH 3 results in placing 3 on top of the stack. In this case the new stack becomes 3, 8, 4, 9, 12, 5, 7. Similarly, the operation POP x removes the top element (3) from the stack and places it into variable x. As a result, the stack is restored to its initial configuration 8, 4, 9, 12, 5, 7. Besides the PUSH and POP operations, an additional operation checks if the stack is empty.