SlideShare a Scribd company logo
1 of 115
ENGIN112 L2: Number Systems September 5, 2003
Number Systems
ENGIN112 L2: Number Systems September 5, 2003
Overview
° The design of computers
• It all starts with numbers
• Building circuits
• Building computing machines
° Digital systems
° Understanding decimal numbers
° Binary and octal numbers
• The basis of computers!
° Conversion between different number systems
ENGIN112 L2: Number Systems September 5, 2003
Digital Computer Systems
° Digital systems consider discrete amounts of data.
° Examples
• 26 letters in the alphabet
• 10 decimal digits
° Larger quantities can be built from discrete values:
• Words made of letters
• Numbers made of decimal digits (e.g. 239875.32)
° Computers operate on binary values (0 and 1)
° Easy to represent binary values electrically
• Voltages and currents.
• Can be implemented using circuits
• Create the building blocks of modern computers
ENGIN112 L2: Number Systems September 5, 2003
Understanding Decimal Numbers
° Decimal numbers are made of decimal digits:
(0,1,2,3,4,5,6,7,8,9)
° But how many items does a decimal number
represent?
• 8653 = 8x103 + 6x102 + 5x101 + 3x100
° What about fractions?
• 97654.35 = 9x104 + 7x103 + 6x102 + 5x101 + 4x100 + 3x10-1 + 5x10-2
• In formal notation -> (97654.35)10
ENGIN112 L2: Number Systems September 5, 2003
Understanding Octal Numbers
° Octal numbers are made of octal digits:
(0,1,2,3,4,5,6,7)
° How many items does an octal number represent?
• (4536)8 = 4x83 + 5x82 + 3x81 + 6x80 = (1362)10
° What about fractions?
• (465.27)8 = 4x82 + 6x81 + 5x80 + 2x8-1 + 7x8-2
° Octal numbers don’t use digits 8 or 9
ENGIN112 L2: Number Systems September 5, 2003
Understanding Binary Numbers
° Binary numbers are made of binary digits (bits):
• 0 and 1
° How many items does an binary number represent?
• (1011)2 = 1x23 + 0x22 + 1x21 + 1x20 = (11)10
° What about fractions?
• (110.10)2 = 1x22 + 1x21 + 0x20 + 1x2-1 + 0x2-2
° Groups of eight bits are called a byte
• (11001001) 2
° Groups of four bits are called a nibble.
• (1101) 2
ENGIN112 L2: Number Systems September 5, 2003
Why Use Binary Numbers?
° Easy to represent 0 and 1 using
electrical values.
° Possible to tolerate noise.
° Easy to transmit data
° Easy to build binary circuits.
AND Gate
1
0
0
ENGIN112 L2: Number Systems September 5, 2003
Conversion Between Number Bases
Decimal(base 10)
Octal(base 8)
Binary(base 2)
Hexadecimal
(base16)
° Learn to convert between bases.
° Already demonstrated how to convert
from binary to decimal.
° Hexadecimal described in next
lecture.
ENGIN112 L2: Number Systems September 5, 2003
Convert an Integer from Decimal to Another Base
1. Divide decimal number by the base (e.g. 2)
2. The remainder is the lowest-order digit
3. Repeat first two steps until no divisor remains.
For each digit position:
Example for (13)10:
Integer
Quotient
13/2 = 6 + ½ a0 = 1
6/2 = 3 + 0 a1 = 0
3/2 = 1 + ½ a2 = 1
1/2 = 0 + ½ a3 = 1
Remainder Coefficient
Answer (13)10 = (a3 a2 a1 a0)2 = (1101)2
ENGIN112 L2: Number Systems September 5, 2003
Convert a Fraction from Decimal to Another Base
1. Multiply decimal number by the base (e.g. 2)
2. The integer is the highest-order digit
3. Repeat first two steps until fraction becomes
zero.
For each digit position:
Example for (0.625)10:
Integer
0.625 x 2 = 1 + 0.25 a-1 = 1
0.250 x 2 = 0 + 0.50 a-2 = 0
0.500 x 2 = 1 + 0 a-3 = 1
Fraction Coefficient
Answer (0.625)10 = (0.a-1 a-2 a-3 )2 = (0.101)2
ENGIN112 L2: Number Systems September 5, 2003
The Growth of Binary Numbers
n 2n
0 20=1
1 21=2
2 22=4
3 23=8
4 24=16
5 25=32
6 26=64
7 27=128
n 2n
8 28=256
9 29=512
10 210=1024
11 211=2048
12 212=4096
20 220=1M
30 230=1G
40 240=1T
Mega
Giga
Tera
ENGIN112 L2: Number Systems September 5, 2003
Binary Addition
° Example of adding two binary numbers…
1 1 1 1 0 1
+ 1 0 1 1 1
---------------------
0
1
0
1
1
1
1
1
1
1 1 0
0
carries
ENGIN112 L2: Number Systems September 5, 2003
Binary Subtraction
° We can also perform subtraction (with borrows in place of
carries).
° Let’s subtract (10111)2 from (1001101)2…
1 10
0 10 10 0 0 10
1 0 0 1 1 0 1
- 1 0 1 1 1
------------------------
1 1 0 1 1 0
borrows
ENGIN112 L2: Number Systems September 5, 2003
Binary Multiplication
° Binary multiplication is much the same as decimal
multiplication, except that the multiplication
operations are much simpler…
1 0 1 1 1
X 1 0 1 0
-----------------------
0 0 0 0 0
1 0 1 1 1
0 0 0 0 0
1 0 1 1 1
-----------------------
1 1 1 0 0 1 1 0
ENGIN112 L2: Number Systems September 5, 2003
Convert an Integer from Decimal to Octal
1. Divide decimal number by the base (8)
2. The remainder is the lowest-order digit
3. Repeat first two steps until no divisor remains.
For each digit position:
Example for (175)10:
Integer
Quotient
175/8 = 21 + 7/8 a0 = 7
21/8 = 2 + 5/8 a1 = 5
2/8 = 0 + 2/8 a2 = 2
Remainder Coefficient
Answer (175)10 = (a2 a1 a0)2 = (257)8
ENGIN112 L2: Number Systems September 5, 2003
Convert an Fraction from Decimal to Octal
1. Multiply decimal number by the base (e.g. 8)
2. The integer is the highest-order digit
3. Repeat first two steps until fraction becomes
zero.
For each digit position:
Example for (0.3125)10:
Integer
0.3125 x 8 = 2 + 5 a-1 = 2
0.5000 x 8 = 4 + 0 a-2 = 4
Fraction Coefficient
Answer (0.3125)10 = (0.24)8
ENGIN112 L2: Number Systems September 5, 2003
Summary
° Binary numbers are made of binary digits (bits)
° Binary and octal number systems
° Conversion between number systems
° Addition, subtraction, and multiplication in binary
ENGIN112 L2: Number Systems September 5, 2003
Overview
° Hexadecimal numbers
• Related to binary and octal numbers
° Conversion between hexadecimal, octal and binary
° Value ranges of numbers
° Representing positive and negative numbers
° Creating the complement of a number
• Make a positive number negative (and vice versa)
ENGIN112 L2: Number Systems September 5, 2003
Understanding Binary Numbers
° Binary numbers are made of binary digits (bits):
• 0 and 1
° How many items does an binary number represent?
• (1011)2 = 1x23 + 0x22 + 1x21 + 1x20 = (11)10
° What about fractions?
• (110.10)2 = 1x22 + 1x21 + 0x20 + 1x2-1 + 0x2-2
° Groups of eight bits are called a byte
• (11001001) 2
° Groups of four bits are called a nibble.
• (1101) 2
ENGIN112 L2: Number Systems September 5, 2003
Understanding Hexadecimal Numbers
° Hexadecimal numbers are made of 16 digits:
• (0,1,2,3,4,5,6,7,8,9,A, B, C, D, E, F)
° How many items does an hex number represent?
• (3A9F)16 = 3x163 + 10x162 + 9x161 + 15x160 = 1499910
° What about fractions?
• (2D3.5)16 = 2x162 + 13x161 + 3x160 + 5x16-1 = 723.312510
° Note that each hexadecimal digit can be represented
with four bits.
• (1110) 2 = (E)16
° Groups of four bits are called a nibble.
• (1110) 2
ENGIN112 L2: Number Systems September 5, 2003
Putting It All Together
° Binary, octal, and
hexadecimal similar
° Easy to build circuits to
operate on these
representations
° Possible to convert
between the three
formats
ENGIN112 L2: Number Systems September 5, 2003
Converting Between Base 16 and Base 2
° Conversion is easy!
 Determine 4-bit value for each hex digit
