Chapter 01 Lec 01

Preview:

Citation preview

DLF DLF

Digital Logic Fundamentals Digital Logic Fundamentals

Theory (3 credit hr)– Capt Mariam KayaniTheory (3 credit hr)– Capt Mariam Kayani

Practicle (1 credit hr) – Ms Amin AkifPracticle (1 credit hr) – Ms Amin Akif

1

Instructor• Instructor: Capt Mariam Kayani

• mariam.signals@gmail.com

• Telephone :119 ext 33246

• Office Hours:

2

Course Resources

• Digital Design (3rd/4th Edition)

By Morris Mano

• Topics from different sources will be indicated during the semester

3

RULES

• Submit your assignments to class senior before

start of class on due date

• No Late submissions. (No exceptions!)

• Assignments with too much similarity will be

penalized appropriately

• If u miss a quiz/Exam College SOP will be

followed 4

Objective of Course

• Introduction to concepts of digital logic, gates, and the digital circuits

• Design and analysis of combinational circuits• Design and analysis of sequential circuits

5

Lecture - 01

April 9, 2023April 9, 2023

6

Digital Systems• Digital System play a prominent role in this digital age

– Communication, medical treatment, internet, DVD, CD, etc…

• Digital Computer follow a sequence of instructions, called programs, that operate on given data– User can specify and change program or data according to needs

• Like Digital Computers, most digital devices are programmable

• Digital Systems have the ability to Manipulate discrete elements of information.– Any set that is restricted to a finite number of elements contains

discrete information• 10 Decimal digits• 26 Alphabet letters• 52 Playing cards• 64 squares of a chessboard

7

Digital Systems• Digital Systems can do hundreds of millions of

operations per second• Extreme reliability due to error-correcting codes• A Digital System is interconnection of digital

modules• To understand Digital module, we need to know

about digital circuits and their logical functions• Hardware Description Language (HDL) is a

programming language that is suitable for describing digital circuit in a textual form– Simulate a digital system to verify operation

before it is built 8

Decimal Number

• 7,392= 7x103 + 3x102 + 9x101 + 2x100

– Thousands, hundreds, etc…power of 10 implied by position of coefficient

• Generally a decimal number is represented by a series of coefficients– a6 a5 a4 a3 a2 a1 a0 (.) a-1 a-2 a-3 a-4

• aj cofficient are any of the 10 digit (0,1,2…9)

• Decimal numbers are base 10.9

Binary Number

• Digital Systems manipulate discrete quantities of information in binary form

• Strings of binary digits (“bits”)

• Two possible values 0 and 1

10

Binary Numbers• Each digit represents a power of 2• Coefficient have two possible values 0 and 1• Strings of binary digits (“bits”)

–n bits can store numbers from 0 to 2n -1–n bits can store 2n distinct combinations of 1’s

and 0’s

• Each coefficient aj is multiplied by 2j

• So 101 binary is 1 x 22 + 0 x 21 + 1 x 20

or 1 x 4 + 0 x 2 + 1 x 1 = 5 11

BITs & Bytes• A bit (short for binary digit) is the smallest unit

of data in a computer. – A bit can hold only one of two values: 0 or 1,

corresponding to the electrical values of off or on, respectively.

– Because bits are so small, you rarely work with information one bit at a time

– A byte is a unit of measure for digital information.

– A single byte contains eight consecutive bits

12

Special Powers of 2

210 (1024) is Kilo, denoted "K"

220 (1,048,576) is Mega, denoted "M"

230 (1,073, 741,824)is Giga, denoted "G"

240 (1,099,511,627,776 ) is Tera, denoted “T"

13

Octal• Octal is base 8• A number is represented by a series of

coefficients

– a6 a5 a4 a3 a2 a1 a0. a-1 a-2 a-3 a-4

• aj cofficient are any of 8 digit (0,1,2…7)

• Need 3 bits for representation• Example:

(127.4)8= 1 X 82 +2 X 81 +7 X 80 +

4 X 8-1

64+16+7+.5= (87.5)10

Dec Bin Octal

0 000 0

1 001 1

2 010 2

3 011 3

4 100 4

5 101 5

6 110 6

7 111 7

14

Hexadecimal• Hexadecimal is base 16• A number is represented by a series

of coefficients– a6 a5 a4 a3 a2 a1 a0. a-1 a-2 a-3 a-4

• aj cofficient are any of 16 digit (0,1,2,3,4,5,

6,7,8, 9,A,B,C,D,E,F)• Need 4 bits for representation• (B65F)16

11 X 163 +6 X 162 + 5 X 161 +15 X 160

= 11x4096 + 6x256 +5x16 +15= 45056 + 1536 + 80 +15 = 46,687

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

8 1000 8

9 1001 9

10 1010 A

11 1011 B

12 1100 C

13 1101 D

14 1110 E

15 1111 F

15

Number-base Conversion

• A number in one base (10,2,8, 16) can be converted into its equivalent in another base.

16

Converting Binary to Decimal

• The conversion of a num in base r to decimal is done by expanding the num in a power series and adding all the terms

• Multiply digit by power of 2.

7 6 5 4 3 2 1 0

27 26 25 24 23 22 21 20

128 64 32 16 8 4 2 1

17

Example

1 0 0 1 1 1 0 0

128+ 0 + 0 + 16 + 8 + 4 + 0 + 0 = 156128+ 0 + 0 + 16 + 8 + 4 + 0 + 0 = 156

•Since a 0 bit does not contribute anything in the Since a 0 bit does not contribute anything in the sum, therefore a binary no. can be converted to sum, therefore a binary no. can be converted to decimal by adding only the 1 bits. decimal by adding only the 1 bits.

What is 10011100 in decimal?What is 10011100 in decimal?

27 26 25 24 23 22 21 20

18

Converting Decimal to Binary

• Example 41• 41 divided by 2, giving quotient of 20 and reminder 1 a0• 20/2 , giving quotient of 10 and reminder 0 a1• 10/2 , giving quotient of 5 and reminder 0 a2• 5/2 , giving quotient of 2 and reminder 1 a3• 2/2 , giving quotient of 1 and reminder 0 a4• ½ , giving quotient of 0 and reminder 1 a5

Therefore, the answer is (41)10= (a5a4a3a2a1a0)=(101001)2

19

Number With Radix Point

• If the number includes a radix point, it is necessary to separate the number into an integer part and a fraction part.

• The conversion of a fractional part in base r is done by multiplying the number and all successive integers are accumulated instead of reminders.

20

Example

• (0.6875)10

integer fractioncoefficient

• 0.6875 * 2 = 1 + 0.3750 a-1 = 1• 0.3750 * 2 = 0 + 0.7500 a-2=0• 0.7500 * 2 = 1 + 0.500 a-3=1• 0.5000 * 2 = 1 + 0.000 a-4=1

(0.1011)2

21

Octal Decimal

• Convert (231)8 to decimal

82 81 80

153

2 3 1

Decimal Octal

• Convert decimal 153 to Octal

• 153 divided by 8, giving quotient of 19 , reminder 1 a0• 19/8 , giving quotient of 2 and reminder 3 a1• 10/8 , giving quotient of 0 and reminder 2 a2

153 = (231)8

23

Decimal Octal (Fraction)• Convert decimal 0.513 to Octal

Integer Fraction Coefficient

0.513 X 8 = 4 + 0.104 a-1=4

0.104 X 8 = 0 + 0.832 a-2=0

0.832 X 8 = 6 + 0.656 a-3=6

0.656 X 8 = 5 + 0.248 a-4=5

0.248 X 8 = 1 + 0.984 a-5=1

0.984 X 8 = 7 + 0.872 a-6=7

(0.513)10= (0.406517)8

24

Hex Decimal

• Just multiply each hex digit by decimal value, and add the results.

4096163

116256160161162

0x2AC0x2AC

2 2 x 256x 256 + 10 + 10 x 16x 16 + 12 + 12 x 1x 1 = 684= 684

15

14

13

12

11

10

9

8

7

6

5

4

3

2

1

0

Dec

F

E

D

C

B

A

9

8

7

6

5

4

3

2

1

0

Hex

25

Decimal Hex

(684)10

684 divided by 16, giving quotient of 42 , reminder 12 a042/16 , giving quotient of 2 and reminder 10 a110/16 , giving quotient of 0 and reminder 2

2AC

26

Binary to Octal

• Partition Binary number into group of three digits each

• The corresponding octal digit is then assigned to each group

• (10 110 001 101 011 . 111 100 000 110)2

• (10 110 001 101 011 . 111 100 000 100)2 = (26153.7406)8

27

Octal to Binary

• Each Octal digit is converted to its three digit binary equivalent

• (26153.7406)8 = (010 110 001 101 011 . 111 100 000 110)2

28

Hex to Binary

• Convention – write 0x before number• Hex to Binary – just convert digits

2ac2ac

00100010 10101010 11001100

0x2ac = 0010101011000x2ac = 001010101100

No magic – remember hex digit = 4 bitsNo magic – remember hex digit = 4 bits29

Binary to Hex

