CSEE W3827 Fundamentals of Computer Systems Homework Assignment 5 Solutions
Transcription
CSEE W3827 Fundamentals of Computer Systems Homework Assignment 5 Solutions
CSEE W3827 Fundamentals of Computer Systems Homework Assignment 5 Solutions Prof. Martha A. Kim Columbia University Due November 13, 2014 at 10:10 AM Write your name and UNI on your solutions Show your work for each problem; we are more interested in how you get the answer than whether you get the right answer. 1. (30 pts.) List the wire names in the datapath below for which the value is ignored when executing the given instruction. 31:26 5:0 MemtoReg Control MemWrite Unit Branch ALUControl2:0 Op ALUSrc Funct RegDst PCSrc RegWrite CLK 0 1 PC' PC A RD Instr Instruction Memory 25:21 20:16 A1 CLK WE3 RD1 RD2 A2 RD2 A3 Register WD3 File 20:16 + 15:11 WriteReg4:0 PCPlus4 WriteData WE A RD Data Memory WD ReadData 0 1 0 1 SignImm 15:0 0 SrcB 1 ALUResult Sign Extend <<2 + 4 Zero SrcA ALU CLK PCBranch Result (a) add $t0, $t0, $t1 PCBranch, SignImm, Zero, ReadData (b) lw $t0, 4($a0) PCBranch, WriteData/RD2 2. Assuming the following dynamic instruction frequency for a program running on the single-cycle MIPS processor... add addi beq lw sw 15% 25% 10% 30% 20% (a) (5 pts.) ... in what fraction of all cycles is the data memory used (either read or written)? Only for loads and stores, so 50%. (b) (5 pts.) ... in what fraction of cycles is the sign extend circuit needed? It is used in all but the add, so 85%. 3. Assuming the single cycle datapath with the components and critical path described on the slides (mips-uarch.pdf, slide 17) as a baseline, analyze the impact of the following changes. (a) (10 pts.) If the ALU were made 5x faster, how much faster would the processor become? (Give a percent.) The 200ps ALU becomes 40ps for a 160ps savings. Alternate frequency interpretation accepted: 160 925 = 17.3%. 1 1 925−160 − 925 1 925 = 20.9% (b) (20 pts.) If you could double the size of the MIPS register file, causing a 100ps increase in register file read time and a 15% reduction in the number of instructions (thanks to fewer loads and stores), should you make this change? Provide quantitative support for your answer. In Seconds Progrm • • = nstrs Progrm · Cyces nstr · Seconds , Cyce this change would ntrs decrease Progrm by 15%, and 100ps Seconds increase Cyce by 925ps = 10.8% so the benefits outweigh the costs for a net benefit. 4. (30 pts.) A “stuck at” fault is a fabrication error where a wire is stuck at some constant value no matter what. Below, design a small MIPS function called stuckatzero to detect whether the Branch control wire is stuck at 0. Your function should take no arguments and return 1 if Branch is stuck at 0 and 0 if the wire is behaving properly. Note: The functon should respect calling conventions, and use only instructions supported by our single cycle processor (lw, sw, beq, addi, add, slt, and, or, addu, subu, and slt) plus jr to return from the function. If Branch is stuck at zero, then PCSrc will also be stuck at zero, and the PC register will always increment to PC+4. If Branch is not stuck, then beq will work. stuckatzero: beq $0, $0, OK addi $v0, $0, 1 jr $ra OK: addu $v0, $0, $0 jr $ra # if Branch working, will be taken # else fall through, so v0 = 1 # v0 = 0