You are on page 1of 31

Digital Designs

S. O. ADEFAMOYE
Faculty of Sciences,
Computer Science Department
+234 – 809 – 073 – 1442
+229 – 6856 – 1587
Digital Designs Fundamentals 2

CHAPTER 1
INTRODUCTION TO NUMBERS AND CODES
1.0 Number representation: Computers can only process binary data –
i.e. 1’s and 0’s. If numeric data is to be processed then it cannot be
processed in its usual base10 form, it must be converted into its base2
form – known as binary. There are two ways that can be used to represent
numbers in binary:
 ‘pure’ binary;
 Binary-coded decimal (BCD).
There are also two ‘half-way’ stages that are sometimes used by
programmers because they are easier to understand than a string of 1s
and 0s:
 Octal;
 Hexadecimal.
1.1 ‘Pure’ binary
Pure binary represents numbers using just two digits (‘0’ and ‘1’) and
columns, which increase by a factor of two.
This is in contrast to our normal number system (denary), which uses ten
digits (0-9) and columns, which increase by a factor of ten.
In denary the number one hundred and ninety seven is represented as:

In binary, it is represented as:

1.2 Converting From Binary to Denary


A binary number such as 1001 0101, can be converted into its denary
equivalent as follows:
1. Write the binary number with the appropriate column headings:

2. Add the column headings under which there is a binary ‘1’:


128 + 16 + 4 + 1 = 149
2
Digital Designs Fundamentals 3

1.2.1 Converting From Denary To Binary


A denary number, such as 107, can be converted into binary as follows:
1. Write down the binary column headings:

2. Then, starting from the left, ‘take out’ the values in the column headings
from the number, if possible: 128 cannot be taken out of 107 so that
column contains a ‘0’:

64 can be taken out of 107 so that column contains a ‘1’; this leaves
107 – 64 = 43:

32 can be taken out of 43 so that column contains a ‘1’; this leaves


43 – 32 = 11:

3. Keep repeating the above process until the whole number has been
converted to pure binary:

1.2.1 Counting in binary, the first 15 numbers are as follows:

3
Digital Designs Fundamentals 4

1.2.3 Binary Coded Decimal (BCD)


Binary Coded Decimal is one of the early memory encodings. Rather than
converting the entire denary value into its pure binary form, it converts each
digit, separately, into its 4-bit binary equivalent. The table below shows the
4-bit BCD equivalents of the ten denary digits:

Note that the higher codes are not used in BCD because they do not
represent a denary digit. These are:

1.2.4 Converting from denary to BCD


Each digit is converted to its 4-bit BCD equivalent. Thus, the number 319
would be represented in 12-bits as follows:

1.2.5 Converting from BCD to denary


Each group of 4-bits are converted into the equivalent denary digit. Thus,
the 12-bit binary coded decimal number 0110 1000 0011 is denary 683 as
shown:

4
Digital Designs Fundamentals 5

1.3 OCTAL NUMBER SYSTEM


The octal number system uses eight digits (0 to 7) to represent numbers,
and columns which increase by a factor of eight.

1.3.1 Converting from octal to denary


The octal number 652 would be converted to denary as shown:

Converting between octal and binary. The octal number 652 (426 in
denary) is represented in binary as:

If we combine the bits in groups of three and label with the appropriate
column headings…

… we can see that converting from octal to binary converts each digit into
its 3-bit binary equivalent (very similar as converting between denary and
BCD).
Thus the octal equivalent of binary number 10011101 will be:

5
Digital Designs Fundamentals 6

1.4 HEXADECIMAL NUMBER SYSTEM


The hexadecimal number system uses 16 digits to represent numbers. The
denary digits 0 – 9 are used together with the first six letters of the alphabet
(A – F).
With hexadecimal, instead of column headings doubling, as they do in
binary, or increasing by a factor of 10 as they do in denary, each column
heading in hexadecimal increases by a factor of 16.
The column headings are:

Examples of hexadecimal numbers include: 3FC2, CFF8, 92B0, EE4D,


ACDC.
Note that the number 9375 could either be ordinary denary or hexadecimal
– to make it clear the symbols ‘h’, ‘#’ or ‘&’ are often used. Thus, if the
number was in hexadecimal, it would be written as 9375h, #9375 or &9375.

1.4.1 Converting From Hexadecimal To Denary


The hexadecimal number 2C5A can be converted into its denary equivalent
as follows:
1. Write the hexadecimal number with the appropriate column headings:

2. Noting that A  10 and C  12, convert in the same way as conversion


from binary to denary:
= (4096 x 2) + (256 x 12) + (16 x 5) + (1 x 10)
= 11 354

1.4.2 Converting from hexadecimal to binary


This uses the same method as octal to binary, except each hexadecimal
digit is represented by 4- bits. Thus, the hexadecimal number B7C can be
converted into a 12-bit binary as follows:

6
Digital Designs Fundamentals 7

1.4.3 Converting from denary to hexadecimal


Convert to binary first and then to hexadecimal. For example, 462 can be
converted as follows:
First convert to binary:

Then convert each group of four into their hexadecimal equivalent:

= 1CE

1.5 USES OF HEXADECIMAL


Hexadecimal is often used by Assembly language programmers to
reference memory. It is also used within HTML property values –
specifically background and font colours.
There are three advantages of using hexadecimal:
 Hexadecimal is quicker for a programmer to enter into a computer than
binary;
 Hexadecimal is easier for a programmer to understand and remember –
8F8B is easier to remember than 1000111110001011.
 It is very easy to convert between binary to hexadecimal.

1.5.1 Expression
Expressing the denary number 195 as eight-bit binary, BCD, octal and
hexadecimal:

Binary

BCD

Octal
Or
Pure Binary:
Group in threes:
Octal value:
7
Digital Designs Fundamentals 8

Hexadecimal
Or:
Pure Binary:
Group in fours:
Hexadecimal value:

1.6 NEGATIVE BINARY NUMBERS


Two’s compliment
Two’s compliment is a method of representing negative numbers in binary,
whereby the most significant bit maintains its magnitude, but is made
negative.
If, for example, one byte is used to represent a ‘signed’ integer using the
two’s compliment method, the column headings would become:

Thus, the denary integer 18 would be represented as:

And the negative integer – 18 would be represented as:

Notes:
 Negative numbers will always start with a ‘1’ and positives will start with
a ‘0’;
 The range of integers that can be represented using one byte is from –
128 up to + 127.

8
Digital Designs Fundamentals 9

1.6.1 Converting a negative denary integer into two’s complement


Due to the way that binary numbers work, there is an easy ‘trick’ that allows
very fast conversion. Taking the denary integer – 52 as an example, you
can use the three stages shown below:

Stage one
Convert the positive form of the number into unsigned binary:

Stage two
Starting at the right hand side, copy each bit, up to and including the first
‘1’:

Stage three
Reverse all the other bits:

This will always work – even if you do not understand why!

1.6.2 Converting a two’s complement number into denary


This is the same as converting any binary number into denary, as long as
you remember that the most significant bit is negative.

For example the ‘signed’ binary number 1 1 0 1 0 1 0 1 is converted as


follows:

= – 128 + 64 + 16 + 4 + 1
= – 43

9
Digital Designs Fundamentals 10

1.7 SIGN AND MAGNITUDE


The alternative to using two’s complement to represent negative numbers
is to use the ‘sign and magnitude’ method – here; the most significant bit is
used as a sign bit without a numerical value.
= – (64 + 8 + 4)
= – 76
Notes:
 The range of integers that can be represented using one byte is from –
127 up to + 127.
 Although the sign and magnitude method is easier for humans it is much
harder to use for computers performing arithmetic.

SPOT CHECK
1. Assuming a single byte is used, convert the following numbers into two’s
compliment binary:
(a) – 5 (b) – 10 (c) – 20
2. What is the denary value of 1010 1011 if the binary codes represent:
(a) a two’s compliment number (b) a sign and magnitude number

1.8 BINARY ARITHMETIC


1.8.1 Addition
Computers will only ever add two numbers at a time – if three numbers
need to be added, a computer will add the first two and then add the third
number will be added to the result. Since only two numbers are added at a
time, there are limited outcomes:
0+0=0
0+1=1
1+0=1
1 + 1 = 2 (‘10’ in binary – this is 0 ‘down’ and ‘carry’ 1)

Note that when you add a ‘carry’ to the next column, it is possible for:
1 + 1 + 1 (the carry) = 3 (‘11’ in binary – this is 1 ‘down’ and ‘carry’ 1)
This is better shown if we add 1010 1110 1100 and 0011 1010 1010:

10
Digital Designs Fundamentals 11

1.8.2 Subtraction
To perform subtraction, the number to be subtracted is converted into its
two’s compliment negative and then added.

For example to subtract 12 from 25:


1. Convert the 12 into two’s compliment –12

12

-12

2. Now add this to the 25:

Note that there is still a ‘carry’ bit, but this is ignored.

11
Digital Designs Fundamentals 12

CHAPTER 2
TEXT (CHARACTER) REPRESENTATION

2.0 Character Set


A character set are the characters that can be recognized by a computer.
2.1 Character encoding
A computer is able to represent four types of characters:
Alphanumeric characters – letters A – Z and a – z and the digits 0 – 9.
Punctuation characters and other ‘special’ symbols such as , . ; : “ ‘ ! @ £ $
%&*()+<
Graphical characters such as ♣, ♦, ♥, ♠, , ✘, ☛, ✻ (and many more…);
Control characters – [Return], [Esc], [Space], [Alt], etc.
Within a computer, each character is represented using a unique binary
code. Although there are many different methods of encoding the
characters, three of the most common are ASCII, EBCDIC and Unicode.
ASCII
American Standard Code for Information Interchange (ASCII) is used for
character encoding by most Windows™ PCs. ASCII can be used to
translate alphanumeric characters into a 7-bit binary code that represents
all the characters available from the keyboard including punctuation and
some special symbols such as ‘@’, # and $:

12
Digital Designs Fundamentals 13

A development of ASCII, known as Extended ASCII, uses an 8-bit code


that also defines codes for additional characters, including some graphical
ones. Note that using an 8-bit code means the maximum number of
characters that can be represented is 256.

2.2 How character encoding works


The diagram below shows how the message “Hello World” is stored in the
memory of a computer using the ASCII codes:

The message is typed at the keyboard. Electronics in the keyboard convert


the typed characters into ASCII binary codes that are sent from the
keyboard along a cable to the computer. The computer stores these codes
in its internal memory. The computer also provides a visual display of the
characters as they are typed. To be able to do this, electronics inside the
computer convert the stored binary codes back into their character
equivalents.

EBCDIC
Extended Binary Coded Decimal Interchange Code (EBCDIC) was
developed by IBM for use in their mainframe systems. It has the same
limitation as ASCII in that its 8-bit code can only define 256 different
characters.

13
Digital Designs Fundamentals 14

Notice how the EBCDIC codes are completely different to ASCII – if a


message was sent that had been encoded using ASCII, but received by a
system that used EBCDIC, then the resulting message would not make
sense.
Unicode.
Unicode is an international system of representing characters using 16 bits.
Using 16 bits means that 216 = 65 536 different characters can be
represented (thus overcoming the limitation of ASCII and EBCDIC).
Unicode allows every character from most alphabets to have a code of its
own – Chinese, Russian, Greek, Urdu etc, including Egyptian
Hieroglyphics. Note that there are plenty of spare codes that are used for
mathematical symbols, common graphics and even the Braille symbols.

14
Digital Designs Fundamentals 15

CHAPTER 3
DIGITAL SYSTEMS
3.0 DIGITAL CIRCUIT VERSUS AN ANALOG CIRCUIT
Digital systems operate based on discrete signals or information, where as
an analog system relies on continuous signals or information.
•Digital systems are binary in nature, they have two distinct states as
opposed to the infinite states available in an analog system.
A Digital system accepts discrete inputs and generates discrete outputs,
such as On/Off, High/Low, True/False, or 1/0.

3.1 LOGIC GATES


A gate is a digital electronic circuit having one or more inputs but only one
output. The output or a signal will appear at the output of the gate only for
certain input signal combinations. There are three basic gates which are:
AND, OR and NOT gates.
Logic gates are the simplest component of any logic circuit. So, to
understand the computer logic, you should understand and master the logic
operators called gates.
Other popular gates are the NAND and the NOR gates; which are simply
combinations of an AND gate or an OR gate with a NOT gate inserted just
before the output signal. Other gates include the XOR “Exclusive-OR” and
the XNOR "Exclusive NOR" gates.
The Gates are used as the building blocks in the design of complex digital
logic circuits. Digital logic circuits consist of a series of special integrated
circuits called “Logic Gates.” These logic gates are the building blocks of
the circuit and can be combined to construct any circuit to satisfy practically
any situation.
15
Digital Designs Fundamentals 16

In this course, we will cover the following gates known as:


1. NOT gate (or inverter)
2. AND gate
3. OR gate
4. NAND gate
5. NOR gate
6. XOR gate (exclusive OR gate)

REPRESENTING LOGIC GATES AND FUNCTIONS


There are several ways of representing logic functions:
 Symbols to represent the gates
 Truth tables to analyze the logic functions and
 Boolean algebra to simplify the logic functions.

1. The NOT gate (inverter) is the simplest of all logic gates


SYMBOL TRUTH TABLE

We use A’ (A prime/Not A) to represent the complement of A or any other


variable.
2. The AND gate
SYMBOL TRUTH TABLE

Note the product AB is read as A and B.


3. The OR gate
SYMBOL TRUTH TABLE

Note the sum A+B is read as A or B.


16
Digital Designs Fundamentals 17

