0% found this document useful (0 votes)
39 views

CENG400 Midterm Fall 2015

This document provides information about an exam for a computer organization and design course. The exam contains 3 questions worth a total of 100 points. Question 1 is worth 25 points and covers CPU performance topics. Question 2 is worth 40 points and covers single cycle data path topics. Question 3 is worth 35 points and covers MIPS assembly language topics including translating machine code, performing operations, and writing a program to swap strings.

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)
39 views

CENG400 Midterm Fall 2015

This document provides information about an exam for a computer organization and design course. The exam contains 3 questions worth a total of 100 points. Question 1 is worth 25 points and covers CPU performance topics. Question 2 is worth 40 points and covers single cycle data path topics. Question 3 is worth 35 points and covers MIPS assembly language topics including translating machine code, performing operations, and writing a program to swap strings.

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/ 10

 

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

Course: CENG 400, Computer Organization and Design

Instructors: Dr. Zaher Merhi, Dr. Ali Ghwouyel, Dr. Ayman Khalil, Dr. Ali Bazzi, Dr.
Abdelmehsen Ahmad, Dr. Ousama Tahan, Dr. Reda Shbib

Date: Friday November 20, 2015-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 10 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 10 
 
Question 1: CPU Performance (25 Points)

a) True or False (5 points)


i. Certain sections of high-level language code could be rewritten in assembler in order
to speed up the entire program.
_______
ii. Using $t0 instead of $a0 to pass an argument to a subprogram will generate an error
________
iii. Loading the immediate value 255 into a word only affects the low-order byte
_______
iv. Registers can be referred to either by their mnemonic name or their number.
_______
v. The stack grows towards address 0.
_______

b) Computer A has an overall CPI of 1.3 and can be run at a clock rate of 600 MHz.
Computer B has a CPI of 2.5 and can be run at a clock rate of 750 MHz. We have a
particular program we wish to run. When compiled for computer A, this program has
exactly 100000 instructions. How many instructions would the program need to have
when compiled for Computer B, in order for the two computers to have exactly the same
execution time for this program? (7 Points)

Page 2 of 10 
 

c) Consider two different processors P1 and P2 executing the same instruction set. P1 has a 3
GHz clock rate and a CPI of 1.5. P2 has a 2.5 GHz clock rate and a CPI of 1.0.
i. Which processor has the highest performance expressed in instructions per
second? (3 points)
 

ii. If the processors each execute a program in 10 seconds, find the number of cycles
and the number of instructions. (3 points)
 

iii. We are trying to reduce the execution time by 30% but this leads to an increase of
20% in the CPI. What clock rate should we have for each of the two processors to
get this time reduction? ( 7 points)

Page 3 of 10 
 
Question 2: Single Cycle Data Path (40 points)

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

- lw $t0, 48($t1)
- Note that the PC and the content of registers $t0 and $t1 are found in bottom left
corner of the figure below

4
2


$t0 = 0x00018AC7 

$t1 = 0x000016F0 

PC = 0x000014BA0 

(Before executing LW) 

Page 4 of 10 
 
1) Fill the table below with the content of the lines indicated by the number on the figure (12
Points). Write down all bits.

1
2
3
4
5
6

b) Assume you have the following implementations of a 32-bit MIPS processor.

Processor IF ID EX MEM WB
Single 200ns 300ns 200ns 400ns 300ns
5-Stage 200 ns 300ns 200ns 400ns 300ns
Pipeline
10-Stage 100ns 100ns 150ns 150ns 100ns 100ns 200ns 200ns 150ns 150ns
Pipeline
For the 10-stage pipeline the IF stage is divided into two stages and so are the rest of the
stages.

1. Calculate the frequency for each implementation ( 6 points)

2. What is the speedup attained in the 5-stage pipeline and 10-stage pipeline
implementation in comparison with the single cycle implementation if you have
100 instructions to execute (assume no stalls will ever occur). (6 points)

Page 5 of 10 
 
c) We need to implement the following new instruction: JAL Label (check MIPS instruction sheet)
This instruction has two functionalities that should be done in the same clock cycle

1. PC = label ( you need to transform it to 32 bits)


2. Register_File($ra) = PC+4
i. Propose a modification to the datapath to support JAL knowing that JAL is of type J. (12
Points)
 You need to give a name, a description and the values of each control you intent to add

Add Extra Hardware Below 

   

                   

Page 6 of 10 
 
Write down assumptions here:

ii. Fill down the controls and the instruction bellow specify new controls in the appropriate
fields (4 Points)

RegDst Branch New controls: _____________________________


MemRead MemtoReg __________________________________________
ALUOp MemWrite __________________________________________
ALUSrc RegWrite __________________________________________

Page 7 of 10 
 
Question 4 – MIPS (35 Points)

a) Translate the following machine codes to MIPS: (5 points)


0x3C12F000

b) What is the value of $t2 after the following instructions, if the value of register $t0 is
0x55555555 and $t1 is 0x12345678? (5 points)

srl $t2, $t0, 3


andi $t2, $t2, 0xFFEF

c) Consider the code fragment: (5 points)


addi $t0, $0, 0
lui $t0, 936
lb $s0, -2956($t0)
What memory address is computed by the lb instruction?

d) (20 points) Write a MIPS programs that performs string swap. String swap works as
follows: consider 2 strings, the first string will be copied to the second string replacing all its
content and the second string will be copied to the first string replacing also all its content. It
is not an issue that strings are not of equal size since they are terminated by the /0.
Consider the following example:
 

String 1 = “ I love MIPS /0” 

String 2 = “ I love CENG400 /0” 

The result will be  

String 1 = “ I love CENG400 /0” 

String 2 = “ I love MIPS /0”  

Page 8 of 10 
 
The two strings are stored in Data Memory and are located at 0x2234F50 and 0x12AD48

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 (2 points)

- Call the function string_swap (2 point)


o Use the stack to save values all static variables (4 points)
o Perform the string swap algorithm as described before (9 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 9 of 10 
 
Extra Sheet

Page 10 of 10 
 

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy