Presentation is loading. Please wait.

Presentation is loading. Please wait.

How Computers Work Lecture 4 Page 1 How Computers Work Lecture 4 Computer Arithmetic.

Similar presentations


Presentation on theme: "How Computers Work Lecture 4 Page 1 How Computers Work Lecture 4 Computer Arithmetic."— Presentation transcript:

1 How Computers Work Lecture 4 Page 1 How Computers Work Lecture 4 Computer Arithmetic

2 How Computers Work Lecture 4 Page 2 WD Memory WD Register File RA2 Memory RD2 WA RC WERF WEMEM WA WE A B A op B Register File RA1 RD1 RA2 RD2 RARBRC BSELASEL ALUFN WDSEL0 01 01012 1 ALU Register File SEXT C 4:0 9:5 20:5 25:2131:26 OPCODE RA1 Memory RD1 PC Q +1 D PC Z 01 BRZ(R31,XADDR,XP) XADDR 01 2 ISEL PCSEL OPCODE A Descending Data Flow View of the Beta Operate class: Rc op

3 How Computers Work Lecture 4 Page 3 What are we going to learn today? How to build the Arithmetic/Logical Unit –Integer adder and multiplier architectures –Time/Space/Cost Trade-offs

4 How Computers Work Lecture 4 Page 4 The 74181 ALU

5 How Computers Work Lecture 4 Page 5 A Wild and Crazy Idea: Arithmetic / Logic Unit is describable by a table: –ergo, we can implement it with a memory: Bad Idea, because: 2 ~70 is a large number of rows! A B ALUFN 32 A few 32

6 How Computers Work Lecture 4 Page 6 A 1 Bit Full Adder Ci00001111Ci00001111 A00110011A00110011 B01010101B01010101 S01101001S01101001 Co00010111Co00010111 FA AB CoCo CiCi S Generates 1 sum bit, carry Can be cascaded to N bits

7 How Computers Work Lecture 4 Page 7 FA Ripple-carry N-bit adder: Problem: It’s Slow!

8 How Computers Work Lecture 4 Page 8 What is Co as a function of Ci, A, B ? Ci00001111Ci00001111 A00110011A00110011 B01010101B01010101 S01101001S01101001 Co00010111Co00010111

9 How Computers Work Lecture 4 Page 9 But What is Co really ? Ci00001111Ci00001111 A00110011A00110011 B01010101B01010101 S01101001S01101001 Co00010111Co00010111 Co = 1 if 2 or more inputs are 1 !

10 How Computers Work Lecture 4 Page 10 How can we build simplified logic? Example: Full Adder : K-Map A B CiCi Ci00001111Ci00001111 A00110011A00110011 B01010101B01010101 S01101001S01101001 Co00010111Co00010111 A B CiCi S: Co:Co:

11 How Computers Work Lecture 4 Page 11 The Karnaugh Map Characteristics: 1: Unit-Distance Input Labels 2: Wrap-Around

12 How Computers Work Lecture 4 Page 12 AND A B A B Q Q

13 How Computers Work Lecture 4 Page 13 OR A B A B Q Q

14 How Computers Work Lecture 4 Page 14 XOR A B A B Q Q

15 How Computers Work Lecture 4 Page 15 Q: What is Cout? A B CiCi

16 How Computers Work Lecture 4 Page 16 Q: What is Cout? A B CiCi A: (A and Ci) or (A and B) or (B and Ci) A: (A Ci) + (A B) + (B Ci) A: A Ci + A B + B Ci

17 How Computers Work Lecture 4 Page 17 How about S ? Ci00001111Ci00001111 A00110011A00110011 B01010101B01010101 S01101001S01101001 A B CiCi

18 How Computers Work Lecture 4 Page 18 Parity A B Ci S

19 How Computers Work Lecture 4 Page 19 Tree Structure N-input TREE has O(log(n)) levels... Signal propagation takes O(log(n)) gate delays. O(n) gates. A 2 A 1 A 4 A 3 A N

20 How Computers Work Lecture 4 Page 20 An Idea ! Speed things up by doing as much work as possible on A & B Inputs before the carry arrives: ? ?

21 How Computers Work Lecture 4 Page 21 Generate and Propagate G P CiCi G P CiCi S: Co:Co: A B A B G: P: (35) (36)

22 How Computers Work Lecture 4 Page 22 Implementation of C o G = A B P = A xor B AB GP CoutCin Cout = G + P Cin

23 How Computers Work Lecture 4 Page 23 Implementation of S G = A B P = A xor B GP S Cin S = P xor Cin

24 How Computers Work Lecture 4 Page 24 Yet Another Idea ! Carry Look-Ahead

25 How Computers Work Lecture 4 Page 25 The 74181 ALU

26 How Computers Work Lecture 4 Page 26 How Fast Can an Adder Get ? Input Sensitivity Analysis: Ultimately, some bits of the answer are dependent on all bits of the inputs. Given an infinite number of bounded fan- in gates, what is the minimum growth of t pd vs. the number of inputs (n)? –Answer: O(log(n))

27 How Computers Work Lecture 4 Page 27 Any more tricks to go faster? What about changing the Encoding of the inputs (i.e. base 4 !!!!!!!) –O(log(n)) limitation still there, but converting to a higher radix, doing the computation, then going back to binary CAN be faster than doing it naively in binary. How about analog computing? –Works, but watch out for noise. How about parallel computing? –Works, but watch out for cost. How about pipelined computing? –Q: What’s a pipelined computer? A: You’re going to find out real soon.

28 How Computers Work Lecture 4 Page 28 Summary Today’s Lecture: –How to build the Arithmetic/Logical Unit –Time/Space/Cost Trade-offs Recitation –K-maps and sum-of-products form –Multipliers


Download ppt "How Computers Work Lecture 4 Page 1 How Computers Work Lecture 4 Computer Arithmetic."

Similar presentations


Ads by Google