Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Final Exam Solutions for ECE 2030 Computer Engineering - Fall 2006, Exams of Computer Science

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

2012/2013

Uploaded on 04/08/2013

sawant_111
sawant_111 🇮🇳

5

(1)

67 documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
ECE 2030 1:00pm Computer Engineering Fall 2006
5 problems, 4 pages Final Exam Solution 14 December 2006
1
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
5)(4 321
1
+
=RRR
R.
# 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 R3
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 + R1
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 R1 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 R1. 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 R1 and R2. The
result should be placed in R1.
# 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 + R2
2 1 X 1 1 1 0001 0 X 0 X 1 1 R1 <- R1 / 2
pf3
pf4

Partial preview of the text

Download Final Exam Solutions for ECE 2030 Computer Engineering - Fall 2006 and more Exams Computer Science in PDF only on Docsity!

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

R R R

R.

# 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

A

B

B

B

C

C

C

OUTW

OUT W = A ⊕ B ⊕ C

A

B C

E

OUTX

D OUTY

OUTx = A ⋅( BC )

OUTY = ( B ⋅ C )+ D + E

Outz

A

B

E

C

D

C

A

B

D

E

OUTZ = ( A + B ⋅ D + E )⋅ C