Download as pdf or txt
Download as pdf or txt
You are on page 1of 20

9/4/2019

Digital Electronics
- Part I: Digital Principle -

Dr. Lê Dũng
Department of Electronics and Computer Engineering (C9-406 407)
School of Electronics and Telecommunications
Hanoi University of Science and Technology
Email: dung.le@hust.edu.vn

Mobile: 0904982398 (ledung1974@gmail.com)

Bách Khoa 2019

Part I: Digital Principles - Overview


Information Digitalization

Logic Clause Logic Level


Boolean True 1 High Electronic circuits
Functions False 0 Low
(Transistor BJT, Diode,
Resister, MOS...) Open-Collector
(Boolean Algebra) Implementation Output
&
Tristate Output

Basic Logic Gates


Inverter,AND,OR,NAND,NOR,XOR,XNOR Digital
Integrated
Analysis & Circuits
Synthesis Logic Circuits
- Custom design Combinational Sequential Logic Families Specifications:
- Standard cell
design
Logic Circuits Logic Circuits RTL, DTL, HTL - Current & Voltages
TTL, CMOS - Fan-in, Fan-out
- Gate array PMOS, NMOS, - Propagation Delay
- PLA, PLD, FPGA BiMOS, ECL, - Noise Margin
- FSMD design - Power Dissipation
Digital System - Speed Power Product
- VHDL

Dr. Le Dung - School of Electronics and Telecommunications Page 2

1
9/4/2019

Part I: Digital Principles - Contents

Chapter 1 : Binary system and Binary Codes

Chapter 2 : Boolean Algebra

Chapter 3 : Logic Gates and Digital Integrated Circuits

Dr. Le Dung - School of Electronics and Telecommunications Page 3

Chapter 1
Binary system and Binary Codes
1.1 Binary System
1.2 Binary Arithmetic
1.3 Sign Number Representation
1.4 Real Number Code
1.5 Binary Coded Decimal (BCD)
1.6 Character Code
1.7 Gray Code
1.8 Error Detection Codes and Error Correction Codes
1.9 Other (Information) Codes

Dr. Le Dung - School of Electronics and Telecommunications Page 4

2
9/4/2019

1.1 Binary System


 Decimal System

+ 10 digits = {0,1,2,3,4,5,6,7,8,9}  radix = 10 (Decimal)

+ A number

D = 1974.2810= 1•103 + 9•102 + 7•101 + 4•100 + 2•10-1 + 8•10-2

r (radix) = 10 and i (weighted position) runs from -2 to 3

Dr. Le Dung - School of Electronics and Telecommunications Page 5

1.1 Binary System


 Number System
+ An ordered set of symbols
+ A number = Positional Notation

n 1
+ Polynomial Notation
(with r- radix and i-weighted position)
N a r
i m
i
i

Dr. Le Dung - School of Electronics and Telecommunications Page 6

3
9/4/2019

1.1 Binary System


 Counting in Decimal System

+ Based on the order {01 23456789}

+ When 9 return 0 at the weighted position (i)


 a change at the weighted position (i+1)

For example: 00  01  02  …  09
10  11  12  …  19
20  21  22  …  29
….………………….. 099  100

Dr. Le Dung - School of Electronics and Telecommunications Page 7

1.1 Binary System


 Binary System
+ Two ordered symbols (2 bits) = {0,1}  radix=2 (Binary)
+ Binary number
B = 1011.1012 = 1•23 + 0•22 + 1•21 + 1•20 + 1•2-1 + 0•2-2 + 1•2-3
= 11.62510
m 1
r (radix) = 2, ai = digit (0  ai  1)
B a 2
i  n
i
i

+ Binary counting {0  1}
{00  01  10  11}
{000  001  ….111}
{0000  0001  …  1111}
Dr. Le Dung - School of Electronics and Telecommunications Page 8

4
9/4/2019

1.1 Binary System


 Why do we use the binary system ?
Because: Two bits {0, 1} can be
represented more easily by:

+ Two positions of an
electrical switch.
+ Two distinct voltage or
current levels allowed by a
circuit.
+ Two distinct levels of light
intensity
+ Two directions of
magnetization or polarization
Calculating machine (Müller 1784)
with decimal system + ….

