Exam Solutions for ECE 2030 I - Computer Engineering Fall 2003, Exams of Computer Science

The solutions to exam three for the computer engineering course ece 2030 i at the university of x, given in fall 2003. The exam covers various topics such as state machines, memory systems, instruction formats, datapath elements, and microcode. Students can use this document as a study resource to review the concepts and understand the solutions to the exam problems.

Typology: Exams

2012/2013

Uploaded on 04/08/2013

seema_852
seema_852 🇮🇳

3.6

(7)

87 documents

1 / 5

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
ECE 2030 I Computer Engineering Fall 2003
5 problems, 6 pages Exam Three Solutions 10 April 2003
1
Problem 1 (3 parts, 25 points) State Machines
A state diagram for the controller of the StickyFinger snack machine is shown below. The machine
accepts nickels, dimes, and quarters, and does not give change. It sometimes dispenses a bag of pretzels
when coins are inserted. Slugs are not detected. The inputs to the controller are C1 and C0, which
indicate which coin is inserted according to the following table.
coin inserted C1 C0
nickel 0 1
dime 1 0
quarter 1 1
When the P output signal is asserted, a snack bag of pretzels is dispensed. The states keep track of how
much money the machine “believes” you have inserted so far. They are number 00 for zero cents, 01 for
five cents, 10 for ten cents, 11 for fifteen cents. Unfortunately, as you can see from the state diagram, the
machine is not always accurate in keeping track of the money you have inserted.
00
01
10
C0 /
11
0 cents
5 cents
10 cents
15 cents
C1 C0 /
C1 C0 / P
C0; C1 C0 /
C1 C0 /
C0 /
C0 /
C1 /
C1 /
C1 /
C1 / P
Part A (5 points) Determine the minimum cost of a bag of pretzels.
Pretzels cost a minimum of 25 cents.
Part B (8 points) The machine occasionally keeps your money without giving you pretzels. Give an
example of a sequence of coins where you would end up in the 0 cents state (00) and not get any pretzels.
Fill in as many coins as you need for your example:
cc
ccc
cc
or
5525
25
25* 10*
10+*means 0 or more
+ means 1 or more
How much money would you lose in this example? <sum of the coins> cents.
Part C (12 points) Fill in the state table corresponding to this state machine.
S1 S0 C1 C0 NS1 NS0 PS1 S0 C1 C0 NS1 NS0 P
00010 1 0 10011 1 0
00101 0 0 10101 0 0
00110 0 1 10110 0 0
01011 0 0 11011 1 0
01101 1 0 11100 0 1
01110 1 0 11111 1 0
pf3
pf4
pf5

Partial preview of the text

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

5 problems, 6 pages Exam Three Solutions 10 April 2003

Problem 1 (3 parts, 25 points) State Machines

A state diagram for the controller of the StickyFinger snack machine is shown below. The machine

accepts nickels, dimes, and quarters, and does not give change. It sometimes dispenses a bag of pretzels

when coins are inserted. Slugs are not detected. The inputs to the controller are C1 and C0, which

indicate which coin is inserted according to the following table.

coin inserted C1 C nickel 0 1 dime 1 0 quarter 1 1

When the P output signal is asserted, a snack bag of pretzels is dispensed. The states keep track of how

much money the machine “believes” you have inserted so far. They are number 00 for zero cents, 01 for

five cents, 10 for ten cents, 11 for fifteen cents. Unfortunately, as you can see from the state diagram, the

machine is not always accurate in keeping track of the money you have inserted.

00

01

10

C0 /

11

0 cents

5 cents

10 cents

15 cents

C1 C0 /

C1 C0 / P

C0; C1 C0 /

C1 C0 /

C0 / C0 /

C1 /

C1 /

C1 /

C1 / P

Part A (5 points) Determine the minimum cost of a bag of pretzels.

Pretzels cost a minimum of 25 cents.

Part B (8 points) The machine occasionally keeps your money without giving you pretzels. Give an

example of a sequence of coins where you would end up in the 0 cents state (00) and not get any pretzels.

Fill in as many coins as you need for your example:

c c c c c

or c c

+ *means 0 or more

  • means 1 or more

How much money would you lose in this example? < sum of the coins> cents.

Part C (12 points) Fill in the state table corresponding to this state machine.

