Docsity

Computer Architecture Exam Practice Questions - Spring 2005, Exams of Electrical and Electronics Engineering

Toggle sidebar
bg1
EEL 4713/5764, Computer Architecture, Spring 2005
Sample Questions for Exam #2
The following questions are intended merely as practice, and to be suggestive of the
approximate style and level of difficulty of questions that might appear on the real exam.
The exact topics of the questions are not guaranteed to be restricted to those shown here.
Any material from the module 6 and 7 lectures and from chapters 3 or 5 (prior to the
multicycle datapath) is fair game for the exam. The exam is open book, open notes. Use
a calculator. Simplify as much as possible, and reduce symbolic answers to plain
numeric form. The real exam will have roughly 7 questions.
1. C to assembly. Below is a C++-language version of the division algorithm on
pp. 184-185 of the textbook, for the case of a 32-bit unsigned dividend and a 16-
bit unsigned divisor. Translate this to MIPS assembly.
// myDivide: Given a 32-bit unsigned dividend and a 16-bit unsigned
// divisor, compute and return the 16-bit unsigned integer quotient and
// also return (in rem) the 16-bit unsigned integer remainder.
unsigned int myDivide(unsigned int dividend, // Number to be divided.
unsigned short divisor, // Number to divide it by.
unsigned short &rem) { // Place to put remainder.
unsigned int
divisor_reg = divisor << 16; // Put divisor in left half of 32b register.
unsigned int quotient = 0; // Quotient register: Initially zero.
int remainder = (int)dividend; // Remainder register: Initially dividend.
for (int i=0; i <= 16; i++) { // Do the following 17 times:
quotient <<= 1; // Make room for a new bit of quotient.
remainder -= divisor_reg; // Trial subtraction of divisor.
if (remainder < 0) // If result is negative,
remainder += divisor_reg; // undo trial subtraction;
else // otherwise,
quotient |= 1; // this bit of the quotient is 1.
divisor_reg >>= 1; } // Shift divisor right to a new position.
rem = (unsigned short)remainder; // Return remainder.
return quotient; } // Return quotient and end.
2. Arithmetic algorithms. In the above division algorithm, show (in a neat table)
the contents of the divisor, remainder, and quotient registers initially and after
each step of the above algorithm for at least the first three loop iterations, in the
case of running it with dividend = 4,000,000,00010 and divisor = 65,00010.
3. Floating point. In standard IEEE 754 single-precision floating-point, what real
number is represented by the word value 7E3616? Write your answer in standard
decimal scientific notation, showing at least six significant figures. Show your
work.
4. ALU control. Given an ALU composed of the 1-bit cells shown in figure B.5.9
(in Appendix B, on the CD), how would all four control bits need to be set to
pf2

Partial preview of the text

Download Computer Architecture Exam Practice Questions - Spring 2005 and more Exams Electrical and Electronics Engineering in PDF only on Docsity!

EEL 4713/5764, Computer Architecture, Spring 2005

Sample Questions for Exam

The following questions are intended merely as practice, and to be suggestive of the

approximate style and level of difficulty of questions that might appear on the real exam.

The exact topics of the questions are not guaranteed to be restricted to those shown here.

Any material from the module 6 and 7 lectures and from chapters 3 or 5 (prior to the

multicycle datapath) is fair game for the exam. The exam is open book, open notes. Use

a calculator. Simplify as much as possible, and reduce symbolic answers to plain

numeric form. The real exam will have roughly 7 questions.

1. C to assembly. Below is a C++-language version of the division algorithm on

pp. 184-185 of the textbook, for the case of a 32-bit unsigned dividend and a 16-

bit unsigned divisor. Translate this to MIPS assembly.

// myDivide: Given a 32-bit unsigned dividend and a 16-bit unsigned // divisor, compute and return the 16-bit unsigned integer quotient and // also return (in rem) the 16-bit unsigned integer remainder. unsigned int myDivide( unsigned int dividend , // Number to be divided. unsigned short divisor , // Number to divide it by. unsigned short & rem ) { // Place to put remainder. unsigned int divisor_reg = divisor << 16; // Put divisor in left half of 32b register. unsigned int quotient = 0; // Quotient register: Initially zero. int remainder = ( int ) dividend ; // Remainder register: Initially dividend. for ( int i =0; i <= 16; i ++) { // Do the following 17 times: quotient <<= 1; // Make room for a new bit of quotient. remainder -= divisor_reg ; // Trial subtraction of divisor. if ( remainder < 0) // If result is negative, remainder += divisor_reg ; // undo trial subtraction; else // otherwise, quotient |= 1; // this bit of the quotient is 1. divisor_reg >>= 1; } // Shift divisor right to a new position. rem = ( unsigned short ) remainder ; // Return remainder. return quotient ; } // Return quotient and end.

2. Arithmetic algorithms. In the above division algorithm, show (in a neat table)

the contents of the divisor, remainder, and quotient registers initially and after

each step of the above algorithm for at least the first three loop iterations, in the

case of running it with dividend = 4,000,000,000 10 and divisor = 65,000 10.

3. Floating point. In standard IEEE 754 single-precision floating-point, what real

number is represented by the word value 7E36 16? Write your answer in standard

decimal scientific notation, showing at least six significant figures. Show your

work.

4. ALU control. Given an ALU composed of the 1-bit cells shown in figure B.5.

(in Appendix B, on the CD), how would all four control bits need to be set to

perform the operation NAND? That is, give the 4-bit value of the ALU control

bus, with bits in the order ( Ainvert )( Bnegate )( Operation ).

5. Single-cycle datapath analysis. Given a diagram of a complete single-cycle

datapath such as that shown in figure 5.24 (p. 314) in the textbook, highlight the

portions of it that are involved in the execution of a given instruction. (Try lw for

practice.) Also specify the values of all control signals.

6. Single-cycle datapath design. Suppose you were asked to extend the single-

cycle datapath from fig. 5.24 to support additional instructions, for example jr

(jump register). What new connections would be needed in the datapath? What

control signals would need to be modified or added? Give an example of logic

that could correctly compute the values of any new control signals that you add.