Dr. Le Dung - School of Electronics and Telecommunications Page 9

1.1 Binary System


 Disadvantage of Binary System ?
- Not easy to read and remember  Hexadecimal system

 Hexadecimal System

+ 16 symbols = {0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F}

+ Hexadecimal Number
2DC.1E16= 2•162 + 13•161 + 12•160 + 1•16-1 + 14•16-2

radix = 16 (Hexadecimal system)  Why ?.

Dr. Le Dung - School of Electronics and Telecommunications Page 10

5
9/4/2019

1.1 Binary System


 Base Conversions
 Convert to base 10
 use the polynomial notation with
radix and weighted positions

 Convert to base 2
 use radix divide method for the
integer part (remainders and quotient)
 use radix multiply method for the
fraction part.

 Convert between base 2 and 16


 4 bits  1 hexadecimal digit

Dr. Le Dung - School of Electronics and Telecommunications Page 11

1.2 Binary Arithmetic


 Addition

Binary addition table Add two binary numbers

1 + 1 = 0 carry 1 = 102

Dr. Le Dung - School of Electronics and Telecommunications Page 12

6
9/4/2019

1.2 Binary Arithmetic


 Subtraction
A (Minuend) 11101
1-1=0-0=0 -
1-0=1 B (Subtrahend) 1111
0 - 1 = 1 borrow 1
borrow 1110

difference 01110

Note: A – B = A + (-B) that means Sub  Add

Dr. Le Dung - School of Electronics and Telecommunications Page 13

1.2 Binary Arithmetic


 Multiplication

Binary multiplication table Multiply two binary numbers

Note: - Multiplication by repeated Add & Shift


- Can be implemented in a faster way

Dr. Le Dung - School of Electronics and Telecommunications Page 14

7
9/4/2019

1.2 Binary Arithmetic


 Division
Divisor 10111010 1110 Dividend
1/1=1 -
1110
0/0=0=0/1 1101 Quotient
1001010
1 / 0 = undefined -
1110
10010
0000
10010
-
1110
100 Remainder

Note: - Division by repeated Sub & Shift

Dr. Le Dung - School of Electronics and Telecommunications Page 15

1.3 Sign Number Representation


 Sign Number Format
MSB

N= S Representing the magnitude

= 0  positive +
Sign
= 1  negative -

 Representing the magnitude


 Sign magnitude representation
 Two’s complement system

Dr. Le Dung - School of Electronics and Telecommunications Page 16

8
9/4/2019

1.3 Sign Number Representation


 Sign-Magnitude representation
MSB
N - integer with n bits lies
N= S Magnitude = absolute value of N
between -(2n-1-1) and +(2n-1-1)

1010 - 2
+
1100 - 4
Carry 10000
0110 +6  error

0011 +3
+
1011 -3
Carry 0110
1110 -6  error

Dr. Le Dung - School of Electronics and Telecommunications Page 17

1.3 Sign Number Representation


 Sign-Magnitude Numbers Addition and Subtraction
 Sign-magnitude representation leads
to slow, expensive adder/subtractor
due to repeated comparison and test
of sign and magnitude

 This is why we represent numbers


mostly using two’s complement
system

Dr. Le Dung - School of Electronics and Telecommunications Page 18

9
9/4/2019

1.3 Sign Number Representation


 Two’s Complement System
Radix-complement D* of a number D with n digits is
D* = rn – D  D* + D = rn

Eg. The 2-complement of D = 00112 is


D* = 24 - 3 = 13 = 11012
0011 +3
+
1101 (+3)2-complement represents (-3)
Carry 11110
0000 0 Ok

Two’s Complement Calculation ?

Dr. Le Dung - School of Electronics and Telecommunications Page 19

1.3 Sign Number Representation


 Two’s Complement System
Two’s Complement Calculation:
Algorithm 1: Complement bits then add 1

Algorithm 2: Copy from LSB to the first 1-bit then


continue replace the bits with their complement until the
MSB has been replaced

Dr. Le Dung - School of Electronics and Telecommunications Page 20

10
9/4/2019

1.3 Sign Number Representation


 Two’s Complement System
MSB

+N = 0 Magnitude = absolute value of N

2-complement calculation

-N = 1

N - integer with n bits lies


between -(2n-1-1) and +(2n-1-1)

