Professional Documents
Culture Documents
EEAC 109lvlodute I
-
6
MODULE I
INTRODUCTION
OBJECTIVES
There are three tessons in the module. Read each lesson carefutty
then ans,wer the exercises/activities to find out how much you have
benefited from it. Work on these exercises carefulty and submit your output
to your instructor or to the COE office.
Lesson 1
Number System
Binary Numbers
A decimal number such as 7,392 represents a quantity equal to 7
thousands, ptus 3 hundreds, plus 9 tens, ptus 2 units. The thousands,
hundreds, etc., are powers of 10 imptied by the position of the coefficients
(symbots) in the number. To be more exact, 7,392 is a shorthand notation
for what shoutd be written as
a5a4a3a2a1ao. a.1a-2a,3
The coefficients o, are any of the 10 digits (0, 1,2, . .., 9), and the
subscript vatue j gives the ptace vatue and, hence, the power of 10 by which
the coefficient must be muttiptied. Thus, the preceding decimat number can
be expressed as
,I
EEAC 09 A,todule I
9
(127.4)a='l " * *
82 + 2 81 + 7 80 + 4' 8'1 = (87.5)10
There are four 1's in the binary number. The corresponding decimal number
is the sum of the four powers of two. Zero and the first 24 numbers obtained
from 2 to the power of n are tisted in Tabte 1.1 . ln computer work, 210 is
referred to as K (kito), 220 as M (mega), 2r0 as G (giga), and 2{ as T (tera).
Thus, 4K = 217 = 4,096 and 16M = 274 = 16,777,216. Computer capacity is
usuatty given in bytes. A byte is equal to eight bits and can accommodate
(i.e., represent the code of) one keyboard character. A computer hard disk
with four gigabytes of storage has a capacity of 4G = 232 bytes
(approximately 4 bittion bytes). A terabyte is 1024 gigabytes, approximately
1 trittion bytes. Arithmetic operations with numbers in base r fottow the
same rutes as for decimal numbers. When a base other than the familiar
base 10 is used, one must be careful to use only the r-altowabte digits.
Examptes of addition, subtraction, and multiptication of two binary numbers
are as foltows:
Table l.l
Powers of Two
n 2' n 2n n 2'
0 I ll l.i6 l(r 65.536
I l 9 5ll l7 l-11.072
l .t l() Lr)l-l (IK lrl 16l.l4.l
l( l.rNri l(, 52.1..1t{s
l l6 tl 4.rF)6 (4K) l(l l.(H{.576 ( ilVl )
5 11 t-l s. te2 lt l.(rr7l5l
6 (rJ IJ t6.-1r{.1 t: .1.t9{.3{B
7 lls t-i -l:.76,\ l.i ,\.3t{s.flr\
EXAMPLE 1.1
(irnvert dccinrll -ll t() hilar\: Firsl. -ll is dividc-d br. I to [ive irn inl!.qcr qu()tienl ol 2{}
aml a rcnrainttcr of|. Thc'n thc quotient is aeain dirid.rl hi.l lo tivc a ncs, qur)ticnr nd
rrnraindct. Thc prft'css is continu!-d urltil thc int('gcr quotienl bccomes O. Th!' .t,.,lh<.it ts
o[ thc dcsired binary numr-$[ at! ohtained frorrr lhc r.,r ,rr)lrt rr as frrlhrus:
EXAMPLE 1.2
('onvc'r'l decinral l5J to oclal. Thc rc-quircd base. r is S. First. l-i-i is divitlcd lrv S 1o qivc
:rn inleg.cr quoticnt ttf l9lntl a rcmairtder of l.'ften l9 is dividetl lrv S lo sivc ln integcr
quolicnt of ) and a tenrainder of -i. Finallr'.2 is divitletl h1, N to givc. a tluoticnl of 0 and
{r rr'maindcr of 2. This process can hc convL.nientlt' mlnipulated as lollows:
l-5-l
l9 I
2 -1
o 2 : (231)t
The convt'rsion o[ a dccin,al ti'ttttitttt to lrinarv is accomplishcd lrv a mcthod sinrilar
to that uscd for intc'qer:r Howevct. nrultiplication is used instc'ad of division. and irrtegcrs
instcad of rcnrainders arc accumulatt'd. Again. thc method is r^usl explaincd tr-v c'xantplc.
I
OCTAL AND HEXADECII,IAL
The conversion from and to binary, octal, and hexadecimat ptays an
important role in digitat computers, because shorter patterns of hex
characters are easier to recognize than long patterns of 1's and 0's. Since 23
= 8 and 2a = 16, each octal digit corresponds to three binary digits and each
hexadecimat digit corresponds to four binary digits. The first 16 numbers in
the decimat, binary, octal, and hexadecimal number systems are tisted in
Tabte 1.2 . The conversion from binary to octal is easity accomptished by
partitioning the binary number into groups of three digits each, starting
from the binary point and proceeding to the teft and to the right. The
corresponding octal digit is then assigned to each group. The fottowing
exampte ittustrates the procedure:
( ilr Il0 0()l lol ()lI III l(n fiX) ll0;, : (26153.7-t()d)x
26153 74t) 6
Trblc l2
Numbers with Dltferpnt Eoses
EEAC 109
13
Complements of Numbers
Given a number N in base r having n digits, the (r - 'l )'s complement
of tl, i.e., its diminished radix complement, is defined as (r - 1) - N. For
decimal numbers, r = 10 and r - 1 = 9,so the 9's comptement of Nis (10n -
1) - N. ln this case, 10, represents a number that consists of a singte 1
fottowed by n 0's. ('10" - 1) is a number represented by n 9,s. For example, if
n = 4, we have1@ = 10,000 and lff - 1 = 9999. tt follows that the 9's
complement of a decimal number is obtained by subtracting each digit from
9. Here are some numerica[ examptes:
Radix Complement
The r's comptement of an n-digit number N in base r is defined as l. - N for
N*0 and as 0 for N = 0. Comparing with the (r - 1)'s comptement, we note
that the r's comptement is obtained by adding 1 to the (r - 1)'s
comptement, since r{' - N = [(r. - 1) - M + 1. Thus, the 10's comptement of
decimal 2389 is 7610 + 1 = 7611 and is obtained by adding 1 to the 9's
comptement value. The 2's complement of binary 101100 is 010011 + 1 =
010100 and is obtained by adding 1 to the 1's-comptement vatue. Since 10 is
a number represented by a 1 followed by n 0's, 10, - N, which is the 10,s
complement of N, can be formed atso by leaving att least significant 0's
unchanged, subtracting the first nonzero teast significant digit from 10, and
subtracting att higher significant digits from 9. Thus,
T-he.]'s complement of the first number is obtained by leaving the two least
significant 0's and the first 1 unchanged and then repiacing 1;s with 0,s and
0's with 1 's in the other four most silnificant digits.'The 2;s comptement of
the second number is..obtained by telving the teast significant 1 Lnchanged
and complementing a[[ other digits.
In the previous definitions, it was assumed that the numbers did not
have a radix point. lf the originat number N contains a radix point, the point
shoutd be removed.temporarity in order to form the ris or (r 1),s -
comptement. The radix point is then restored to the comptementd number
in the same retative position. lt is also worth mentioning that the
complement of the complement restores the number to Its original
value. To see this relationship, note that the r,s complement of N is rri- N,
so that the comptement of the comptement is 14 - (r, - N) = N and is equal to
the original number.
method works wetl when peopte perform subtraction with paper and pencil.
However, when subtraction is implemented with digitat hardware, the
method is less efficient than the method that uses comptements. The
subtraction of two n-digit unsigned numbers l,t - N in base r can be done as
follows:
EXAMPLE I.5
Using l0's complement, subtrrcl 72532 - 3250.
M: 72532
l0's complement of N= " f!!
Sum = 169?f'2
Discard end carrv lG< = - IIIXXX)
Answer = 692112
Note that Mhas (i}€ disits and Nhas only four digitr Both numhcrs must have the sanre
numher of digits so we write N as t)3250. Tating th!, l0's crrmplement of N pnxlues a
9 in lhe mo6t sitnificr8nt position.The occurrence of tbe end carq, signifies that t{ N j
and that the rBult is therefore p,ositive.
I
EXAMPLE I.6
Using lt)'s complerr^,^nt, subtracr -115() - 7]5-U.
ll : 0325(r
l0's complemeot of 19 : + l7t5tl
Sum = 30?lll
There is no end carrl-Thert'fore. the answer is -( l0's complement of 3t7l lt) = -6g82.
n-otc that sincc .
7?532. the result is negative. Because we are dealing with
-1250
unsisned numbers. thcre is rcally no wav to get arl unsigoed rcsull for this cas{..-When
subtracting with conrplemenls we recognize the negative answer frolll the absence
of lhc end carrv and the complemented resuk. When *orking wirh paper and pencil.
we can change the ans*er to a signed negtative numbcr in order topur it in a famil_
iar form.
Subtraaion rrith complements is done *ith trinary numhers in a similar manncr. using
_
lhe procedure outlioed previouslv
a
signed-magnituderepresentation: 10001001
signed- 1's-comptement representation: I 1 1 1 01 1 0
signed-2's-complement representation : 1 1 1 1 01 1 1
T.blc l.,
Lesson 2
*l
\P Truth Tabtes
Truth tabtes are used to hetp show the function of a togic gate. lf you are
unsure about truth tabtes and need guidence on how go about drawning
them for individual gates or [ogic circuits then use the truth tabte section
tink.
,,'l
V Logic gates
Digital systems are said to be constructed by using logic gates. These gates
are the AND, OR, NOT, NAND, NOR, EXOR and EKNOR gates. The basic
operations are described betow with the aid of truth tables.
AND gate
2lnpfiA D qata
A A.B
A ! 0 0
AB 0 1 tl
B
1 0 0
AND 1 1 1
The AND gate is an etectronic circuit that gives a igh ou tput (1 ) onty
if all its inputs are high. A dot (.) is used to show the AN D operation
i.e. A.B. Bear in mind that this dot is sometimes omitted i.e. AB
OR gate
2 lrpul OR q.rte
A D A+B
tl 0 0
A
B
A-+B ! 1 1
l U 1
OR T 1 1
NOT gate
NOT onle
A A
^lA
0lj
NOT 1 lo
The NOT gate i s an etectronic circuit that produces an inverted
version of the input at its output. lt is also known as an inverter. lf
the input variable is A, the inverted output is known as NOT A. This
is atso shown as A', or A with a bar over the top, as shown at the
outputs. The diagrams below show two ways that the NAND togic gate
can be configured to produce a NOT gate. lt can also be done using
NOR togic gates in the same way.
A_ A
A E 1-_*,!-
NAND gate
0
1
1
1
NAND l 1 0
This is a NOT-AND gate whi ch is equal to an AND ga te ollowed by a
NOT gate. The outputs of atl NAND gates are hi gh if any of the inputs
are ow. The symbol is an AND gate with a sma [[ circle on the output.
The smatl circte represents inversion.
NOR gate
2 lnpul IOR qate
A A+B
A rl rl 1
r1
A+R 0 1 tl
1 rl rl
NOtr 1 1 0
This is a NOT-OR gate which is eq uat to an OR gate Iowed by a NOT
gate. Th e outputs of att NOR gates are low if any of the inp uts are
high.
EE AC 109 rvodute i
19
The symbol is an OR gate with a sma[[ circle on the output. The smatl
circle represents inversion.
EXOR gate
2 lnpur EXOR qate
A E AOE
0 0 0
A
B A(:JB 0 1 1
1 rl 1
EOR ,l
l 0
The 'Exclusive-OR gate is a circuit which wit give a high output
if either, but not both, of its two inputs are high. An encircled ptus
sign (@) is used to show the EOR operation.
EXNOR gate
2 hpur EX OR qare
A E A@E
0 0 'l
A
B reE 0
1
,]
0
0
0
EN{:IR 1 1 1
The 'Exclusive-NoR' gate circuit does the opposite to the EOR gate. lt wilt
give a low output if either, but not both, of its two inputs are high. The
symbol is an E(OR gate with a sma[[ circle on the output. The smalt circle
represents inversion.
The NAND and NOR gates are catled universo I functions since with either
one the AND and OR functions and NOT can be generated.
Note:
A
R
AB ! ----i-.-'-n.+
AND OR
A
A
D
ru B ---l )>, TE
NNND NOR
A
R
---lt 1I......--
AOB
A A troR
NOT A
lt$B
B
-l ENOR
INPUTS OUTFUTS
A B AND NAND OR NOR EXOR EXNOR
l{ OT q are 0 0 0 1 0 1 0 1
A 0 1 0 1 1 0
,l
0
,l
0 I ,1
0 0 1 0
,l
0
1 0 1 1 1 0 'l 0 0 1
=L
Example
-l
A NAND gate can be used as a NOT gate using either of the fottowing wiring
configurations.
P,
-d lr-r 1
Lesson 3
A.0=0 A in series A
with __?.__o
o- Annutment
open = "OPEN"
Ain paratlel
A+A=A with
L^-J
-A-t- ldempotent
A.A=0 A in
NOT A = "OPEN"
series with *-L Complement
A in J/*
A+B = B+A
paratte[ with
B in paraltel with A
B=
fu-J Commutative
A.B = B.A
A in
B
series
in series with A
with B= _L3* Commutative
A+B = A.B
invert and reptace OR de r\rlorgan's
with AND Theorem
A.B = A+B
invert and reptace AND de Morgan's
with OR Theorem
.Annulment Law - A term AND'ed with a ,.0,, equats 0 or OR'ed with a .,1,,
witt equat 1
.ldentitv Law - A term OR'ed with a .,0,' or AND'ed with a .,1', witt atways
equal that term
.Comptement Law - A term AND'ed with its comptement equats "0" and a
term OR'ed with its comptement equats "1"
I
. de Morgan's Theorem - There are two "de Morgan's,, rutes or theorems,
L
.(1) Two separate termsNoR'ed together is the same as the two terms
inverted (Comptement) and AND'ed for exampte: A+B = A . B
!
I
.(2) Two separate terms NAND'ed together is the same as the two terms
inverted (Comptement) and OR'ed for exampte: A.B = A + B
l-
b EEAC 1 lvlodute I
,-
25
.6 LEARNING ACTIVIry
Present the truth tabte for 3-input and AND and 3-input OR
gates.
H a
MODULE SUAAAAARY
EEAC l09lrtodute I
26
Congratutations! You have just studied lvlodute l. now you are ready
to evatuate how much you have benefited from your reading by ansrering
the summative test. Good Luck!!!
,6 SUMMATIVE TEST
1. What is the targest binary number that can be expressed with 14 bits?
What are the equivalent decimat and hexadecimal numbers?
2. Convert decimat number 431 in two ways: (a) Convert directty to
binary; (b) convert first to hexadecimal and then from hexadecimal
to binary. Which method is faster?
3. Obtain the 1's and 2's comptements of the fottowing binary numbers:
a. 10000000
b. 00000000
c. 11011010
d.01110110
L e. 10000101
f. 11111111
4. Find the 9's and the 10's comptement of the fottowing decimal
number:
a. 52,7U,630
b. 63,325,600
c. 25,000,000
d. 00,000,000
5. (a) Find the 16's comptement of B2FA.
L (b) Convert BZFA to binary.
(c) Find the 2's comptement of the result in b.
(d) Convert the answer in (c) to hexadecimat and compare with the
L answer in (a).
6. Perform subtraction on the given unsigned numbers using 10's
comptement of the subtrahend. When the result shoutd be negative,
find its 10's comptement and affix a minus sign. Verify your answers.
a. 6,428 - 3,409
b. 125 - 1,900
c. 2,043 - 6,152
d. 1,631 - 745
7. Decode the fottowing in ASCII code:
L EEAC 109l'lodute I
uIIllF
27
abc
o
5
fiGURE pi.35
EEAC 109