Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS3410 HW1 Review 2014, 2, 21. Agenda We will go through the HW1 questions together TAs will then walk around to help.

Similar presentations


Presentation on theme: "CS3410 HW1 Review 2014, 2, 21. Agenda We will go through the HW1 questions together TAs will then walk around to help."— 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 abcout c ab Sum of products: Karnaugh map minimization: Cover all 1’s Group adjacent blocks of 2 n 1’s that yield a regular shape Encode common features

4 Rules for Karnaugh Map Minimization Minterms can overlap Minterms can span 1, 2, 4, 8 … cells The map can wrap around c ab c ab

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 x Output Okay x0 Spam filter x2 x1 Question 4: FSM (cont.) …

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

9 Question 4: FSM (cont.) Current stateInputNext stateOutput x1x2x0x1’=x0x2’=x okay spam ……………… 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 * * *.15 = 2.1 CPU Time = # Instructions x CPI x Clock Cycle Time – Assuming 400k instructions, 30 MHz : 400k * 2.1 / 30 = µ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) CPR (new) Cost (new) Cost (old) Perf (old) Perf (new) 1 speedup

14 Question 9/10/11: Assembler Code Writing the instructions in a human-readable format – p/MIPS_Vol2.pdf p/MIPS_Vol2.pdf Core instruction set – p/project/pa1/pa1.html p/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: int myArray[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?


Download ppt "CS3410 HW1 Review 2014, 2, 21. Agenda We will go through the HW1 questions together TAs will then walk around to help."

Similar presentations


Ads by Google