4. The NAND gate is simply the combination of an AND gate with a


NOT gate inserted just before the output signal.
SYMBOL TRUTH TABLE

5. The NOR gate is simply the combination of an OR gate with a NOT


gate inserted just before the output signal.
SYMBOL TRUTH TABLE

6. The XOR gate (exclusive OR gate)


SYMBOL TRUTH TABLE

17
Digital Designs Fundamentals 18

3.3 BASIC OPERATIONS OF BOOLEAN ALGEBRA


Compliment Notation

0’ = 1 (read as NOT 0 is equal to 1)


1’ = 0 (read as NOT 1 is equal to 0)
If A=1 then A’=0
If A’=1 then A=0
Therefore (A’)’ = A

Additive Behavior Multiplicative Behavior:


(OR Gates) (AND Gates)
0+0=0 0*0 = 0
0+1=1 0*1 = 0
1+1=1 1*1 = 1

IMPORTANT LAWS OF BOOLEAN ALGEBRA SOME BASIC BOOLEAN ALGEBRA THEOREMS

Commutative Laws Theorem 1 A+0=A


AB = BA Theorem 2 A+1=1
A+B = B+A
Theorem 3 A+A=A
Associative Laws Theorem 4 A*1=A
(AB)C = A(BC)
Theorem 5 A*0=0
(A+B)+C = A+(B+C)
Theorem 6 A*A=A
Distributive Laws
Theorem 7 (A’)’=A
A(B+C) = AB + AC
A+BC = (A+B)(A+C) Theorem 8 A+A’=1

Theorem 9 A*A’=0

18
Digital Designs Fundamentals 19

How to use Boolean algebra to simplify a sum of products expression


1. Try to find variables that can be factored out in such a way as to leave
terms that will simplify to zero or one.
For example AB’ + AB = A(B’+B) = A(1)=A.
2. If it helps you recognize patterns, rearrange the order of the terms in the
expression to group terms that have common variables together.
3. Keep the second distributive law in mind. It is used a great deal and
situations where it would help are often missed by people new to Boolean
expression simplification. A+BC = (A+B)(A+C)

Example: Simplify F=A’B’+A’B+AB’


Soln:
From the First Distributive law: A(B+C) = AB + AC
Therefore F=A’B’+A’B+AB’→ F=A’(B’+B)+AB’
From Theorem 8: B’+B = 1,
Therefore F=A’(B’+B)+AB’ → F=A’+AB’

From the Second Distributive law: A+BC = (A+B)(A+C)


Therefore F=A’+AB’ → F=(A’+A)(A’+B’)
From Theorem 8: A’+A = 1
Therefore F=(A’+A)(A’+B’) → F=(1)(A’+B’)
Therefore F=A’+B’ End Result.

19
Digital Designs Fundamentals 20

DeMorgan’s Theorem Part a. (AB)’ = A’+B’


DeMorgan’s Theorem Part b. (A+B)’ = A’B’

GATE SYMBOL TRUTH BOOLEAN EXPRESSION


TABLE

NOT y=ā

A NOT gate is also called an ‘inverter’


- y is only TRUE if a is FALSE
- Circle (or ‘bubble’) on the output of a gate implies
that it has an inverting (or complemented) output

AND y = a .b

- y is TRUE only if a is TRUE and b is TRUE

- In Boolean algebra AND is represented by a dot .

OR y=a+b

-y is TRUE if a is TRUE or b is TRUE (or both)


-In Boolean algebra OR is represented by a plus
sign 

NAND y  a.b

-y is TRUE if a is FALSE or b is FALSE (or both)


-y is FALSE only if a is TRUE and b is TRUE

NOR y  a+b

- y is TRUE only if a is FALSE and b is FALSE


- y is FALSE if a is TRUE or b is TRUE (or both)

XOR y  ab

- y is TRUE if a is TRUE or b is TRUE (but not both)


In Boolean algebra XOR is represented by  sign

20
Digital Designs Fundamentals 21

3.4 COMBINATION OF LOGIC GATES


Logic circuit is a system of connected logic gates.
PUMPING WATER EXAMPLE
• If tap is NOT blocked AND the tank is empty AND the pilot light is lit, then
open the main water valve to start pumping water.
b = tap blocked c = tank is empty
p = pilot light lit v = water valve

3.5 HOW TO DETERMINE THE BEHAVIOR OF LOGIC CIRCUITS