Dr. Le Dung - School of Electronics and Telecommunications Page 21

1.3 Sign Number Representation


 Add and Sub in Two’s Complement System
0010 +2 0010 +2 1110 - 2
Addition 0100 +4 1100 - 4 1100 - 4
+ 00000 + 00000 + 11000
0110 +6 1110 - 2 1010 - 6

Subtraction 0010 +2 0010 +2 1110 - 2


A+(B)’+1 1011 (+4)’ 0011 (- 4)’ 0011 (- 4)’
+ 00111 + 00111 + 11111
1110 - 2 0110 +6 0010 +2

0111 +7 1001 - 7
Overflow 0110 +6 1010 - 6
+ 01100 + 10000
1101 - 3 0011 +3

Dr. Le Dung - School of Electronics and Telecommunications Page 22

11
9/4/2019

1.3 Sign Number Representation


 Summary of Two’s Complement Addition and Subtraction

Dr. Le Dung - School of Electronics and Telecommunications Page 23

1.4 Real Number Code


 Coding the position of the radix point
 Fixed-point

 Floating-point
Scientific notation

Dr. Le Dung - School of Electronics and Telecommunications Page 24

12
9/4/2019

1.4 Real Number Code


 Computer floating-point number

Dr. Le Dung - School of Electronics and Telecommunications Page 25

1.5 Binary Coded Decimal (BCD)


 Coding 10 decimal digits by 4 bits DCBA

DCBA

Problem : Add two BCD codes ?

Dr. Le Dung - School of Electronics and Telecommunications Page 26

13
9/4/2019

1.6 Character Codes


 American Standard Code for Information Interchange
(ASCII 7-bit code)

 Unicode

Dr. Le Dung - School of Electronics and Telecommunications Page 27

1.7 Gray Code

00  01  11  10
10  11  01  00

 Two consecutive number differ


in only 1 bit (distance = 1)

Why do we use the gray code ?.

Dr. Le Dung - School of Electronics and Telecommunications Page 28

14
9/4/2019

1.8 Error Detection Code


Error Correction Code

 Error ?

 Error Control: Error Detection and Error Correction

 Parity Code

 Hamming Code

 Cyclic Redundancy Code (CRC-16, CRC-32)

Dr. Le Dung - School of Electronics and Telecommunications Page 29

1.8 Error Detection Code


Error Correction Code
 Error Control: Error Detection and Error Correction

Dr. Le Dung - School of Electronics and Telecommunications Page 30

15
9/4/2019

1.8 Error Detection Code


Error Correction Code
 Parity Code:

Dr. Le Dung - School of Electronics and Telecommunications Page 31

1.8 Error Detection Code


Error Correction Code
 Parity Code for Error Detection:

Dr. Le Dung - School of Electronics and Telecommunications Page 32

16
9/4/2019

1.8 Error Detection Code


Error Correction Code
 Hamming Code: Error Correction

Example:

Dr. Le Dung - School of Electronics and Telecommunications Page 33

1.8 Error Detection Code


Error Correction Code
 Cyclic Redundancy Code : (CRC)

Dr. Le Dung - School of Electronics and Telecommunications Page 34

17
9/4/2019

1.8 Error Detection Code


Error Correction Code
 CRC for Error Dectection in Computer Network

CRC32

CRC16

Dr. Le Dung - School of Electronics and Telecommunications Page 35

1.9 Other Code

 Voice Encoding (Pulse Code Modulation)

 Image and Video Encoding (Pixels, Frames)

 Other information Encoding (ADC, DAC)

Dr. Le Dung - School of Electronics and Telecommunications Page 36

18
9/4/2019

1.9 Other Code


 Voice Encoding (Pulse Code Modulation)

Dr. Le Dung - School of Electronics and Telecommunications Page 37

1.9 Other Code


 Image Encoding (Raster Image  Pixels)

Pixels

Dr. Le Dung - School of Electronics and Telecommunications Page 38

19
9/4/2019

1.9 Other Code


 Video Encoding (Frames)

Frames Frames

Frames

Dr. Le Dung - School of Electronics and Telecommunications Page 39

1.9 Other Code


 ADC – Analog to Digital Converter

Dr. Le Dung - School of Electronics and Telecommunications Page 40

20

You might also like