Docsity

MIPS Microprocessor Performance Optimization and Logic Gate Design, Exams of Computer Architecture and Organization

Toggle sidebar
bg1
CS152 Computer Architecture and Engineering
Computer Science Division
Department of Electrical Engineering and Computer Sciences
University of California, Berkeley
Sp97 D.K. Jeong
Midterm #1
March 3, 1997
Name Key
SID Number
Discussion Section
You may bring one double-sided note. You have 180 minutes. Please write your name on
this cover and also at the top left of each page. The point value of each question is
indicated in brackets after it. Make sure to show your work to get at least partial credit.
Problem Possible Score
115
220
310
420
515
Total 80
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download MIPS Microprocessor Performance Optimization and Logic Gate Design and more Exams Computer Architecture and Organization in PDF only on Docsity!

CS152 Computer Architecture and Engineering Computer Science Division Department of Electrical Engineering and Computer Sciences University of California, Berkeley

Sp97 D.K. Jeong

Midterm # March 3, 1997

Name Key

SID Number

Discussion Section

You may bring one double-sided note. You have 180 minutes. Please write your name on this cover and also at the top left of each page. The point value of each question is indicated in brackets after it. Make sure to show your work to get at least partial credit.

Problem Possible Score 1 15

2 20 3 10 4 20 5 15

Total 80

Name:

Question 1. (Performance) [15 pts]

You are to improve cost/performance on an existing system based on a single-chip microprocessor having the following parameters.

Base Machine Clock Frequency 100MHz

Die Size 10 mm x 10 mm Instruction Mix int 62 % FP 38 %

CPI int 1.

FP 4.

(a) What is the MIPS number of the base machine? [2 pts]

CPI = Σ CPIi * IC (^) I, where CPI is cycles per instruction, and IC is instruction count.

CPI = 1.6*.62 + 4.2 * .38 = 2.

MIPS = Clk freq/CPI = 100 MHz/2.588 = 38.64 MIPS

By using an optimizing compiler, the number of FP instructions is reduced by 20% and int instructions by 10% for the same application program.

(b) What is the new MIPS number of the base machine when using the optimizing compiler? (Instruction mix is changed!)[2 pts]

Instruction mix has changed, so that there is a different proportion of FP and int instructions. Therefore, we need to recalculate CPI:

CPI = (0.9 .621.6 + .8.384.2) / (.9.62 + .8.38) = 2.

The denominator represents the decrease in Instruction Count, due to the optimizing compiler.

MIPS_comp = Clk freq/CPI = 100MHz/2.5169 = 39.73 MIPS

As an alternative, you are going use a new, scaled CMOS technology without re- designing. In that case, the clock frequency changes to 125 MHz, its wafer cost doubles, and its die size is reduced by 15%. Use the same yield rule.

(f) How much performance improvement over the base machine do you expect? [1 pts]

The CPI and IC is the same as the base machine. The only difference is the clock rate.

Performance_scaled = 125 MHz = 1.25 improvement. Performance_base 100 MHz

The scaled CMOS is 25% faster.

(g) How much additional cost over the base machine do you expect? [2 pts]

The new technology is 15% smaller, that is 1-.15 = .85x the base machine.

The scaled CMOS costs 1.044 times as much or 4.4% more.

(h) Compare the two hardware options and determine which approach you will choose for better cost/performance ratio? [2 pts]

The cost/performance of the scaled CMOS is .507x that of the FP hardware, or 1.97 times better. So we would choose the scaled CMOS technology.

/ * _

/ * _

_

_ 34

dies wafer die yeld

Cost wafer

dies wafer die yield

Cost wafer

Cost base

Cost scaled

_

_

_

_

Performance FP

Cost FP

Perforamce scaled

Cost scaled

Name:

Question 2. (Delay) [20 pts]

You have the following gates and flip-flops available for your design. Do not assume any wiring capacitance in solving this problem. Try to minimize the overall delay.

2-input NAND

2-input OR

2-input XOR

INV 2-input MUX Input Load 100fF 100fF 100fF 50fF 100fF

TPhl, TPlh 0.3ns 0.4ns 0.5ns 0.2ns 0.3ns TPhlf, TPlhf 0.001ns/fF 0.001ns/fF 0.001ns/fF 0.001ns/fF 0.001ns/fF

D-FF

Set-up Time 2.0ns Hold Time 1.0ns Clock-to-Q Delay 1.0ns TPhlf, TPlhf 0.001ns/fF

You are to design a circuit of the following logic block.

Clk B Clk

32-bit Adder

A

S

(c) What is the maximum clock skew allowed for correct operation with any input on B? [5 pts] TClk-Q + T_shortest path – Tskew > Thold The shortest path is from input FF to A or B to S to output FF, assuming no carries are generated or propagated. T_shortest path = TPf_FFCin_A + TP_A»S + TPf_SCin_FF = .001300 + 1.1 + .001100 =1.5 ns 1.0 ns + 1.5 ns – Tskew > 1.0 ns Tskew > 1.5 ns

(d) Using full adders in (a) and muxes, sketch a carry select adder and estimate the maximum clock frequency. Do not use more than 48 such full adders. Assume no clock skew. [5 pts]

