cs3350b computer organization chapter 2 synchronous
play

CS3350B Computer Organization Chapter 2: Synchronous Circuits - PowerPoint PPT Presentation

CS3350B Computer Organization Chapter 2: Synchronous Circuits Prelude Alex Brandt Department of Computer Science University of Western Ontario, Canada Thursday January 24, 2019 Alex Brandt Chapter 2: Synchronous Circuits, Prelude Thursday


  1. Gates as Switches Both A and B must be true/1 to get the circuit to complete. Either A or B can be true/1 to get the circuit to complete. Alex Brandt Chapter 2: Synchronous Circuits, Part 1: Gates & Boolean Algebra Tuesday January 29, 2019 10 / 28

  2. Logic Gates In Detail: AND Truth Table for AND A C B A B A ∧ B ≡ C 0 0 0 0 1 0 A ∧ B ≡ C 1 0 0 1 1 1 A ⋅ B ≡ C Alex Brandt Chapter 2: Synchronous Circuits, Part 1: Gates & Boolean Algebra Tuesday January 29, 2019 11 / 28

  3. Logic Gates In Detail: OR Truth Table for OR A C B A B A ∨ B ≡ C 0 0 0 0 1 1 A ∨ B ≡ C 1 0 1 1 1 1 A + B ≡ C Alex Brandt Chapter 2: Synchronous Circuits, Part 1: Gates & Boolean Algebra Tuesday January 29, 2019 12 / 28

  4. Logic Gates In Detail: NOT Truth Table for NOT A C A ¬ A ≡ C 0 1 ¬ A ≡ C 1 0 A ≡ C Alex Brandt Chapter 2: Synchronous Circuits, Part 1: Gates & Boolean Algebra Tuesday January 29, 2019 13 / 28

  5. More Interesting Logic Gates: NAND A Truth Table for NAND C B A B A ⋅ B ≡ C 0 0 1 ¬ (A ∧ B) ≡ C 0 1 1 1 0 1 A ⋅ B ≡ C 1 1 0 𝐵 ⋃︁ 𝐶 Alex Brandt Chapter 2: Synchronous Circuits, Part 1: Gates & Boolean Algebra Tuesday January 29, 2019 14 / 28

  6. More Interesting Logic Gates: NOR Truth Table for NOR A C B A B A + B ≡ C 0 0 1 0 1 0 ¬ (A ∨ B) ≡ C 1 0 0 1 1 0 A + B ≡ C Alex Brandt Chapter 2: Synchronous Circuits, Part 1: Gates & Boolean Algebra Tuesday January 29, 2019 15 / 28

  7. More Interesting Logic Gates: XOR (Exclusive OR) Truth Table for XOR A C A B A ⊕ B ≡ C B 0 0 0 0 1 1 1 0 1 A ⊕ B ≡ C 1 1 0 Alex Brandt Chapter 2: Synchronous Circuits, Part 1: Gates & Boolean Algebra Tuesday January 29, 2019 16 / 28

  8. Outline 1 Introduction 2 Logic Gates 3 Boolean Algebra Alex Brandt Chapter 2: Synchronous Circuits, Part 1: Gates & Boolean Algebra Tuesday January 29, 2019 17 / 28

  9. The Algebra of Logic Gates Due to the equivalence of truth values and binary digital signals, Boolean Algebra is heavily used discussing circuitry. Associativity: Identity: ( 𝐵 + 𝐶 ) + 𝐷 ≡ 𝐵 + ( 𝐶 + 𝐷 ) 𝐵 + 0 ≡ 𝐵 ( 𝐵 ⋅ 𝐶 ) ⋅ 𝐷 ≡ 𝐵 ⋅ ( 𝐶 ⋅ 𝐷 ) 𝐵 ⋅ 1 ≡ 𝐵 Commutativity: Annihilation: 𝐵 + 𝐶 ≡ 𝐶 + 𝐵 𝐵 + 1 ≡ 1 𝐵 ⋅ 𝐶 ≡ 𝐶 ⋅ 𝐵 𝐵 ⋅ 0 ≡ 0 Distributivity: Idempotence: 𝐵 + ( 𝐶 ⋅ 𝐷 ) ≡ ( 𝐵 + 𝐶 ) ⋅ ( 𝐵 + 𝐷 ) 𝐵 + 𝐵 ≡ 𝐵 𝐵 ⋅ ( 𝐶 + 𝐷 ) ≡ ( 𝐵 ⋅ 𝐶 ) + ( 𝐵 ⋅ 𝐷 ) 𝐵 ⋅ 𝐵 ≡ 𝐵 Alex Brandt Chapter 2: Synchronous Circuits, Part 1: Gates & Boolean Algebra Tuesday January 29, 2019 18 / 28

  10. Boolean Algebra: More Interesting Laws Absorption: 𝐵 ⋅ ( 𝐵 + 𝐶 ) ≡ 𝐵 De Morgan’s Laws: 𝐵 + ( 𝐵 ⋅ 𝐶 ) ≡ 𝐵 𝐵 + 𝐶 ≡ 𝐵 ⋅ 𝐶 Double Negation 𝐵 ⋅ 𝐶 ≡ 𝐵 + 𝐶 𝐵 ≡ 𝐵 Look familiar? Complementation: ë Definitions of NOR and NAND. 𝐵 + 𝐵 ≡ 1 𝐵 ⋅ 𝐵 ≡ 0 Alex Brandt Chapter 2: Synchronous Circuits, Part 1: Gates & Boolean Algebra Tuesday January 29, 2019 19 / 28

  11. Proving De Morgan’s Laws Proof by Exhaustion: ë The easiest way to prove something is to write out each expression’s truth table. 𝐵 + 𝐶 ≡ 𝐵 ⋅ 𝐶 A B A + B 𝐵 + 𝐶 A B 𝐵 𝐶 𝐵 ⋅ 𝐶 0 0 0 1 0 0 1 1 1 0 1 1 0 0 1 1 0 0 1 0 1 0 1 0 0 1 0 1 1 1 0 1 1 0 0 0 Alex Brandt Chapter 2: Synchronous Circuits, Part 1: Gates & Boolean Algebra Tuesday January 29, 2019 20 / 28

  12. Simplifying Expressions with Boolean Algebra (1/2) 𝑦𝑧𝑨 + 𝑦𝑧𝑨 𝑦𝑧𝑨 + 𝑦𝑧𝑨 ≡ 𝑦𝑧 ( 𝑨 + 𝑨 ) Factor 𝑦𝑧 ≡ 𝑦𝑧 ( 1 ) Complementation of 𝑨 ≡ 𝑦𝑧 Identity with 𝑦𝑧 𝑦 𝑧 𝑨 𝑦𝑧𝑨 𝑦𝑧𝑨 𝑦𝑧𝑨 + 𝑦𝑧𝑨 0 0 0 1 0 1 0 0 1 0 1 1 0 1 0 0 0 0 ‘ 0 1 1 0 0 0 1 0 0 0 0 0 1 0 1 0 0 0 1 1 0 0 0 0 1 1 1 0 0 0 Alex Brandt Chapter 2: Synchronous Circuits, Part 1: Gates & Boolean Algebra Tuesday January 29, 2019 21 / 28

  13. Simplifying Expressions with Boolean Algebra (2/2) Sometimes a truth table is too challenging... ë For 𝑤 variables a truth table has 2 v rows. ( 𝑦 + 𝑨 )( 𝑏𝑐𝑑𝑒 + 𝑦𝑨 ) � ⇒ 6 variables, 64 rows Instead we can simplify using the laws of Boolean algebra: ( 𝑦 + 𝑨 )( 𝑏𝑐𝑑𝑒 + 𝑦𝑨 ) ≡ 𝑦𝑨 ( 𝑏𝑐𝑑𝑒 + 𝑦𝑨 ) De Morgan’s Law ≡ 𝑦𝑨 ( 𝑏𝑐𝑑𝑒 + 𝑦𝑨 ) Double negation of 𝑦 and 𝑨 ≡ 𝑦𝑨 Absorption Alex Brandt Chapter 2: Synchronous Circuits, Part 1: Gates & Boolean Algebra Tuesday January 29, 2019 22 / 28

  14. Simplifying Expressions for Simplified Circuits 𝑧 = (( 𝑏𝑐 ) + 𝑏 ) + 𝑑 ⇓ 𝑧 ≡ ( 𝑏𝑐 + 𝑏 ) + 𝑑 ≡ 𝑏 ( 𝑐 + 1 ) + 𝑑 Factor 𝑏 ≡ 𝑏 ( 1 ) + 𝑑 Annihilaltion ≡ 𝑏 + 𝑑 Identity Alex Brandt Chapter 2: Synchronous Circuits, Part 1: Gates & Boolean Algebra Tuesday January 29, 2019 23 / 28

  15. Canonical Forms Different standard or canonical forms . Conjunctive Normal Form (CNF) ⇒ AND of ORs ë “Product-of-sums” Disjunctive Normal Form (DNF) ⇒ ORs of ANDs ë “Sum-of-products” CNF ( 𝑏 + 𝑐 ) ⋅ ( 𝑏 + 𝑐 ) ⋅ ( 𝑏 + 𝑐 ) DNF 𝑏𝑐 + 𝑏𝑐 + 𝑏𝑐 Every variable should appear in every sub-expression. ë Products for DNF, Sums for CNF. ë Some authors call this "Full DNF" or "Full CNF". Every boolean expression can be converted to a canonical form. DNF more useful and practical ⇒ truth tables. Alex Brandt Chapter 2: Synchronous Circuits, Part 1: Gates & Boolean Algebra Tuesday January 29, 2019 24 / 28

  16. Truth Tables and Disjunctive Normal Forms We can get a DNF expression directly from a truth table. 𝑏 , 𝑐 , 𝑑 are inputs, 𝑔 is output. Create one product term for every entry in the table with 𝑔 ≡ 1 . Put 𝑦 in product if 𝑦 is false in that row. Put 𝑦 in product if 𝑦 is true in that row. OR all products together. 𝑏 𝑐 𝑑 𝑔 0 0 0 1 0 0 1 0 0 1 0 1 0 1 1 0 � ⇒ 𝑏𝑐𝑑 + 𝑏𝑐𝑑 + 𝑏𝑐𝑑 + 𝑏𝑐𝑑 1 0 0 1 1 0 1 0 1 1 0 0 1 1 1 1 Alex Brandt Chapter 2: Synchronous Circuits, Part 1: Gates & Boolean Algebra Tuesday January 29, 2019 25 / 28

  17. Functional Completeness Functional Completeness - A set of functions (operators) which can adequately describe every operation and outcome in an algebra. For Boolean algebra the classical set of operators: {+ , ⋅ , ¬ } is functionally complete but not minimal . Thanks to De Morgan’s Law we only need one of AND or OR. The sets { + , ¬ } and { ⋅ , ¬ } are both functionally complete and minimal. ë minimal - removing any one of the operators would make the set functionally incomplete . NAND alone is functionally complete; so is NOR alone. Alex Brandt Chapter 2: Synchronous Circuits, Part 1: Gates & Boolean Algebra Tuesday January 29, 2019 26 / 28

  18. NAND is Functionally Complete 𝑌 𝑌 𝑌 ⋅ 𝑌 𝑌 ⋅ 𝑌 NAND alone is functionally complete. 0 1 0 1 NAND ≡ ⋃︁ 1 0 1 0 To prove functional completeness 𝐵 ≡ 𝑌 | 𝑍 simply show that the operators of X Y 𝐵 | 𝐵 the set can mimic the functionality 0 0 1 0 of the set {+ , ⋅ , ¬ } . 0 1 1 0 1 0 1 0 ¬ 𝑌 ≡ 𝑌 | 𝑌 1 1 0 1 X Y 𝑌 𝑍 𝑌 ⋃︁ 𝑍 𝑌 ⋅ 𝑍 ≡ 𝑌 | 𝑍 ≡ ( 𝑌 | 𝑍 ) | ( 𝑌 | 𝑍 ) 0 0 1 1 0 0 1 1 0 1 1 0 0 1 1 𝑌 + 𝑍 ≡ 𝑌 + 𝑍 ≡ 𝑌 ⋅ 𝑍 ≡ ( 𝑌 ⋃︁ 𝑌 ) ⋃︁ ( 𝑍 ⋃︁ 𝑍 ) 1 1 0 0 1 Alex Brandt Chapter 2: Synchronous Circuits, Part 1: Gates & Boolean Algebra Tuesday January 29, 2019 27 / 28

  19. Summary Boolean algebra can simplify circuits. Remove variables that the output does not depend on. Simplifies expression, removing needless gates. Space and time complexity improved! Truth tables, canonical forms, functional completeness. Help generating truth tables: http://turner.faculty.swau.edu/mathematics/ materialslibrary/truth/ Alex Brandt Chapter 2: Synchronous Circuits, Part 1: Gates & Boolean Algebra Tuesday January 29, 2019 28 / 28

  20. CS3350B Computer Organization Chapter 2: Synchronous Circuits Part 2: Stateless Circuits Alex Brandt Department of Computer Science University of Western Ontario, Canada Tuesday February 05, 2019 Alex Brandt Chapter 2: Synchronous Circuits, Part 2: Stateless Circuits Tuesday February 05, 2019 1 / 27

  21. Outline 1 Combinational Circuits 2 Adders and Subtractors 3 MUX and DEMUX 4 Arithmetic Logic Units Alex Brandt Chapter 2: Synchronous Circuits, Part 2: Stateless Circuits Tuesday February 05, 2019 2 / 27

  22. Stateless Circuits are Combinational Circuits Stateless ⇒ No memory. Combinational ⇒ Output is a combination of the inputs alone. Combinational circuits are formed from a combination of logic gates and other combinational cirtcuits. ë Modular Design, ë Reuse, ë Simple to add new components. Sometimes, these are called functional blocks , they implement functions . Alex Brandt Chapter 2: Synchronous Circuits, Part 2: Stateless Circuits Tuesday February 05, 2019 3 / 27

  23. Increasing Arity Arity: the number of inputs to a gate, function, etc. How can we build an 𝑜 -way add from simple 2-input and gates? ë Simply chain together 𝑜 − 1 2-way gates. Example: 5-way AND Works for AND, OR, XOR. Doesn’t work for NAND, NOR. Alex Brandt Chapter 2: Synchronous Circuits, Part 2: Stateless Circuits Tuesday February 05, 2019 4 / 27

  24. Block Diagrams A block diagram or schematic diagram can use used to express the high-level specification of a circuit. How many inputs, how many bits for each input? How many outputs, how many bits for each output? What does the circuit do? Formula or truth table. 𝑏 𝑐 𝑑 𝐺 0 0 0 1 0 0 1 0 0 1 0 0 0 1 1 0 1 0 0 0 1 0 1 0 𝐺 ≡ 𝑏𝑐𝑑 + 𝑏𝑐𝑑 1 1 0 0 1 1 1 1 Alex Brandt Chapter 2: Synchronous Circuits, Part 2: Stateless Circuits Tuesday February 05, 2019 5 / 27

  25. From Blocks to Gates (1/2) 1 Generate truth table. 2 Get canonical form: 𝑏 𝑐 𝑑 𝐺 𝐺 ≡ 𝑏𝑐𝑑 + 𝑏𝑐𝑑 + 𝑏𝑐𝑑 + 𝑏𝑐𝑑 0 0 0 0 3 Simplify if possible: 0 0 1 0 0 1 0 0 𝑏𝑐𝑑 + 𝑏𝑐𝑑 + 𝑏𝑐𝑑 + 𝑏𝑐𝑑 0 1 1 1 1 0 0 0 ≡ 𝑏𝑐𝑑 + 𝑏𝑐𝑑 + 𝑏𝑐𝑑 + 𝑏𝑐𝑑 + 𝑏𝑐𝑑 + 𝑏𝑐𝑑 1 0 1 1 ≡ 𝑏𝑐𝑑 + 𝑏𝑐𝑑 + 𝑏𝑐𝑑 + 𝑏𝑐𝑑 + 𝑏𝑐𝑑 + 𝑏𝑐𝑑 1 1 0 1 ≡ 𝑐𝑑 + 𝑏𝑑 + 𝑏𝑐 1 1 1 1 Alex Brandt Chapter 2: Synchronous Circuits, Part 2: Stateless Circuits Tuesday February 05, 2019 6 / 27

  26. From Blocks to Gates (2/2) 3 Simplify if possible: 𝐺 ≡ 𝑐𝑑 + 𝑏𝑑 + 𝑏𝑐 4 Draw your circuit from simplified formula. 𝑏 𝑐 𝑑 𝐺 0 0 0 0 0 0 1 0 0 1 0 0 0 1 1 1 1 0 0 0 1 0 1 1 1 1 0 1 1 1 1 1 This is called a majority circuit. Output is true iff majority of inputs are true. Alex Brandt Chapter 2: Synchronous Circuits, Part 2: Stateless Circuits Tuesday February 05, 2019 7 / 27

  27. Outline 1 Combinational Circuits 2 Adders and Subtractors 3 MUX and DEMUX 4 Arithmetic Logic Units Alex Brandt Chapter 2: Synchronous Circuits, Part 2: Stateless Circuits Tuesday February 05, 2019 8 / 27

  28. 1 Bit Adder Adder interprets bits as a binary number and does addition. c 𝑏 𝑐 𝑡 0 0 0 0 0 1 1 0 1 0 1 0 1 1 0 1 𝑡 = 𝑏𝑒𝑒 ( 𝑏,𝑐 ) 𝑑 = carry (overflow) bit Alex Brandt Chapter 2: Synchronous Circuits, Part 2: Stateless Circuits Tuesday February 05, 2019 9 / 27

  29. 1 Bit Full Adder Full Adder does addition of 3 inputs: a, b, and carry in . ë Previous adder was a half adder. 𝑡 = 𝑌𝑃𝑆 ( 𝑏,𝑐,𝑑 in ) 𝑑 = 𝑏𝑐 + ( 𝑌𝑃𝑆 ( 𝑏,𝑐 ) ⋅ 𝑑 in ) Alex Brandt Chapter 2: Synchronous Circuits, Part 2: Stateless Circuits Tuesday February 05, 2019 10 / 27

  30. 1 Bit Full Adder using Half Adders A full adder can be built from half adders. ë Modular design, reuse, simplified view. Alex Brandt Chapter 2: Synchronous Circuits, Part 2: Stateless Circuits Tuesday February 05, 2019 11 / 27

  31. n-Bit Full Adder 𝑜 -bit adder: Add 𝑜 bits with carry. ë Just like long addition done by hand. ë Combine 𝑜 full adders, adding bit by bit, carrying the carry from lowest-ordered bit to highest-ordered bit. ë Final carry bit is 𝑑 n . Alex Brandt Chapter 2: Synchronous Circuits, Part 2: Stateless Circuits Tuesday February 05, 2019 12 / 27

  32. Addition Overflow (1/2) Overflow occurs when arithmetic results in a number strictly larger than can fit in the predetermined number of bits. For unsigned integers, overflow is detected by 𝑑 n being 1. For signed (i.e. twos-compliment) integers, overflow more interesting. Example: Addition in 4 bits. (carry bits) 1000 1101 + 0110 ⇒ 𝑑 n is 1. Overflow? 10011 Alex Brandt Chapter 2: Synchronous Circuits, Part 2: Stateless Circuits Tuesday February 05, 2019 13 / 27

  33. Addition Overflow (1/2) Overflow occurs when arithmetic results in a number strictly larger than can fit in the predetermined number of bits. For unsigned integers, overflow is detected by 𝑑 n being 1. For signed (i.e. twos-compliment) integers, overflow more interesting. Example: Addition in 4 bits. − 3 (carry bits) 1000 + 6 1101 + 0110 3 ⇒ No overflow Discard last carry bit ⇒ 𝑑 n is 1. Overflow? 10011 Alex Brandt Chapter 2: Synchronous Circuits, Part 2: Stateless Circuits Tuesday February 05, 2019 13 / 27

  34. Addition Overflow (2/2) In twos-compliment when is there overflow? Most significant bit encodes a negative number in two’s compliment. If both operands are positive and 𝑑 n − 1 ≡ 1 then we have overflow. If one positive and one negative, overflow impossible. ë Their sum is always closer to zero than either of the operands. If both operands are negative and 𝑑 n ≡ 1 then we have overflow. 1000 ⇒ Overflow 1000 1000 + 1000 0101 1101 + 0110 + 0110 10000 ⇒ Overflow 10011 ⇒ No overflow 1011 Overflow in two’s compliment: 𝑑 n XOR 𝑑 n − 1 . Alex Brandt Chapter 2: Synchronous Circuits, Part 2: Stateless Circuits Tuesday February 05, 2019 14 / 27

  35. n-bit Subtractor (1/2) 𝑜 -bit subtractor: Subtract two 𝑜 -bit numbers. We want 𝑡 = 𝑏 − 𝑐 . Start with an 𝑜 -bit adder. XOR 𝑐 with a control signal for subtraction. ë signal is 1 for subtraction, 0 for addition. XOR works as conditional inverter. ë A XOR B ≡ C � ⇒ if (B) then A ≡ C else A ≡ C. A B A ⊕ B ≡ C 0 0 0 0 1 1 1 0 1 1 1 0 Alex Brandt Chapter 2: Synchronous Circuits, Part 2: Stateless Circuits Tuesday February 05, 2019 15 / 27

  36. n-bit Subtractor (2/2) Control signal SUB acts as 𝑑 0 . ë Recall: signed negation . Invert and add one. ë XOR does invert. Alex Brandt Chapter 2: Synchronous Circuits, Part 2: Stateless Circuits Tuesday February 05, 2019 16 / 27

  37. Outline 1 Combinational Circuits 2 Adders and Subtractors 3 MUX and DEMUX 4 Arithmetic Logic Units Alex Brandt Chapter 2: Synchronous Circuits, Part 2: Stateless Circuits Tuesday February 05, 2019 17 / 27

  38. Multiplexer A multiplexer “mux” conditionally chooses among its inputs to set value of output. Uses control signal to control which input is chosen. Still no state, output depending only on inputs: input bits and control signal. 2-way multiplexer If 𝑡 ≡ 0 then 𝑑 ≡ 𝑏 . If 𝑡 ≡ 1 then 𝑑 ≡ 𝑐 . Notice actual value of 𝑏 and 𝑐 have no effect on decision. ë 0 and 1 in multiplexer is not the value of 𝑏 or 𝑐 but the “index”. Alex Brandt Chapter 2: Synchronous Circuits, Part 2: Stateless Circuits Tuesday February 05, 2019 18 / 27

  39. 2-way Multiplexer How to encode this “if-then” behaviour without actual conditionals? 𝑑 ≡ 𝑁𝑉𝑌 ( 𝑏,𝑐,𝑡 ) ≡ 𝑡𝑏 ( 𝑐 + 𝑐 ) + 𝑡𝑐 ( 𝑏 + 𝑏 ) ≡ 𝑡𝑏 + 𝑡𝑐 Note: 𝑌 ⋅ ( 𝑍 + 𝑍 ) encodes “ 𝑌 independent of what the value of 𝑍 is”. Alex Brandt Chapter 2: Synchronous Circuits, Part 2: Stateless Circuits Tuesday February 05, 2019 19 / 27

  40. 4-way Multiplexer 𝑓 ≡ 𝑁𝑉𝑌 ( 𝑏,𝑐,𝑑,𝑒,𝑇 ) ≡ 𝑡 1 𝑡 0 𝑏 + 𝑡 1 𝑡 0 𝑐 + 𝑡 1 𝑡 0 𝑑 + 𝑡 1 𝑡 0 𝑒 The index of each input is now 0 through 3. Need 2 bits to choose among 4 inputs. Control signal’s bit-width is now 2. Alex Brandt Chapter 2: Synchronous Circuits, Part 2: Stateless Circuits Tuesday February 05, 2019 20 / 27

  41. Big Data Multiplexer Bit-width of input and output must match, but bit-width of control signal only determined by number of inputs to choose from. Alex Brandt Chapter 2: Synchronous Circuits, Part 2: Stateless Circuits Tuesday February 05, 2019 21 / 27

  42. Demultiplexer Demultiplexer “demux” conditionally chooses among its outputs. ë Opposite of MUX. ë Un-selected outputs are set to 0. Alex Brandt Chapter 2: Synchronous Circuits, Part 2: Stateless Circuits Tuesday February 05, 2019 22 / 27

  43. Outline 1 Combinational Circuits 2 Adders and Subtractors 3 MUX and DEMUX 4 Arithmetic Logic Units Alex Brandt Chapter 2: Synchronous Circuits, Part 2: Stateless Circuits Tuesday February 05, 2019 23 / 27

  44. Arithmetic Logic Unit An ALU is a black-box type circuit which can do many different arithmetic or logic operations on its inputs. ë Not many at one time, but selectively acts as many. Depending on the implementation can do addition, subtraction, multiplication, division, logical AND, logical OR, shifting, etc. Use a control signal to choose which operation to perform. Essentially a big collection of MUX and combinational blocks for each operation. Alex Brandt Chapter 2: Synchronous Circuits, Part 2: Stateless Circuits Tuesday February 05, 2019 24 / 27

  45. Simple ALU Circuit Alex Brandt Chapter 2: Synchronous Circuits, Part 2: Stateless Circuits Tuesday February 05, 2019 25 / 27

  46. Optimizing ALU Remember, every additional gate increases delay and space. Instead, optimize via the normal four step process: 1 Generate a truth table, 2 Get canonical from from truth table, 3 Simplify expression, 4 Make circuit. Another option: programmable logic array. Alex Brandt Chapter 2: Synchronous Circuits, Part 2: Stateless Circuits Tuesday February 05, 2019 26 / 27

  47. Programmable Logic Array A programmable logic array (PLA) directly implements a truth table/canonical disjunctive normal form. Each AND row is a truth table row. Each OR column is one output bit. Each ⊕ is a programmable (i.e. optional) join of the input to the circuit. Alex Brandt Chapter 2: Synchronous Circuits, Part 2: Stateless Circuits Tuesday February 05, 2019 27 / 27

  48. CS3350B Computer Organization Chapter 2: Synchronous Circuits Part 3: State Circuits Alex Brandt Department of Computer Science University of Western Ontario, Canada Thursday February 07, 2019 Alex Brandt Chapter 2: Synchronous Circuits, Part 3: State Circuits Thursday February 07, 2019 1 / 37

  49. Outline 1 Digital Signals 2 The Clock 3 Flip-Flops and Registers 4 Finite State Machines Alex Brandt Chapter 2: Synchronous Circuits, Part 3: State Circuits Thursday February 07, 2019 2 / 37

  50. Digital Signals We digitalize an analog (voltage) signal to encode binary. “High” voltage ⇒ 1. “Low” voltage ⇒ 0. Alex Brandt Chapter 2: Synchronous Circuits, Part 3: State Circuits Thursday February 07, 2019 3 / 37

  51. Transmitting Digital Signals For our purposes: Transmission is continuous. There’s always something on the wire. Transmission/switching is effectively instantaneous. Alex Brandt Chapter 2: Synchronous Circuits, Part 3: State Circuits Thursday February 07, 2019 4 / 37

  52. Grouping Signals To Encode Many Bits Alex Brandt Chapter 2: Synchronous Circuits, Part 3: State Circuits Thursday February 07, 2019 5 / 37

  53. Signals and Circuits Unfortunately for us, combinational circuits cause propagation delay . The more complex the circuit the longer 2 5 3 -3 the delay. Every gate adds 2 1 2 3 some delay. 4 6 5 0 Alex Brandt Chapter 2: Synchronous Circuits, Part 3: State Circuits Thursday February 07, 2019 6 / 37

  54. Dealing with Delay Problems with propagation delay: Inputs transmit (change) instantaneously, but output does not. When can the next circuit read the output and ensure it is getting the correct value? Synchronize the circuits via a clock . Alex Brandt Chapter 2: Synchronous Circuits, Part 3: State Circuits Thursday February 07, 2019 7 / 37

  55. Outline 1 Digital Signals 2 The Clock 3 Flip-Flops and Registers 4 Finite State Machines Alex Brandt Chapter 2: Synchronous Circuits, Part 3: State Circuits Thursday February 07, 2019 8 / 37

  56. The Clock Signal The clock is a digital signal which has a precise timing for switching between 1/0. Synchronous circuits use the clock to sync their executions, decide when to read inputs/outputs. ë Heartbeat of a synchronous system. Alex Brandt Chapter 2: Synchronous Circuits, Part 3: State Circuits Thursday February 07, 2019 9 / 37

  57. How to Synchronize Circuits usually synchronize to the rising edge of the clock. ë The transition from 0 to 1. ë Depending on the system, can instead sync on the falling edge . 0,0 1,0 0,1 1,0 Alex Brandt Chapter 2: Synchronous Circuits, Part 3: State Circuits Thursday February 07, 2019 10 / 37

  58. Clock Multipliers We know that CPU and memory operate at difference speeds. So how do they synchronize? One central clock used. Central clock is as slow as the slowest component. Faster components use a clock multiplier . A clock multiplier multiplies the central clock frequency so that a component has many internal cycles for a single clock cycle of the entire system . Note: this is simply a technicality of implementation. Generally, we still discuss speeds based on frequency the CPU experiences. Our old metrics still work as they always have. Alex Brandt Chapter 2: Synchronous Circuits, Part 3: State Circuits Thursday February 07, 2019 11 / 37

  59. Outline 1 Digital Signals 2 The Clock 3 Flip-Flops and Registers 4 Finite State Machines Alex Brandt Chapter 2: Synchronous Circuits, Part 3: State Circuits Thursday February 07, 2019 12 / 37

  60. Circuits that Remember Sometimes values on a wire (i.e. a bit) cannot be maintained indefinitely on that wire. Values must change. Computer memory is circuits which remember . Circuits implement memory but are also used within other circuits to hold state. ë Modular design. Flip-flop: a circuit which implements a single bit of memory. ë All flip-flops based on a simple design: inputs, combined with current state, give next state. ë Essentially, the implementation of static RAM (SRAM). Register: a storage for multiple bits of memory. Alex Brandt Chapter 2: Synchronous Circuits, Part 3: State Circuits Thursday February 07, 2019 13 / 37

  61. Edge-Triggered Flip-Flop A flip-flop which looks at its input on the edge of clock. ë Rising edge or positive edge (usually), or ë Falling edge or negative edge. This is a delay flip-flop Alex Brandt Chapter 2: Synchronous Circuits, Part 3: State Circuits Thursday February 07, 2019 14 / 37

  62. D Flip-Flop Delay flip-flop: takes input and, with some delay, sets output equal to the input. ë Simplest (conceptually) flip-flop. ë Requires constant updating to maintain state. ë Grabs input on rising edge and outputs that until next clock cycle. ë Current state does not affect next state. D Q Q next 0 - 0 1 - 1 Flip-flops usually produce next state and negation of next state simultaneously. Alex Brandt Chapter 2: Synchronous Circuits, Part 3: State Circuits Thursday February 07, 2019 15 / 37

  63. T Flip-Flop Toggle flip-flop: if input is 1, toggle current state. ë Uses current state to determine next state. ë 𝑈 ≡ 0 ⇒ “Hold”. Next state is same as current. ë 𝑈 ≡ 1 ⇒ “Toggle”. Next state is opposite of current. T Q Q next 0 0 0 0 1 1 1 0 1 1 1 0 Alex Brandt Chapter 2: Synchronous Circuits, Part 3: State Circuits Thursday February 07, 2019 16 / 37

  64. SR Flip-Flop Set-Reset flip-flop ë Two inputs, S (set), R (reset), synchronized by a clock. ë 𝑇 ≡ 1 ⇒ “Set”. Next state is 1. ë 𝑆 ≡ 1 ⇒ “Reset”. Next state is 0. ë 𝑇 ≡ 0 ∧ 𝑆 ≡ 0 ⇒ “Hold”. S R Q Q next 0 0 - Q 0 1 - 0 1 0 - 1 1 1 - - Can not have both 𝑇 and 𝑆 set to 1. . . Alex Brandt Chapter 2: Synchronous Circuits, Part 3: State Circuits Thursday February 07, 2019 17 / 37

  65. SR Technicalities E “enable” ⇐ ⇒ clock 𝑇 ≡ 𝑆 ≡ 𝐹 ≡ 1 � ⇒ 1 + 𝑅 ≡ 0 ≡ 1 + 𝑅 � ⇒ 𝑅 ≡ 𝑅 ??? We get undefined behaviour. This is weird and can destabilize the system. Alex Brandt Chapter 2: Synchronous Circuits, Part 3: State Circuits Thursday February 07, 2019 18 / 37

  66. JK Flip-Flop JK flip-flop ë Two inputs, J (set), K (reset), synchronized by a clock. ë Same as SR except with toggle. ë 𝐾 ≡ 1 ∧ 𝐿 ≡ 1 ⇒ “Toggle”. J K Q Q next 0 0 - Q 0 1 - 0 1 0 - 1 1 1 - 𝑅 Alex Brandt Chapter 2: Synchronous Circuits, Part 3: State Circuits Thursday February 07, 2019 19 / 37

  67. Registers A register is just a collection of flip-flops. Technically, this is a shift register . 𝑜 -bits � ⇒ 𝑜 flip-flops. Clock pulse connected to all flip-flops. Can be encoded using any type of flip-flop. This example is a parallel in, parallel out register. Alex Brandt Chapter 2: Synchronous Circuits, Part 3: State Circuits Thursday February 07, 2019 20 / 37

  68. PIPO Registers Parallel In, Parallel Out Register: All inputs bits come in in parallel, and output bits get output in parallel. Most common. Input/output of each flip-flop is independent. Can be encoded using any type of flip-flop. Alex Brandt Chapter 2: Synchronous Circuits, Part 3: State Circuits Thursday February 07, 2019 21 / 37

  69. SIPO Registers Serial In, Parallel Out Register: One input bit at a time, output all bits at once. Input bit moves through chain of flip-flops. Transitions at each clock. This example uses D flip-flops. Sometimes it is useful to clear the entire register without waiting 𝑜 cycles for 𝑜 bits of data to shift out. Additional control signals can be used to set all flip-flops to 1 ( 𝑇 ) or all flip-flops to 0 ( 𝑆 ). Alex Brandt Chapter 2: Synchronous Circuits, Part 3: State Circuits Thursday February 07, 2019 22 / 37

  70. SISO/PISO Registers Serial In, Serial Out Register: A linear chain of flip-flops. Output of one flip-flop is the input of the next. One input bit and one output bit. Kind of like a conveyor belt of bits. Parallel In, Serial Out Register: A linear chain of flip-flops + control circuits. Data loaded in parallel: 𝑜 flip-flops load 𝑜 bits at once. Data output in serial: Acts as SISO for output. ë Output one bit at a time. ë Bits are shifted one over on each output. Requires clock and additional write/shift control signal. Alex Brandt Chapter 2: Synchronous Circuits, Part 3: State Circuits Thursday February 07, 2019 23 / 37

  71. Timing a Flip-Flop All gates/circuits introduce propagation delay. For flip-flops this propagation delay is called clk-to-q delay . Alex Brandt Chapter 2: Synchronous Circuits, Part 3: State Circuits Thursday February 07, 2019 24 / 37

  72. Timing a Flip-Flop: Data Stability Input to a flip-flop must have a stable value around the rising edge of the clock. ë Before the rising edge: setup time . ë After the rising edge: hold time . setup hold Despite how it’s shown here, hold time is less than clk-to-q delay. Alex Brandt Chapter 2: Synchronous Circuits, Part 3: State Circuits Thursday February 07, 2019 25 / 37

  73. Putting it all Together: Accumulator An accumulator: continually adds input value to its stored value. This doesn’t work. Would spin once per circuit’s propagation delay, not once per input. Need clock to synchronize reading from input. Alex Brandt Chapter 2: Synchronous Circuits, Part 3: State Circuits Thursday February 07, 2019 26 / 37

  74. Clocked Accumulator Insert register to store output. Only need to clock the register, not the combinational circuit. Clock on register determines when output of circuit actually gets stored. Alex Brandt Chapter 2: Synchronous Circuits, Part 3: State Circuits Thursday February 07, 2019 27 / 37

  75. Timing the Accumulator setup adder delay clk-to-q Clock must be slow enough to include: Adder delay, Clk-to-q, Setup time. Alex Brandt Chapter 2: Synchronous Circuits, Part 3: State Circuits Thursday February 07, 2019 28 / 37

  76. Synchronous Circuits: Clock Frequency (Max Clock Freq.) Min. Clock Period = Combinational Circuit Propagation Delay + Setup Time + Clk-To-Q Alex Brandt Chapter 2: Synchronous Circuits, Part 3: State Circuits Thursday February 07, 2019 29 / 37

  77. Pipeline for Performance (1/2) Delay of adder and shifter is very long. Forces clock cycle to be very long. Slows down other circuits in this synchronous system. Alex Brandt Chapter 2: Synchronous Circuits, Part 3: State Circuits Thursday February 07, 2019 30 / 37

  78. Pipeline for Performance (2/2) Split add and shift into two different tasks. Insert register between to store results temporarily. Increase clock frequency. Alex Brandt Chapter 2: Synchronous Circuits, Part 3: State Circuits Thursday February 07, 2019 31 / 37

  79. General Synchronous Systems All systems follow a general pattern: A chain of logic circuit blocks, separated by registers, controlled by a single clock. Foreshadowing for MIPS pipeline. Alex Brandt Chapter 2: Synchronous Circuits, Part 3: State Circuits Thursday February 07, 2019 32 / 37

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend