Docsity

Computer Architecture: Binary Multiplication, Interrupts, Two's Complement, and Cache, Exams of Electrical and Electronics Engineering

Toggle sidebar
bg1
Name______________________________ Page 1
Student ID__________________________
Problem 1: Short Answers (35 points)
a) (2 points) Assuming that there are enough bits so that overflow is not a problem, how
would you multiply a binary number by two?
1) Shift all bits one bit to the left
2) Shift all bits one bit to the right
3) Shift all bits two bits to the left
4) Shift all bits two bits to the right
b) (2 points) Single-bit multiplication is equivalent to which of the following gates? (2
points)
1) OR
2) AND
3) XOR
4) NAND
c) (5 points) There are three different types of data hazards, RAW, WAR, and WAW.
Define them, giving a short code sequence to illustrate each, and describe how a 5-stage
pipeline removes them.
d) (4 points) What are control hazards? Name and explain two different techniques for
getting rid of them.
pf3
pf4
pf5
pf8
pf9
pfa
pfd

Partial preview of the text

Download Computer Architecture: Binary Multiplication, Interrupts, Two's Complement, and Cache and more Exams Electrical and Electronics Engineering in PDF only on Docsity!

Student ID__________________________

Problem 1: Short Answers (35 points)

a) (2 points) Assuming that there are enough bits so that overflow is not a problem, how would you multiply a binary number by two?

  1. Shift all bits one bit to the left
  2. Shift all bits one bit to the right
  3. Shift all bits two bits to the left
  4. Shift all bits two bits to the right

b) (2 points) Single-bit multiplication is equivalent to which of the following gates? ( points)

  1. OR
  2. AND
  3. XOR
  4. NAND

c) (5 points) There are three different types of data hazards, RAW, WAR, and WAW. Define them, giving a short code sequence to illustrate each, and describe how a 5-stage pipeline removes them.

d) (4 points) What are control hazards? Name and explain two different techniques for getting rid of them.

Student ID__________________________

e) (4 points) Give a simple definition of precise interrupts/exceptions:

f) (4 points) Consider the following claim: “Having a larger number of processor registers makes it possible to reduce the number of memory accesses needed to perform complex tasks”. Devise a simple computational task to show the validity of this statement for a processor that has four registers as opposed to a processor that has only 2 registers.

g) (2 points) Convert the decimal numbers +26 and +19 into a 6-bit binary two’s- complement representation.

Student ID__________________________

Problem 2: Performance (20 points, 4 each)

a) Ryan and Gang decide to compare two computers which implement the x86 instruction set (the long standing computer instruction set family defined by Intel). To do this, they each take a chess playing program, written in C, and compile it on their respective machines and then calculate the instruction processing rate. Ryan's machine executes the program at 100 million instructions per second, and Gang's machine achieves 120 million instructions per second. Precisely state the relative performance result for these two systems, based on these measurements.

b) Give one specific reason why this performance comparison might be flawed

. c) Now, Tom comes along and runs the same program on his computer, an Apple Power Macintosh, which uses the PowerPC processor. Tom's machine runs the program at 130 million instructions per second. How should we compare the performance of Tom's machine with Ryan and Gang's?

Student ID__________________________

d) Consider a multi-cycle implementation of the MIPS instruction set in which the mix across instruction classes is as shown below:

Instruction Dynamic Frequency (by count) R-class (arithmetic/logic) 65% Memory (load/store) 15% Branch (branch and jump) 20%

If R-class instructions on average take 4 cycles, memory instructions 6 cycles, and branch instructions 3 cycles, compute the CPI (cycles per instruction) for this machine.

e) Based on Amdahl's law, what is the maximum performance improvement achievable for the system described in part (d) possible by improving the performance of branch instructions?

Student ID__________________________

b) (20 points) Fill out the microprogram table below to implement this FSM. SrcA and SrcB fields specify which signals will be assigned to BusA and BusB WrtA and WrtB fields specify what components are receiving inputs from the busses. The SrcX and WrtX fields can be any one of the state registers ( IR, A, B, S, M ), the register file ( RegFile ), or memory ( Mem ). Sequence specifies the function of a jump counter ( next for next instruction, fetch for go to 00 or dispatch ).

μ Address Instruction SrcA SrcB ALUOp WrtA WrtB Sequence

00 Fetch PC Mem IR Next

01 Decode

02 ADDI

04 LW

Student ID__________________________

Problem 4: Memory Hierarchy (50 points)

a) (5 points) Assume that we have a 32-bit processor (with 32-bit words) and that this processor is byte-addressed (i.e. addresses specify bytes). Suppose that it has a 512-byte cache that is two-way set-associative, has 4-word cache lines, and uses LRU replacement. Split the 32-bit address into “tag”, “index”, and “cache-line offset” pieces. Which address bits comprise each piece? Remember: 1 word = 4 bytes

Tag:

Index:

Cache-line offset:

b) (5 points) How many sets does this cache have?

c) (20 points) Draw a block diagram for this cache. Show a 32-bit address coming into the diagram and a 32-bit data result and “Hit” signal coming out. Include all of the comparators in the system and any muxes as well. Include the data storage memories (indexed by the “Index”), the tag matching logic, and any muxes. You can indicate RAM with a simple block, but make sure to label address widths and data widths. Make sure to label the function of various blocks and the width of any buses.

Student ID__________________________

d) (15 points) Below is a series of memory read references set to the cache from part (a). Assume that the cache is initially empty and classify each memory references as a hit or a miss. Identify each miss as either compulsory, conflict, or capacity. One example is shown. Hint: start by splitting the address into components. Show your work. Address Hit/Miss? Miss Type?

0x300 Miss Compulsory

0x1BC

0x

0x

0x

0x1A

0x1B

0x2AE

0x3B

0x10C

0x

0x

0x3AE

0x1A

0x3A

0x1BA

Student ID__________________________

e) (5 points) Calculate the miss rate and hit rate.

Student ID__________________________

b) (10 points) In the course of working through the above instructions, and the forwarding paths that are needed, you realized that there are still some cases where no amount of forwarding can resolve the dependencies, the data is simply not ready by the time the next instruction needs it. The only way to resolve the hazard is to insert a bubble into the pipeline, stalling the next instruction, which needs the data, while allowing the current instruction that is using the data, to continue processing. You have come up with some instruction sequences with these problems, and now you have to figure out how many bubbles need to be inserted in each case. One bubble is equivalent to stalling for one clock cycle. The cases of interest are shown in the table below. Fill in the total number of bubbles that need to be inserted for the block of code shown, in order to resolve all hazards.

Instruction Sequence

Total Number of Bubbles ADD $2, $3, $ SUB $7, $2, $ LW $5, 24($6) ADD $9, $8, $ SUB $6, $9, $ LW $5, 12($13) LW $5, 16($8) LW $4, 32($3) LW $5, 32($4) LW $6, 32($5) ADD $7, $4, $ LW $4, 0($7) SW $7, 0($12) XOR $2, $7, $