Final Exam Solution - Test Paper Final Exam Solution - Test Paper
Final Exam Solution - Test Paper Final Exam Solution - Test Paper
Final Exam Solution - Test Paper Final Exam Solution - Test Paper
Final Examination
Semester 1 2017
Instructions:
2) 2FAOC is equivalent to
A. 195 084 in decimal
B. 001011111100011101100
C. Both A and B
D. None of the above
4) A page fault
A. Occurs when there is an error in a specific page.
B. Occurs when a program accesses a page of main memory.
C. Occurs when a program accesses a page not currently in main memory.
D. Occurs when a program accesses a page belonging to another program.
5) If an instruction takes 3 cycles for execution, then how many cycles are needed for executing 4
instructions of the same type in a sequence using a 3-stage pipeline? Assume that there are no
interrupts or exceptions while executing them.
A. 12 cycles
B. 6 cycles
C. 9 cycles
D. 4 cycles
6) Which of the following architecture has the fixed instruction length feature?
A. CISC
B. RISC
C. X86
D. None of the above
7) How do Direct Addressing Mode instructions compare with respect to the Indirect Addressing
Mode instructions?
A. Faster
B. Slower
C. No difference
D. None of the above
8) The first person who attempted to build a digital computer was _______________
A. Charles Babbage
B. Blaise Pascal
C. Baron Wilhelm
D. Alan Turing
10) When you transfer the record from a Big Endian system to a Little Endian system over the
network in order to get the original value, you must:
A. Reverse the byte within a word
B. Reverse the bytes in an integer
C. Reverse the characters in a word
D. There is no simple solution
x y z F(x,y,z)
0 0 0 0
0 0 1 1
0 1 0 1
0 1 1 0
1 0 0 0
1 0 1 1
1 1 0 1
1 1 1 0
a. Write the disjunctive normal form (DNF) for the above truth table. (2 marks)
b. Simplify the DNF form in part a) using Boolean algebra. (3 marks)
c. Draw the logic diagram for the simplified expression in part b). (2 marks)
d. Draw a multiplexor for the above truth table. (3 marks)
2. For the following three questions, assume that memory locations contain the values shown in
the following table:
Location Value
-------- -----
100 150
110 130
120 110
130 100
140 120
150 140
What value will be loaded into the accumulator if the following instructions are encountered? (3
marks)
a. Load immediate 100
b. Load direct 100
c. Load indirect 100
Answer:
1 mark each
a) 100
b) 150
c) 140
X = ((A-B)+((C-D)/E))*F
Answer:
a)
MOVE A,R0
SUB B,R0
MOVE C,R1
SUB D,R1
DIV E,R1
ADD R0R1
MUL F,R1
MOVE R1,X
PUSH A
PUSH B
SUB
PUSH C
PUSH D
SUB
PUSH E
DIV
ADD
PUSH F
MUL
POP X
Answer:
Answer:
0000 R1 R2 R3
…. 1 mark
1110 R1 R2 R3
1111 0000 r2 r3
& 1 mark
1111 1101 r2 r3
&. 1 mark
&& 1 mark
6. What is one major problem in Clocked SR latch and explain how a clocked D latch solves the
problem? ( 3 marks)
Answer:
An error (ambiguity) occurs in the SR latch when S and R inputs are both 1 (1.5 marks)
It prevents both inputs S and R being 1 at the same time by providing one input D and its
complement (1.5 marks)
7. List three different ways to achieve processor –level parallelism when designing computers.
(3 marks)
Answer:
Array computers
Multi processors
Multi computers
8. For the page references given below, answer the questions that follow.
A, B, C, D, B, E, C, G, D, A, G, D, B, E, C
a. How many page faults will occur if optimal page replacement algorithm is used? Show all
working. [2 marks]
b. How many page faults will occur if LRU page replacement algorithm is used? Show all
working. [2 marks]
c. How many page faults will occur if FIFO page replacement algorithm is used? Show all
working. [2 marks]
Answer:
9. Assume you have a superscalar CPU with in-order issue and in-order instructions that uses 8
registers (R0-R7). The usual rules include: up to two instructions can be issued in one cycle;
instructions have to complete in the order they are issued; an instruction attempting to write to
a register that is being read by any incomplete instruction cannot be issued until the incomplete
instruction completes; any instruction attempting to read a register that is being written to by
any incomplete instruction cannot be issued until the incomplete instruction retires; no new
instructions can be issued in a cycle when instructions are retiring; multiplication/division
instructions takes 3 cycles to complete while addition/subtraction instructions take only 2
cycles. Suppose you need to run the following four instructions:
1. R3 = R1 + R2
2. R1 = R4 * R5
3. R5 = R2 * R8
4. R6 = R1 + R4
a. How many cycles in total will the CPU take to complete the four instructions above. Use a
scoreboard as shown below to illustrate your answer. (4 marks)
b. How many cycles will the CPU take if out-of-order instruction issue and execution is allowed.
Use a scoreboard as shown above to illustrate your answer. (4 marks)
Answer:
a. 11 cycles (0.5 mark)
2
3 1 0.5
4 2 0.5
3 R5 = R2 * R8 -
5
6
7 2 0.5
8 3 0.5
4 R6 = R1 + R4 4
9
10
11 3 0.5
4
2 3 S2 = R2 * R8 3 1
4 R6 = R1 + R4 4
3 1 0.5
4 2 1
4
5 3 0.5
10. Suppose you are designing a computer from scratch and that your company’s budget allows a
very small amount of memory bandwidth. Which of the following characteristics would you
choose in the ISA and the microarchitecture? Explain your answer. (6 marks)
a. Variable length or fixed length instructions?
b. Complex instructions or simple instructions?
c. A large cache or a small cache?
Answer:
a. Variable length =>smaller code therefore less bandwidth to transfer instructions 2 marks
b. Complex instructions => smaller program because each instruction is more powerful
therefore less bandwidth to transfer instructions. 2 marks
c. Large cache => higher cache hit rate which will result in less need to access memory. 2
marks
11. Two processors with different ISA need performance evaluation. The first processor with ISA A
performs at the rate of 10 instructions per cycle where as the second processor with ISA B
performs at the rate of 2 instructions per cycle. The first processor has 500 MHz clock while the
second processor has 600 MHz clock.
a. What is the performance in MIPS of the processor implementing ISA A? (1 mark)
b. What is the performance in MIPS of the processor implementing ISA A? (1 mark)
c. Which is the higher performance processor? Explain your answer. (2 marks)
Answer:
a. 10 IPC X 500 MHz = 5000 MIPS 1 mark
b. 2 IPC X 600 MHz = 1200 MIPS 1 mark
c. Not enough information provided. We don’t know the number of instructions
executed on each processor, so we can’t compare performance. Processor A for
example may have very simple instructions . Processor B could be faster if its
instructions actually accomplish significantly more work than Processor A’s. The
MIPS metric does not take into account number of executed instructions, which also
affects the performance (i.e. execution time) of each processor. 2 marks
12. What would be the code word if you encode the data word 10011010 to allow one bit error
detection and correction using hamming code with even parity? (4 marks)
Answer:
_ _ 1 _ 0 0 1 _ 1 0 1 0 (0.5 mark)
13. The instruction execution cycle consists of six steps. The second step is <Increment the program
counter=. Explain the purpose for the second step? (2 marks)
Answer: Program counter points to the next instruction to execute. To make progress in
program execution.
14. A segmented address space uses paged virtual memory. Each virtual address has a 2 bit segment
number, a 2 bit page number and an 8 bit offset within the page. In the following page tables, a
<-= indicates that the page is not in memory, which has 8 page frames.
a. What is the lowest hexadecimal virtual address in segment 2 that will cause a page fault?
(2 marks)
b. Find the real memory address (in hexadecimal) if the virtual hexadecimal address is FAA.
(2 marks)
c. Find the virtual address (in decimal) if the real memory decimal address is 1000.
(2 marks)
a. 10 00 00000000 = 800
(1.5 marks) (0.5 mark)
15. Which value does this two’s complement binary number 11110100 represents? (2 marks)
Ans: 00001011
+ 1
---------------------
16. Suppose the hard disk above has 1024 cylinders, 8 tracks per cylinder, 32 sectors per track and
512 Bytes per sector. The maximum seek time is 450 msec, the time to move between adjacent
cylinders is 10 msec, the rotation time is 14. If the entire disk was full of data stored
consecutively, how much time would it take to read the entire disk if the read/write head is
already positioned on the first sector of the first track of the first cylinder of the disk? (3 marks)
Answer:
Total time = cylinder read + track switch + track switch wait + cylinder switch/wait
= (8*14)*1024 + (0) + (0) + (1023*14)
= 129010 msec
17. On computer 1, all instructions take 10 nsec to execute. On computer 2, they all take 5 nsec to
execute. Can you say for certain that computer 2 is faster? Explain your answer. (3 marks)
Answer:
You cannot say anything for sure. If computer 1 has a five-stage pipeline, it can issue up to 500 million
instructions/second. If computer 2 is not pipelined, it cannot do any better than 200 million
instructions/sec. Thus without more information, you cannot say which is faster.
18. A machine instruction is needed during execution. The instruction could be in an instruction
cache (with probability 0.65) or in memory (with probability 0.3) or on disk. The access times for
cache and disk are 50 ns and 6000 ns respectively. Assume each instruction source is checked
before a slower one to find the instruction. What minimum memory access time (in ns) will give
an expected access time of 800 ns? (3 marks)
Answer:
19. Why do you think John von Neumann’s original basic design of a computer, known as von
Neumann machine, is still the basis for nearly all digital computers? (2 marks)
Answer:
His machine has 5 basic parts (memory, control unti, ALU, input and output) which are still found and
are important components of a digital computer.
Extend the Wombat 3 accumulator based assembly language to the Wombat 4 addressing modes.
Addressing modes will be used only on STORE and LOAD machine instructions. There are three modes
that can be used: Direct, Indirect and Immediate. For example, LOAD IMM 122 will load the value 122
into the accumulator and STORE IND L2 will store the contents of the accumulator to address stored at
location L2.
Write a complete Wombat 3 assembly language main and subprogram. The main program tests the
subprogram: it reads in exactly one integer, checks that the integer is valid input, calls the subprogram
and writes out the result. The subprogram must compute the function: f(n) = 4 × n × f(n − 1)
where f(0) = 3. The program must be properly commented.
Answer: