0% found this document useful (0 votes)
27 views9 pages

CENG400-Midterm-Fall 2014

This document contains a computer organization and design exam for a course taught in fall 2014-2015. The exam has 3 questions worth a total of 100 points. Question 1 is worth 25 points and covers CPU performance and optimizations. Question 2 is worth 35 points and involves analyzing the data path of a single cycle MIPS processor. Question 3 is worth 40 points and contains MIPS assembly programming questions, including tracing a program and translating instructions to binary. Students are instructed to show all work and answer all parts of the 3 questions.

Uploaded by

Mohamad Issa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views9 pages

CENG400-Midterm-Fall 2014

This document contains a computer organization and design exam for a course taught in fall 2014-2015. The exam has 3 questions worth a total of 100 points. Question 1 is worth 25 points and covers CPU performance and optimizations. Question 2 is worth 35 points and involves analyzing the data path of a single cycle MIPS processor. Question 3 is worth 40 points and contains MIPS assembly programming questions, including tracing a program and translating instructions to binary. Students are instructed to show all work and answer all parts of the 3 questions.

Uploaded by

Mohamad Issa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

 

School of Engineering
Department of Computer and Communication Engineering
Fall 2014 – 2015

Course: CENG 400, Computer Organization and Design

Instructors: Dr. Zaher Merhi, Dr. Ali Ghwouyel, Dr. Ayman Khalil, Dr. Ali Bazzi, Dr.
Abdelmehsen Ahmad

Date: Friday November 21, 2014-8:00 to 9:15

Time: 75 minutes

Student Name: _________________________ Section________ Campus __________

There are three Questions in the booklet each has several parts, please answer all parts of the 3
questions to the best of your ability.
Marking Scheme:

Questions Weight Mark


Question 1 25 points
Question 2 35 points
Question 3 40 points
Total 100 points
 
1. This booklet contains 9 pages including this one + 2 page MIPS Reference Sheet (not
numbered). Make sure you have all these pages.
2. Closed Book Examination. Calculators are allowed
3. The cheating penalty will be “F” in the exam
Good Luck
 

Page 1 of 9 
 
Question 1: CPU Performance (25 Points)

a) Consider a Processor P1 that implements three classes of instructions A, B and C.


Consider a program consisting of 3*103 instructions (1000 instructions per class). The
number of clock cycles for each class existing in the program is given in the following
table.
Nb. Clock Cycles A Nb. Clock Cycles B Nb. Clock Cycles C
P1 1000 5000 6000

1. What is the average CPI for each class? ( 3 points)

2. What is the average CPI for P1? ( 3 points)

3. If Processor P1 runs the program in 0.01 ms, what should be the clock rate? ( 4 points)

4. Processor P1 is re-designed and the optimized version called P2 is faster than P1 by 20


%. This will increase by 5 % the total number of cycles. What should be the clock rate
for P2? ( 6 points)

Page 2 of 9 
 
5. Consider now that the instructions of Class A represents addition operations and the
instructions of class C represent multiplications. An optimization is done to reduce the
number of clock cycles of this class of instructions. Each multiplication is then replaced
by 3 addition operations. That is, we can completely replace Class C with Class A in this
way each class C instruction takes 3 class A instructions. Class B remains unchanged.
a. What will be the total number of clock cycles needed to run the program? ( 3
points)

b. What is the new average CPI for P1? ( 3 points)

c. The execution of the program takes now 3 microseconds. What is the new clock
rate for P1? ( 3 points)

Page 3 of 9 
 
Question 2: Single Cycle Data Path (35 points)

a) Consider the data path below for a single cycle 32-bits MIPS processor
Assume that we are executing the following instruction

- beq $t0, $t1, -3


- Note that the PC and the content of these registers are found in bottom left corner of the
figure below

4
2


$t0 = 0x00000A57 

$t1 = 0x000006B0 

PC = 0x000000B30 

Page 4 of 9 
 
1) Fill the table below with the content of the lines indicated by the number on the figure (12
Points)

1
2
3
4
5
6

2) For each of the following instructions fill the respective tables (6 points)

lw   

RegDst Branch
MemRead MemtoReg
ALUOp MemWrite
ALUSrc RegWrite

slt 

RegDst Branch
MemRead MemtoReg
ALUOp MemWrite
ALUSrc RegWrite

beq  

RegDst Branch
MemRead MemtoReg
ALUOp MemWrite
ALUSrc RegWrite

Page 5 of 9 
 
b) Consider the following MIPS program that was run on 5 stage MIPS pipeline processor
addi $t0, $t1, 100 
lw   $t2, 4($t0)  
lw $t0, 8($t2) 
lw $t2, 16($t0) 
add $t2, $t2,$t1 
sw  $t1, 0($t3) 
addi $t4, $t3, 100 

i. Assume Now that forwarding is employed, fill the table below. Indicate Stalls by writing
ST in the Clock cycle (C) where it occurs and Forwarding by an arrow() (12 points)
 

Clock cycle
Instruction C1 C2 C3 C4 C5 C6 C7 C8 C9 C C C 12 C 13 C 14 C 15 C 16 C 17 C 18
10 11
addi $t0,
$t1, 100

lw $t2,
4($t0)

lw $t0,
8($t2)

lw $t2,
16($t0)

add $t2,
$t2,$t1

sw $t1,
0($t3)

addi $t4,
$t3, 100

ii. Is it possible to re-write the program in order to reduce the number of stall cycles? if yes
explain how? (5 points)

Page 6 of 9 
 
Question 4 – MIPS (40 Points)

(a) (20 points) Given the following MIPS program what does
Address Program Comment (what is the instruction performing)
0x12ABC ADD $v0, $v0, $0 Set the content of $s0 to 0
ADDi $t0, $0, 1
Label2: AND $t2, $a0, $t0
BEQ $t2, $0, Label1
ADDi $v0, $v0, 1
Label1: SLL $t0, $t0, 1
BEQ $t0, $0, Exit
J Label2
Exit:
a) Fill the table by adding all addresses and comments on each program instruction (7
points)

b) Assume that the value of $a0 = 0x00000007 trace the program and find the value of $v0,
write down the first 4 iteration (3 points)

Iteration $t0 $v0 $t2 $a0


1
2
3
4
 

c) What is the aim of the above program in one sentence (2 points)

d) Translate to binary the following instructions taken from the program above
i. ( 3 points)
Instruction BEQ $t2, $0, Label1
Binary
HEX

ii. ( 3 points)
Instruction J Label2
Binary
HEX

iii. (2 points)
Instruction AND $t2, $a0, $t0
Binary
HEX
 

Page 7 of 9 
 
(b) (20 points) Write a MIPS programs that performs the concatenation of two strings. That is, if
the first string is “I Love \0” and the second string is “MIPS \0” after performing the function
the result will be anther string with the value “I love MIPS \0”.

In this way String 3 = String1 + String2.

The two strings are stored are located 0x2234F50 and 0x12AD48 and the resulting string will
be located at address 0x100.

The following is what your program should do


- String 1 address must be saved in $s1 (2points)
- String 2 address must be saved in $s2 (1 points)
- The resulting string must be saved in $s3
- Call the function string_concatenation (2 point)
o Push in the stack values $s1, $s2, and $s3 (3 points)
o Perform the string concatenation algorithm as described above (8 points)
o POP the string from the stack (3 points)
o Return to main program (1 point)

Assume that the string contents are already existing in memory and that each string is
terminated by ‘/0’
 

Page 8 of 9 
 
Extra Sheet

Page 9 of 9 
 

You might also like