• Just convert groups of 4 bits

101001101111011101001101111011

10111011

55 33 77 bb

101001101111011 = 537B101001101111011 = 537B

0101 0101 0111 0111 0011 0011

30

Arithmetic -- addition

• Binary similar to decimal arithmetic

+ 10001

00110

10111

No carries 001101

+ 11101

01101

1 10110

Carries

1+1 is 2 (or 102), which results in a carry

3131

32

Arithmetic -- subtraction

- 01001

01101

00100

No borrows 01100

- 11001

01111

11010

Borrows

0 - 1 results in a borrowBorrow makes it (10)2 =(2) 10

33

Arithmetic -- multiplication

1101

1 110

0000

1 11101

Successive additions of multiplicand or zero,multiplied by 2 (102).

Note that multiplication by 102 just shifts bits left.

1101

101 X

34

Complements

• Simply Subtraction

(Subtraction by addition)– R’s Complement

• In Binary 2’s complement• In Decimal 10’s complement

– (R-1) Complement• In Binary 1’s complement• In Decimal 9’s Complement

35

Diminished Radix Complement

• Given a number N in base r having n digits, it is (rn -1 )-N• Decimal: (10n -1 )-N

– If n=6 then 106-1=1000000-1=999999– 9’s complement of 546700 is 999999-546700=453299– In simple words subtract each digit from 9

• Binary: (2n -1 )-N– If n=4 then 24= (16)10= (10000)2

– 24 – 1 = (15)10= (1111)2

– Note: 1-0=1 and 1-1 =0 (Bit Changes)– In simple words just change the bits

36

Radix Complement• Given a number N in base r having n

digits, it is (rn –N)• Simply add one to the radix-1 complement

(rn –N) = [(rn -1 )-N] +1

• Decimal: – 2389 7610+1=7611

• Binary: (2n -1 )-N– 101100010011+1=010100

37

Subtraction with r-Complement• M-N• Add the minuend, M to r’s complement

of Subtrahend, N– M+ (rn -N)= M-N+ rn

• If M GTE N then sum will produce end carry rn. Ignore it

• If M LT N (No Carry) then take r’s complement of answer (Negative)

38

Subtraction with r’s Complement

• Using 10’s complement subtract 72532-03250

• Using 10’s complement subtract 03250 -72532

• Using 2’s complement subtract 1010100 -1000011

• Using 2’s complement subtract 1000011- 1010100

39

Subtraction with r-1 Complement

• Similar to r’s complement• But since r-1 complement is 1 less than r complement,

Carry is added back to get the result• If no carry, result is negative1’s complement to get the

answer– 1010100-1000011– 1000000-1010100

40

Signed Binary Numbers• Need notation for negative values• Everything must be represented by binary

digits• Signed magnitude convention

– Left most bit can be used • 0 Positive• 1 Negative• 01001 is +9 and 11001 is -9 (Not 25. Convention known in

advance)

• Signed Complement (Store negative as comps)– Signed 1’s complement (8 bits)11110110 – Signed 2’s complement (8 bits)11110111– Signed Magnitude (8 bits) 10001001

41

42

Complements

• Simply Subtraction (Subtraction by addition)– R’s Complement

• In Binary 2’s complement• In Decimal 10’s complement

– (R-1) Complement• In Binary 1’s complement• In Decimal 9’s Complement

43

Diminished Radix Complement• Given a number N in base r having n

digits, it is (rn -1 )-N• Decimal: (10n -1 )-N

– If n=6 then 106-1=1000000-1=999999– 9’s complement of 546700 is 999999-

546700=453299– In simple words subtract each digit from 9

• Binary: (2n -1 )-N– If n=4 then 24= (16)10= (10000)2

– 24 – 1 = (15)10= (1111)2

– Note: 1-0=1 and 1-1 =0 (Bit Changes)– In simple words just change the bits

44

Radix Complement

• Given a number N in base r having n digits, it is (rn –N)

• Simply add one to the radix-1 complement(rn –N) = [(rn -1 )-N] +1

• Decimal: – 2389 7610+1=7611

• Binary: (2n -1 )-N– 101100010011+1=010100

45

Subtraction with r-Complement• M-N• Add the minuend, M to r’s complement

of Subtrahend, N– M+ (rn -N)= M-N+ rn

• If M GTE N then sum will produce end carry rn. Ignore it

• If M LT N (No Carry) then take r’s complement of answer (Negative)

46

Subtraction with r’s Complement

• Using 10’s complement subtract 72532-03250

• Using 10’s complement subtract 03250 -72532

• Using 2’s complement subtract 1010100 -1000011