The critical path is calculated similarly to part b). We first calculate the delay from the input FF to A0 to C1…to C15. Then C15 must drive 16 muxes, which will be a significant delay, because it is a very big load. To optimize this, you might use inverters in parallel as buffers, since they would have a better TPf. Finally, the outputs from the muxes go to the output FF. Critical path = TClk-Q + Tsu + TPf_FFCin_A + TP_A»Cout + 15(TPf_CoutCin_Ci + TP_Ci»Cout) + TPf_Cout16Cin_mux + TP_mux + TPf_muxCin_FF + Thold.

Critical path = 1.0 + 2.0 + .001300 + 1.2 + 15(.001200 + .7) + .00116100 + .3 + .001100 + 1. Critical Path = 21 ns Cycle Time = 1/Critical Path = 47.6 MHz

By using inverters as buffers to drive the sixteen muxes we can reduce the critical path. Note that we can use only one inverter stage, and have our select signal be inverted, and just switch the inputs to the muxes, so that if C15 is one, it will be inverted but still select the correct input to the mux. We will use 4 inverters in parallel. Without buffers, it took 1.6 ns to drive the muxes. With 4 inverters in parallel, this is reduced to .8 ns (including the inverter delay, so that the .8 ns is cut off the critical path.

C

16-bit adder 16-bit adder

16-bit adder

Name:

Question 3. (Floating-point) [10 pts]

(a) Add the two single precision FP numbers in IEEE format and represent the result in IEEE format. Show all the calculation and intermediate result. Use IEEE standard rounding method (nearest even in case of a tie) and make sure to include Guard, Round, and Sticky bits in calculation. [6 pts]

The exponent of the top number is given as 10011000 2 –127 10 = 152 – 127 = 25 10 The exponent for the second number is 128 – 127 = 1. This corresponds to:

1.000…00 x 2^25

  • 1.000…01 x 2^1

We then shift the bottom number to the right 24 places, so that the radix points line up. As we shift, the sticky bit gets turned on, since the 1 that was originally the LSB of the significand gets shifted out to the right. The one to the left of the radix point will be shifted all the way out to the guard bit, one place to the right of the LSB of the significand.

1.000…00 000 x 2^25

  • 0.000…00 101 x 2^25

The result is rounded up since the round bit corresponds to ½ and the sticky bit is on. The sum is 1.00000000000000000000001 x 2^25 =

0 10011000 00000000000000000000001

(b) Without Sticky bit, what would have been the result and why? [4 pts]

The guard bit tells us we are at ½. The round bit is zero and there is no sticky bit, so we must be at exactly ½. Since the LSB is zero, we would round down to the nearest even. Our sum would be exactly 1.0 x 2^25 , which is different from our result of part (a).

0 10011000 00000000000000000000000

Sticky bit Round bit Guard bit

Name:

(b) An instruction, TAS (Test and Set), which loads memory to a register and stores 1 in the same memory location. Memory is addressed with the same addressing mode as a LOAD instruction. [10 pts]

TAS Rt, imm16(Rs)

We can do all reading and writing in the same cycle, since reads are simply combinational logic, and writes happen on the falling edge of the clock. Control signals are added to insure that the data from the memory is written to register Rt, the write enable of the memory is on, and a “1” will be muxed into the write data of the memory.

32

ALUctr

Clk

busW

RegWr

32

32

busA

32

busB

5 5 5 Rw Ra Rb 32 32-bit Registers

Rs

Rt

Rt

Rd

RegDst

Extender

Mux

imm16 16 32

ExtOp ALUSrc

Mux

MemtoReg

Clk

Data In

(^32) WrEn Adr Data Memory

MemWr

ALU

Equal

Instruction<31:0>

0

1

0

1

1 0

<21:25><16:20><11:15><0:15>

Rs Rt Rd Imm

=

imm

Adder

Adder

PC

Clk

Mux^00

4

nPC_sel

PC Ext

Adr

Inst Memory

sign ext

+4 rt add

Set

“1”

0 1

“1”

“1” “1” “1”

Name:

Question 5. (MIPS Assembly Language) Complete the optimized MIPS assembly language program for the following C program. Assume that delayed branches are used. Only one instruction per slot. Try to follow the register usage convention described in COD appendix A. Add appropriate comments to explain your idea. [15 pts]

int fibonacci (int k) { if (k == 0 || k == 1) return (1); return (fibonacci (k-1) + fibonacci (k-2)); }

fibonacci: subu $sp,$sp, sw $31,24($sp) sw $17,20($sp) move $17,$ sltu $2,$17,2 # check if k<2________________ bne $2,$0,$L sw $16,16($sp)____ # store saved register—will have result of last fibonacci jal fibonacci addu $4,$17,- move $16,$2 # (this moves result of fib into $16, to be saved later jal fibonacci addu $4,$17,-2______ # find fib(k-2).Remember this is in the delay slot of jal j $L addu $2,$16,$2______ # $2 has fib(k-2), $16 has____ fib(k-1), add them together, and return as fib(k-1)+fib(k-2)

$L2: li $2,0x00000001 # 1 $L3: lw $31,24($sp)____ # restore return address______ lw $17,20($sp)____ # restore saved registers_____ lw $16,16($sp)____ # ____”_____”______”__________ addui$sp,$sp,32_____ # restore stack pointer_______ j $ .end fibonacci

(end of Midterm #1)