° Note that there are 24 = 16 different values of four
bits
° Easier to read and write in hexadecimal.
° Representations are equivalent!
3A9F16 = 0011 1010 1001 11112
3 A 9 F
ENGIN112 L2: Number Systems September 5, 2003
Converting Between Base 16 and Base 8
1. Convert from Base 16 to Base 2
2. Regroup bits into groups of three starting from right
3. Ignore leading zeros
4. Each group of three bits forms an octal digit.
352378 = 011 101 010 011 1112
5 2 3 7
3
3A9F16 = 0011 1010 1001 11112
3 A 9 F
ENGIN112 L2: Number Systems September 5, 2003
How To Represent Signed Numbers
• Plus and minus sign used for decimal
numbers: 25 (or +25), -16, etc.
• For computers, desirable to represent
everything as bits.
• Three types of signed binary number
representations: signed magnitude, 1’s
complement, 2’s complement.
• In each case: left-most bit indicates sign:
positive (0) or negative (1).
Consider signed magnitude:
000011002 = 1210
Sign bit Magnitude
100011002 = -1210
Sign bit Magnitude
ENGIN112 L2: Number Systems September 5, 2003
One’s Complement Representation
• The one’s complement of a binary number
involves inverting all bits.
• 1’s comp of 00110011 is 11001100
• 1’s comp of 10101010 is 01010101
• For an n bit number N the 1’s complement is
(2n-1) – N.
• Called diminished radix complement .since 1’s
complement for base (radix 2).
• To find negative of 1’s complement number
take the 1’s complement.
000011002 = 1210
Sign bit Magnitude
111100112 = -1210
Sign bit Magnitude
ENGIN112 L2: Number Systems September 5, 2003
Two’s Complement Representation
• The two’s complement of a binary number
involves inverting all bits and adding 1.
• 2’s comp of 00110011 is 11001101
• 2’s comp of 10101010 is 01010110
• For an n bit number N the 2’s complement is
(2n-1) – N + 1.
• Called radix complement. since 2’s
complement for base (radix 2).
• To find negative of 2’s complement number
take the 2’s complement.
000011002 = 1210
Sign bit Magnitude
111101002 = -1210
Sign bit Magnitude
ENGIN112 L2: Number Systems September 5, 2003
Two’s Complement Shortcuts
° Algorithm 1 – Simply complement each bit and
then add 1 to the result.
• Finding the 2’s complement of (01100101)2 and of its 2’s
complement…
N = 01100101 [N] = 10011011
10011010 01100100
+ 1 + 1
--------------- ---------------
10011011 01100101
° Algorithm 2 – Starting with the least significant bit,
copy all of the bits up to and including the first 1
bit and then complementing the remaining bits.
• N = 0 1 1 0 0 1 0 1
[N] = 1 0 0 1 1 0 1 1
ENGIN112 L2: Number Systems September 5, 2003
Finite Number Representation
° Machines that use 2’s complement arithmetic can
represent integers in the range
-2n-1 <= N <= 2n-1-1
where n is the number of bits available for
representing N. Note that 2n-1-1 = (011..11)2 and
–2n-1 = (100..00)2
oFor 2’s complement more negative numbers than
positive.
oFor 1’s complement two representations for zero.
oFor an n bit number in base (radix) z there are zn
different unsigned values.
(0, 1, …zn-1)
ENGIN112 L2: Number Systems September 5, 2003
1’s Complement Addition
° Using 1’s complement numbers, adding numbers
is easy.
° For example, suppose we wish to add +(1100)2
and +(0001)2.
° Let’s compute (12)10 + (1)10.
• (12)10 = +(1100)2 = 011002 in 1’s comp.
• (1)10 = +(0001)2 = 000012 in 1’s comp. 0 1 1 0 0
+ 0 0 0 0 1
--------------
0 0 1 1 0 1
0
--------------
0 1 1 0 1
Add carry
Final
Result
Step 1: Add binary numbers
Step 2: Add carry to low-order bit
Add
ENGIN112 L2: Number Systems September 5, 2003
1’s Complement Subtraction
° Using 1’s complement numbers, subtracting
numbers is also easy.
° For example, suppose we wish to subtract
+(0001)2 from +(1100)2.
° Let’s compute (12)10 - (1)10.
• (12)10 = +(1100)2 = 011002 in 1’s comp.
• (-1)10 = -(0001)2 = 111102 in 1’s comp.
0 1 1 0 0
- 0 0 0 0 1
--------------
0 1 1 0 0
+ 1 1 1 1 0
--------------
1 0 1 0 1 0
1
--------------
0 1 0 1 1
Add carry
Final
Result
Step 1: Take 1’s complement of 2nd operand
Step 2: Add binary numbers
Step 3: Add carry to low order bit
1’s comp
Add
ENGIN112 L2: Number Systems September 5, 2003
2’s Complement Addition
° Using 2’s complement numbers, adding numbers
is easy.
° For example, suppose we wish to add +(1100)2
and +(0001)2.
° Let’s compute (12)10 + (1)10.
• (12)10 = +(1100)2 = 011002 in 2’s comp.
• (1)10 = +(0001)2 = 000012 in 2’s comp. 0 1 1 0 0
+ 0 0 0 0 1
--------------
0 0 1 1 0 1
Final
Result
Step 1: Add binary numbers
Step 2: Ignore carry bit
Add
Ignore
ENGIN112 L2: Number Systems September 5, 2003
2’s Complement Subtraction
° Using 2’s complement numbers, follow steps for
subtraction
° For example, suppose we wish to subtract
+(0001)2 from +(1100)2.
° Let’s compute (12)10 - (1)10.
• (12)10 = +(1100)2 = 011002 in 2’s comp.
• (-1)10 = -(0001)2 = 111112 in 2’s comp.
0 1 1 0 0
- 0 0 0 0 1
--------------
0 1 1 0 0
+ 1 1 1 1 1
--------------
1 0 1 0 1 1
Final
Result
Step 1: Take 2’s complement of 2nd operand
Step 2: Add binary numbers
Step 3: Ignore carry bit
2’s comp
Add
Ignore
Carry
ENGIN112 L2: Number Systems September 5, 2003
2’s Complement Subtraction: Example #2
° Let’s compute (13)10 – (5)10.
• (13)10 = +(1101)2 = (01101)2
• (-5)10 = -(0101)2 = (11011)2
° Adding these two 5-bit codes…
° Discarding the carry bit, the sign bit is seen to be
zero, indicating a correct result. Indeed,
(01000)2 = +(1000)2 = +(8)10.
0 1 1 0 1
+ 1 1 0 1 1
--------------
1 0 1 0 0 0
carry
ENGIN112 L2: Number Systems September 5, 2003
2’s Complement Subtraction: Example #3
° Let’s compute (5)10 – (12)10.
• (-12)10 = -(1100)2 = (10100)2
• (5)10 = +(0101)2 = (00101)2
° Adding these two 5-bit codes…
° Here, there is no carry bit and the sign bit is 1.
This indicates a negative result, which is what we
expect. (11001)2 = -(7)10.
0 0 1 0 1
+ 1 0 1 0 0
--------------
1 1 0 0 1
ENGIN112 L2: Number Systems September 5, 2003
Summary
° Binary numbers can also be represented in octal and
hexadecimal
° Easy to convert between binary, octal, and hexadecimal
° Signed numbers represented in signed magnitude, 1’s
complement, and 2’s complement
° 2’s complement most important (only 1 representation
for zero).
° Important to understand treatment of sign bit for 1’s
and 2’s complement.
ENGIN112 L2: Number Systems September 5, 2003
Number Codes
ENGIN112 L2: Number Systems September 5, 2003
Overview
° 2’s complement numbers
• Addition and subtraction
° Binary coded decimal
° Gray codes for binary numbers
° ASCII characters
° Moving towards hardware
• Storing data
• Processing data
ENGIN112 L2: Number Systems September 5, 2003
1’s complement
° The ones' complement of a binary number is
defined as the value obtained by inverting all the
bits in the binary representation of the number
(swapping 0s and 1s).
0 0000 1111
1 0001 1110
2 0010 1101
3 0011 1100
4 0100 1011
5 0101 1010
6 0110 1001
7 0111 1000
ENGIN112 L2: Number Systems September 5, 2003
2’s Complement
To get 2’s complement of a binary number, simply
invert the given number and add 1 to the least
significant bit (LSB) of given result.
Binary number 1’s complement 2’s complement
000 111 000
001 110 111
010 101 110
011 100 101
100 011 100
101 010 011
110 001 010
111 000 001
ENGIN112 L2: Number Systems September 5, 2003
2’s Complement Subtraction
° Let’s compute (13)10 - (5)10.
• (13)10 = +(1101)2 = (01101)2
• (-5)10 = -(0101)2 = (11011)2
° Adding these two 5-bit codes…
° Discarding the carry bit, the sign bit is seen to be
zero, indicating a correct result.
0 1 1 0 1
+ 1 1 0 1 1
--------------
1 0 1 0 0 0
carry
ENGIN112 L2: Number Systems September 5, 2003
2’s Complement Subtraction
° Let’s compute (5)10 – (12)10.
• (-12)10 = -(1100)2 = (10100)2
• (5)10 = +(0101)2 = (00101)2
° Adding these two 5-bit codes…
° Here, there is no carry bit and the sign bit is 1.
This indicates a negative result, which is what we
expect. (11001)2 = -(7)10.
° Numbers in hexadecimal
0 0 1 0 1
+ 1 0 1 0 0
--------------
1 1 0 0 1
ENGIN112 L2: Number Systems September 5, 2003
Binary codes
ENGIN112 L2: Number Systems September 5, 2003
Binary Coded Decimal Code
° Binary coded decimal (BCD) represents each decimal
digit with four bits
• Ex. 0011 0010 1001 = 32910
° This is NOT the same as 0011001010012
° BCD code is a class of binary encodings of decimal
numbers where each decimal digit is represented by
four number of bits.
Digit BCD
Code
Digit BCD
Code
0 0000 5 0101
1 0001 6 0110
2 0010 7 0111
3 0011 8 1000
4 0100 9 1001
3 2 9
ENGIN112 L2: Number Systems September 5, 2003
Putting It All Together
° BCD not very efficient
° Used in early
computers (40s, 50s)
° Used to encode
numbers for seven-
segment displays.
ENGIN112 L2: Number Systems September 5, 2003
Gray Code
The gray code is an ordering of the binary numeral system
such that two successive values differ in only one bit(binary
digit).
The advantage of the Gray code over the straight binary
number sequence is that only one bit in the code group
changes in going from one number to the next.
For example,
in going from 7 to 8, the Gray code changes from 0100 to
1100. Only the first bit changes, from 0 to 1; the other three
bits remain the same. By contrast, with binary numbers the
change from 7 to 8 will be from 0111 to 1000, which causes all
four bits to change values.
ENGIN112 L2: Number Systems September 5, 2003
Gray Code
° Gray code is not a number system.
• It is an alternate way to represent four
bit data
° Only one bit changes from one
decimal digit to the next
° Useful for reducing errors in
communication.
° Can be scaled to larger numbers.
° It is a non-weighted code and it is
not arithmetic codes. That means
there are no specific weights
assigned to the bit position.
Digit Binary Gray
Code
0 0000 0000
1 0001 0001
2 0010 0011
3 0011 0010
4 0100 0110
5 0101 0111
6 0110 0101
7 0111 0100
8 1000 1100
9 1001 1101
10 1010 1111
11 1011 1110
12 1100 1010
13 1101 1011
14 1110 1001
15 1111 1000
ENGIN112 L2: Number Systems September 5, 2003
Application of the Gray code
° The reflected binary code or gray code was
originally designed to prevent spurious output from
electromechanical switches.
° Today, Gray codes are widely used to facilitate
error correction in digital communications such as
digital terrestrial television and some cable TV
systems.
ENGIN112 L2: Number Systems September 5, 2003
ASCII Code
Many applications of digital computers require the
handling not only of numbers, but also of other characters
or symbols, such as the letters of the alphabet. For
instance, consider a high‐tech company with thousands of
employees. To represent the names and other pertinent
information, it is necessary to formulate a binary code for
the letters of the alphabet.
The standard binary code for the alphanumeric characters
is the American Standard Code for Information Interchange
(ASCII), which uses seven bits to code 128 characters
ENGIN112 L2: Number Systems September 5, 2003
ASCII Code
° American Standard Code for Information
Interchange
° ASCII is a 7-bit code, frequently used with an 8th bit
for error detection (more about that in a bit).
Character ASCII (bin) ASCII (hex) Decimal Octal
A 1000001 41 65 101
B 1000010 42 66 102
C 1000011 43 67 103
…
Z
a
…
1
‘
ENGIN112 L2: Number Systems September 5, 2003
ASCII Codes and Data Transmission
° ASCII Codes
° A – Z (26 codes), a – z (26 codes)
° 0-9 (10 codes), others (@#$%^&*….)
° Transmission susceptible to noise
° Typical transmission rates (1500 Kbps, 56.6 Kbps)
° How to keep data transmission accurate?
ENGIN112 L2: Number Systems September 5, 2003
Parity bit
° A parity bit, or check bit, is a bit added to a string of
binary code to ensure that the total number of 1-
bits in the string is even or odd. Parity bits are used
as the simplest form of error detecting code.
° There are two variants of parity bits: even parity bit
and odd parity bit.
ENGIN112 L2: Number Systems September 5, 2003
° In the case of even parity, for a given set of bits, the
occurrences of bits whose value is 1 is counted. If
that count is odd, the parity bit value is set to 1,
making the total count of occurrences of 1s in the
whole set (including the parity bit) an even number.
If the count of 1s in a given set of bits is already
even, the parity bit's value is 0.
° In the case of odd parity, the coding is reversed. For
a given set of bits, if the count of bits with a value of
1 is even, the parity bit value is set to 1 making the
total count of 1s in the whole set (including the
parity bit) an odd number. If the count of bits with a
value of 1 is odd, the count is already odd so the
parity bit's value is 0.
ENGIN112 L2: Number Systems September 5, 2003
Parity Codes
° Parity codes are formed by concatenating a parity
bit, P to each code word of C.
° In an odd-parity code, the parity bit is specified so
that the total number of ones is odd.
° In an even-parity code, the parity bit is specified
so that the total number of ones is even.
Information Bits
P
1 1 0 0 0 0 1 1

Added even parity bit
0 1 0 0 0 0 1 1

Added odd parity bit
ENGIN112 L2: Number Systems September 5, 2003
Parity Code Example
° Concatenate a parity bit to the ASCII code for the
characters 0, X, and = to produce both odd-parity
and even-parity codes.
Character ASCII Odd-Parity
ASCII
Even-Parity
ASCII
0 0110000 10110000 00110000
X 1011000 01011000 11011000
= 0111100 10111100 00111100
ENGIN112 L2: Number Systems September 5, 2003
Binary Data Storage
• Binary cells store individual bits of data
• Multiple cells form a register.
• Data in registers can indicate different values
• Hex (decimal)
• BCD
• ASCII
Binary Cell
0 0 1 0 1 0 1 1
ENGIN112 L2: Number Systems September 5, 2003
ENGIN112 L2: Number Systems September 5, 2003
circuit that generates parity bit from four message bits
ENGIN112 L2: Number Systems September 5, 2003
Basic Logic Gates
© Alan T. Pinck / Algonquin College; 2003
ENGIN112 L2: Number Systems September 5, 2003
Logic Gates
° a logic gate is a physical device implementing a
Boolean function;
° that is, it performs a logical operation on one or
more binary inputs and produces a single binary
output.
ENGIN112 L2: Number Systems September 5, 2003
° Logic operations include any operations that
manipulate Boolean values.
° Boolean values are either true or false. They are
named after English mathematician George Boole,
who invented Boolean algebra,
ENGIN112 L2: Number Systems September 5, 2003
Describing Circuit Functionality: Inverter
° Basic logic functions have symbols.
° The same functionality can be represented with truth
tables.
• Truth table completely specifies outputs for all input combinations.
° The Output signal from a NOT gate is True (on, 1) if and
only if the Input signal is False.
° The Output signal from a NOT gate is False (off, 0) if
and only if the Input signal is True.
A Y
0 1
1 0
Input Output
A Y
Symbol
Truth Table
ENGIN112 L2: Number Systems September 5, 2003
The AND Gate
° The Output signal from an AND
gate is True (on, 1) if and only if
both Input signals are True (on,
1).
° The Output signal from an AND
gate is False (off, 0), otherwise.
A B Y
0 0 0
0 1 0
1 0 0
1 1 1
A
B
Y
Truth Table
ENGIN112 L2: Number Systems September 5, 2003
The OR Gate
° The Output signal from an OR
gate is True (on, 1) if either, or
both, Input signals are True (on,
1).
° The Output signal from an OR
gate is False (off, 0) if and only if
both Input signals are False (off,
0).
A B Y
0 0 0
0 1 1
1 0 1
1 1 1
A
B
Y
ENGIN112 L2: Number Systems September 5, 2003
Describing Circuit Functionality: Waveforms
° Waveforms provide another approach for representing
functionality.
° Values are either high (logic 1) or low (logic 0).
° Can you create a truth table from the waveforms?
A B Y
0 0 0
0 1 0
1 0 0
1 1 1
AND Gate
ENGIN112 L2: Number Systems September 5, 2003
Logic Gates : NOT combined with other gates
° Note that in the “classic: electronic
engineering form, it is really the “bubble”
that indicates the NOT activity.
ENGIN112 L2: Number Systems September 5, 2003
Consider three-input gates
3 Input OR Gate
ENGIN112 L2: Number Systems September 5, 2003
Ordering Boolean Functions
° How to interpret AB+C?
• Is it AB ORed with C ?
• Is it A ANDed with B+C ?
° Order of precedence for Boolean algebra: AND
before OR.
° Note that parentheses are needed here :
ENGIN112 L2: Number Systems September 5, 2003
Boolean Algebra
° A Boolean algebra is defined as a closed algebraic
system containing a set K or two or more elements
and the two operators, . and +.
° Useful for identifying and minimizing circuit
functionality
° Identity elements
a + 0 = a
a . 1 = a
° 0 is the identity element for the + operation.
° 1 is the identity element for the . operation.
ENGIN112 L2: Number Systems September 5, 2003
Commutativity and Associativity of the Operators
° The Commutative Property:
° a binary operation is commutative if changing the order of
the operands does not change the result.
For every a and b in K,
a + b = b + a
a . b = b . a
° The Associative Property:
° Within an expression containing two or more occurrences
in a row of the same associative operator, the order in
which the operations are performed does not matter as
long as the sequence of the operands is not changed.
For every a, b, and c in K,
a + (b + c) = (a + b) + c
a . (b . c) = (a . b) . c
ENGIN112 L2: Number Systems September 5, 2003
Distributivity of the Operators and Complements
° The Distributive Property:
For every a, b, and c in K,
• a + ( b . c ) = ( a + b ) . ( a + c )
• a . ( b + c ) = ( a . b ) + ( a . c )
° The Existence of the Complement:
For every a in K there exists a unique element
called a’ (complement of a) such that,
• a + a’ = 1
• a . a’ = 0
° To simplify notation, the . operator is frequently
omitted. When two elements are written next to
each other, the AND (.) operator is implied…
• a + b . c = ( a + b ) . ( a + c )
• a + bc = ( a + b )( a + c )
ENGIN112 L2: Number Systems September 5, 2003
Duality
° The principle of duality is an important concept.
This says that if an expression is valid in Boolean
algebra, the dual of that expression is also valid.
° To form the dual of an expression, replace all +
operators with . operators, all . operators with +
operators, all ones with zeros, and all zeros with
ones.
° Form the dual of the expression
a + (bc) = (a + b)(a + c)
° Following the replacement rules…
a(b + c) = ab + ac
° Take care not to alter the location of the
parentheses if they are present.
ENGIN112 L2: Number Systems September 5, 2003
Involution
° This theorem states:
a’’ = a
° Remember that aa’ = 0 and a+a’=1.
• Therefore, a’ is the complement of a and a is also the
complement of a’.
• As the complement of a’ is unique, it follows that a’’=a.
° Taking the double inverse of a value will give the
initial value.
ENGIN112 L2: Number Systems September 5, 2003
Absorption
° This theorem states:
a + ab = a a(a+b) = a
° To prove the first half of this theorem:
a + ab = a . 1 + ab
= a (1 + b)
= a (b + 1)
= a (1)
a + ab= a
ENGIN112 L2: Number Systems September 5, 2003
DeMorgan’s Theorem
° A key theorem in simplifying Boolean algebra
expression is DeMorgan’s Theorem. It states:
(a + b)’ = a’b’ (ab)’ = a’ + b’
° Complement the expression
a(b + z(x + a’)) and simplify.
(a(b+z(x + a’)))’ = a’ + (b + z(x + a’))’
= a’ + b’(z(x + a’))’
= a’ + b’(z’ + (x + a’)’)
= a’ + b’(z’ + x’a’’)
= a’ + b’(z’ + x’a)
ENGIN112 L2: Number Systems September 5, 2003
Basic theorems
ENGIN112 L2: Number Systems September 5, 2003
Summary
° Basic logic functions can be made from AND, OR,
and NOT (invert) functions
° The behavior of digital circuits can be represented
with waveforms, truth tables, or symbols
° Primitive gates can be combined to form larger
circuits
° Boolean algebra defines how binary variables can
be combined
° Rules for associativity, commutativity, and
distribution are similar to algebra
° DeMorgan’s rules are important.
• Will allow us to reduce circuit sizes.
ENGIN112 L2: Number Systems September 5, 2003
Overview
° Expressing Boolean functions
° Relationships between algebraic equations, symbols,
and truth tables
° Simplification of Boolean expressions
° Minterms and Maxterms
° AND-OR representations
• Product of sums
• Sum of products
ENGIN112 L2: Number Systems September 5, 2003
Boolean Functions
° Boolean algebra deals with binary variables and
logic operations.
° Function results in binary 0 or 1
x
0
0
0
0
1
1
1
1
y
0
0
1
1
0
0
1
1
z
0
1
0
1
0
1
0
1
F
0
0
0
0
1
0
1
1 F = x(y+z’)
x
y
z
z’
y+z’ F = x(y+z’)
ENGIN112 L2: Number Systems September 5, 2003
Boolean Functions
° Boolean algebra deals with binary variables and
logic operations.
° Function results in binary 0 or 1
x
0
0
0
0
1
1
1
1
y
0
0
1
1
0
0
1
1
z
0
1
0
1
0
1
0
1
xy
0
0
0
0
0
0
1
1
x
y
z
G = xy +yz
yz
xy
We will learn how to transition between equation,
symbols, and truth table.
yz
0
0
0
1
0
0
0
1
G
0
0
0
1
0
0
1
1
ENGIN112 L2: Number Systems September 5, 2003
Representation Conversion
° Need to transition between boolean expression,
truth table, and circuit (symbols).
° Converting between truth table and expression is
easy.
° Converting between expression and circuit is
easy.
° More difficult to convert to truth table.
Truth
Table
Circuit Boolean
Expression
ENGIN112 L2: Number Systems September 5, 2003
Truth Table to Expression
° Converting a truth table to an expression
• Each row with output of 1 becomes a product term
• Sum product terms together.
x
0
0
0
0
1
1
1
1
y
0
0
1
1
0
0
1
1
z
0
1
0
1
0
1
0
1
G
0
0
0
1
0
0
1
1
xyz + xyz’ + x’yz
Any Boolean Expression can be
represented in sum of products form!
ENGIN112 L2: Number Systems September 5, 2003
Equivalent Representations of Circuits
° All three formats are equivalent
° Number of 1’s in truth table output column equals AND
terms for Sum-of-Products (SOP)
x y z
x
0
0
0
0
1
1
1
1
y
0
0
1
1
0
0
1
1
z
0
1
0
1
0
1
0
1
G
0
0
0
1
0
0
1
1
G = xyz + xyz’ + x’yz
G
x x
x
x
x
x
x
x
x
ENGIN112 L2: Number Systems September 5, 2003
Reducing Boolean Expressions 1
° Is this the smallest possible implementation of
this expression? No!
° Use Boolean Algebra rules to reduce complexity
while preserving functionality.
° Step 1: Use Theorum 1 (a + a = a)
• So xyz + xyz’ + xy’z’ = xyz + xyz’ + xyz’ + xy’z’
° Step 2: Use distributive rule a(b + c) = ab + ac
• So xyz + xyz’ + xyz’ + xy’z’ = xy(z + z’) + xz’(y + y’)
° Step 3: Use Postulate 3 (a + a’ = 1)
• So xy(z + z’) + xz’(y + y’) = xy.1 + xz’.1
° Step 4: Use Postulate 2 (a . 1 = a)
• So xy.1 + xz’.1 = xy + xz’ = xyz + xyz’ + xy’z’
G = xyz + xyz’ + xy’z’
ENGIN112 L2: Number Systems September 5, 2003
Reducing Boolean Expressions 2
° Is this the smallest possible implementation of
this expression? No!
° Use Boolean Algebra rules to reduce complexity
while preserving functionality.
° Step 1: Use Theorum 1 (a + a = a)
• So xyz + xyz’ + x’yz = xyz + xyz + xyz’ + x’yz
° Step 2: Use distributive rule a(b + c) = ab + ac
• So xyz + xyz + xyz’ + x’yz = xy(z + z’) + yz(x + x’)
° Step 3: Use Postulate 3 (a + a’ = 1)
• So xy(z + z’) + yz(x + x’) = xy.1 + yz.1
° Step 4: Use Postulate 2 (a . 1 = a)
• So xy.1 + yz.1 = xy + yz = xyz + xyz’ + x’yz
G = xyz + xyz’ + x’yz
ENGIN112 L2: Number Systems September 5, 2003
Reduced Hardware Implementation
° Reduced equation requires less hardware!
° Same function implemented!
x y z
x
0
0
0
0
1
1
1
1
y
0
0
1
1
0
0
1
1
z
0
1
0
1
0
1
0
1
G
0
0
0
1
0
0
1
1
G = xyz + xyz’ + x’yz = xy + yz
G
x x
x
x
ENGIN112 L2: Number Systems September 5, 2003
Minterms and Maxterms (POS AND SOP Forms
° Each variable in a Boolean expression is a literal
° Boolean variables can appear in normal (x) or
complement form (x’)
° Each AND combination of terms is a minterm
° Each OR combination of terms is a maxterm
For example:
Minterms
x y z Minterm
0 0 0 x’y’z’ m0
0 0 1 x’y’z m1
…
1 0 0 xy’z’ m4
…
1 1 1 xyz m7
For example:
Maxterms
x y z Maxterm
0 0 0 x+y+z M0
0 0 1 x+y+z’ M1
…
1 0 0 x’+y+z M4
…
1 1 1 x’+y’+z’ M7
ENGIN112 L2: Number Systems September 5, 2003
Representing Functions with Minterms
° Minterm number same as row position in truth table
(starting from top from 0)
° Shorthand way to represent functions
x
0
0
0
0
1
1
1
1
y
0
0
1
1
0
0
1
1
z
0
1
0
1
0
1
0
1
G
0
0
0
1
0
0
1
1
G = xyz + xyz’ + x’yz
G = m7 + m6 + m3 = Σ(3, 6, 7)
ENGIN112 L2: Number Systems September 5, 2003
Complementing Functions
° Minterm number same as row position in truth table
(starting from top from 0)
° Shorthand way to represent functions
x
0
0
0
0
1
1
1
1
y
0
0
1
1
0
0
1
1
z
0
1
0
1
0
1
0
1
G
0
0
0
1
0
0
1
1
G = xyz + xyz’ + x’yz
G’ = (xyz + xyz’ + x’yz)’ =
G’
1
1
1
0
1
1
0
0
ENGIN112 L2: Number Systems September 5, 2003
Truth table representing minterm and maxterm
ENGIN112 L2: Number Systems September 5, 2003
Canonical Form
° In Boolean algebra,Boolean function can be
expressed as Canonical Disjunctive Normal Form
known as minterm and some are expressed as
Canonical Conjunctive Normal Form known as maxterm
.
° In Minterm, we look for the functions where the output
results in “1” while in Maxterm we look for function
where the output results in “0”.
° We perform Sum of minterm also known as Sum of
products (SOP) .
° We perform Product of Maxterm also known as Product
of sum (POS).
° Boolean functions expressed as a sum of product
form(minterm) or product of sum form(maxterm) are
said to be in canonical form.
ENGIN112 L2: Number Systems September 5, 2003
Standard Form
A Boolean variable can be expressed in either true form or
complemented form.
In standard form Boolean function will contain all the
variables in either true form or complemented form
while in canonical form number of variables depends on
the output of SOP or POS.
ENGIN112 L2: Number Systems September 5, 2003
A Boolean function can be expressed algebraically
from a given truth table by forming a :
minterm for each combination of the variables that
produces a 1 in the function and then taking the OR
of all those terms.
maxterm for each combination of the variables that
produces a 0 in the function and then taking the AND
of all those terms
ENGIN112 L2: Number Systems September 5, 2003
Complementing Functions
° Step 1: assign temporary names
• b + c -> z
• (a + z)’ = G’
° Step 2: Use DeMorgans’ Law
• (a + z)’ = a’ . z’
° Step 3: Resubstitute (b+c) for z
• a’ . z’ = a’ . (b + c)’
° Step 4: Use DeMorgans’ Law
• a’ . (b + c)’ = a’ . (b’. c’)
° Step 5: Associative rule
• a’ . (b’. c’) = a’ . b’ . c’
G’ = (a + b + c)’
G = a + b + c
G’ = a’ . b’ . c’ = a’b’c’
G = a + b + c
ENGIN112 L2: Number Systems September 5, 2003
Complementation Example
° Find complement of F = x’z + yz
• F’ = (x’z + yz)’
° DeMorgan’s
• F’ = (x’z)’ (yz)’
° DeMorgan’s
• F’ = (x’’+z’)(y’+z’)
° Reduction -> eliminate double negation on x
• F’ = (x+z’)(y’+z’)
This format is called product of sums
ENGIN112 L2: Number Systems September 5, 2003
Conversion Between Canonical Forms
° Easy to convert between minterm and maxterm
representations
° For maxterm representation, select rows with 0’s
x
0
0
0
0
1
1
1
1
y
0
0
1
1
0
0
1
1
z
0
1
0
1
0
1
0
1
G
0
0
0
1
0
0
1
1
G = xyz + xyz’ + x’yz
G = m7 + m6 + m3 = Σ(3, 6, 7)
G = M0M1M2M4M5 = Π(0,1,2,4,5)
G = (x+y+z)(x+y+z’)(x+y’+z)(x’+y+z)(x’+y+z’)
ENGIN112 L2: Number Systems September 5, 2003
Representation of Circuits
° All logic expressions can be represented in 2-
level format
° Circuits can be reduced to minimal 2-level
representation
° Sum of products representation most common in
industry.
ENGIN112 L2: Number Systems September 5, 2003
Summary
° Truth table, circuit, and boolean expression formats
are equivalent
° Easy to translate truth table to SOP and POS
representation
° Boolean algebra rules can be used to reduce circuit
size while maintaining function
° All logic functions can be made from AND, OR, and
NOT
° Easiest way to understand: Do examples!
° Next time: More logic gates!
ENGIN112 L2: Number Systems September 5, 2003
The NAND Gate
° This is a NAND gate. It is a combination of an
AND gate followed by an inverter. Its truth table
shows this…
° NAND gates have several interesting properties…
• NAND(a,a)=(aa)’ = a’ = NOT(a)
• NAND’(a,b)=(ab)’’ = ab = AND(a,b)
• NAND(a’,b’)=(a’b’)’ = a+b = OR(a,b)
A B Y
0 0 1
0 1 1
1 0 1
1 1 0
A
B
Y
ENGIN112 L2: Number Systems September 5, 2003
The NAND Gate
° These three properties show that a NAND gate with both
of its inputs driven by the same signal is equivalent to a
NOT gate
° A NAND gate whose output is complemented is
equivalent to an AND gate, and a NAND gate with
complemented inputs acts as an OR gate.
° Therefore, we can use a NAND gate to implement all three
of the elementary operators (AND,OR,NOT).
° Therefore, ANY switching function can be constructed using
only NAND gates. Such a gate is said to be primitive or
functionally complete or UNIVERSAL GATE.
ENGIN112 L2: Number Systems September 5, 2003
A
Y
A
B
Y
Y
A
B
NOT Gate
AND Gate
OR Gate
NAND Gates into Other Gates
(what are these circuits?)
ENGIN112 L2: Number Systems September 5, 2003
The NOR Gate
° This is a NOR gate. It is a combination of an OR
gate followed by an inverter. It’s truth table shows
this…
° NOR gates also have several
interesting properties…
• NOR(a,a)=(a+a)’ = a’ = NOT(a)
• NOR’(a,b)=(a+b)’’ = a+b = OR(a,b)
• NOR(a’,b’)=(a’+b’)’ = ab = AND(a,b)
A B Y
0 0 1
0 1 0
1 0 0
1 1 0
A
B
Y
ENGIN112 L2: Number Systems September 5, 2003
Functionally Complete Gates
° Just like the NAND gate, the NOR gate is
functionally complete…any logic function can be
implemented using just NOR gates.
° Both NAND and NOR gates are very valuable as
any design can be realized using either one.
° It is easier to build an IC chip using all NAND or
NOR gates than to combine AND,OR, and NOT
gates.
° NAND/NOR gates are typically faster at switching
and cheaper to produce.
ENGIN112 L2: Number Systems September 5, 2003
NOT Gate
OR Gate
AND Gate
NOR Gates into Other Gates
A
Y
Y
A
B
A
B
Y
ENGIN112 L2: Number Systems September 5, 2003
The XOR Gate (Exclusive-OR)
° This is a XOR gate.
° XOR gates assert their output
when exactly one of the inputs
is asserted, hence the name.
° The switching algebra symbol
for this operation is , i.e.
1  1 = 0 and 1  0 = 1.
A B Y
0 0 0
0 1 1
1 0 1
1 1 0
A
B
Y
ENGIN112 L2: Number Systems September 5, 2003
The XNOR Gate
° This is a XNOR gate.
° This functions as an
exclusive-NOR gate, or
simply the complement of
the XOR gate.
° The switching algebra symbol
for this operation is , i.e.
1  1 = 1 and 1  0 = 0.
A B Y
0 0 1
0 1 0
1 0 0
1 1 1
A
B
Y
ENGIN112 L2: Number Systems September 5, 2003
NOR Gate Equivalence
° NOR Symbol, Equivalent Circuit, Truth Table
ENGIN112 L2: Number Systems September 5, 2003
DeMorgan’s Theorem
° The theorem explains that the complement of the product
of all the terms is equal to the sum of the complement of
each term. Likewise, the complement of the sum of all the
terms is equal to the product of the complement of each
term. ie
(a + b)’ = a’b’ (ab)’ = a’ + b’
° Complement the expression
a(b + z(x + a’)) and simplify.
(a(b+z(x + a’)))’ = a’ + (b + z(x + a’))’
= a’ + b’(z(x + a’))’
= a’ + b’(z’ + (x + a’)’)
= a’ + b’(z’ + x’a’’)
= a’ + b’(z’ + x’a)
ENGIN112 L2: Number Systems September 5, 2003
Example
° Determine the output expression for the below
circuit and simplify it using DeMorgan’s Theorem
ENGIN112 L2: Number Systems September 5, 2003
A universal gate is a gate which can implement any Boolean
function without need to use any other gate type.
The NAND and NOR gates are universal gates.
In practice, this is advantageous since NAND and NOR gates
are economical and easier to fabricate and are the basic gates
used in all IC digital logic families.
universal gate
ENGIN112 L2: Number Systems September 5, 2003
Universality of NAND and NOR gates
ENGIN112 L2: Number Systems September 5, 2003
Universality of NOR gate
° Equivalent representations of the AND, OR, and
NOT gates
ENGIN112 L2: Number Systems September 5, 2003
Example
ENGIN112 L2: Number Systems September 5, 2003
Interpretation of the two NAND gate symbols
° Determine the output expression for circuit via
DeMorgan’s Theorem
ENGIN112 L2: Number Systems September 5, 2003
Interpretation of the two OR gate symbols
° Determine the output expression for circuit via
DeMorgan’s Theorem
ENGIN112 L2: Number Systems September 5, 2003
Summary
° Basic logic functions can be made from NAND, and
NOR functions
° The behavior of digital circuits can be represented
with waveforms, truth tables, or symbols
° Primitive gates can be combined to form larger
circuits
° Boolean algebra defines how binary variables with
NAND, NOR can be combined
° DeMorgan’s rules are important.
• Allow conversion to NAND/NOR representations

More Related Content

Similar to Module I - Digital Systems & Logic Gates.ppt

12.Representation of signed binary numbers. Binary codes - BCD code, Gray co...
12.Representation of signed binary numbers.  Binary codes - BCD code, Gray co...12.Representation of signed binary numbers.  Binary codes - BCD code, Gray co...
12.Representation of signed binary numbers. Binary codes - BCD code, Gray co...JatinJatin30
 
1. NUMBER SYSTEM.pptx Computer Applications in Pharmacy
1. NUMBER SYSTEM.pptx Computer Applications in Pharmacy1. NUMBER SYSTEM.pptx Computer Applications in Pharmacy
1. NUMBER SYSTEM.pptx Computer Applications in PharmacyVedika Narvekar
 
Chapter 1 digital systems and binary numbers
Chapter 1 digital systems and binary numbersChapter 1 digital systems and binary numbers
Chapter 1 digital systems and binary numbersMohammad Bashartullah
 
B sc cs i bo-de u-i number system
B sc cs i bo-de u-i number systemB sc cs i bo-de u-i number system
B sc cs i bo-de u-i number systemRai University
 
Logic Design 2009
Logic Design 2009Logic Design 2009
Logic Design 2009lionking
 
Lesson4.1 u4 l1 binary representation
Lesson4.1 u4 l1 binary representationLesson4.1 u4 l1 binary representation
Lesson4.1 u4 l1 binary representationLexume1
 
Chapter two FHI.pptx
Chapter two FHI.pptxChapter two FHI.pptx
Chapter two FHI.pptxODAATUBE1
 
UNIT - I.pptx
UNIT - I.pptxUNIT - I.pptx
UNIT - I.pptxamudhak10
 
UNIT - I.pptx
UNIT - I.pptxUNIT - I.pptx
UNIT - I.pptxamudhak10
 
21EC201– Digital Principles and system design.pptx
21EC201– Digital Principles and system design.pptx21EC201– Digital Principles and system design.pptx
21EC201– Digital Principles and system design.pptxGobinathAECEJRF1101
 

Similar to Module I - Digital Systems & Logic Gates.ppt (20)

Okkkkk
OkkkkkOkkkkk
Okkkkk
 
12.Representation of signed binary numbers. Binary codes - BCD code, Gray co...
12.Representation of signed binary numbers.  Binary codes - BCD code, Gray co...12.Representation of signed binary numbers.  Binary codes - BCD code, Gray co...
12.Representation of signed binary numbers. Binary codes - BCD code, Gray co...
 
Cit 1101 lec 02
Cit 1101 lec 02Cit 1101 lec 02
Cit 1101 lec 02
 
1. NUMBER SYSTEM.pptx Computer Applications in Pharmacy
1. NUMBER SYSTEM.pptx Computer Applications in Pharmacy1. NUMBER SYSTEM.pptx Computer Applications in Pharmacy
1. NUMBER SYSTEM.pptx Computer Applications in Pharmacy
 
Number Systems.ppt
Number Systems.pptNumber Systems.ppt
Number Systems.ppt
 
Number system
Number systemNumber system
Number system
 
DLD-Introduction.pptx
DLD-Introduction.pptxDLD-Introduction.pptx
DLD-Introduction.pptx
 
Chapter 1 digital systems and binary numbers
Chapter 1 digital systems and binary numbersChapter 1 digital systems and binary numbers
Chapter 1 digital systems and binary numbers
 
B sc cs i bo-de u-i number system
B sc cs i bo-de u-i number systemB sc cs i bo-de u-i number system
B sc cs i bo-de u-i number system
 
Logic Design 2009
Logic Design 2009Logic Design 2009
Logic Design 2009
 
Digital electronics
Digital electronicsDigital electronics
Digital electronics
 
Alu1
Alu1Alu1
Alu1
 
Number system
Number systemNumber system
Number system
 
Lesson4.1 u4 l1 binary representation
Lesson4.1 u4 l1 binary representationLesson4.1 u4 l1 binary representation
Lesson4.1 u4 l1 binary representation
 
Chapter two FHI.pptx
Chapter two FHI.pptxChapter two FHI.pptx
Chapter two FHI.pptx
 
UNIT - I.pptx
UNIT - I.pptxUNIT - I.pptx
UNIT - I.pptx
 
UNIT - I.pptx
UNIT - I.pptxUNIT - I.pptx
UNIT - I.pptx
 
DCF QNA edited
DCF QNA editedDCF QNA edited
DCF QNA edited
 
21EC201– Digital Principles and system design.pptx
21EC201– Digital Principles and system design.pptx21EC201– Digital Principles and system design.pptx
21EC201– Digital Principles and system design.pptx
 
Module 4
Module 4Module 4
Module 4
 

Recently uploaded

SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 

Recently uploaded (20)

SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 

Module I - Digital Systems & Logic Gates.ppt

  • 1. ENGIN112 L2: Number Systems September 5, 2003 Number Systems
  • 2. ENGIN112 L2: Number Systems September 5, 2003 Overview ° The design of computers • It all starts with numbers • Building circuits • Building computing machines ° Digital systems ° Understanding decimal numbers ° Binary and octal numbers • The basis of computers! ° Conversion between different number systems
  • 3. ENGIN112 L2: Number Systems September 5, 2003 Digital Computer Systems ° Digital systems consider discrete amounts of data. ° Examples • 26 letters in the alphabet • 10 decimal digits ° Larger quantities can be built from discrete values: • Words made of letters • Numbers made of decimal digits (e.g. 239875.32) ° Computers operate on binary values (0 and 1) ° Easy to represent binary values electrically • Voltages and currents. • Can be implemented using circuits • Create the building blocks of modern computers
  • 4. ENGIN112 L2: Number Systems September 5, 2003 Understanding Decimal Numbers ° Decimal numbers are made of decimal digits: (0,1,2,3,4,5,6,7,8,9) ° But how many items does a decimal number represent? • 8653 = 8x103 + 6x102 + 5x101 + 3x100 ° What about fractions? • 97654.35 = 9x104 + 7x103 + 6x102 + 5x101 + 4x100 + 3x10-1 + 5x10-2 • In formal notation -> (97654.35)10
  • 5. ENGIN112 L2: Number Systems September 5, 2003 Understanding Octal Numbers ° Octal numbers are made of octal digits: (0,1,2,3,4,5,6,7) ° How many items does an octal number represent? • (4536)8 = 4x83 + 5x82 + 3x81 + 6x80 = (1362)10 ° What about fractions? • (465.27)8 = 4x82 + 6x81 + 5x80 + 2x8-1 + 7x8-2 ° Octal numbers don’t use digits 8 or 9
  • 6. ENGIN112 L2: Number Systems September 5, 2003 Understanding Binary Numbers ° Binary numbers are made of binary digits (bits): • 0 and 1 ° How many items does an binary number represent? • (1011)2 = 1x23 + 0x22 + 1x21 + 1x20 = (11)10 ° What about fractions? • (110.10)2 = 1x22 + 1x21 + 0x20 + 1x2-1 + 0x2-2 ° Groups of eight bits are called a byte • (11001001) 2 ° Groups of four bits are called a nibble. • (1101) 2
  • 7. ENGIN112 L2: Number Systems September 5, 2003 Why Use Binary Numbers? ° Easy to represent 0 and 1 using electrical values. ° Possible to tolerate noise. ° Easy to transmit data ° Easy to build binary circuits. AND Gate 1 0 0
  • 8. ENGIN112 L2: Number Systems September 5, 2003 Conversion Between Number Bases Decimal(base 10) Octal(base 8) Binary(base 2) Hexadecimal (base16) ° Learn to convert between bases. ° Already demonstrated how to convert from binary to decimal. ° Hexadecimal described in next lecture.
  • 9. ENGIN112 L2: Number Systems September 5, 2003 Convert an Integer from Decimal to Another Base 1. Divide decimal number by the base (e.g. 2) 2. The remainder is the lowest-order digit 3. Repeat first two steps until no divisor remains. For each digit position: Example for (13)10: Integer Quotient 13/2 = 6 + ½ a0 = 1 6/2 = 3 + 0 a1 = 0 3/2 = 1 + ½ a2 = 1 1/2 = 0 + ½ a3 = 1 Remainder Coefficient Answer (13)10 = (a3 a2 a1 a0)2 = (1101)2
  • 10. ENGIN112 L2: Number Systems September 5, 2003 Convert a Fraction from Decimal to Another Base 1. Multiply decimal number by the base (e.g. 2) 2. The integer is the highest-order digit 3. Repeat first two steps until fraction becomes zero. For each digit position: Example for (0.625)10: Integer 0.625 x 2 = 1 + 0.25 a-1 = 1 0.250 x 2 = 0 + 0.50 a-2 = 0 0.500 x 2 = 1 + 0 a-3 = 1 Fraction Coefficient Answer (0.625)10 = (0.a-1 a-2 a-3 )2 = (0.101)2
  • 11. ENGIN112 L2: Number Systems September 5, 2003 The Growth of Binary Numbers n 2n 0 20=1 1 21=2 2 22=4 3 23=8 4 24=16 5 25=32 6 26=64 7 27=128 n 2n 8 28=256 9 29=512 10 210=1024 11 211=2048 12 212=4096 20 220=1M 30 230=1G 40 240=1T Mega Giga Tera
  • 12. ENGIN112 L2: Number Systems September 5, 2003 Binary Addition ° Example of adding two binary numbers… 1 1 1 1 0 1 + 1 0 1 1 1 --------------------- 0 1 0 1 1 1 1 1 1 1 1 0 0 carries
  • 13. ENGIN112 L2: Number Systems September 5, 2003 Binary Subtraction ° We can also perform subtraction (with borrows in place of carries). ° Let’s subtract (10111)2 from (1001101)2… 1 10 0 10 10 0 0 10 1 0 0 1 1 0 1 - 1 0 1 1 1 ------------------------ 1 1 0 1 1 0 borrows
  • 14. ENGIN112 L2: Number Systems September 5, 2003 Binary Multiplication ° Binary multiplication is much the same as decimal multiplication, except that the multiplication operations are much simpler… 1 0 1 1 1 X 1 0 1 0 ----------------------- 0 0 0 0 0 1 0 1 1 1 0 0 0 0 0 1 0 1 1 1 ----------------------- 1 1 1 0 0 1 1 0
  • 15. ENGIN112 L2: Number Systems September 5, 2003 Convert an Integer from Decimal to Octal 1. Divide decimal number by the base (8) 2. The remainder is the lowest-order digit 3. Repeat first two steps until no divisor remains. For each digit position: Example for (175)10: Integer Quotient 175/8 = 21 + 7/8 a0 = 7 21/8 = 2 + 5/8 a1 = 5 2/8 = 0 + 2/8 a2 = 2 Remainder Coefficient Answer (175)10 = (a2 a1 a0)2 = (257)8
  • 16. ENGIN112 L2: Number Systems September 5, 2003 Convert an Fraction from Decimal to Octal 1. Multiply decimal number by the base (e.g. 8) 2. The integer is the highest-order digit 3. Repeat first two steps until fraction becomes zero. For each digit position: Example for (0.3125)10: Integer 0.3125 x 8 = 2 + 5 a-1 = 2 0.5000 x 8 = 4 + 0 a-2 = 4 Fraction Coefficient Answer (0.3125)10 = (0.24)8
  • 17. ENGIN112 L2: Number Systems September 5, 2003 Summary ° Binary numbers are made of binary digits (bits) ° Binary and octal number systems ° Conversion between number systems ° Addition, subtraction, and multiplication in binary
  • 18. ENGIN112 L2: Number Systems September 5, 2003 Overview ° Hexadecimal numbers • Related to binary and octal numbers ° Conversion between hexadecimal, octal and binary ° Value ranges of numbers ° Representing positive and negative numbers ° Creating the complement of a number • Make a positive number negative (and vice versa)
  • 19. ENGIN112 L2: Number Systems September 5, 2003 Understanding Binary Numbers ° Binary numbers are made of binary digits (bits): • 0 and 1 ° How many items does an binary number represent? • (1011)2 = 1x23 + 0x22 + 1x21 + 1x20 = (11)10 ° What about fractions? • (110.10)2 = 1x22 + 1x21 + 0x20 + 1x2-1 + 0x2-2 ° Groups of eight bits are called a byte • (11001001) 2 ° Groups of four bits are called a nibble. • (1101) 2
  • 20. ENGIN112 L2: Number Systems September 5, 2003 Understanding Hexadecimal Numbers ° Hexadecimal numbers are made of 16 digits: • (0,1,2,3,4,5,6,7,8,9,A, B, C, D, E, F) ° How many items does an hex number represent? • (3A9F)16 = 3x163 + 10x162 + 9x161 + 15x160 = 1499910 ° What about fractions? • (2D3.5)16 = 2x162 + 13x161 + 3x160 + 5x16-1 = 723.312510 ° Note that each hexadecimal digit can be represented with four bits. • (1110) 2 = (E)16 ° Groups of four bits are called a nibble. • (1110) 2
  • 21. ENGIN112 L2: Number Systems September 5, 2003 Putting It All Together ° Binary, octal, and hexadecimal similar ° Easy to build circuits to operate on these representations ° Possible to convert between the three formats
  • 22. ENGIN112 L2: Number Systems September 5, 2003 Converting Between Base 16 and Base 2 ° Conversion is easy!  Determine 4-bit value for each hex digit ° Note that there are 24 = 16 different values of four bits ° Easier to read and write in hexadecimal. ° Representations are equivalent! 3A9F16 = 0011 1010 1001 11112 3 A 9 F
  • 23. ENGIN112 L2: Number Systems September 5, 2003 Converting Between Base 16 and Base 8 1. Convert from Base 16 to Base 2 2. Regroup bits into groups of three starting from right 3. Ignore leading zeros 4. Each group of three bits forms an octal digit. 352378 = 011 101 010 011 1112 5 2 3 7 3 3A9F16 = 0011 1010 1001 11112 3 A 9 F
  • 24. ENGIN112 L2: Number Systems September 5, 2003 How To Represent Signed Numbers • Plus and minus sign used for decimal numbers: 25 (or +25), -16, etc. • For computers, desirable to represent everything as bits. • Three types of signed binary number representations: signed magnitude, 1’s complement, 2’s complement. • In each case: left-most bit indicates sign: positive (0) or negative (1). Consider signed magnitude: 000011002 = 1210 Sign bit Magnitude 100011002 = -1210 Sign bit Magnitude
  • 25. ENGIN112 L2: Number Systems September 5, 2003 One’s Complement Representation • The one’s complement of a binary number involves inverting all bits. • 1’s comp of 00110011 is 11001100 • 1’s comp of 10101010 is 01010101 • For an n bit number N the 1’s complement is (2n-1) – N. • Called diminished radix complement .since 1’s complement for base (radix 2). • To find negative of 1’s complement number take the 1’s complement. 000011002 = 1210 Sign bit Magnitude 111100112 = -1210 Sign bit Magnitude
  • 26. ENGIN112 L2: Number Systems September 5, 2003 Two’s Complement Representation • The two’s complement of a binary number involves inverting all bits and adding 1. • 2’s comp of 00110011 is 11001101 • 2’s comp of 10101010 is 01010110 • For an n bit number N the 2’s complement is (2n-1) – N + 1. • Called radix complement. since 2’s complement for base (radix 2). • To find negative of 2’s complement number take the 2’s complement. 000011002 = 1210 Sign bit Magnitude 111101002 = -1210 Sign bit Magnitude
  • 27. ENGIN112 L2: Number Systems September 5, 2003 Two’s Complement Shortcuts ° Algorithm 1 – Simply complement each bit and then add 1 to the result. • Finding the 2’s complement of (01100101)2 and of its 2’s complement… N = 01100101 [N] = 10011011 10011010 01100100 + 1 + 1 --------------- --------------- 10011011 01100101 ° Algorithm 2 – Starting with the least significant bit, copy all of the bits up to and including the first 1 bit and then complementing the remaining bits. • N = 0 1 1 0 0 1 0 1 [N] = 1 0 0 1 1 0 1 1
  • 28. ENGIN112 L2: Number Systems September 5, 2003 Finite Number Representation ° Machines that use 2’s complement arithmetic can represent integers in the range -2n-1 <= N <= 2n-1-1 where n is the number of bits available for representing N. Note that 2n-1-1 = (011..11)2 and –2n-1 = (100..00)2 oFor 2’s complement more negative numbers than positive. oFor 1’s complement two representations for zero. oFor an n bit number in base (radix) z there are zn different unsigned values. (0, 1, …zn-1)
  • 29. ENGIN112 L2: Number Systems September 5, 2003 1’s Complement Addition ° Using 1’s complement numbers, adding numbers is easy. ° For example, suppose we wish to add +(1100)2 and +(0001)2. ° Let’s compute (12)10 + (1)10. • (12)10 = +(1100)2 = 011002 in 1’s comp. • (1)10 = +(0001)2 = 000012 in 1’s comp. 0 1 1 0 0 + 0 0 0 0 1 -------------- 0 0 1 1 0 1 0 -------------- 0 1 1 0 1 Add carry Final Result Step 1: Add binary numbers Step 2: Add carry to low-order bit Add
  • 30. ENGIN112 L2: Number Systems September 5, 2003 1’s Complement Subtraction ° Using 1’s complement numbers, subtracting numbers is also easy. ° For example, suppose we wish to subtract +(0001)2 from +(1100)2. ° Let’s compute (12)10 - (1)10. • (12)10 = +(1100)2 = 011002 in 1’s comp. • (-1)10 = -(0001)2 = 111102 in 1’s comp. 0 1 1 0 0 - 0 0 0 0 1 -------------- 0 1 1 0 0 + 1 1 1 1 0 -------------- 1 0 1 0 1 0 1 -------------- 0 1 0 1 1 Add carry Final Result Step 1: Take 1’s complement of 2nd operand Step 2: Add binary numbers Step 3: Add carry to low order bit 1’s comp Add
  • 31. ENGIN112 L2: Number Systems September 5, 2003 2’s Complement Addition ° Using 2’s complement numbers, adding numbers is easy. ° For example, suppose we wish to add +(1100)2 and +(0001)2. ° Let’s compute (12)10 + (1)10. • (12)10 = +(1100)2 = 011002 in 2’s comp. • (1)10 = +(0001)2 = 000012 in 2’s comp. 0 1 1 0 0 + 0 0 0 0 1 -------------- 0 0 1 1 0 1 Final Result Step 1: Add binary numbers Step 2: Ignore carry bit Add Ignore
  • 32. ENGIN112 L2: Number Systems September 5, 2003 2’s Complement Subtraction ° Using 2’s complement numbers, follow steps for subtraction ° For example, suppose we wish to subtract +(0001)2 from +(1100)2. ° Let’s compute (12)10 - (1)10. • (12)10 = +(1100)2 = 011002 in 2’s comp. • (-1)10 = -(0001)2 = 111112 in 2’s comp. 0 1 1 0 0 - 0 0 0 0 1 -------------- 0 1 1 0 0 + 1 1 1 1 1 -------------- 1 0 1 0 1 1 Final Result Step 1: Take 2’s complement of 2nd operand Step 2: Add binary numbers Step 3: Ignore carry bit 2’s comp Add Ignore Carry
  • 33. ENGIN112 L2: Number Systems September 5, 2003 2’s Complement Subtraction: Example #2 ° Let’s compute (13)10 – (5)10. • (13)10 = +(1101)2 = (01101)2 • (-5)10 = -(0101)2 = (11011)2 ° Adding these two 5-bit codes… ° Discarding the carry bit, the sign bit is seen to be zero, indicating a correct result. Indeed, (01000)2 = +(1000)2 = +(8)10. 0 1 1 0 1 + 1 1 0 1 1 -------------- 1 0 1 0 0 0 carry
  • 34. ENGIN112 L2: Number Systems September 5, 2003 2’s Complement Subtraction: Example #3 ° Let’s compute (5)10 – (12)10. • (-12)10 = -(1100)2 = (10100)2 • (5)10 = +(0101)2 = (00101)2 ° Adding these two 5-bit codes… ° Here, there is no carry bit and the sign bit is 1. This indicates a negative result, which is what we expect. (11001)2 = -(7)10. 0 0 1 0 1 + 1 0 1 0 0 -------------- 1 1 0 0 1
  • 35. ENGIN112 L2: Number Systems September 5, 2003 Summary ° Binary numbers can also be represented in octal and hexadecimal ° Easy to convert between binary, octal, and hexadecimal ° Signed numbers represented in signed magnitude, 1’s complement, and 2’s complement ° 2’s complement most important (only 1 representation for zero). ° Important to understand treatment of sign bit for 1’s and 2’s complement.
  • 36. ENGIN112 L2: Number Systems September 5, 2003 Number Codes
  • 37. ENGIN112 L2: Number Systems September 5, 2003 Overview ° 2’s complement numbers • Addition and subtraction ° Binary coded decimal ° Gray codes for binary numbers ° ASCII characters ° Moving towards hardware • Storing data • Processing data
  • 38. ENGIN112 L2: Number Systems September 5, 2003 1’s complement ° The ones' complement of a binary number is defined as the value obtained by inverting all the bits in the binary representation of the number (swapping 0s and 1s). 0 0000 1111 1 0001 1110 2 0010 1101 3 0011 1100 4 0100 1011 5 0101 1010 6 0110 1001 7 0111 1000
  • 39. ENGIN112 L2: Number Systems September 5, 2003 2’s Complement To get 2’s complement of a binary number, simply invert the given number and add 1 to the least significant bit (LSB) of given result. Binary number 1’s complement 2’s complement 000 111 000 001 110 111 010 101 110 011 100 101 100 011 100 101 010 011 110 001 010 111 000 001
  • 40. ENGIN112 L2: Number Systems September 5, 2003 2’s Complement Subtraction ° Let’s compute (13)10 - (5)10. • (13)10 = +(1101)2 = (01101)2 • (-5)10 = -(0101)2 = (11011)2 ° Adding these two 5-bit codes… ° Discarding the carry bit, the sign bit is seen to be zero, indicating a correct result. 0 1 1 0 1 + 1 1 0 1 1 -------------- 1 0 1 0 0 0 carry
  • 41. ENGIN112 L2: Number Systems September 5, 2003 2’s Complement Subtraction ° Let’s compute (5)10 – (12)10. • (-12)10 = -(1100)2 = (10100)2 • (5)10 = +(0101)2 = (00101)2 ° Adding these two 5-bit codes… ° Here, there is no carry bit and the sign bit is 1. This indicates a negative result, which is what we expect. (11001)2 = -(7)10. ° Numbers in hexadecimal 0 0 1 0 1 + 1 0 1 0 0 -------------- 1 1 0 0 1
  • 42. ENGIN112 L2: Number Systems September 5, 2003 Binary codes
  • 43. ENGIN112 L2: Number Systems September 5, 2003 Binary Coded Decimal Code ° Binary coded decimal (BCD) represents each decimal digit with four bits • Ex. 0011 0010 1001 = 32910 ° This is NOT the same as 0011001010012 ° BCD code is a class of binary encodings of decimal numbers where each decimal digit is represented by four number of bits. Digit BCD Code Digit BCD Code 0 0000 5 0101 1 0001 6 0110 2 0010 7 0111 3 0011 8 1000 4 0100 9 1001 3 2 9
  • 44. ENGIN112 L2: Number Systems September 5, 2003 Putting It All Together ° BCD not very efficient ° Used in early computers (40s, 50s) ° Used to encode numbers for seven- segment displays.
  • 45. ENGIN112 L2: Number Systems September 5, 2003 Gray Code The gray code is an ordering of the binary numeral system such that two successive values differ in only one bit(binary digit). The advantage of the Gray code over the straight binary number sequence is that only one bit in the code group changes in going from one number to the next. For example, in going from 7 to 8, the Gray code changes from 0100 to 1100. Only the first bit changes, from 0 to 1; the other three bits remain the same. By contrast, with binary numbers the change from 7 to 8 will be from 0111 to 1000, which causes all four bits to change values.
  • 46. ENGIN112 L2: Number Systems September 5, 2003 Gray Code ° Gray code is not a number system. • It is an alternate way to represent four bit data ° Only one bit changes from one decimal digit to the next ° Useful for reducing errors in communication. ° Can be scaled to larger numbers. ° It is a non-weighted code and it is not arithmetic codes. That means there are no specific weights assigned to the bit position. Digit Binary Gray Code 0 0000 0000 1 0001 0001 2 0010 0011 3 0011 0010 4 0100 0110 5 0101 0111 6 0110 0101 7 0111 0100 8 1000 1100 9 1001 1101 10 1010 1111 11 1011 1110 12 1100 1010 13 1101 1011 14 1110 1001 15 1111 1000
  • 47. ENGIN112 L2: Number Systems September 5, 2003 Application of the Gray code ° The reflected binary code or gray code was originally designed to prevent spurious output from electromechanical switches. ° Today, Gray codes are widely used to facilitate error correction in digital communications such as digital terrestrial television and some cable TV systems.
  • 48. ENGIN112 L2: Number Systems September 5, 2003 ASCII Code Many applications of digital computers require the handling not only of numbers, but also of other characters or symbols, such as the letters of the alphabet. For instance, consider a high‐tech company with thousands of employees. To represent the names and other pertinent information, it is necessary to formulate a binary code for the letters of the alphabet. The standard binary code for the alphanumeric characters is the American Standard Code for Information Interchange (ASCII), which uses seven bits to code 128 characters
  • 49. ENGIN112 L2: Number Systems September 5, 2003 ASCII Code ° American Standard Code for Information Interchange ° ASCII is a 7-bit code, frequently used with an 8th bit for error detection (more about that in a bit). Character ASCII (bin) ASCII (hex) Decimal Octal A 1000001 41 65 101 B 1000010 42 66 102 C 1000011 43 67 103 … Z a … 1 ‘
  • 50. ENGIN112 L2: Number Systems September 5, 2003 ASCII Codes and Data Transmission ° ASCII Codes ° A – Z (26 codes), a – z (26 codes) ° 0-9 (10 codes), others (@#$%^&*….) ° Transmission susceptible to noise ° Typical transmission rates (1500 Kbps, 56.6 Kbps) ° How to keep data transmission accurate?
  • 51. ENGIN112 L2: Number Systems September 5, 2003 Parity bit ° A parity bit, or check bit, is a bit added to a string of binary code to ensure that the total number of 1- bits in the string is even or odd. Parity bits are used as the simplest form of error detecting code. ° There are two variants of parity bits: even parity bit and odd parity bit.
  • 52. ENGIN112 L2: Number Systems September 5, 2003 ° In the case of even parity, for a given set of bits, the occurrences of bits whose value is 1 is counted. If that count is odd, the parity bit value is set to 1, making the total count of occurrences of 1s in the whole set (including the parity bit) an even number. If the count of 1s in a given set of bits is already even, the parity bit's value is 0. ° In the case of odd parity, the coding is reversed. For a given set of bits, if the count of bits with a value of 1 is even, the parity bit value is set to 1 making the total count of 1s in the whole set (including the parity bit) an odd number. If the count of bits with a value of 1 is odd, the count is already odd so the parity bit's value is 0.
  • 53. ENGIN112 L2: Number Systems September 5, 2003 Parity Codes ° Parity codes are formed by concatenating a parity bit, P to each code word of C. ° In an odd-parity code, the parity bit is specified so that the total number of ones is odd. ° In an even-parity code, the parity bit is specified so that the total number of ones is even. Information Bits P 1 1 0 0 0 0 1 1  Added even parity bit 0 1 0 0 0 0 1 1  Added odd parity bit
  • 54. ENGIN112 L2: Number Systems September 5, 2003 Parity Code Example ° Concatenate a parity bit to the ASCII code for the characters 0, X, and = to produce both odd-parity and even-parity codes. Character ASCII Odd-Parity ASCII Even-Parity ASCII 0 0110000 10110000 00110000 X 1011000 01011000 11011000 = 0111100 10111100 00111100
  • 55. ENGIN112 L2: Number Systems September 5, 2003 Binary Data Storage • Binary cells store individual bits of data • Multiple cells form a register. • Data in registers can indicate different values • Hex (decimal) • BCD • ASCII Binary Cell 0 0 1 0 1 0 1 1
  • 56. ENGIN112 L2: Number Systems September 5, 2003
  • 57. ENGIN112 L2: Number Systems September 5, 2003 circuit that generates parity bit from four message bits
  • 58. ENGIN112 L2: Number Systems September 5, 2003 Basic Logic Gates © Alan T. Pinck / Algonquin College; 2003
  • 59. ENGIN112 L2: Number Systems September 5, 2003 Logic Gates ° a logic gate is a physical device implementing a Boolean function; ° that is, it performs a logical operation on one or more binary inputs and produces a single binary output.
  • 60. ENGIN112 L2: Number Systems September 5, 2003 ° Logic operations include any operations that manipulate Boolean values. ° Boolean values are either true or false. They are named after English mathematician George Boole, who invented Boolean algebra,
  • 61. ENGIN112 L2: Number Systems September 5, 2003 Describing Circuit Functionality: Inverter ° Basic logic functions have symbols. ° The same functionality can be represented with truth tables. • Truth table completely specifies outputs for all input combinations. ° The Output signal from a NOT gate is True (on, 1) if and only if the Input signal is False. ° The Output signal from a NOT gate is False (off, 0) if and only if the Input signal is True. A Y 0 1 1 0 Input Output A Y Symbol Truth Table
  • 62. ENGIN112 L2: Number Systems September 5, 2003 The AND Gate ° The Output signal from an AND gate is True (on, 1) if and only if both Input signals are True (on, 1). ° The Output signal from an AND gate is False (off, 0), otherwise. A B Y 0 0 0 0 1 0 1 0 0 1 1 1 A B Y Truth Table
  • 63. ENGIN112 L2: Number Systems September 5, 2003 The OR Gate ° The Output signal from an OR gate is True (on, 1) if either, or both, Input signals are True (on, 1). ° The Output signal from an OR gate is False (off, 0) if and only if both Input signals are False (off, 0). A B Y 0 0 0 0 1 1 1 0 1 1 1 1 A B Y
  • 64. ENGIN112 L2: Number Systems September 5, 2003 Describing Circuit Functionality: Waveforms ° Waveforms provide another approach for representing functionality. ° Values are either high (logic 1) or low (logic 0). ° Can you create a truth table from the waveforms? A B Y 0 0 0 0 1 0 1 0 0 1 1 1 AND Gate
  • 65. ENGIN112 L2: Number Systems September 5, 2003 Logic Gates : NOT combined with other gates ° Note that in the “classic: electronic engineering form, it is really the “bubble” that indicates the NOT activity.
  • 66. ENGIN112 L2: Number Systems September 5, 2003 Consider three-input gates 3 Input OR Gate
  • 67. ENGIN112 L2: Number Systems September 5, 2003 Ordering Boolean Functions ° How to interpret AB+C? • Is it AB ORed with C ? • Is it A ANDed with B+C ? ° Order of precedence for Boolean algebra: AND before OR. ° Note that parentheses are needed here :
  • 68. ENGIN112 L2: Number Systems September 5, 2003 Boolean Algebra ° A Boolean algebra is defined as a closed algebraic system containing a set K or two or more elements and the two operators, . and +. ° Useful for identifying and minimizing circuit functionality ° Identity elements a + 0 = a a . 1 = a ° 0 is the identity element for the + operation. ° 1 is the identity element for the . operation.
  • 69. ENGIN112 L2: Number Systems September 5, 2003 Commutativity and Associativity of the Operators ° The Commutative Property: ° a binary operation is commutative if changing the order of the operands does not change the result. For every a and b in K, a + b = b + a a . b = b . a ° The Associative Property: ° Within an expression containing two or more occurrences in a row of the same associative operator, the order in which the operations are performed does not matter as long as the sequence of the operands is not changed. For every a, b, and c in K, a + (b + c) = (a + b) + c a . (b . c) = (a . b) . c
  • 70. ENGIN112 L2: Number Systems September 5, 2003 Distributivity of the Operators and Complements ° The Distributive Property: For every a, b, and c in K, • a + ( b . c ) = ( a + b ) . ( a + c ) • a . ( b + c ) = ( a . b ) + ( a . c ) ° The Existence of the Complement: For every a in K there exists a unique element called a’ (complement of a) such that, • a + a’ = 1 • a . a’ = 0 ° To simplify notation, the . operator is frequently omitted. When two elements are written next to each other, the AND (.) operator is implied… • a + b . c = ( a + b ) . ( a + c ) • a + bc = ( a + b )( a + c )
  • 71. ENGIN112 L2: Number Systems September 5, 2003 Duality ° The principle of duality is an important concept. This says that if an expression is valid in Boolean algebra, the dual of that expression is also valid. ° To form the dual of an expression, replace all + operators with . operators, all . operators with + operators, all ones with zeros, and all zeros with ones. ° Form the dual of the expression a + (bc) = (a + b)(a + c) ° Following the replacement rules… a(b + c) = ab + ac ° Take care not to alter the location of the parentheses if they are present.
  • 72. ENGIN112 L2: Number Systems September 5, 2003 Involution ° This theorem states: a’’ = a ° Remember that aa’ = 0 and a+a’=1. • Therefore, a’ is the complement of a and a is also the complement of a’. • As the complement of a’ is unique, it follows that a’’=a. ° Taking the double inverse of a value will give the initial value.
  • 73. ENGIN112 L2: Number Systems September 5, 2003 Absorption ° This theorem states: a + ab = a a(a+b) = a ° To prove the first half of this theorem: a + ab = a . 1 + ab = a (1 + b) = a (b + 1) = a (1) a + ab= a
  • 74. ENGIN112 L2: Number Systems September 5, 2003 DeMorgan’s Theorem ° A key theorem in simplifying Boolean algebra expression is DeMorgan’s Theorem. It states: (a + b)’ = a’b’ (ab)’ = a’ + b’ ° Complement the expression a(b + z(x + a’)) and simplify. (a(b+z(x + a’)))’ = a’ + (b + z(x + a’))’ = a’ + b’(z(x + a’))’ = a’ + b’(z’ + (x + a’)’) = a’ + b’(z’ + x’a’’) = a’ + b’(z’ + x’a)
  • 75. ENGIN112 L2: Number Systems September 5, 2003 Basic theorems
  • 76. ENGIN112 L2: Number Systems September 5, 2003 Summary ° Basic logic functions can be made from AND, OR, and NOT (invert) functions ° The behavior of digital circuits can be represented with waveforms, truth tables, or symbols ° Primitive gates can be combined to form larger circuits ° Boolean algebra defines how binary variables can be combined ° Rules for associativity, commutativity, and distribution are similar to algebra ° DeMorgan’s rules are important. • Will allow us to reduce circuit sizes.
  • 77. ENGIN112 L2: Number Systems September 5, 2003 Overview ° Expressing Boolean functions ° Relationships between algebraic equations, symbols, and truth tables ° Simplification of Boolean expressions ° Minterms and Maxterms ° AND-OR representations • Product of sums • Sum of products
  • 78. ENGIN112 L2: Number Systems September 5, 2003 Boolean Functions ° Boolean algebra deals with binary variables and logic operations. ° Function results in binary 0 or 1 x 0 0 0 0 1 1 1 1 y 0 0 1 1 0 0 1 1 z 0 1 0 1 0 1 0 1 F 0 0 0 0 1 0 1 1 F = x(y+z’) x y z z’ y+z’ F = x(y+z’)
  • 79. ENGIN112 L2: Number Systems September 5, 2003 Boolean Functions ° Boolean algebra deals with binary variables and logic operations. ° Function results in binary 0 or 1 x 0 0 0 0 1 1 1 1 y 0 0 1 1 0 0 1 1 z 0 1 0 1 0 1 0 1 xy 0 0 0 0 0 0 1 1 x y z G = xy +yz yz xy We will learn how to transition between equation, symbols, and truth table. yz 0 0 0 1 0 0 0 1 G 0 0 0 1 0 0 1 1
  • 80. ENGIN112 L2: Number Systems September 5, 2003 Representation Conversion ° Need to transition between boolean expression, truth table, and circuit (symbols). ° Converting between truth table and expression is easy. ° Converting between expression and circuit is easy. ° More difficult to convert to truth table. Truth Table Circuit Boolean Expression
  • 81. ENGIN112 L2: Number Systems September 5, 2003 Truth Table to Expression ° Converting a truth table to an expression • Each row with output of 1 becomes a product term • Sum product terms together. x 0 0 0 0 1 1 1 1 y 0 0 1 1 0 0 1 1 z 0 1 0 1 0 1 0 1 G 0 0 0 1 0 0 1 1 xyz + xyz’ + x’yz Any Boolean Expression can be represented in sum of products form!
  • 82. ENGIN112 L2: Number Systems September 5, 2003 Equivalent Representations of Circuits ° All three formats are equivalent ° Number of 1’s in truth table output column equals AND terms for Sum-of-Products (SOP) x y z x 0 0 0 0 1 1 1 1 y 0 0 1 1 0 0 1 1 z 0 1 0 1 0 1 0 1 G 0 0 0 1 0 0 1 1 G = xyz + xyz’ + x’yz G x x x x x x x x x
  • 83. ENGIN112 L2: Number Systems September 5, 2003 Reducing Boolean Expressions 1 ° Is this the smallest possible implementation of this expression? No! ° Use Boolean Algebra rules to reduce complexity while preserving functionality. ° Step 1: Use Theorum 1 (a + a = a) • So xyz + xyz’ + xy’z’ = xyz + xyz’ + xyz’ + xy’z’ ° Step 2: Use distributive rule a(b + c) = ab + ac • So xyz + xyz’ + xyz’ + xy’z’ = xy(z + z’) + xz’(y + y’) ° Step 3: Use Postulate 3 (a + a’ = 1) • So xy(z + z’) + xz’(y + y’) = xy.1 + xz’.1 ° Step 4: Use Postulate 2 (a . 1 = a) • So xy.1 + xz’.1 = xy + xz’ = xyz + xyz’ + xy’z’ G = xyz + xyz’ + xy’z’
  • 84. ENGIN112 L2: Number Systems September 5, 2003 Reducing Boolean Expressions 2 ° Is this the smallest possible implementation of this expression? No! ° Use Boolean Algebra rules to reduce complexity while preserving functionality. ° Step 1: Use Theorum 1 (a + a = a) • So xyz + xyz’ + x’yz = xyz + xyz + xyz’ + x’yz ° Step 2: Use distributive rule a(b + c) = ab + ac • So xyz + xyz + xyz’ + x’yz = xy(z + z’) + yz(x + x’) ° Step 3: Use Postulate 3 (a + a’ = 1) • So xy(z + z’) + yz(x + x’) = xy.1 + yz.1 ° Step 4: Use Postulate 2 (a . 1 = a) • So xy.1 + yz.1 = xy + yz = xyz + xyz’ + x’yz G = xyz + xyz’ + x’yz
  • 85. ENGIN112 L2: Number Systems September 5, 2003 Reduced Hardware Implementation ° Reduced equation requires less hardware! ° Same function implemented! x y z x 0 0 0 0 1 1 1 1 y 0 0 1 1 0 0 1 1 z 0 1 0 1 0 1 0 1 G 0 0 0 1 0 0 1 1 G = xyz + xyz’ + x’yz = xy + yz G x x x x
  • 86. ENGIN112 L2: Number Systems September 5, 2003 Minterms and Maxterms (POS AND SOP Forms ° Each variable in a Boolean expression is a literal ° Boolean variables can appear in normal (x) or complement form (x’) ° Each AND combination of terms is a minterm ° Each OR combination of terms is a maxterm For example: Minterms x y z Minterm 0 0 0 x’y’z’ m0 0 0 1 x’y’z m1 … 1 0 0 xy’z’ m4 … 1 1 1 xyz m7 For example: Maxterms x y z Maxterm 0 0 0 x+y+z M0 0 0 1 x+y+z’ M1 … 1 0 0 x’+y+z M4 … 1 1 1 x’+y’+z’ M7
  • 87. ENGIN112 L2: Number Systems September 5, 2003 Representing Functions with Minterms ° Minterm number same as row position in truth table (starting from top from 0) ° Shorthand way to represent functions x 0 0 0 0 1 1 1 1 y 0 0 1 1 0 0 1 1 z 0 1 0 1 0 1 0 1 G 0 0 0 1 0 0 1 1 G = xyz + xyz’ + x’yz G = m7 + m6 + m3 = Σ(3, 6, 7)
  • 88. ENGIN112 L2: Number Systems September 5, 2003 Complementing Functions ° Minterm number same as row position in truth table (starting from top from 0) ° Shorthand way to represent functions x 0 0 0 0 1 1 1 1 y 0 0 1 1 0 0 1 1 z 0 1 0 1 0 1 0 1 G 0 0 0 1 0 0 1 1 G = xyz + xyz’ + x’yz G’ = (xyz + xyz’ + x’yz)’ = G’ 1 1 1 0 1 1 0 0
  • 89. ENGIN112 L2: Number Systems September 5, 2003 Truth table representing minterm and maxterm
  • 90. ENGIN112 L2: Number Systems September 5, 2003 Canonical Form ° In Boolean algebra,Boolean function can be expressed as Canonical Disjunctive Normal Form known as minterm and some are expressed as Canonical Conjunctive Normal Form known as maxterm . ° In Minterm, we look for the functions where the output results in “1” while in Maxterm we look for function where the output results in “0”. ° We perform Sum of minterm also known as Sum of products (SOP) . ° We perform Product of Maxterm also known as Product of sum (POS). ° Boolean functions expressed as a sum of product form(minterm) or product of sum form(maxterm) are said to be in canonical form.
  • 91. ENGIN112 L2: Number Systems September 5, 2003 Standard Form A Boolean variable can be expressed in either true form or complemented form. In standard form Boolean function will contain all the variables in either true form or complemented form while in canonical form number of variables depends on the output of SOP or POS.
  • 92. ENGIN112 L2: Number Systems September 5, 2003 A Boolean function can be expressed algebraically from a given truth table by forming a : minterm for each combination of the variables that produces a 1 in the function and then taking the OR of all those terms. maxterm for each combination of the variables that produces a 0 in the function and then taking the AND of all those terms
  • 93. ENGIN112 L2: Number Systems September 5, 2003 Complementing Functions ° Step 1: assign temporary names • b + c -> z • (a + z)’ = G’ ° Step 2: Use DeMorgans’ Law • (a + z)’ = a’ . z’ ° Step 3: Resubstitute (b+c) for z • a’ . z’ = a’ . (b + c)’ ° Step 4: Use DeMorgans’ Law • a’ . (b + c)’ = a’ . (b’. c’) ° Step 5: Associative rule • a’ . (b’. c’) = a’ . b’ . c’ G’ = (a + b + c)’ G = a + b + c G’ = a’ . b’ . c’ = a’b’c’ G = a + b + c
  • 94. ENGIN112 L2: Number Systems September 5, 2003 Complementation Example ° Find complement of F = x’z + yz • F’ = (x’z + yz)’ ° DeMorgan’s • F’ = (x’z)’ (yz)’ ° DeMorgan’s • F’ = (x’’+z’)(y’+z’) ° Reduction -> eliminate double negation on x • F’ = (x+z’)(y’+z’) This format is called product of sums
  • 95. ENGIN112 L2: Number Systems September 5, 2003 Conversion Between Canonical Forms ° Easy to convert between minterm and maxterm representations ° For maxterm representation, select rows with 0’s x 0 0 0 0 1 1 1 1 y 0 0 1 1 0 0 1 1 z 0 1 0 1 0 1 0 1 G 0 0 0 1 0 0 1 1 G = xyz + xyz’ + x’yz G = m7 + m6 + m3 = Σ(3, 6, 7) G = M0M1M2M4M5 = Π(0,1,2,4,5) G = (x+y+z)(x+y+z’)(x+y’+z)(x’+y+z)(x’+y+z’)
  • 96. ENGIN112 L2: Number Systems September 5, 2003 Representation of Circuits ° All logic expressions can be represented in 2- level format ° Circuits can be reduced to minimal 2-level representation ° Sum of products representation most common in industry.
  • 97. ENGIN112 L2: Number Systems September 5, 2003 Summary ° Truth table, circuit, and boolean expression formats are equivalent ° Easy to translate truth table to SOP and POS representation ° Boolean algebra rules can be used to reduce circuit size while maintaining function ° All logic functions can be made from AND, OR, and NOT ° Easiest way to understand: Do examples! ° Next time: More logic gates!
  • 98. ENGIN112 L2: Number Systems September 5, 2003 The NAND Gate ° This is a NAND gate. It is a combination of an AND gate followed by an inverter. Its truth table shows this… ° NAND gates have several interesting properties… • NAND(a,a)=(aa)’ = a’ = NOT(a) • NAND’(a,b)=(ab)’’ = ab = AND(a,b) • NAND(a’,b’)=(a’b’)’ = a+b = OR(a,b) A B Y 0 0 1 0 1 1 1 0 1 1 1 0 A B Y
  • 99. ENGIN112 L2: Number Systems September 5, 2003 The NAND Gate ° These three properties show that a NAND gate with both of its inputs driven by the same signal is equivalent to a NOT gate ° A NAND gate whose output is complemented is equivalent to an AND gate, and a NAND gate with complemented inputs acts as an OR gate. ° Therefore, we can use a NAND gate to implement all three of the elementary operators (AND,OR,NOT). ° Therefore, ANY switching function can be constructed using only NAND gates. Such a gate is said to be primitive or functionally complete or UNIVERSAL GATE.
  • 100. ENGIN112 L2: Number Systems September 5, 2003 A Y A B Y Y A B NOT Gate AND Gate OR Gate NAND Gates into Other Gates (what are these circuits?)
  • 101. ENGIN112 L2: Number Systems September 5, 2003 The NOR Gate ° This is a NOR gate. It is a combination of an OR gate followed by an inverter. It’s truth table shows this… ° NOR gates also have several interesting properties… • NOR(a,a)=(a+a)’ = a’ = NOT(a) • NOR’(a,b)=(a+b)’’ = a+b = OR(a,b) • NOR(a’,b’)=(a’+b’)’ = ab = AND(a,b) A B Y 0 0 1 0 1 0 1 0 0 1 1 0 A B Y
  • 102. ENGIN112 L2: Number Systems September 5, 2003 Functionally Complete Gates ° Just like the NAND gate, the NOR gate is functionally complete…any logic function can be implemented using just NOR gates. ° Both NAND and NOR gates are very valuable as any design can be realized using either one. ° It is easier to build an IC chip using all NAND or NOR gates than to combine AND,OR, and NOT gates. ° NAND/NOR gates are typically faster at switching and cheaper to produce.
  • 103. ENGIN112 L2: Number Systems September 5, 2003 NOT Gate OR Gate AND Gate NOR Gates into Other Gates A Y Y A B A B Y
  • 104. ENGIN112 L2: Number Systems September 5, 2003 The XOR Gate (Exclusive-OR) ° This is a XOR gate. ° XOR gates assert their output when exactly one of the inputs is asserted, hence the name. ° The switching algebra symbol for this operation is , i.e. 1  1 = 0 and 1  0 = 1. A B Y 0 0 0 0 1 1 1 0 1 1 1 0 A B Y
  • 105. ENGIN112 L2: Number Systems September 5, 2003 The XNOR Gate ° This is a XNOR gate. ° This functions as an exclusive-NOR gate, or simply the complement of the XOR gate. ° The switching algebra symbol for this operation is , i.e. 1  1 = 1 and 1  0 = 0. A B Y 0 0 1 0 1 0 1 0 0 1 1 1 A B Y
  • 106. ENGIN112 L2: Number Systems September 5, 2003 NOR Gate Equivalence ° NOR Symbol, Equivalent Circuit, Truth Table
  • 107. ENGIN112 L2: Number Systems September 5, 2003 DeMorgan’s Theorem ° The theorem explains that the complement of the product of all the terms is equal to the sum of the complement of each term. Likewise, the complement of the sum of all the terms is equal to the product of the complement of each term. ie (a + b)’ = a’b’ (ab)’ = a’ + b’ ° Complement the expression a(b + z(x + a’)) and simplify. (a(b+z(x + a’)))’ = a’ + (b + z(x + a’))’ = a’ + b’(z(x + a’))’ = a’ + b’(z’ + (x + a’)’) = a’ + b’(z’ + x’a’’) = a’ + b’(z’ + x’a)
  • 108. ENGIN112 L2: Number Systems September 5, 2003 Example ° Determine the output expression for the below circuit and simplify it using DeMorgan’s Theorem
  • 109. ENGIN112 L2: Number Systems September 5, 2003 A universal gate is a gate which can implement any Boolean function without need to use any other gate type. The NAND and NOR gates are universal gates. In practice, this is advantageous since NAND and NOR gates are economical and easier to fabricate and are the basic gates used in all IC digital logic families. universal gate
  • 110. ENGIN112 L2: Number Systems September 5, 2003 Universality of NAND and NOR gates
  • 111. ENGIN112 L2: Number Systems September 5, 2003 Universality of NOR gate ° Equivalent representations of the AND, OR, and NOT gates
  • 112. ENGIN112 L2: Number Systems September 5, 2003 Example
  • 113. ENGIN112 L2: Number Systems September 5, 2003 Interpretation of the two NAND gate symbols ° Determine the output expression for circuit via DeMorgan’s Theorem
  • 114. ENGIN112 L2: Number Systems September 5, 2003 Interpretation of the two OR gate symbols ° Determine the output expression for circuit via DeMorgan’s Theorem
  • 115. ENGIN112 L2: Number Systems September 5, 2003 Summary ° Basic logic functions can be made from NAND, and NOR functions ° The behavior of digital circuits can be represented with waveforms, truth tables, or symbols ° Primitive gates can be combined to form larger circuits ° Boolean algebra defines how binary variables with NAND, NOR can be combined ° DeMorgan’s rules are important. • Allow conversion to NAND/NOR representations