Introduction to Digital Logic Missouri S&T University CPE 2210 Number Systems Egemen K. Çetinkaya Egemen K. Çetinkaya Department of Electrical & Computer Engineering Missouri University of Science and Technology cetinkayae@mst.edu http://web.mst.edu/~cetinkayae/teaching/cpe2210spring2018 22 January 2018 rev. 18.0 2014 2018 Egemen K. Çetinkaya
Number Systems Outline Signals and representations Number systems Summary 22 January 2018 MST CPE2210 Number Systems 2
value Egemen K. Çetinkaya Digital vs. Analog Analog Signal Signal: physical phenomenon has unique value at every instant of time Analog signal (aka continuous signal) Infinite set of possible values Examples: temperature: 72.16 F degrees human speech pressure light time Possible values: 1.00, 1.01, 2.0000009,... infinite possibilities 22 January 2018 MST CPE2210 Number Systems 3
value Egemen K. Çetinkaya Digital vs. Analog Digital Signal Signal: physical phenomenon has unique value at every instant of time Digital signal (aka discrete signal) Finite set of possible values Examples: pressing a button on keypad switch on/off 4 3 2 1 0 time Possible values: 0, 1, 2, 3, or 4. That s it. 22 January 2018 MST CPE2210 Number Systems 4
value Egemen K. Çetinkaya Digital Systems Representations Digital signals represented by two values on/off, 0/1 Two-value representation: binary representation A single value is called bit (binary digit) Digital system: take digital inputs generates digital outputs Digital circuits: connection of digital components Embedded systems: for a particular purpose 1 0 time 22 January 2018 MST CPE2210 Number Systems 5
Why binary system? Digital Systems Representations 22 January 2018 MST CPE2210 Number Systems 6
Why binary system? Digital Systems Representations Ease of operation compared to 3 digits or more ease of storage, computing, transmission Transistors operate on two-value logic transistor is a basic electrical circuit component 22 January 2018 MST CPE2210 Number Systems 7
Digital-Analog Conversion ADC (A2D) and DAC (D2A) Egemen K. Çetinkaya 22 January 2018 MST CPE2210 Number Systems 8
Digital vs. Analog Pros and Cons What are the pros and cons of analog vs. digital? 22 January 2018 MST CPE2210 Number Systems 9
Digital vs. Analog Pros and Cons What are the pros and cons of analog vs. digital? Analog signal is prone to noise amplified during transmission, storage, processing Digitized analog signal is never exact due to sampling Digital signal can be compressed repetitive patterns can be encoded in other way 00000000 00 22 January 2018 MST CPE2210 Number Systems 10
Number Systems Overview Type Natural numbers N Explanation {0, 1, 2, } Integers Z {, -2, -1, 0, 1, 2, } Rational numbers Q m/n where m and n are integers and n 0: e.g. 5/4, -8/3 Irrational numbers J Any real number that can t be expressed as ratio of integers e.g.: π, e, 2 Real numbers R Rational & irrational numbers, +, 0, or Complex numbers C a+bi, where i 2 = 1 and a and b are real numbers 22 January 2018 MST CPE2210 Number Systems 11
Number Systems Representation Type Explanation positive x > 0 negative x < 0 non-negative x 0 non-positive x 0 signed (in computing) represents both negative and positive numbers unsigned (in computing) represents only non-negative numbers 22 January 2018 MST CPE2210 Number Systems 12
Number Systems Representations Important bases throughout the class: Decimal (base 10) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] Binary (base 2) [0, 1] Octal (base 8) [0, 1, 2, 3, 4, 5, 6, 7] Hexadecimal (base 16) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F] For the number 3205, what is the minimum base? 22 January 2018 MST CPE2210 Number Systems 13
Number Systems Floating Point vs. Fixed Point Representation Floating point approximates real number 2015.82814 = + 2.01582814 x 10 3 exponent sign mantissa (significand) base IEEE 754 standard is followed Fixed point: radix is fixed at a point less costly to represent compared to floating point Other real number representations: binary-coded decimal (BCD) logarithmic number systems 22 January 2018 MST CPE2210 Number Systems 14
Number Systems Decimal Representation position 3 2 1 0-1 -2 weight b 3 b 2 b 1 b 0 b -1 b -2 digit a 3 a 2 a 1 a 0 a -1 a -2 decimal example weight 10 3 10 2 10 1 10 0 10-1 10-2 decimal example digit 2 0 1 8 0 1 whole part fractional part radix (decimal) point 22 January 2018 MST CPE2210 Number Systems 15
Number Systems Binary Representation position 3 2 1 0-1 -2 weight b 3 b 2 b 1 b 0 b -1 b -2 digit a 3 a 2 a 1 a 0 a -1 a -2 binary example weight 2 3 2 2 2 1 2 0 2-1 2-2 binary example digit 1 0 1 1 1 0 binary point 22 January 2018 MST CPE2210 Number Systems 16
Number Systems Octal Representation position 3 2 1 0-1 -2 weight b 3 b 2 b 1 b 0 b -1 b -2 digit a 3 a 2 a 1 a 0 a -1 a -2 octal example weight 8 3 8 2 8 1 8 0 8-1 8-2 octal example digit 1 7 5 3 6 2 22 January 2018 MST CPE2210 Number Systems 17
Number Systems Hexadecimal Representation position 3 2 1 0-1 -2 weight b 3 b 2 b 1 b 0 b -1 b -2 digit a 3 a 2 a 1 a 0 a -1 a -2 hex example weight 16 3 16 2 16 1 16 0 16-1 16-2 hex example digit 2 0 A F 0 0 22 January 2018 MST CPE2210 Number Systems 18
Binary Systems Powers of Two 2 0 = 2 1 = 2 2 = 2 3 = 2 4 = 2 5 = 2 6 = 2 7 = 2 8 = 2 9 = 2 10 = 22 January 2018 MST CPE2210 Number Systems 19
Binary Systems Powers of Two 2 0 = 1 2 1 = 2 2 2 = 4 2 3 = 8 2 4 = 16 2 5 = 32 2 6 = 64 2 7 = 128 2 8 = 256 2 9 = 512 2 10 = 1024 22 January 2018 MST CPE2210 Number Systems 20
Number System Conversion Binary to Decimal binary 1 binary weight 2 0 multiply weights and add decimal 1 binary 1 0 binary weight 2 1 2 0 decimal 2 + 0 = 2 binary 1 0 1 binary weight 2 2 2 1 2 0 decimal 4 + 0 + 1 = 5 Egemen K. Çetinkaya 22 January 2018 MST CPE2210 Number Systems 21
Number System Conversion Binary to Decimal Egemen K. Çetinkaya binary 0 1 1 binary weight 2 2 2 1 2 0 decimal 0 + 2 + 1 = 3 binary 1 0 1. 1 binary weight 2 2 2 1 2 0 2-1 decimal 4 + 0 + 1 + 0.5 = 5.5 22 January 2018 MST CPE2210 Number Systems 22
Number System Conversion Decimal to Binary Egemen K. Çetinkaya Desired decimal number: 12 Current sum Binary number (a) 16 > 12, too big; Put 0 in 16 s place 0 0 16 8 4 2 1 (b) 8 <= 12, so put 1 in 8 s place, current sum is 8 8 0 1 16 8 4 2 1 (c) 8+4=12 <= 12, so put 1 in 4 s place, current sum is 12 12 0 1 1 16 8 4 2 1 a (d) Reached desired 12, so put 0s in remaining places done 0 1 1 0 0 16 8 4 2 1 22 January 2018 MST CPE2210 Number Systems 23
Number Systems Base 16 System hex binary hex binary 0 8 1 9 2 A 3 B 4 C 5 D 6 E 7 F 22 January 2018 MST CPE2210 Number Systems 24
Number Systems Base 16 System hex binary 0 0000 1 0001 2 0010 3 0011 4 0100 5 0101 6 0110 7 0111 hex binary 8 1000 9 1001 A 1010 B 1011 C 1100 D 1101 E 1110 F 1111 22 January 2018 MST CPE2210 Number Systems 25
Number System Conversion Hex to Binary Examples Egemen K. Çetinkaya 22 January 2018 MST CPE2210 Number Systems 26
Number System Conversion Binary to Hex Examples Egemen K. Çetinkaya 22 January 2018 MST CPE2210 Number Systems 27
Number System Conversion Hex to Decimal Examples Egemen K. Çetinkaya 22 January 2018 MST CPE2210 Number Systems 28
Number System Conversion Decimal to Hex Examples Egemen K. Çetinkaya 22 January 2018 MST CPE2210 Number Systems 29
LSB: Least Significant Bit right-most bit MSB: Most Significant Bit higher-order bit left-most bit Number Systems Representations Example: where is LSB and MSB? 1 0 1 0 1 1 0 1 22 January 2018 MST CPE2210 Number Systems 30
LSB: Least Significant Bit right-most bit MSB: Most Significant Bit higher-order bit left-most bit Example: LSB MSB Number Systems Representations 1 0 1 0 1 1 0 1 22 January 2018 MST CPE2210 Number Systems 31
bit: binary digit (b) Byte: 8-bits (B) nibble: 4-bits Number Systems Representations 1 0 1 0 1 1 0 1 high nibble low nibble 22 January 2018 MST CPE2210 Number Systems 32
Performance Metrics Unit Multipliers SI decimal 10 1 deci d 10 1 deka da 10 2 centi c 10 2 hecto h EIC binary 10 3 milli m 10 3 kilo k 2 10 kibi Ki 10 6 micro 10 6 Mega M 2 20 mebi Mi 10 9 nano n 10 9 Giga G 2 30 gibi Gi 10 12 pico p 10 12 Tera T 2 40 tebi Ti 10 15 femto f 10 15 Peta P 2 50 pebi Pi 10 18 atto a 10 18 Exa E 2 60 exbi Ei 10 21 zepto z 10 21 Zetta Z 10 24 yocto y 10 24 Yotta Y Egemen K. Çetinkaya 22 January 2018 MST CPE2210 Number Systems 33
Signals can be: analog: continuous digital: discrete Important terminology: bit, byte, nibble, LSB, MSB Number Systems Summary Important number systems: decimal, binary, hex, octal Conversions will be needed throughout your careers: know 2 0-2 10 by heart 22 January 2018 MST CPE2210 Number Systems 34
References and Further Reading [V2011] Frank Vahid, Digital Design with RTL Design, VHDL, and Verilog, 2nd edition, Wiley, 2011. [S2017] John Seiffertt, Digital Logic for Computing, 1st edition, Springer, 2017. 22 January 2018 MST CPE2210 Number Systems 35
End of Foils 22 January 2018 MST CPE2210 Number Systems 36