• Using 2’s complement subtract 1000011- 1010100

Signed Binary Numbers• Need notation for negative values• Everything must be represented by binary digits• “Signed magnitude convention” is where;

– Left most bit can be used • 0 Positive• 1 Negative• 01001 is +9 and 11001 is -9 (Not 25. Convention

known in advance)

• Signed Complement sys

(Store negative no is rep by its complement)– Signed 1’s complement (8 bits)11110110 – Signed 2’s complement (8 bits)11110111– Signed Magnitude (8 bits) 10001001

47

Arithmetic -- addition

• Binary similar to decimal arithmetic

+ 10001

00110

10111

No carries 001101

+ 11101

01101

1 10110

Carries

1+1 is 2 (or 102), which results in a carry

48

Arithmetic -- subtraction

- 01001

01101

00100

No borrows 01100

- 11001

01111

11010

Borrows

0 - 1 results in a borrowBorrow makes it (10)2 =(2) 10

49

Arithmetic -- multiplication

1101

1 110

0000

1 11101

Successive additions of multiplicand or zero,multiplied by 2 (102).

Note that multiplication by 102 just shifts bits left.

1101

101 X

50

BCD (Binary Coded Decimal)

• Representing the decimal digits by mean of code that contains 1 , 0 i.e. Decimal digits stored in binary

– Four bits/digit (Use 10 instead of 16)– Num with k decimal digit will require 4k bits – BCD is base as its equivalent binary number 0 – 9– Binary combination 1010-111 are not used in BCD– Example 931 is coded as 1001 0011 0001

– Decimal 15 is BCD 0001 0101 in Binary it was 1111

51

BCD Addition• Since each digit is max 9 Sum will always

be less than 19= 9+9+1(carry)• Two BCD digits are added as binary

numbers– When binary sum is more than binary (1001)2,

result is invalid (unlike Hex last 6 were ignored)

• Addition of 6=(0110)2 make a correct BCD and produces a carry– Binary Sum carry and Decimal Carry differ by

16-10=6

• 4+5, 4+8, 8+9• 184+576

52

Decimal Arithmetic• Representation of signed decimal number in BCD is

similar to the rep of signed number in binary– Sign and mag system– Sign complement system

• Designate a plus with 0 and minus with 9• For Addition, add all digits including the sign digit and

discard the carry. This assumes that all –ive no are in 10’s complement form– (+375) + (-240) = +135

• Method for Subtraction is same as binary signed number

53

Binary Codes for Numbers• Binary codes for decimal digits require 4 bits per digit• Many codes are use 4 bits in 10 distinct possible combinations (out of 16)• 2421 and Excess 3 are self complementing (1 and 0 9’s Comp of decimal)• Contents can be interpreted differently. Contents can be interpreted differently. • What decimal value does 1100001111001001 represent in different What decimal value does 1100001111001001 represent in different

binary codes?binary codes?

Dec Binary BCD Excess-3 2421 84-2-1 0 0 0000 0011 0000 0000 1 1 0001 0100 0001 0111 2 10 0010 0101 0010 0110 3 11 0011 0110 0011 0101 4 100 0100 0111 0100 0100 5 101 0101 1000 1011 1011 • 110 0110 1001 1100 1010 • 111 0111 1010 1101 1001 • 1000 1000 1011 1110 1000 • 1001 1001 1100 1111 1111

Other Codes Exist

Gray Code – to represent te digital data when it is converted from analog data– Only one bit changes at a time– 0000,0001,0011,0010,0110,0111,0101,0100,1

100,1101,1111,1110,1010,1011,1001,1000– Why is this useful?

• 01111000 All Four bits need to be changed, may cause intermediate erroneous number

– Application of Gray code is when analog data are rep by a continuous change of shaft position

55

Character Codes• ASCII

– Many applications require handling of not only numbers but letters and special characters

– Stands for American Standard Code for Information Interchange

– 7 Bits to store 128 characters – In ASCII, every letter, number, and punctuation

symbol has a corresponding number, or ASCII code– This encoding system not only lets a computer store

a document as a series of numbers, but also lets it share such documents with other computers that use the ASCII system.

56

57

Error Detection

• 8th bit is sometimes added to the ASCII character to represent its parity

• A parity bit is an extra bit included with a message to make the total num of 1’s either even or odd.

Note that parity detects only simple errors– One, three, etc. bits

• More complex methods exist• Some that enable recovery of original info

– Cost is more redundant bits58

Even Parity

• ExamplesA (01000001) with even parity is 01000001

C (01000011) with even parity is 11000011

59

Odd Parity

