





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 ece 2030 h computer engineering spring 2004 final exam. The exam covers various topics including logic design, memory and shifting, encoding and counting, assembly language programming, microcode, and mips instruction set. Students are required to solve problems related to these topics and show their work for maximum credit. The exam is a closed book, closed note exam and calculators are not permitted.
Typology: Exams
1 / 9
This page cannot be seen from the preview
Don't miss anything!






5 problems, 9 pages Final Exam 30 April 2004
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
30 30 15 35 25 135
5 problems, 9 pages Final Exam 30 April 2004
Problem 1 (3 parts, 30 points) Logic Design Part A (16 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 = ( A + B )( C + D ⋅ E + F )
Part B (6 points) Transform the following Boolean expression to a form where it can be implemented using switches (i.e., there should be no bars in the expression except for complements of the inputs A, B, C, etc.). The behavior of the expression should remain unchanged.
Out (^) X = ( A ⋅ B ⋅ C + E ⋅ FD )⋅ G ⋅ H = Part C (8 points) For the mixed-logic 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 design. A B C D E F
OUTx
OUTX = (^) transistors:Number of
5 problems, 9 pages Final Exam 30 April 2004
Problem 3 (2 parts, 15 points) Encoding and Counting Part A (10 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 1 0 1 0 0 0 0 0 1 0 0 1 1 1 1 0 1 1 1 1 1 1 1 0 1 0 1 1 1 0 0 0 0 0 0 0 0 0 0
Part B (5 points) Suppose you have a counter with a count enable CE and an active high clear CLR. The counter has three outputs (O 2 , O 1 and O 0 ) which form an unsigned integer (O 2 O 1 O 0 ). Its behavior is described by the following timing diagram. Each dotted vertical line denotes the end of one full clock cycle.
What type of counter is this? This is a divide by counter.
5 problems, 9 pages Final Exam 30 April 2004
Problem 4 (5 parts, 35 points) Assembly Language Programming Suppose we are writing part of the code for a program to do chromakeying. Chromakeying is used to superpose a figure, such as a weatherman, on a background image, such as a weathermap. The subroutine “chromakey” is shown below; it calls two subroutines “create_mask” and “mask_b”. The create_mask subroutine takes as input register $1 and computes a mask value which it puts in register $3. The mask_b subroutine takes a boolean value in $3 and puts its complement in $4. Most of chromakey has been written, but instructions necessary for preserving registers across calls are missing. Part A (8 points) To begin, define a Push and Pop stack macro below. Use $x to denote the value being preserved. Use register $29 as the stack pointer. label instruction comment Push($x) Pop($x)
Part B (10 points) Assume we are using caller-save convention so the caller is responsible for pushing and 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 chromakey to ensure that registers that are needed after the calls to create_mask and mask_b are preserved. Use your Push and Pop macros. chromakey: addi $12,$0,2000 # blue screen image starts at addr 2000 addi $15,$0,3024 # initialize $15 to upperbound addr 3024 loop: addi $13,$12,2000 # background image is 2000 away from blue scr. lw $1, ($12) # read in pixels from blue screen image lw $2, ($13) # read in pixels from background image
jal create_mask # $3 = create_mask($1) jal mask_B # $4 = not($3)
and $6,$2,$3 # $6 = background pixels AND mask and $7,$1,$4 # $7 = blue screen pixels AND NOT(mask) or $8,$6,$7 # $8 = $6 or $ addi $14,$12,5000 # output image is 5000 away from blue scr. sw $8, ($14) # save output image pixels addi $12,$12,4 # increment blue screen image address bne $12,$15,loop # loop back if still below upperbound jr $31 # return to caller
5 problems, 9 pages Final Exam 30 April 2004
Problem 5 (3 parts, 25 points) Microcode and MIPS Use the data path attached to the exam to answer the following. For maximum credit, use the minimum number of microinstructions to code the answer. Put an “x” in fields that are “don’t cares”. Express any immediate values in hexadecimal. Part A (15 points) Write a microcode fragment (1 or more microinstructions) that implements the following MIPS assembly language program fragment: addi $1, $0, 0x lw $4, ($1) ori $8,$4,0xFF sub $3, $8, $ sw $3, ($1) You may not need to use all the rows in the table. # 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
Part B (5 points) Write a microcode fragment (1 or more microinstructions) that loads the value that is in memory location 0xDEF into register 17. You may not need to use all the rows in the table. You may use other registers as needed. # 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
Part C (5 points) Write the MIPS assembly language instruction that corresponds to this microinstruction: # X Y Z rwe imen im va auen -a/s enlu lf (^) ensu st (^) enld enst -wr/ selm description 1 2 x 5 1 1 0xFFFB 0 x 0 x 1 1 0 0 x 0 This microinstruction is equivalent to the MIPS instruction:
5 problems, 9 pages Final Exam 30 April 2004
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*