


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
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
The solutions to the final exam of the ece 2030 computer engineering course given in fall 2006. It includes microcode fragments, minmax subroutine analysis, instruction format questions, and a full adder implementation using nand gates and inverters.
Typology: Exams
1 / 4
This page cannot be seen from the preview
Don't miss anything!
5 problems, 4 pages Final Exam Solution 14 December 2006
Problem 1 (3 parts, 27 points) Microcode
Using the supplied datapath, write microcode fragments to accomplish the following procedures. Express all values in hexadecimal notation. Use ‘X’ when a value is don’t cared. For maximum credit, complete the description field. Recall that ⊕ means XOR. Use only registers 1, 2, and 3.
Part A (15 points) 8
1
# X Y Z rwe im en
im va au en
-a /s
lu en
lf su en
st description
(^1 2 3 2 1 0) X 0 X 1 6 0 X R2 <- R2 xor R
(^2 1) X 1 1 1 FFFE 0 X 0 X 1 1 R1 <- R1 * 4
(^3 1 2 1 1 0) X 1 0 0 X 0 X R1 <- R2 + R
(^4 1) X 1 1 1 0005 1 1 0 X 0 X R1 <- R1 - 5
(^5 1) X 1 1 1 0003 0 X 0 X 1 1 R1 <- R1 / 8
Part B (6 points) Assume R 1 contains three packed unsigned integer bytes (A, B, and C). Assume A is the least significant byte, then B, then C. Write a microcode fragment that unpacks B, placing it in the lowest eight bits of R 1. All other bits should be zero. # X Y Z rwe im en
im va au en
-a /s
lu en
lf su en
st description
(^1 1) X 1 1 1 0008 0 X 0 X 1 0 R1 <- R1 >> 8
(^2 1) X 1 1 1 00FF 0 X 1 8 0 X R1 <- R1 & FF
Part C (6 points) Write a microcode sequence that averages the initial values of R 1 and R 2. The result should be placed in R 1. # X Y Z rwe im en
im va au en
-a /s
lu en
lf su en
st description
(^1 1 2 1 1 0) X 1 0 0 X 0 X R1 <- R1 + R
(^2 1) X 1 1 1 0001 0 X 0 X 1 1 R1 <- R1 / 2
5 problems, 4 pages Final Exam Solution 14 December 2006
Problem 2 (4 parts, 32 points) MinMax Redux
In this problem, you are given a subroutine that computes the minimum and maximum value of an array of integers. The address of the first and last elements of the array are stored in $1 and $ before the subroutine is called. The min and max are returned in $3 and $4 respectively. register inputs register outputs $1 address of first element $3 min value $2 address of last element $4 max value
address label instruction 1000 MinMax: lw $3, ($1) 1004 lw $4, ($1) 1008 Loop: lw $5, ($1) (^1012) slt $6, $5, $ 1016 beq $6, $0, Skip 1020 add $3, $5, $ 1024 Skip1: slt $6, $4, $ 1028 beq $6, $0, Skip 1032 add $4, $5, $ 1036 Skip2: addi $1, $1, 4 1040 slt $6, $2, $ 1044 beq $6, $0, Loop 1048 jr $
Part A (6 points) What is the branch offset (in bytes) for the beq instruction at 1044?
branch offset (in bytes): -10 instructions x 4 bytes/I = -40 bytes
Part B (8 points) Write an expression for the number of times the loop body is executed in terms of $1 and $2?
Times Loop: executed = ($2 - $1 + 4) / 4
Part C (12 points) Write a block of code that calls MinMax, passing in a 100 integer array that starts at 5000. When the subroutine returns, use the min and max to compute the value range (max – min) storing the value in $5. label instruction comment addi $1, $0, 5000 # load first address add $2, $1, 396 # load last address jal MinMax # call min max subroutine sub $5, $4, $3 # compute min max delta
Part D (6 points) Suppose a jal instruction occurs at address 2024. What is the value of $ following the instruction’s execution?
$31 = 2024 + 4 = 2028
5 problems, 4 pages Final Exam Solution 14 December 2006
Problem 5 (3 parts, 30 points) Reverse Engineering
For each part below, determine the behavior and write as a Boolean expression.
A
B C
E
OUTX
D OUTY
OUTx = A ⋅( B ⋅ C )
Outz
A