ENG2410 Digital Design Introduction to Digital Systems Fall 2017 S. Areibi School of Engineering University of Guelph
Resources Chapter #1, Mano Sections 1.1 Digital Computers 1.2 Number Systems 1.3 Arithmetic Operations 1.4 Decimal Codes 1.5 Alphanumeric Codes 2
Topics Computing Devices and VLSI Design Signals (Digital vs. Analog) Digital Systems and Computers Number systems [binary, octal, hex] Base Conversion Arithmetic Operations Decimal Codes [BCD] Alphanumeric Codes 3
4
Computing Devices Everywhere! Embedded Systems PC PDA Car Game console Home Networking Household Body Super Computer Entertainment Medicine Communication What is the main enabler to such digital systems? 5
The Transistor Revolution First transistor Bell Labs, 1948 Bipolar logic 1960 s Intel 4004 processor Designed in 1971 Almost 3000 transistors Speed:1 MHz operation 6
The VLSI Design Cycle Specification SYSTEM Functional design + MODULE Logic design Circuit design Physical design GATE CIRCUIT Test/Fabrication S n+ G n+ D DEVICE
1.3 VLSI Design Styles Vdd Contact Vdd IN1 IN2 OUT IN1 IN2 OUT Metal layer Poly layer Diffusion layer p-type transistor KLMH GND GND n-type transistor IN1 IN2 OUT Power (Vdd)-Rail Ground (GND)-Rail 8 Lienig
9
Signals An information variable represented by a physical quantity (speech, Temp, humidty, noise, ) 10
Signals Signals can be analog or digital: 1. Analog signals can have an infinite number of values in a range; 2. Digital signals can have only a limited number of values. 11
Analog Signals Time Analog Continuous in value & time 12
Digital Signals For digital systems, the variable takes on discrete values (i.e., not continuous) Time Digital Discrete in value 13
Signal Examples Over Time Digital (Binary) values are represented by: digits 0 and 1 / False (F) and True (T) words (symbols) Low (L) and High (H) words On and Off. Time Asynchronous Digital Synchronous Discrete in value & continuous in time Discrete in value & time 14
Binary Values: Other Physical Quantities What are other physical quantities represent 0 and 1? CPU: Voltage Hard Drive: Magnetic Field Direction Dynamic Ram: Electric Charge CD: Surface Pits/Light 15
A Digital Computer Example Data/Instructions/code All in 01010010010 Memory CPU Control unit Datapath clock Inputs: Keyboard, mouse, modem, microphone Input/Output Outputs: CRT, LCD, modem, speakers 16
17
Number Systems Representation A number with radix r is represented by a string of digits: A n -1 A n -2 A 1 A 0. A -1 A -2 A -m +1 A -m in which 0 A i < rand. is the radix point. The string of digits represents the power series: (Number) r = ( i = n - 1 ) ( j = - 1 ) i j A r i + i = 0 j = - m A (Integer Portion) + (Fraction Portion) j r 18
Decimal Number System Base (also called radix) = 10 10 digits { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 } Digit Position Integer & fraction Formal Notation Digit Weight Weight = (Base) Position Magnitude Sum of Digit x Weight 2 1 0-1 -2 5 1 2 7 4 (512.74) 10 100 10 1 0.1 0.01 500 10 2 0.7 0.04 d 2 *B 2 +d 1 *B 1 +d 0 *B 0 +d -1 *B -1 +d -2 *B -2 19
Octal Number System Base = 8 8 digits { 0, 1, 2, 3, 4, 5, 6, 7 } Weights Weight = (Base) Position Formal Notation Magnitude Sum of Digit x Weight 64 8 1 1/8 1/64 5 1 2 7 4 2 1 0-1 -2 (512.74) 8 5 *8 2 +1 *8 1 +2 *8 0 +7 *8-1 +4 *8-2 =(330.9375) 10 20
Octal Number System: Example For Example, (27) 8 can be expressed as: ( ) 10 (17.1) 8 can be expressed as: ( ) 10 21
Hexadecimal Number System Base = 16 16 digits { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F } Weights Weight = (Base) Position Formal Notation Magnitude Sum of Digit x Weight 256 16 1 1/16 1/256 1 E 5 7 A 2 1 0-1 -2 (1E5.7A) 16 1 *16 2 +14 *16 1 +5 *16 0 +7 *16-1 +10 *16-2 =(485.4765625) 10 22
Hex to Decimal Just multiply each hex digit by decimal value, and add the results. (2ac) 16 2 256 + 10 16 + 12 1 = (684) 10 16 3 16 2 16 1 16 0 4096 256 16 1 Dec Hex 0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 a 11 b 12 c 13 d 14 e 15 f 23
24
Binary Number System Base = 2 2 digits { 0, 1 }, called binary digits or bits Weights Weight = (Base) Position Magnitude Sum of Bit x Weight Formal Notation 4 2 1 1/2 1/4 1 0 1 0 1 2 1 0-1 -2 1 *2 2 +0 *2 1 +1 *2 0 +0 *2-1 +1 *2-2 =(5.25) 10 (101.01) 2 Groups of bits 4 bits = Nibble 8 bits = Byte 1 0 1 1 1 1 0 0 0 1 0 1 25
Binary Decimal: Example 7 6 5 4 3 2 1 0 2 7 2 6 2 5 2 4 2 3 2 2 2 1 2 0 position value 128 64 32 16 8 4 2 1 What is 10011100 in decimal? 7 6 5 4 3 2 1 0 position 1 0 0 1 1 1 0 0 Binary # 128 + 0 + 0 + 16 + 8 + 4 + 0 + 0 = (156) 10 26
Binary Numbers Examples: (00) 2 (0) 10 (01) 2 (1) 10 (0000001) 2 (1) 10 (10) 2 (2) 10 (010) 2 (2) 10 (11) 2 (3) 10 (100) 2 (4) 10 (1001010101000) 2 Strings of binary digits ( bits ) One bitcan store a number from 0 to 1 nbits can store numbers from 0 to 2 n -1 27
Binary Fractions 2 i 2 i-1 4 2 Integer Values 1 b i b i-1... b 2 b 1 b 0 b -1 b -2 b -3 b -j 1/2 Fractional Values 1/4 1/8 2 -j decimal number = 28
Example 1 1 1 0. 1 1 2 1 x 2 2 + 1 x 2 1 + 0x2 0 + 1x2-1 + 1x2-2 6 and 3/4 29
Example 2 0. 1 1 1 1 1 1 2 0 x 2 0 + 1 x 2-1 + 1x2-2 + 1x2-3 + 1x2-4 + 1x2-5 + 1x2-6 63/64 Note: (1) Numbers of the form 0.11111 2 are just below 1.0 (2) Short form notation for such numbers is 1.0 -ε 30
Why Binary? This is easier to implement in hardware than a unit that can take on 10 different values. For instance, it can be represented by a transistor being off (0) or on (1). Alternatively, it can be a magnetic stripe that is magnetized with North in one direction (0) or the opposite (1). Binary also has a convenient and natural association with logical values of: False (0) and True (1). 31
The Power of 2 n 2 n 0 2 0 =1 1 2 1 =2 2 2 2 =4 3 2 3 =8 4 2 4 =16 5 2 5 =32 6 2 6 =64 7 2 7 =128 n 2 n 8 2 8 =256 9 2 9 =512 10 2 10 =1024 11 2 11 =2048 12 2 12 =4096 20 2 20 =1M 30 2 30 =1G 40 2 40 =1T Kilo Mega Giga Tera 32
33
Number Base Conversions Evaluate Magnitude Evaluate Magnitude Octal (Base 8) Decimal (Base 10) Binary (Base 2) Evaluate Magnitude Hexadecimal (Base 16) 34
Conversion Between Bases To convert from one base to another: 1) Convert the Integer Part 2) Convert the Fraction Part 3) Join the two results with a radix point 35
Decimal to Binary Conversion
Decimal (Integer) to Binary Conversion Divide the number by the Base (=2) Take the remainder (either 0 or 1) as a coefficient Take the quotient and repeat the division Example: (13) 10 Quotient Remainder Coefficient 13/ 2 = 6 1 a 0 = 1 6 / 2 = 3 0 a 1 = 0 3 / 2 = 1 1 1 / 2 = 0 1 a 2 = 1 a 3 = 1 Answer: (13) 10 = (a 3 a 2 a 1 a 0 ) 2 = (1101) 2 MSB LSB 37
Decimal (Fraction) to Binary Conversion Multiply the number by the Base (=2) Take the integer (either 0 or 1) as a coefficient Take the resultant fraction and repeat multiplication Example: (0.625) 10 Integer Fraction Coefficient 0.625 * 2 = 1. 25 a -1 = 1 0.25 * 2 = 0. 5 a -2 = 0 0.5 * 2 = 1. 0 a -3 = 1 Answer: (0.625) 10 = (0.a -1 a -2 a -3 ) 2 = (0.101) 2 MSB LSB 38
Decimal to Octal Conversion Example: (175) 10 Quotient Remainder Coefficient 175 / 8 = 21 7 a 0 = 7 21 / 8 = 2 5 a 1 = 5 2 / 8 = 0 2 a 2 = 2 Answer: (175) 10 = (a 2 a 1 a 0 ) 8 = (257) 8 Example: (0.3125) 10 Integer Fraction Coefficient 0.3125 * 8 = 2. 5 a -1 = 2 0.5 * 8 = 4. 0 a -2 = 4 Answer: (0.3125) 10 = (0.a -1 a -2 a -3 ) 8 = (0.24) 8 39
Decimal to Hex (684) 10 684/16 = 42 rem 12=c c 42/16 = 2 rem 10=a ac 2/16 = 0 rem 2 2ac 16 3 16 2 16 1 16 0 4096 256 16 1 Dec Hex 0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 a 11 b 12 c 13 d 14 e 15 f 40
Hexadecimal (Base 16) Strings of 0 s and 1 s too hard to write Use base-16 or hexadecimal 4 bits Dec Bin Hex 0 0000 0 1 0001 1 2 0010 2 3 0011 3 4 0100 4 5 0101 5 6 0110 6 7 0111 7 Dec Bin Hex 8 1000 8 9 1001 9 10 1010 a 11 1011 b 12 1100 c 13 1101 d 14 1110 e 15 1111 f Why use base 16? Power of 2 Size of byte 41
Hex to Binary Convention write 0x (prefix) before number Hex to Binary just convert digits 0x2ac (2ac) 16 0010 1010 1100 0x2ac = (001010101100) 2 No magic remember hex digit = 4 bits Bin Hex 0000 0 0001 1 0010 2 0011 3 0100 4 0101 5 0110 6 0111 7 1000 8 1001 9 1010 a 1011 b 1100 c 1101 d 1110 e 1111 f 42
Binary Hexadecimal Conversion 16 = 2 4 Each group of 4 bits represents a hexadecimal digit Example: Pad with Zeros ( 1 0 1 1 0. 0 1 ) 2 ( 1 6. 4 ) 16 Hex Works both ways (Binary to Hex & Hex to Binary) Binary 0 0 0 0 0 1 0 0 0 1 2 0 0 1 0 3 0 0 1 1 4 0 1 0 0 5 0 1 0 1 6 0 1 1 0 7 0 1 1 1 8 1 0 0 0 9 1 0 0 1 A 1 0 1 0 B 1 0 1 1 C 1 1 0 0 D 1 1 0 1 E 1 1 1 0 F 1 1 1 1 43
Binary to Hex Just convert groups of 4 bits (101001101111011) 2 0101 0011 0111 1011 5 3 7 b (101001101111011) 2 = 0x537b = (537b) 16 Bin Hex 0000 0 0001 1 0010 2 0011 3 0100 4 0101 5 0110 6 0111 7 1000 8 1001 9 1010 a 1011 b 1100 c 1101 d 1110 e 1111 f 44
Octal Hexadecimal Conversion Convert to Binary as an intermediate step Example: ( 2 6. 2 ) 8 Assume Zeros Assume Zeros ( 0 1 0 1 1 0. 0 1 0 ) 2 ( 1 6. 4 ) 16 Works both ways (Octal to Hex & Hex to Octal) 45
46
Addition Decimal Addition + 1 1 Carry 5 5 5 5 1 1 0 = Ten Base Subtract a Base 47
Adding bits: 0 + 0 = 0 0 + 1 = 1 Binary Addition 1 + 0 = 1 1 + 1 = (1) 0 1 + 1 + 1 = (1) 1 carry carry Adding integers: 1 1 0 0 0 0...... 0 1 1 (1) 2 = (7) 10 + 0 0 0...... 0 1 1 (0) 2 = (6) 10 = 0 0 0..... 1 (1)1 (1)0 (0) (1) 2 = (13) 10 48
Binary Addition Column Addition 1 1 1 1 1 1 1 1 1 1 0 1 = (61) 10 + 1 0 1 1 1 = (23) 10 1 0 1 0 1 0 0 = (84) 10 (2) 10 49
50
Binary Numbers and Binary Coding Flexibility of representation Within constraints below, can assign any binary combination (called a code word) to any data as long as data is uniquely encoded. Information Types Numeric Must represent range of data needed Very desirable to represent data such that simple, straightforward computation for common arithmetic operations permitted Tight relation to binary numbers Non-numeric Greater flexibility since arithmetic operations not applied. Not tied to binary numbers 51
Non-numeric Binary Codes Given n binary digits (called bits), a binary code is a mapping from a set of represented elements to a subset of the 2 n binary numbers. Example: A binary code for the seven colors of the rainbow Code 100 is not used Color Red Orange Yellow Green Blue Indigo Violet Binary Number 000 001 010 011 101 110 111 52
Number of Bits Required Given M elements to be represented by a binary code, the minimum number of bits, n, needed, satisfies the following relationships: 2 n > M >2 (n 1) n = log 2 M where x, is called the ceiling function, i.e the integer greater than or equal to x. 53
Number of Bits Required Given M elements to be represented by a binary code, the minimum number of bits, n, needed, satisfies the following relationships: 2 n n = M > 2 n 1, where log 2 M = ceiling(log2 M ) Example: How many bits are required to represent decimal digits with a binary code? M = 10, hence n = ceiling (log 2 10) = ceiling (3.3219) = 4 Checking: 2 4 = 16 10 > 2 3 = 8 54
Binary Codes Group of n bits Up to 2 n combinations Each combination represents an element of information Binary Coded Decimal (BCD) Each Decimal Digit is represented by 4 bits (0 9) Valid combinations (10 15) Invalid combinations Decimal BCD 0 0 0 0 0 1 0 0 0 1 2 0 0 1 0 3 0 0 1 1 4 0 1 0 0 5 0 1 0 1 6 0 1 1 0 7 0 1 1 1 8 1 0 0 0 9 1 0 0 1 55
Gray Code One bit changes from one code to the next code Different than Binary Decimal Gray 00 0000 01 0001 02 0011 03 0010 04 0110 05 0111 06 0101 07 0100 08 1100 09 1101 10 1111 11 1110 12 1010 13 1011 14 1001 15 1000 Binary 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 56
Binary Representations A bit is the most basic unit of information in a computer. It is a state of on or off in a digital circuit. Sometimes these states are high or low voltage instead of on or off.. A group of four bits is called a nibble(or nybble). Bytes, therefore, consist of two nibbles: a high-order nibble, and a low-order nibble. A byteis a group of eight bits. A byte is the smallest possible addressable (can be found via its location) unit of computer storage. A wordis a contiguous group of bytes. Words can be any number of bits (16, 32, 64 bits are common). 57
Conversion or Coding? Do NOTmix up conversion of a decimal number to a binary number with codinga decimal number with a BINARY CODE. (13) 10 = (1101) 2 (This is conversion) (13) BCD (0001 0011) BCD (This is coding) Advantages/Disadvantages? 58
BCD: Advantages/Disadvantages Disadvantage: It is obvious that a BCD number needs more bitsthan its equivalent binary value (26) 10 = (11010) 2 (26) 10 = (0010 0110) BCD Advantages: Computer input/output data are handled by people who use the decimal system. So it is easier to convert back/forth to BCD. 59
60
Character Codes From numbers to letters ASCII Stands for American Standard Code for Information Interchange Only 7 bits defined Unicode 61
ASCII Code American Standard Code for Information Interchange Info 7-bit Code A 1000001 B 1000010.. Z 1011010 a 1100001 b 1100010.. z 1111010 @ 1000000? 0111111 + 0101011 62
ASCII table 63
Reading Read Chapter 1 Make sure you re comfortable with material Check the lecture notes from the Web site. Solve the assignment. 64
Homework See Assignment #1 On Web I expect you to know number systems well and be able to do conversions and arithmetic Decimal Binary Binary Decimal Decimal Hex Hex Decimal Will be on test! 65
66