1 CSC 205 Chapt 1 To 2 Digital & Hardware
1 CSC 205 Chapt 1 To 2 Digital & Hardware
CSC 205: Introduction to Digital Logic & Computer Hardware (3 Units: LH 30, PH 45)
Course Description
CSC 205: Introduction to Digital Logic & Computer Hardware (3 Units: LH 30, PH 45)
Binary arithmetic operations: addition, subtraction, multiplication, division. Binary point, floating point.
Basic logic gates, symbols, truth tables. Boolean Algebra; Theorems, Minimization methods, Karnaugh
maps (up to to six variables) etc. Computer circuits; diode arrays, PIAs etc, Integrated circuits fabrication
process. Use of MSI, LSI and VLSI IC’ hardware Design. Primary and Secondary memories; core
memory, etc. Magnetic devices; disks, tapes, video disks etc. Peripheral devices; printers, CRT’s,
keyboards, character recognition.
Recommended Texts:
1
Course Outline: Nov, 2023 – February, 2024
Week Day Topic Assignment Reference
1 Listed above
2 No 1
3
4
5
6
7
8
9 No 2
10
11
12
13
14
2
CHAPTER ONE
BINARY ARITHMETIC OPERATIONS
1.1 INTRODUCTION
The decimal number system is the common number system we use in our daily transactions and
other forms of record keeping. This number system is also referred to as base ten and it has ten digits
of numbers ranging from 0 to 9 (i.e. 0,1,2,3,4,5,6,7,8 & 9).
Since computers are electronics devices, they cannot store numbers and letters directly. They can only
store digital electrical signal which are either charged or discharged that is, in one of the two possible
states. And the storage locations in the computer system are divided into cells with each cell capable
of storing one BInary digiT (BIT) which can either be 0 or 1. Because of this convenience of
representing data in 0 (off) and 1 (on) state any character that has to be stored must be identified in
the patterns of 0’s and 1’s.
Other base numbers are ternary (base 3), quaternary (base 4), quinary (base 5), octal (base 8),
duodecimal (base 12) and hexadecimal (base 16). But the relevant base numbers to the concept of data
representation in computer are octal, decimal (denary) and hexadecimal.
Example 1
Convert (10010110) two to decimal
Solution:
Step 1: Position: 76543210
Digits: 10010110
Step 2: (1 * 2 ) +(0 * 2 ) +(0 * 25) +(1 *24) +(0 * 23) + (1 * 22) + (1 * 21) + (0* 20)
7 6
3
So, (100100110) two = 150ten
Another method is the one that follows:
(10010110) two
= 1 0 0 1 0 1 1 0
*2
2+0=2
*2
4+ 0=4
*2
8+1=9
*2
18 + 0 = 18
*2
36 + 1 = 37
*2
74 + 1 = 75
*2
150 + 0 = 150 ten
So, (10010110) two = 150ten
Example 2
Convert (1111001)2 to decimal
Solution:
Step 1: Position: 6543210
Digits: 1111001
Example 3
Convert (150) ten to a number in binary
4
Solution:
Example 4
Convert 87410 to binary
Solution:
Example 5
Add 1111012 and 0011012 together
5
Solution:
Binary Decimal
111101 61
+001101 +1 3
1 0 0 1 0 1 02 7 410
Example 6
Add 1 0 1 1 0 0 and 1 0 0 1 1 using binary system.
Solution:
Binary Decimal
101100 44
+10011 19
1 1 1 1 1 12 6 3 10
Example 7
Subtract 1111 base two from 101101 base two.
Solution:
Binary Decimal
101101 59
- 1111 - 14
11111 31
Example 8
Subtract 10101 from 111011 all in binary number.
Solution:
Binary Decimal
111011 59
- 10101 - 21
100110 38
But when you are subtracting a larger number from a smaller number, the result you will get will be
the 2’s complement. This implies that instead of getting a negative number, we get the 2’s
complement of the negative number.
Example 9
Subtract 101101 from 1111 all in binary
6
Solution:
Binary Decimal
001111 15
-101101 -45
Ignore Carry 1 -30
00010
10
In this binary subtraction, instead of getting -11110 (-30) we get the 2’s complement of 11110, which
is 10.
Complements
The term complement is used by computers to perform subtraction sand to represent negative
numbers. There are two types of complements that are used in binary subtraction: The 1’s
complement and 2’s complement. Also, there are two types of complements in decimal or denary
systems which are 9’s complement and 10’s complement. The reason why complement is used is it is
convenient and efficient with two state devices.
1. One’s Complement
The 1’s complement of a binary number is referred to 9’s complement in the decimal system. In order
to obtain the 1’s complement of a number, each bit is subtracted from 1. For example, the 1’s
complement of 10011 is 0110 while that of 010110 is 101001. One’s complement is also called radix-
minus-one complement (or diminished radix complement).
One of the easiest methods of subtracting binary numbers from each other is the One’s
Complemental Subtraction: The rules for using this method is as follows:
(i) First of all, compute the subtrahend by subtracting each bit from 1.
(ii) Add this complement to the minuend.
(iii) Perform end-around carry of the last bit 0 or 1.
(iv) If there is no end-around carry that is the bit is 0, then the answer must be recoplemented and
a negative sign is attached to it.
(v) And if the end-around carries is 1, then no need for recomplementing. You only add the end-
around carry to the normal digits.
Example 10
Using the 9’s complement subtracts 30964 from 999999 and find its 10’s complement.
Solution:
999999
- 030964
969035 9’ complement
+ 1 Add 1
969036 10’s complement
7
Example 11
Using 1’s complements subtract the binary number 110001 from 011011. Also find the two’s
complement.
Solution:
The question can be rephrased to 010111 – 110000)2
011011 Minuend
+001110 1’s compliment of subtrahend 110001
100101
As seen, there is no end-around carry, so following rule (iv), the answer must be recomplemented to
obtain 011010 and a negative sign attached.
The two’s complement can be obtained by adding 1 to the 1’s complement.
Example 12
Using one’s complements subtract 1011 from 1110 all in binary.
Solution:
1110 Minuend
+0100 1’s complement of subtrahend 1011
10010
+ 1
0011
2. Two’s Complement
The 2’s complement in binary system is called the 10’s complement in the decimal system. In order
to get 2’s complement you add 1 to 1’s complement. i.e. 2’s complement = 1’s complement + 1. Two’s
complement is also referred to as radix complement (true or noughts complement).
Two’s complement subtraction can be used to solve the problem of two’s complement and the
procedures involved are as follows:
(i) First of all find the 2’s complement of the subtrahend.
(ii) Add this complement to the minuend.
(iii) Drop the final carry if it is 1, then the answer is positive and does not need to be
recomplemented.
(iv) If there is no carry, you first of all subtract 1 from the answer then recomplement the result
obtained and attach minus sign to obtain the final answer.
Example 13
Using two’s complement subtract the following binary numbers from each other:
(a) 110101 from 011001
(b) 1011 from 1110
8
Solution:
(a) The question can be rephrased to 011001 - 110101
The 1’s complement of subtrahend 110101 is 001010
3rd rule: From the third rule you drop the final carry if it is 1, then the answer is positive and does not
need to be recomplemented
So, the final answer is 1011two
Solution:
1 0 1
*1 1 0
0 0 0
+1 0 1
1 0 1
1 1 1 1 0
Answer = 11110
Example 15
Divide 11001 by 101 all in binary numbers.
9
Solution:
The divisor is 1112 while the dividend is 110012. The procedure for doing this is the same as that of
the decimal division.
11 0
101 1 1 0 0 1
1 0 1
0 1 1 0
1 0 1
0 1 1
The quotient of 11001 divide by 110 is 1102 while the remainder is 112.
1. Binary Coded Decimal (BCD): This is a 4-bit code used for coding numeric values
only and this 4-bit is used to represent a decimal number. For example, 3 is represented
by 0011. And if a decimal number has more than one digit such as 25, each of the digits
is represented individually by its equivalent 4 bits binary code. The BCD equivalent of
25 will now be 0010 0101.
2. Standard BCD 6-Bit Code: In other to allow the non-numeric characters to be coded
on the BCD 4-bit code, it is extended by two bits.
3. Extended Binary Coded Decimal Interchange Code (EBCDIC): This code is often
pronounced as “Eb-See Dick” and sometimes called “8-bit ASCII”. It is an 8-bit code
without parity, 9th bit can be used for parity. With 8 bits up to 256 characters can be
coded. EBCDIC has code that can represent every number, alphabetic characters or
special characters.
Revision Questions
1. (a) What do you understand by the term coding system?
(b) Briefly explain the following coding systems:
(i) ASCII Code (ii) Binary Coded Decimal (iii) EBCDIC
10
(c) Differentiate between binary and floating-point systems,
2. Using two’s complement, subtract the following binary numbers from each other:
(a) 110101 from 011001 (b) 1011 from 1110
4. Briefly describe the usefulness of the following terms in modern day computers:
(a) Check digit (b) Parity bit (C) Differentiate between a computer structure and its
function.
11
CHAPTER TWO
LOGIC GATES
2.1 INTRODUCTION
This chapter introduces some basic concepts that the reader needs to be familiar with
in order to understand the simplest form of electronic logic. The chapter further
describes the meaning of logic gates, the various types and construction of simple truth
tables.
Eventually, vacuum tubes replaced relays for logic operations. In 1907, Lee De Forest's
modified the vacuum tube to Fleming valve which can be used as AND logic gate. Ludwig
Wittgenstein introduced a version of the 16-row truth table in logic gates and hardware,
as a proposal of Tractatus Logico-Philosophicus in 1921. Claude E. Shannon
introduced the use of Boolean algebra in the analysis and design of switching circuits
in 1937. Walther Bothe, inventor of the coincidence circuit, got part of the 1954 Nobel
Prize in physics, for the first modern electronic AND gate in 1924. Active research is
taking place in molecular logic gates.
A logic gate takes one or more logic-level inputs (binary form) and produces a single
logic-level output of 1 or 0. Because the output is also a logic level an output of one
logic gate can connect to the input of one or more other logic gates. With some types of
logic gates such as those with open-collector outputs, two outputs may be wired to
produce what is known as a wired OR.
The primary application of logic gates is to implement logic in the flow of digital signals
in a digital circuit. The term logic in its ordinary sense is defined as a branch of philosophy
that deals with what is true and false, based on whether other things are true and false.
The fundamental function of logic gates in digital circuits is to determine which outputs
will be true or false, given a set of inputs that can either be true (logic 1) or false (logic
0).
12
The earliest logic gates were mechanically made. But primarily logic gates are
electronically implemented using diodes or transistors and can also be constructed
using electromagnetic relays, fluidics, optics, or even mechanical elements. The
simplest form of electronic logic is diode logic. This allows AND and OR gates to be
built, but not inverters, and so is an incomplete form of logic. In order to build a
complete logic system, valves or transistors can be used. The simplest family of logic
gates using bipolar transistors is called resistor-transistor logic or RTL. For higher
speed, the resistors used in RTL were replaced by diodes leading to diode-transistor
logic, or DTL. Later, it was discovered that one transistor could do the job of one diode,
so transistor-transistor logic or TTL was created. To further reduce the size and power
consumption in some types of chips, the bipolar were replaced with complimentary
field-effect transistors (MOSFETs), thereby resulting in complimentary metal-oxide-
semiconductor (CMOS) logic.
Three of these gates which are AND, OR and NOT are referred to as simple gates,
because they combine to perform complex decision-making process. The complex logic
gates are XOR, NAND, NOR and XNOR. Among all these gates NAND and NOR are the
13
pillars of logic in that all other types of Boolean logic gates (i.e. AND, OR, NOT, XOR
and XNOR) can be created from a suitable network of just NAND or NOR gate. Hence,
these gates NAND and NOR gates are called Universal Gates. The term Boolean as
used in this context is like the common algebra, which deals with manipulation of
expressions to solve or simplify equations, while the expressions used in Boolean
algebra are called Boolean expressions. The details about the seven types of logic gates
are as follows:
1. AND Gate
The AND gate is a logic gate which will give a high output if and only if all its inputs are
high. It symbolizes logical multiplication. The AND gate is so called because if 0 is false
and 1 is true, the gate acts in the same way as the logical ‘and’ operator. This can
further be described as a logic gate that gives an output of ‘1’ only when all of its inputs
are '1'. Thus, its output is '0' whenever at least one of its inputs is '0'. Mathematically,
Q = A · B.
Also, the output Q is true if input A AND input B are both true. An AND gate can have
two or more inputs, its output is true if all inputs are true. AND gate can be represented
with either the traditional or IEC symbol with its truth table shown in Figure 3.
Truth Table
2. OR Gate
The OR gate is a gate which produces a high output of any or both (all) if its inputs are
high. It symbolizes logic addition. The OR gate got its name from the fact that it behaves
after the fashion of the logical inclusive "or." The OR gate gives an output which is "true"
if either or both of the inputs are "true." If both inputs are "false," then the output is
14
"false". Thus, its output is '1' whenever at least one of its inputs is '1'. Mathematically,
Q = A + B (or Q = A OR B).
An OR gate can have two or more inputs; its output is true if at least one input is true.
An OR gate can be represented with either a traditional or IEC symbol as shown in
figure 3.4 with the truth table.
Input A Output, Q
0 1
1 0
Truth Table
Figure 2.5: NOT Gate Symbols
15
4. NOR Gate (NOR = Not OR)
The NOR gate is an OR with a NOT gate at its end. Consequently, for the same
combination of inputs, the output of a NOR gate will be the opposite of that of an OR
gate. Also, a NOR gate can be described as an OR gate with inverted output. A NOR gate
can have two or more inputs and its output is true if no inputs are true. Mathematically,
Q = NOT (A OR B).
16
6. EX-OR Gate (EXclusive-OR)
The EXOR gate is a logic gate that gives an output of 1 when only one of its inputs is 1.
It is like an OR gate but excludes both inputs being true. That is to say the output is
true if inputs A and B are different. EX-OR gate scan only have two inputs.
Mathematically, Q = (A AND NOT B) OR (B AND NOT A)
17
2.6 INPUTS AND OUTPUTS OF A LOGIC GATE
Logic gates have two or more inputs, except a NOT gate which has only one input. All
gates have only one output. Usually the letters A, B, C and so on are used to label
inputs, and Q is used to label the output. On this page the inputs are shown on the left
and the output on the right.
Most books do not distinguish between an AND2 gate and an AND3 gate. They claim an
AND gate is an AND gate, regardless of the number of inputs. While this is actually true,
I subscript it but an AND2 and an AND3 do not have the same truth table. In particular,
an AND2 truth table has 4 rows while an AND3 has 8. While the two truth tables are
related, they still define different functions.
Also, some gate symbols have a circle on their output which means that their functions
include inverting the output. This is equivalent to feeding the output through a NOT
gate. For example, the NAND (Not AND) gate symbol shown on the right is the same as
an AND gate symbol but with the addition of an inverting circle on the output.
The figure below summarizes the output states for all types of 2-input and 3-input
gates, which can be useful if one is trying to select a suitable gate for two or three
inputs.
18
ummary for all 2-input gates Summary for all 3-input
Inputs Output of each gate gates
A B AND NAND OR NOR EX-OR EX-NOR Inputs Output of each gate
0 0 0 1 0 1 0 1 A B C AND NAND OR NOR
0 1 0 1 1 0 1 0 0 0 0 0 1 0 1
1 0 0 1 1 0 1 0 0 0 1 0 1 1 0
1 1 1 0 1 0 0 1 0 1 0 0 1 1 0
0 1 1 0 1 1 0
1 0 0 0 1 1 0
Note that EX-OR and EX-NOR 1 0 1 0 1 1 0
gates can only have 2 inputs.
1 1 0 0 1 1 0
1 1 1 1 0 1 0
However, because logic gates are physical, they have some characteristics that are not
expressed in the truth tables. In particular, gate delay; this describes the amount of
time it takes for the output to change when the input changes. This time is not zero,
thus, one must wait a while for the output to take effect. Real gates have delay. For
example, if one changes the values of the inputs, say from 0 and 0 to 0 and 1, then the
output takes some small amount of time before it changes. This delay is called gate
delay. The delay is due to the fact that information can travel at the speed of light, but
in reality, the time taken for computation is not considerably fast. This delay limits the
speed at which the inputs can change and still give the output a meaningful value.
3. Briefly explain the following logic gates and draw their truth table:
(i) AND gates (ii) OR gates (iii) NOR gates
(iv) NAND gates (v) XOR gates
19