• Similar except make the number of 1’s odd

• ExamplesA (01000001) with odd parity is 11000001

C (01000011) with odd parity is 01000011

60

Binary Storage and Registers• Physical existence in information storage medium

for storing individual bits• A binary cell is a device that posses stable stages

and is capable of storing one bit of information• A Register is a group of binary cells.

– Can store any discrete quantity of information that contains n bits.

– 1100001111001001 is a 16 bit register– 2n possible states to store 0 to 2n -1

number– Contents can be interpreted differently 61

Register Transfers

• Basic Operation in digital systems• When Key is pressed 8 bit

alphanumeric character code in to Input Register

• Contents of Input Register are transferred to eight least significant cells of a Processor Register

• After every transfer input register is cleared for new keystroke

• Each eight bit character transfer to the processor register is preceded by shift of previous character to next eight cells on its left

• When Processor Register is full, its contents are transferred to the Memory Register 62

• Adding two 10 bit binary numbers

• Memory Unit• Processor Unit

Manipulation of binary variable

63

Binary Logic• Variables have two possible distinct values, 0

and 1

• Three Logic operations– AND “ . ” If and only if all variable are 1– OR “ + ” If any one or more of the variable is 1– NOT “ ’ ” Complement (Reverse)

• Truth Table of Logical Operations

64

Representation of Binary variables• Different Digital Systems represent 0 and 1

differently– Logical 0 as 0 volts. Logical 1 as 4 volts– Range

65

Logic Gates are electronic circuits that operate on one or more input signals to produce an output signal

Logic Gates

66

Gates with Multiple Inputs

67

Binary Codes for Numbers• Binary codes for decimal digits require 4 bits per digitDec Binary BCD Excess-3 2421 84-2-1

0 0000 0000 0011 0000 0000

1 0001 0001 0100 0001 0111

2 0010 0010 0101 0010 0110

3 0011 0011 0110 0011 0101

4 0100 0100 0111 0100 0100

5 0101 0101 1000 1011 1011

0110 0110 1001 1100 1010

0111 0111 1010 1101 1001

1000 1000 1011 1110 1000

1001 1001 1100 1111 1111

Example : 395

Binary Storage and Registers• Physical existence in information storage medium

for storing individual bits• A binary cell is a device that posses stable stages

and is capable of storing one bit of information• A Register is a group of binary cells.

– Can store any discrete quantity of information that contains n bits.

– 1100001111001001 is a 16 bit register– 2n possible states to store 0 to 2n -1

number– Contents can be interpreted differently 69

Register Transfers• Basic Operation in digital systems• When Key is pressed 8 bit

alphanumeric character code in to Input Register

• Contents of Input Register are transferred to eight least significant cells of a Processor Register

• After every transfer input register is cleared for new keystroke

• Each eight bit character transfer to the processor register is preceded by shift of previous character to next eight cells on its left

• When Processor Register is full, its contents are transferred to the Memory Register

70

• Adding two 10 bit binary no• Memory Unit• Processor Unit

Manipulation of binary variable

71

Binary Logic

• Variables have two possible distinct values, 0 and 1

• Three Logic operations– AND “ . ” If and only if all variable are 1– OR “ + ” If any one or more of the variable is 1– NOT “ ’ ” Complement (Reverse)

• Truth Table of Logical Operations

72

Representation of Binary variables

• Different Digital Systems represent 0 and 1 differently– Logical 0 as 0 volts. Logical 1 as 4 volts– Range

73

Logic Gates are electronic circuits that operate on one or more input signals to produce an output signal

Logic Gates

74

Gates with Multiple Inputs

75

General Queries

• How to determine the base of number?– Example

• 14/2=5• 24+17= 40

• 54/4 = ?

76

General Queries• How to fine the base Given the solution of the quadratic

Equation?– Example

• X2 -11x +22 = 0 is x=3, x=6 what is the base of the number

Substitute both the values of x in the equation

(3)^2 – 11(3) +22 = 0

9 – (33) + (22) = 0

9 – (3xr^1 + 3xr^0) + (2xr^1 + 2xr^0) =0

9 – 3r -3 + 2r + 2 =0

r = 8 77

General Queries

• How to determine the r’s/(r-1)’complement of number with fraction ?– Example

• 2’s Complement (0.0110)2

r^n – N = 2^0-(0.0110)2 = (1)2– (0.0110)2 = 0.1010• 1’s Complement (0.0110)2

1- r^n –N = (1- 2^-4)10 – (0.0110)2 = (0.935)10- (0.0110)2 (0.1111)2- (0.0110)2 = (0.1001)2

78