21
CS3410 HW1 Review 2014, 2, 21

CS3410 HW1 Review

  • Upload
    dacia

  • View
    39

  • Download
    0

Embed Size (px)

DESCRIPTION

CS3410 HW1 Review. 2014, 2, 21. Agenda. We will go through the HW1 questions together TAs will then walk around to help. Question 1: Karnaugh Map. Sum of products: Karnaugh map minimization: Cover all 1’s Group adjacent blocks of 2 n 1’s that yield a regular shape - PowerPoint PPT Presentation

Citation preview

1

CS3410 HW1 Review2014, 2, 211AgendaWe will go through the HW1 questions togetherTAs will then walk around to help

Question 1: Karnaugh Mapabcout000000110100011110011011110011100001110100 01 11 1001cab01011100Sum of products:

Karnaugh map minimization:Cover all 1sGroup adjacent blocks of 2n 1s that yield a regular shapeEncode common features

Rules for Karnaugh Map MinimizationMinterms can overlapMinterms can span 1, 2, 4, 8 cellsThe map can wrap around0001110100 01 11 1001cab100010000001110110 00 01 1101cab10100000Question 2: Numbers & Arithmetic Binary translation:Base conversion via repetitive divisionFrom binary to Hex and OctNegating a number (2s complement)OverflowOverflow happened iffcarry into msb != carry out of msb

Example: 13Overflow example: 1011 + 0111 no overflow 1011 + 1011 overflow5Question 4: FSM

xOutputOkayx0Spam filterx2x1Question 4: FSM (cont.)01012..0127xOutputOkayx0Spam filterx2x1Question 4: FSM (cont.)01012..012SPAM8Question 4: FSM (cont.)Current stateInputNext stateOutputx1x2x0x1=x0x2=x100000okay00110okay00220okay01000okay01110okay01220okay02000spamState (x1=0, x2=0) and (x1=0, x2=1) have exactly the same transitions AND output. So they are NOT distinct states.Question 7: PerformanceInstruction mix for some program P, assume:25% load/store ( 3 cycles / instruction)60% arithmetic ( 2 cycles / instruction)15% branches ( 1 cycle / instruction)CPI:3 * .25 + 2 * .60 + 1 * .15 = 2.1CPU Time = # Instructions x CPI x Clock Cycle TimeAssuming 400k instructions, 30 MHz : 400k * 2.1 / 30 = 28000 s (1 s = 1 microsecond = 1/1M S)

Question 8

Registers and Control are in parallelQuestion 8 (cont.)Refer to section 1.6 in the text book4.3.1: The clock cycle time is determined by the critical path (the load instruction)4.3.2: Speedup =

Execution time = cycle time * num of instructionsSpeedup < 1 means we are actually slowing downExecution time (old)Execution time (new)Question 8 (cont.)4.3.3:Cost-performance ratio (CPR) = The higher, the betterThis question asks for a comparison of CPR

CPR ratio= = * PerformanceCostCPR (old)CPR (new)Cost (new)Cost (old) Perf (old)Perf (new) 1speedupQuestion 9/10/11: Assembler CodeWriting the instructions in a human-readable formathttp://www.cs.cornell.edu/courses/CS3410/2014sp/MIPS_Vol2.pdfCore instruction sethttp://www.cs.cornell.edu/courses/CS3410/2014sp/project/pa1/pa1.html

Assembler CodeWhen writing the assembler code:Decide which register stores which variableTypically you should use $t0~$t9 and $s0~$s7 (You dont need to understand their difference now)Decide which instruction you want to useGet familiar with the core instruction setGet familiar with some basic patternsBasic Assembler Coding PatternsArithmeticC code:

Assembler:

a = b + c;#a: $s0, b: $s1, c:$s2ADD $s0, $s1, $s2Basic Assembler Coding PatternsBrunchC code:

Assembler:

if(a < b)//DO A...else//DO B...#a: $s0, b: $s1SLT $t0, $s0, $s1BEQ $t0, $zero, POINTB#DO A...

POINTB:#DO B...Basic Assembler Coding PatternsWhile loopC code:

Assembler:

while(a < b)//Do something...#a: $s0, b: $s1LOOP:SLT $t0, $s0, $s1BEQ $t0, $zero, EXIT#Do something...J LOOPEXIT:#Out of the loop...Basic Assembler Coding PatternsArray accessC code:

Assembler:

int myArray[10];a = myArray[2];#a: $s0, myArray: $s1LW $s0, 8($s1)C ProgrammingHave you tried the hello-world?Use csuglab machines. It is easier.How to read input from the terminal?scanf:

You need a buffer for it

int scanf ( const char * format, ... );Show a demo20Good Luck! Questions?