S1 S0 C1 C0 NS1 NS0 P S1 S0 C1 C0 NS1 NS0 P

5 problems, 6 pages Exam Three Solutions 10 April 2003

Problem 2 (3 parts, 27 points) Memory Systems

The following two parts consider memory systems built using a 1MByte DRAM organized as 2

million addresses of 4-bit words.

Part A (12 points) Consider a memory system organized as 32 million addresses of 32-bit

words.

number of chips needed in one bank 32/4 = 8

number of banks for memory system 32M/2M = 16M

number of memory system address bits log 2 (32M) = 25 bits

memory decoder required ( n to m ) 4-to-

number of DRAM chips required 8*16 = 128

memory system capacity (in MBytes ) 32M words * 4bytes/word = 128MB or

128chips * 1MB/chip = 128MB

Part B (10 points) Consider a memory system with 32 DRAM chips total and a 1-to-2 memory

decoder.

number of banks 2

number of chips used in one bank 16

number of addresses 2M*2 = 4M

word size (in bits ) 16*4 = 64 bits

memory system capacity (in MBytes ) 4M words * 8 bytes/word = 32MB or

32 chips * 1MB/chip = 32MB

Part C (5 points) Draw an SRAM memory cell. Label all signals.

D D

S

5 problems, 6 pages Exam Three Solutions 10 April 2003

Part B (6 points) What building block can be used to implement a logical unit? Label the

diagram below with the building block name and its inputs and outputs. (Fill in all the dashed

boxes.)

Name:

4-to-1 MUX

I 0

I 1

I 2

I 3

S 0 S 1

Out

LF 0

LF 1

LF 2

LF 3

Out

X Y

Part C (9 points) Suppose the following inputs (in hexadecimal) are applied to the 32-bit

barrel shifter used in the datapath. Determine the output (in hexadecimal). Assume the shift

amount is drawn from the 16-bit immediate value.

Shift Type Shift Amount Input Value Output Value

rotate 0xFFF8^ A83579E4^ 3579E4A

arithmetic 0x0004^ ACE3697B^ FACE

logical 0x000C^ DE410598^ 000DE

Problem 5 (3 parts, 24 points) Microcode

Use the data path discussed in class (and 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”.

Part A (3 points) Write a microinstruction to copy the data value in register 7 to register 5.

Any of the following is correct:

# 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 x 7 5 1 0 x 0 x 1 C 0 x 0 0 x (^0) R5 ← R

1 7 x 5 1 0 x 0 x 1 A 0 x 0 0 x (^0) R5 ← R

1 7 x 5 1 1 0 1 0 0 x 0 x 0 0 x 0 R5 ← R7+

1 7 0 5 1 0 x 1 0 0 x 0 x 0 0 x 0 R5 ← R7+R (assumes R0 = 0)

1 7 x 5 1 1 0 0 x 1 E 0 x 0 0 x (^0) R5 ← R7 or 0

5 problems, 6 pages Exam Three Solutions 10 April 2003

Part B (3 points) Write a microinstruction to clear register 9 using only the arithmetic unit.

Either of these is correct:

# 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 9 9 9 1 0 x 1 1 0 x 0 x 0 0 x (^0) R9 ← R9 – R

1 0 0 9 1 0 x 1 0 0 x 0 x 0 0 x (^0) R9 ← R0 + R (assumes R0 = 0)

Part C (6 points) Write a microcode fragment (1 or more microinstructions) that writes the value

that is in register 5 to memory location 0xA29. 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 x x 4 1 1 0xA29 0 x 1 C 0 x 0 0 x 0 R4 ← 0xA

2 4 5 x 0 0 x 0 x 0 x 0 x 0 1 0 1 (R4) ← R

Part D (12 points) Write a microcode fragment (1 or more microinstructions) that multiplies the

value in memory location 0x917 by 9 and puts the result in register 3. 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 x x 4 1 1 0x917 0 x 1 C 0 x 0 0 x (^0) R4 ← 0x

2 4 x 8 1 0 x 0 x 0 x 0 x (^1 0 1 1) R8 ← (R4)

3 8 x 3 1 1 0xFFFD 0 x 0 x 1 0/1 0 0 x (^0) R3 ← R8 ash - (or lsh)

4 3 8 3 1 0 x 1 0 0 x 0 x 0 0 x 0 R3 ← R3 + R