CS 271- Spring 2002
Home Work 4 solutions
Chapter #4
1.
F0 |
F1 |
ENA |
ENB |
INVA |
INC |
Function |
1 |
1 |
1 |
0 |
0 |
0 |
A |
2.
The total data path takes (1 + 3 + 1 + 2) = 6 nsec. The clock pulse is 2 nsec.
Thus, the minimum clock cycle is (2+6) = 8 nsec or (1/8 nsec) = 125 MHz.
The machine can run at 100 MHz (10 nsec) , but not at 150 MHz (6.7 nsec)
7.
Translation 1 |
Translation 2 |
ILOAD j |
ILOAD j |
ILOAD k |
ILOAD k |
IADD |
BIPUSH 4 |
BIPUSH 4 |
IADD |
IADD |
IADD |
ISTORE i |
ISTORE i |
11.
JAVA Code |
Micro-instructions |
ILOAD j |
main1 + iload(5) =6 |
ILOAD k |
main1 + iload(5) =6 |
IADD |
main1 + iadd(3) =4 |
ISTORE i |
main1 + istore(6) =7 |
6+6+4+7 = 23 microinstructions. Since at 200MHz, each instruction takes 5 nsec. 23*5 = 115 nsec is required to execute this statement.
12.
JAVA Code |
Micro-instructions |
ILOAD j |
iload(3) =3 |
ILOAD k |
iload(3) =3 |
IADD |
iadd(3) =3 |
ISTORE i |
istore(5) =5 |
3+3+3+5 = 14 microinstructions. Thus 5nsec * 14 = 70 nsec in required to execute this statement.
Mic-1 require 115 nsec, Mic-2 require 70 nsec.
Thus a program runs for 100 nsec on the Mic-1 would take 100 * (70/115) = 60.87 sec. on the Mic-2
17.
MAIN1
POPTWO1 MAR =SP = SP - 1;rd
POPTWO2
POPTWO3 TOS = MDR; goto Main
MAIN1
POPTWO1 MAR =SP = SP - 1;rd
POPTWO2
POPTWO3 TOS = MDR; goto Main
24.
No, it wont be possible. The reason is that there is going to be difference. GOTO1 is stored at location 0xA7.
When Z is set to 1, the address of GOTO1 is set to 1xA7.
This all has to do with what values are set by the HOB in determining what the addres of GOTO1 is going to be.
No, the machine will not run any faster because either way, it takes 2 instructions to get to the same place in the code.
27.
Assuming that the read is of the same data as the write the write allocation does win, but it only wins over the first read, all subsequent reads would be in cache regardless. This is not a big win, but it is a gain, and saves us one trip to memory for the first read.