1 / 21

CS3410 HW1 Review

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

dacia
Télécharger la présentation

CS3410 HW1 Review

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS3410 HW1 Review 2014, 2, 21

  2. Agenda • We will go through the HW1 questions together • TAs will then walk around to help

  3. Question 1: Karnaugh Map • Sum of products: • Karnaugh map minimization: • Cover all 1’s • Group adjacent blocks of 2n 1’s that yield a regular shape • Encode common features ab c 00 01 11 10 0 0 0 0 1 1 1 1 0 1

  4. Rules for Karnaugh Map Minimization • Minterms can overlap • Minterms can span 1, 2, 4, 8 … cells • The map can wrap around ab ab c c 00 01 11 10 10 00 01 11 0 0 1 0 0 1 1 1 0 0 1 1 0 0 0 0 0 0 0 0

  5. Question 2: Numbers & Arithmetic • Binary translation: • Base conversion via repetitive division • From binary to Hex and Oct • Negating a number (2’s complement) • Overflow • Overflow happened iff carry into msb != carry out of msb

  6. Question 4: FSM

  7. Question 4: FSM (cont.) Spam filter x 2 0 1 2 0 1 0 1 ….. x2 x0 x1 Output Okay

  8. Question 4: FSM (cont.) Spam filter x 2 0 1 2 0 1 0 1 ….. x2 x0 x1 Output Okay SPAM

  9. Question 4: FSM (cont.) State (x1=0, x2=0) and (x1=0, x2=1) have exactly the same transitions AND output. So they are NOT distinct states.

  10. Question 7: Performance • Instruction 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.1 • CPU Time = # Instructions x CPI x Clock Cycle Time • Assuming 400k instructions, 30 MHz : • 400k * 2.1 / 30 = 28000 µs (1 µs = 1 microsecond = 1/1M S)

  11. Question 8 Registers and Control are in parallel

  12. Question 8 (cont.) • Refer to section 1.6 in the text book • 4.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 instructions • Speedup < 1 means we are actually slowing down Execution time (old) Execution time (new)

  13. Question 8 (cont.) • 4.3.3: • Cost-performance ratio (CPR) = • The higher, the better • This question asks for a “comparison” of CPR CPR ratio= = * Performance Cost CPR (old) Cost (new) Perf (old) CPR (new) Cost (old) Perf (new) 1 speedup

  14. Question 9/10/11: Assembler Code • Writing the instructions in a human-readable format • http://www.cs.cornell.edu/courses/CS3410/2014sp/MIPS_Vol2.pdf • Core instruction set • http://www.cs.cornell.edu/courses/CS3410/2014sp/project/pa1/pa1.html

  15. Assembler Code • When writing the assembler code: • Decide which register stores which variable • Typically you should use $t0~$t9 and $s0~$s7 (You don’t need to understand their difference now) • Decide which instruction you want to use • Get familiar with the core instruction set • Get familiar with some basic patterns

  16. Basic Assembler Coding Patterns • Arithmetic • C code: • Assembler: a = b + c; #a: $s0, b: $s1, c:$s2 ADD $s0, $s1, $s2

  17. Basic Assembler Coding Patterns • Brunch • C code: • Assembler: if(a < b) //DO A... else //DO B... #a: $s0, b: $s1 SLT $t0, $s0, $s1 BEQ $t0, $zero, POINTB #DO A... POINTB: #DO B...

  18. Basic Assembler Coding Patterns • While loop • C code: • Assembler: while(a < b) //Do something... #a: $s0, b: $s1 LOOP: SLT $t0, $s0, $s1 BEQ $t0, $zero, EXIT #Do something... J LOOP EXIT: #Out of the loop...

  19. Basic Assembler Coding Patterns • Array access • C code: • Assembler: intmyArray[10]; a = myArray[2]; #a: $s0, myArray: $s1 LW $s0, 8($s1)

  20. C Programming • Have 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, ... );

  21. Good Luck! Questions?

More Related