





Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The instructions and problems for the final exam of the computer engineering course (ece 2030 g) held in fall 2003. The exam consists of five problems, each with multiple parts, and covers topics such as switches and gates, counter design, instruction formats, and assembly language programming.
Typology: Exams
1 / 9
This page cannot be seen from the preview
Don't miss anything!






5 problems, 6 pages Final Exam 12 December 2003
Instructions: This is a closed book, closed note exam. Calculators are not permitted. If you have a question, raise your hand and I will come to you. Please work the exam in pencil and do not separate the pages of the exam. For maximum credit, show your work. Good Luck!
Your Name ( please print ) ________________________________________________
1 2 3 4 5 total
20 30 40 44 66 200
5 problems, 6 pages Final Exam 12 December 2003
Problem 1 (2 parts, 20 points) (^) Switches and Gates Part A (12 points) For each expression below, create a switch level implementation using N and P type switches. Assume both inputs and their complements are available. Your design should contain no shorts or floats. Use as few transistors as possible.
OUTx = A + ( B ⋅( C + D ))+( E ⋅ F ) OUTy = ( G + H )⋅( K +( L ⋅ M ⋅ N ))
Part B (8 points) For the design below, determine the behavior and write as a Boolean expression. Do not simplify the expression. Also determine the number of transistors used in the gate-level design.
OUTX = Number of transistors:
5 problems, 6 pages Final Exam 12 December 2003
Problem 3 (2 parts, 40 points) Sorting Out Priorities Part A (20 points) Consider the following circuit. For each combination of inputs listed below, describe the corresponding outputs.
oops!
2 to 4 decoder
In 0 In 1 En
Out 0 Out 1 Out 2 Out 3
4 to 2 priority encoder
In 0 In 1 In 2 In (^3) In 3 > In 2 > In 1 > In 0
Out 0 Out 1 C V
A B C X Y Z 0 0 0 0 0 1 1 0 1 0 1 1 1 1 1
Part B (20 points) Suppose we have an 8 to 3 priority encoder with the following priority: (lowest priority) I 4 < I 6 < I 2 < I 1 < I 3 < I 0 < I 7 < I 5 (highest priority) Complete the following truth table entries with appropriate outputs for this priority scheme:
I 7 I 6 I 5 I 4 I 3 I 2 I 1 I 0 O 2 O 1 O 0 Valid 0 0 0 0 0 0 0 0 1 1 0 0 1 1 1 1 0 1 0 1 0 1 1 0 0 1 0 1 1 1 1 1 0 0 0 1 0 0 0 0
5 problems, 6 pages Final Exam 12 December 2003
Problem 4 (1 part, 44 points) Instruction Formats and Microcode Part A (20 points) Suppose a datapath has three operand busses (two source, one destination), 256 operation types, and 128 registers where each register is 64 bits wide. Immediate operands can be in the range of ±128K. Determine the following values for the resulting instruction format. For the last two questions, assume the same operand number and types used in the MIPS format.
minimum # bits needed to specify an R-format instruction minimum # bits needed to specify an I-format instruction Part B (24 points) Write a microcode fragment (1 or more microinstructions) that implements the following MIPS assembly language program fragment: lw $2, ($1) andi $6,$2,0xF srl $2, $2, 4 sub $6, $2, $ sw $6, ($3) You may not need to use all the rows in the table. You may use other registers as needed. Put an “x” in fields that are “don’t cares”. Express any immediate values in hexadecimal. # X Y Z rwe im en im va au en -a /s lu en lf su en st ld en st en r/ -w m sel description
1 2 3 4 5 6 7 8 9
5 problems, 6 pages Final Exam 12 December 2003
Part B (20 points) Suppose we are writing part of the code for a mathematics tool which solves polynomial equations. In particular, we are writing the code for a procedure Quadsolver, which takes 3 arguments (a, b, and c in registers $1, $2, and $3, respectively) and determines the roots of a quadratic equation using the quadratic formula: − b ± b − ac a
It puts the two roots it computes in $4 and $5. QuadSolver is called by PolySolver (which solves n-degree polynomials). QuadSolver calls Sqrt to compute the positive square root of a number x ; Sqrt takes its input x in $1 and stores the positive square root of x in $6. Most of QuadSolver has already been written (see below), but instructions necessary for preserving registers across calls are missing. Assume we are using caller-save convention so the caller is responsible for pushing/popping register values onto/from the stack to preserve them across subroutine calls. In the spaces provided below, write any additional lines of code that must be added to QuadSolver to ensure that registers that are needed after the call to Sqrt are preserved. Use register $29 as the stack pointer.
QuadSolver: add $9, $0, $1 # $9 = a addi $11, $0, 2 # $11 = 2 mul $9, $9, $11 # $9 = 2a mul $13, $9, $11 # $13 = 4a mul $13, $13, $3 # $13 = 4ac mul $12, $2, $2 # $12 = b 2 sub $1,12, $13 # $1 = b 2 - 4ac sub $12, $0, $2 # $12 = -b
jal Sqrt # $6 = Sqrt($1)
add $4, $12, $6 # $4 = -b + sqrt div $4, $4, $9 # $4 = -b+sqrt/2a sub $5, $12, $6 # $5 = -b – sqrt div $5, $5, $9 # $5 = -b-sqrt/2a jr $31 # return
5 problems, 6 pages Final Exam 12 December 2003
MIPS Instruction Set (subset) instruction example meaning add add $1,$2,$3 $1 = $2 + $ subtract sub $1,$2,$3 $1 = $2 - $ add immediate addi $1,$2,100 $1 = $2 + 100 multiply mul $1,$2,$3 $1 = $2 * $ divide div $1,$2,$3 $1 = $2 / $ and and $1,$2,$3 $1 = $2 & $ or or $1,$2,$3 $1 = $2 | $ and immediate andi $1,$2,100 $1 = $2 & 100 or immediate ori $1,$2,100 $1 = $2 | 100 xor xor $1, $2, $3 (^) $1 = $2 ⊕ $ xor immediate xori $1, $2, 255 (^) $1 = $2 ⊕ 255 shift left logical sll $1,$2,5 $1 = $2 << 5 (logical) shift right logical srl $1,$2,5 $1 = $2 >> 5 (logical) shift left arithmetic sla $1,$2,5 $1 = $2 << 5 (arithmetic) shift right arithmetic sra $1,$2,5 $1 = $2 >> 5 (arithmetic) load word lw $1, ($2) $1 = memory [$2] store word sw $1, ($2) memory [$2] = $ load upper immediate lui $1,100 (^) $1 = 100 x 2 16 branch if equal beq $1,$2,100 if ($1 = $2), PC = PC + 4 + (1004) branch if not equal bne $1,$2,100 (^) if ($1 ≠ $2), PC = PC + 4 + (1004) set if less than slt $1, $2, $3 if ($2 < $3), $1 = 1 else $1 = 0 set if less than immediate slti $1, $2, 100 if ($2 < 100), $1 = 1 else $1 = 0 jump j 10000 PC = 10000* jump register jr $31 PC = $ jump and link jal 10000 $31 = PC + 4; PC = 10000*