1. Given a Logic circuit, how do we determine the behavior of that circuit?
That is for a given set of inputs, what will the output of the circuit be?
2. Given a set of outputs, how do we create a Logic circuit that will satisfy
the outputs?
When analyzing a logic circuit, our goal will be to create a Truth Table.
There are several methods that can be used to accomplish this task. We
will explore two methods:
1) Circuit tracing (the most basic and time consuming approach).
2) Writing a Boolean expression which we will then use to generate a
truth table (recommended method for this class).
METHOD ONE: CIRCUIT TRACING
1. We write out our truth table, leaving the outputs blank.
2. Place the first input combination, from the truth table, onto the inputs of
the circuit and trace the logic outputs through the entire circuit.
3. Place the output result in the truth table and move to the next input
combination.
4. Repeat steps 2 and 3 for all of the input combinations.

21
Digital Designs Fundamentals 22

Example: Trace the following circuit

1. We write out our truth table, leaving the outputs blank.


2. Place the first input combination, from the truth table, onto the inputs of
the circuit and trace the logic through the entire circuit.

3. Place the output result in the truth table and move to the next input
combination.

4. Repeat steps 2 and 3 for all of the input combinations.

22
Digital Designs Fundamentals 23

METHOD TWO: GENERATING A TRUTH TABLE from a derived Boolean


expression (Our preferred approach)
1. Begin by labeling the inputs to the circuit (A, B, C,……).
2. Label the outputs of the first set of gates encountered based on the
inputs.
3. Label the next set of gate outputs based on the previous gate output.
4. Repeat step 3 until you reach the final circuit output, this will be your
circuit derived Boolean expression.
5. Generate a truth table based on the Boolean expression derived for the
circuit.

23
Digital Designs Fundamentals 24

Step 5 generating the truth table


1. Identify the inputs to the Boolean expression.
2. Create a truth table with all possible permutations of the inputs.
3. Determine the outputs using the inputs and your Boolean expression.

Do the following examples as exercise…


Example 1: Find the truth table

Example 2: Find the truth table

24
Digital Designs Fundamentals 25

CONVERTING A TRUTH TABLE TO A LOGIC CIRCUIT


There are several ways that a truth table can be converted into a logic
circuit. But we will focus on the sum of products or minterm method.
A Minterm basically, is the product of n variables in which each variable
appears only once, or a list of all possible permutations of the n variables.
So, for a given logic circuit, there are as many possible minterms as there
are rows in the circuit’s truth table.
This turns out to be a two step process
1) Use minterms to create a Boolean Expression (sum of products) for the
desired circuit.
2) Build a circuit from the Boolean expression
We care about minterms because a Boolean
expression may be constructed by picking out the
minterms of a truth table that evaluate to 1 and
summing them.

STEP ONE: find the minterms and write a Boolean expression


1. Find the rows in the truth table with true (1) results.
2. Determine the minterms for these rows.
3. Create a Boolean expression consisting of the sum of these minterms.

25
Digital Designs Fundamentals 26

STEP TWO: going from the Boolean expression to the Circuit


A product represents the operation of an AND gate.
A sum indicates the operation of an OR gate.
Using AND gates to represent the products, OR gates to represent the
sums, and NOT gates to represent the complimented terms, we can easily
construct our circuit. This approach, when applied correctly, will produce a
working circuit. However, the circuit will not necessarily be the most
efficient

Create a circuit for: F=A’B’+A’B+AB’


1. Start with the product terms (AND Gates)

2. Create the sum, OR the AND gates (3-input OR Gate)

26
Digital Designs Fundamentals 27

3. Create the complemented inputs (NOT Gates).

Example Create a circuit for:


F=A'B'C' BC AC

Example Create a circuit for:

27
Digital Designs Fundamentals 28

PRACTICAL CONSIDERATIONS
What gates really look like

Typical High/Low voltages for TTL (Transistor Transistor Logic) and CMOS
(Complementary Metal Oxide Semiconductor) logic

Vsupply fixed for TTL but for CMOS can be approximately 3 - 18 volts

WHAT YOU SHOULD KNOW


1. Know the Basic Logic Gates symbols and their Truth Tables
2. Know how to create a Truth Table from a circuit
3. Know how to create a circuit from a Truth Table

28
Digital Designs Fundamentals 29

DIGITAL HARDWARE SYSTEMS


Common terms for signals:
Asserted signal:
Asserted signal is a signal that is logically true, or 1.
De-asserted signal:
De-asserted signal is a signal that is logically false, or 0.
Combinational logic:
Combinational logic is a logic system whose blocks do not contain
memory and hence compute the same output based on the given input.
Sequential logic:
Sequential logic is a group of logic elements that contain memory and
hence the value depends on the inputs as well as the current contents of
the memory.

29
Digital Designs Fundamentals 30

30
Digital Designs Fundamentals 31

31

You might also like