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
(Notes Accompanying the Handout "Computer System Organization: the Microarchitecture Level")
Material That You Should Know
(including pages from the book):
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).
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)