1 / 19

Number Systems and Logic Functions in Digital Design

This overview covers topics such as number systems, base conversion, logic functions, and truth tables in digital design. Learn about the different approaches to representing negative numbers and the basics of combinational logic.

mirandac
Download Presentation

Number Systems and Logic Functions in Digital Design

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. Overview • Last lecture: • Abstraction and hierarchy in digital design • Combinational vs. sequential systems • High-level examples of combinational and sequential designs • The whole course in 2 examples! • In section • Number systems • Binary; 2’s complement • Today • Number systems (very quick review) • Combinational logic • Logic functions and truth tables CSE 370 – Winter 2002 - Number syst.; Logic functions- 1

  2. The basics binary numbers • Base conversion (binary, octal, decimal, hexadecimal) • Positional number system • 1012=510 (1 * 22 + 0 * 21+ 1 * 20) • 1478=10310 (1 * 82 + 4 * 81+ 7 * 80) Octal (base 8) • 2C116=70510 (2 * 162 + 12 * 161+ 1 * 160) hexadecimal (base 16) • Do it also for fractions • Conversion between binary/octal/hex • Binary: 10011110001 • Octal: 10 | 011 | 110 | 001=23618 • Hex: 100 | 1111 | 0001=4F116 • Addition and subtraction are trivial, but worth practicing • See Katz, appendix A CSE 370 – Winter 2002 - Number syst.; Logic functions- 2

  3. The basics base conversion • Conversion from decimal to binary/octal/hex: divide by the base • The digits are generated from least significant (rightmost) to most significant (leftmost) • Why does it work (recall positional system) CSE 370 – Winter 2002 - Number syst.; Logic functions- 3

  4. Number systems • How do we write negative binary numbers? • We want same number of positive and negative representations (or as close to same as possible) • How do we represent zero? • How do we recognize easily if a number is positive or negative? • Historically: Three approaches • Sign and magnitude • Ones complement • Twos complement • Twos complement makes addition and subtraction easy • Used almost universally in present-day systems CSE 370 – Winter 2002 - Number syst.; Logic functions- 4

  5. Approach 1: Sign and magnitude • The most-significant bit (msb) is the sign digit • 0  positive • 1 negative • The remaining bits are the number’s magnitude • Problem 1: Two representations for zero • 0 = 0000 and also –0 = 1000 • Problem 2: Arithmetic is cumbersome CSE 370 – Winter 2002 - Number syst.; Logic functions- 5

  6. Approach 2: Ones complement • Negative number: Bitwise complement of positive number • 0011  310 • 1100 –310 • Solves the arithmetic problem • Remaining problem: Two representations for zero • 0 = 0000 and also –0 = 1111 CSE 370 – Winter 2002 - Number syst.; Logic functions- 6

  7. Only one zero! msb is the sign digit 0  positive 1 negative Negative number: Bitwise complement plus one 0011  310 1101 –310 Number wheel Note: one more negative number – 1 0 – 2 + 1 1111 0000 1110 0001 – 3 + 2 1101 0010 – 4 + 3 1100 0011 1011 0100 – 5 + 4 1010 0101 – 6 + 5 1001 0110 1000 0111 – 7 + 6 – 8 + 7 Approach 3: Twos complement CSE 370 – Winter 2002 - Number syst.; Logic functions- 7

  8. Twos complement (con’t) • Complementing a complement restores the original number • Arithmetic is easy • We ignore the carry • Same as a full rotation around the wheel • Subtraction = negation and addition • Easy to implement in hardware CSE 370 – Winter 2002 - Number syst.; Logic functions- 8

  9. – 1 – 1 0 0 – 2 – 2 + 1 + 1 1111 1111 0000 0000 1110 1110 0001 0001 – 3 – 3 + 2 + 2 1101 1101 0010 0010 – 4 – 4 + 3 + 3 1100 1100 0011 0011 1011 1011 0100 0100 – 5 – 5 + 4 + 4 1010 1010 0101 0101 – 6 – 6 + 5 + 5 1001 1001 0110 0110 1000 1000 0111 0111 + 6 + 6 – 7 – 7 – 8 – 8 + 7 + 7 Overflow • Conditions: Sign bit changes • Summing two positive numbers gives a negative result • Summing two negative numbers gives a positive result 6 + 4  –6 –7 – 3  +6 CSE 370 – Winter 2002 - Number syst.; Logic functions- 9

  10. Combinational logic topics • Logic functions, truth tables, and switches • NOT, AND, OR, NAND, NOR, XOR, . . . • minimal set • Axioms and theorems of Boolean algebra • proofs by re-writing • proofs by perfect induction • Gate logic • networks of Boolean functions • time behavior • Canonical forms • two-level • incompletely specified functions • Simplification • Boolean cubes and Karnaugh maps • two-level simplification CSE 370 – Winter 2002 - Number syst.; Logic functions- 10

  11. Logic functions and truth tables X Y 0 0 1 1 • Buffer (identity) X • NOT X X’ • AND X.Y XY • OR X+Y Y X X Y 0 1 1 0 X Y X X Y Z 0 0 0 0 1 0 1 0 0 1 1 1 Z Y X Y Z 0 0 0 0 1 1 1 0 1 1 1 1 X Z Y CSE 370 – Winter 2002 - Number syst.; Logic functions- 11

  12. Logic functions and truth tables (ct’d) X Y Z 0 0 1 0 1 1 1 0 1 1 1 0 X • NAND X.Y XY • NOR X+Y • XOR X  Y Z Y X Y Z 0 0 1 0 1 0 1 0 0 1 1 0 X Z Y X Y Z 0 0 0 0 1 1 1 0 1 1 1 0 X Z Y CSE 370 – Winter 2002 - Number syst.; Logic functions- 12

  13. Possible logic functions of two variables • There are 16 possible functions of 2 input variables: • in general, there are 2**(2**n) functions of n inputs X F Y • X Y 16 possible functions (F0–F15)0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 10 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 • 1 0 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 • 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 X not X Y not Y X xor Y X = Y X and Y X nand Y X or Y X nor Y CSE 370 – Winter 2002 - Number syst.; Logic functions- 13

  14. Cost of different logic functions • Different functions are easier or harder to implement • each has a cost associated with the number of switches (transistors) needed • 0 (F0) and 1 (F15): require 0 switches, directly connect output to low/high • X (F3) and Y (F5): require 0 switches, output is one of inputs • X' (F12) and Y' (F10): require 2 switches for "inverter" or not-gate • X nor Y (F4) and X nand Y (F14): require 4 switches (cf. Katz page 677) • X or Y (F7) and X and Y (F1): require 6 switches • X = Y (F9) and X  Y (F6): require 16 switches • thus, because NOT, NOR, and NAND are the cheapest they are the functions we implement the most in practice CSE 370 – Winter 2002 - Number syst.; Logic functions- 14

  15. Minimal set of functions • All logic functions can be implemented from NOT, AND, and OR • Can we do it with only 2 of the 3? • Can we implement all logic functions from NOT, NOR, and NAND? • For example, implementing X and Yis the same as implementing not (X nand Y) • In fact, we can do it with only NOR or only NAND • NOT is just a NAND or a NOR with both inputs tied together X’ = X nand X X’ = X nor X • NAND and NOR are "duals",that is, it’s easy to implement one using the other X nand Y not ( (not X) nor (not Y) ) X nor Y not ( (not X) nand (not Y) ) CSE 370 – Winter 2002 - Number syst.; Logic functions- 15

  16. From (logic) expressions to gates • More than one way to map expressions to gates • e.g., Z = A' • B' • (C + D) = (A' • (B' • (C + D))) T2 T1 use of 3-input gate A Z A B T1 B Z C C T2 D D CSE 370 – Winter 2002 - Number syst.; Logic functions- 16

  17. What is the optimal gate realization? • We can use the theorems and axioms of Boolean algebra to optimize our designs • Design goals vary depending on the technology. For example: • Reduce the number of inputs? (variables, e.g., A, X and their complements, e.g., A are also called literals) • Reduce number of gates? • Reduce number of levels? • More options (e.g., limited fan-in and fan-out) • How do we explore the trade-offs? • CAD tools • Logic minimization: Reduce number of gates and complexity • Logic optimization: Minimization vs. speed and delay CSE 370 – Winter 2002 - Number syst.; Logic functions- 17

  18. The Mathematics: Boolean algebra • A Boolean algebra is an algebraic structure that consists of • a set of elements B; B = {0, 1} • binary operations { + , • }; + is logical OR, • is logical AND • and a unary operation { ' }; ' is logical NOT • such that the following axioms (laws) hold: 1. the set B contains at least two elements, a, b, such that a  b2. closure: a + b is in B a • b is in B3. commutativity: a + b = b + a a • b = b • a4. associativity: a + (b + c) = (a + b) + c a • (b • c) = (a • b) • c5. identity: a + 0 = a a • 1 = a6. distributivity: a + (b • c) = (a + b) • (a + c) a • (b + c) = (a • b) + (a • c)7. complementarity: a + a' = 1 a • a' = 0 CSE 370 – Winter 2002 - Number syst.; Logic functions- 18

  19. Logic functions and Boolean algebra • Any logic function that can be expressed as a truth table can be written as an expression in Boolean algebra using the operators: ', +, and • X Y X • Y0 0 00 1 01 0 0 1 1 1 X Y X' X' • Y0 0 1 00 1 1 11 0 0 0 1 1 0 0 X Y X' Y' X • Y X' • Y' ( X • Y ) + ( X' • Y' )0 0 1 1 0 1 10 1 1 0 0 0 01 0 0 1 0 0 0 1 1 0 0 1 0 1 ( X • Y ) + ( X' • Y' )  X = Y Boolean expression that is true when the variables X and Y have the same value and false, otherwise X, Y are Boolean algebra variables CSE 370 – Winter 2002 - Number syst.; Logic functions- 19

More Related