Introduction To Digital Logic: Number & Codes
Introduction To Digital Logic: Number & Codes
INTRODUCTION TO
DIGITAL LOGIC
Digitalvs.Analog
Decimalnumberingsystem(Base10)
Binarynumberingsystem(Base2)
Hexadecimalnumberingsystem(Base16)
Octalnumberingsystem(Base8)
Numberconversion
Binaryarithmetic
1sand2scomplementsofbinarynumbers
Digitalvs.Analog(1)
Twowaysofrepresentingthenumericalvaluesof
quantities:
i)Analog(continuous)
ii)Digital(discrete)
Analog:aquantityrepresentedbyvoltage,currentor
meter movement that is proportional to the value
thatquantity.
9/16/2015
Digitalvs.Analog(3)
Digitalvs.Analog(2)
Digitalsystem:
Digital
combinationofdevicesdesignedtomanipulatelogical
informationorphysicalquantitiesthatarerepresentedin
digitalforms
Analogsystem:
containsdevicesmanipulatephysicalquantitiesthatare
representedinanalogforms
2 Digitalrepresentationthequantities AnalogrepresentationaquantityI/
digits(0/1)
V/metermovement
3
4 Example:Digitalwatch,PSP,iPod,
Handphone,digitalcomputersand
calculators
Example:audioamplifiers,magnetic
taperecordingandplayback
equipment
DigitalTechniques
Digitalvs.Analog(4)
Advantages:
Whydigital?
Problemwithallsignalsnoise
Noiseisn'tjustsomethingthatyoucanhearthefuzz
thatappearsonoldvideorecordingsalsoqualifiesas
noise.Ingeneral,noiseisanyunwantedchangetoa
signalthattendstocorruptit.
Digitalandanaloguesignalswithaddednoise:
Digital:easilyberecognizedeven
amongallthatnoise:either0or1
Analog
1 Systemswhichprocessdiscrete(step Systemswhicharecapableof
bystep)values
processingacontinuousrangeof
valuesvaryingwithrespecttotime
Easiertodesign
Informationstorageiseasy
Accuracyandprecisionaregreater
Operationcanbeprogrammedsimple
Digitalcircuitslessaffectedbynoise
MoredigitalcircuitrycanbefabricatedonICchips
Limitations:
Analog:nevergetbackaperfectcopy
oftheoriginalsignal
Inrealworldthereareanaloginnatureandthese
quantitiesareoftenI/Othatarebeingmonitored,
operatedon,andcontrolledbyasystem.Thus,
conversionandreconversioninneeded
9/16/2015
AnalogWaveform
DigitalWaveform
IntroductiontoNumberingSystems
NumberingSystems(1)
Wearefamiliarwithdecimalnumbersystems
fordailyusedsuchascalculator,calendar,
phoneoranycommondevicesusethis
numberingsystem:
Decimal
Binary
Octal
Hexadecimal
Decimal=Base10
Someothernumbersystems:
Binary=Base2
Octal=Base8
Hexadecimal=Base16
0~9
0~1
0~7
0~9,A~F
9/16/2015
NumberingSystems(2)
N
U
M
B
E
R
S
Y
S
T
E
M
S
Dec
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Hex
0
1
2
3
4
5
6
7
8
9
A
B
C
D
E
F
Octal
00
01
02
03
04
05
06
07
10
11
12
13
14
15
16
17
Binary
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
1101
1110
1111
SignificantDigits
Binary:101101
MostSignificantBitLeastSignificantBit
(MSB)(LSB)
Hexadecimal:1D63A7
MostSignificantDigitLeastsignificantDigit
(MSD)(LSD)
BinaryNumberSystem
Decimalnumberingsystem(Base10)
Base10system:(0,1,2,3,4,5,6,7,8,9)
Weightsforwhole
Example:39710
numbersarepositive
Base2system:(0,1)
usedtomodeltheseriesofcomputerelectrical
signalsrepresenttheinformations.
0representsthenovoltageoranoffstate
1representsthepresenceofvoltageoranon
state
poweroftenthat
increasefromrightto
left,beginningwith100
Example:1012
3 X 102
9 X 101
=> 300 + 90 + 7
=> 39710
7 X 100
1X 22
+ 0 X 21 + 1 X 20
=> 4 + 0 + 1
=> 510
Weightsinabinary
numberarebasedon
poweroftwo,that
increasefromrightto
righttoleft,beginning
with20
9/16/2015
OctalNumberSystem
Base8system:(0,1,,7)
multiplicationanddivisionalgorithmsforconversiontoandfrombase10
example:7568converttodecimal
7X 82 + 5 X 81 + 6 X 80
=> 448 + 40 + 6
=> 49410
Weightsinabinary
numberarebasedon
powerofeightthat
increasefromrightto
righttoleft,beginning
with80
Readilyconvertstobinary
Groupsofthree(binary)digitscanbeusedtorepresenteachoctalnumber
example:7568converttobinary
756
1111011102
HexadecimalNumberSystem(2)
Base16system
multiplicationanddivisionalgorithmsforconversiontoandfrombase10
example:A9F16converttodecimal
9
F
Weightsinahexadecimal
numberarebasedonpower
10X 162 + 9 X 161 + 15 X 160 ofsixteenthatincreasefrom
righttorightto
=> 2560 + 144 + 15
left,beginningwith160
HexadecimalNumberSystem(1)
HEXADECIMAL
Base16system
Usesdigits0~9&
lettersA,B,C,D,E,F
Groupsoffourbits
representeach
base16digit
DECIMAL
BINARY
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
10
1010
11
1011
12
1100
13
1101
14
1110
15
1111
NumberConversion
Any Radix (base) to Decimal Conversion
=> 271910
Readilyconvertstobinary
Groupsoffour(binary)digitscanbeusedtorepresenteachhexadecimalnumber
example:A9F16converttobinary
A9F
1010100111112
9/16/2015
BinarytoDecimalConversion
NumberConversion(BASE2>10)
Binary to Decimal Conversion
Convert(10101101)2toitsdecimalequivalent:
Binary
10101101
x x x x x x x x
PositionalValues
Products
27 26 25 24 23 22 21 20
128 + 0 + 32 + 0 + 8 + 4 + 0 + 1
= 17310
OctaltoDecimalConversion
Convert6538toitsdecimalequivalent:
Octal Digits
Positional Values
Products
HexadecimaltoDecimalConversion
Convert3B4F16toitsdecimalequivalent:
82
81
80
Positional Values
384 + 40 + 3
= 42710
HexDigits
Products
163
162
161
160
= 15,18310
9/16/2015
DecimaltoBinaryConversion
NumberConversion
Decimal to Any Radix (Base) Conversion
1. INTEGER DIGIT:
Repeated division by the radix & record
the remainder
2. FRACTIONAL DECIMAL:
Multiply the number by the radix until
the answer is in integer
Remainder
2 5 = 12 +
2
12 = 6 +
2
6 = 3 +
2
3 = 1 +
2
1
2
example :
25.3125 to Binary
0.625 x 2 = 1.25
0.25 x 2 = 0.50
0.5 x 2 = 1.00
Answer:
MSB
.0
MSB
LSB
2510 = 1 1 0 0 1 2
DecimaltoOctalConversion
DecimaltoBinaryConversion
Carry
0.3125 x 2 = 0.625
0
= 0 +
LSB
1 0 1
Convert42710toitsoctalequivalent:
427/8=53R3
53/8=6R5
6/8=0R6
Dividedby8;RisLSD
DivideQby8;Risnextdigit
RepeatuntilQ=0
6538
1 1 0 0 1.0 1 0 1
9/16/2015
NumberConversion
DecimaltoHexadecimalConversion
BinarytoOctalConversion(vice
versa)
Groupingthebinaryposition
ingroupsofthreestartingat
theleastsignificantposition.
Convert83010toitshexadecimalequivalent:
830/16=51R14
51/16=3R3
3/16=0R3
= E in Hex
33E16
OctaltoBinaryConversion
Eachoctalnumberconvertsto3binarydigits
NumberConversion(1)
Example:
Convertthefollowingbinarynumberstotheiroctal
equivalent(viceversa).
a) 1001.11112
b) 47.38
c) 1010011.110112
Answer:
a) 11.748
b) 100111.0112
c) 123.668
9/16/2015
NumberConversion(2)
BinarytoHexadecimalConversion(vice
versa)
Groupingthebinarypositionin4bit
groups,startingfromtheleast
significantposition.
BinarytoHexadecimalConversion
Theeasiestmethodforconvertingbinarytohexadecimal
isusingasubstitutioncode
Eachhexnumberconvertsto4binarydigits
SubstitutionCode(1)
NumberConversion
Example:
Convert the following binary numbers to
their hexadecimal equivalent (vice versa).
a) 10000.12
b) 1F.C16
Answer:
a) 10.816
b) 00011111.11002
Convert(010101101010111001101010)2tohexusingthe4
bitsubstitutioncode:
01010110101011100110
1010
= 56AE6A16
9/16/2015
SubstitutionCode(2)
BinaryAddition
Substitutioncodecanalsobeusedtoconvertbinaryto
octalbyusing3bitgroupings:
010101101010111001101
010
= 255271528
SimpleArithmetic
Addition
Example:
100011002
+1011102
101110102
Substraction
Example:
10001002
1011102
101102
11001
111
+ 1101
+ 11
100110
???
Binary Subtraction
0-0=0
Example:
5816
+ 2416
7C16
1-1=0
1-0=1
10 -1 = 1
0 -1 with a borrow of 1
Example:
-
1011
101
111
- 11
100
???
10
9/16/2015
BinaryMultiplication
0X0=0
0X1=0
Example:
1X0=0
BinaryDivision
100110
1X1=1
101
100110
000000
100110
10111110
2scomplementsofbinarynumbers
2scomplement
Binary number
0 0 10 11 0 10
1s complement
Step1:Find1scomplementofthenumber
Binary#
11000110
1scomplement
00111001
Step2:Add1tothe1scomplement
00111001
+1
00111010
11
9/16/2015
Signnumbers
SignedMagnitudeNumbers
Leftmostisthesignbit
110010..
Sign bit
0 = positive
1 = negative
00101110010101
Signnumbers
2s complement
The positive number same as sign
magnitude and 1s complement
The negative number is the 2s complement
of the corresponding positive number.
Example:
Express +19 and -19 in
i. sign magnitude
ii. 1s complement
iii. 2s complement
0isforpositive,and1isfornegative
Signmagnitude
00011001=+25
signbitmagnitudebits
1scomplement
Thenegativenumberisthe1scomplementof
thecorrespondingpositivenumber
Example:
+25is0001100125is11100110
DigitalCodes(1)
BCD (Binary Coded Decimal) / 8421
Code
Represent each of the 10 decimal digits
(0~9) as a 4-bit binary code.
Example:
Convert 15 to BCD.
1
0001 0101
Convert 10 to binary and BCD.
12
9/16/2015
DigitalCodes(3)
DigitalCodes(2)
ASCII (American Standard Code for
Information Interchange) Code
Used to translate from the keyboard characters
to computer language
A world standard alphanumeric code for
microcomputers and computers
A 7-bit code representing 27 (128) diff. characters
(26 upper case, 26 lower case, 10 numbers, 33
special characters/symbol, 33 ctrl characters
8-bit version ASCII (USACC-II 8 or ASCII-8)
represent max. of 256 characters.
DigitalCodes(4)
Excess-3 Code
Used to express decimal numbers.
The code derives its name from the fact
that each binary code is the
corresponding 8421 code plus 3
Decimal Binary
Gray
Code
0000
0000
0001
0001
0010
0011
0011
0010
0100
0110
0101
0111
0110
0101
DigitalCodes(6)
Error Detecting and Correction Code
Required for reliable transmission and
storage of digital data.
1) Error Detecting Codes
13
9/16/2015
DigitalCodes(7)
EBCDIC (Extended Binary Coded
Decimal Interchange) Code
Mainly used with large computer
systems like mainframe.
An 8-bit code and accommodates up to
256 characters
Divided into 2 portions:
4 zone bits (on the left) and
4 numeric bits (on the right)
FloatingPointNumbers(FPN)
A real number or FPN is a number which has
both an integer and a fractional part.
Examples:
Real decimal numbers: 123.45, 0.1234, -0.12345
Real binary numbers: 1100.1100, 0.1001, -1.001
exponent
14