Lec01 CSE345
Lec01 CSE345
01
CSE 245
Prepared by msj
CSE-345
• Know what the digital systems are, how they differ from analog systems
and why it is advantageous to use the digital systems in many applications.
• Comprehend different number systems including the binary system and
Boolean algebraic principles
• Apply Boolean algebra to switching logic design and simplification.
• Analyze a given digital system and decompose it into logical blocks
involving both combinational and sequential circuit elements.
• Synthesize a given system starting with problem requirements, identifying
and designing the building blocks, and then integrating blocks designed
earlier
• Validate the system functionality and evaluate the relative merits of
different designs.
• Optimization of the existing design and perform new research.
Reference Book
• Text-1:
– G. D. Micheli. Synthesis
and Optimization of Digital
Circuits, 1st edition,
McGraw. Hill
Reference Book
• Ref-1:
Hachtel, Gary D.,
and Fabio Somenzi.
Logic Synthesis and
Verification
Algorithms, 1st ed.
Boston, MA.: Springer.
Reference Book
• Ref-2:
Md. Mozammel Huq
Azad Khan, Digital
Logic Design,
Bangladesh University
Grants Commission,
Dhaka, Bangladesh.
Reference Book
• Ref-3:
Ronald J. Tocci, Neal
Widmer, Greg Moss,
Digital Systems:
Principles and
Applications, 11th
edition, Pearson.
Course Website
– http://bit.ly/ewucseALI
– You will find
• Syllabus
• Course lecture
• Lab Manual
• PDF documents
Introduction
Digital Logic Design- What is it?
The Three Terms
Digital:
Logic:
Design:
+5 x y
0
time
+5
0
time
Pros & cons of digital vs analog
• Digital systems have inherent ability to deal
with electrical signals that have been
degraded by transmission through circuits
Used by Used in
System Base Symbols humans? computers?
Decimal 10 0, 1, … 9 Yes No
Binary 2 0, 1 No Yes
Octal 8 0, 1, … 7 No No
Hexa- 16 0, 1, … 9, No No
decimal A, B, … F
Quantities/Counting (1 of 3)
Hexa-
Decimal Binary Octal decimal
0 0 0 0
1 1 1 1
2 10 2 2
3 11 3 3
4 100 4 4
5 101 5 5
6 110 6 6
7 111 7 7
Quantities/Counting (2 of 3)
Hexa-
Decimal Binary Octal decimal
8 1000 10 8
9 1001 11 9
10 1010 12 A
11 1011 13 B
12 1100 14 C
13 1101 15 D
14 1110 16 E
15 1111 17 F
Quantities/Counting (3 of 3)
Hexa-
Decimal Binary Octal decimal
16 10000 20 10
17 10001 21 11
18 10010 22 12
19 10011 23 13
20 10100 24 14
21 10101 25 15
22 10110 26 16
23 10111 27 17 Etc.
Conversion Among Bases
• The possibilities:
Decimal Octal
Binary Hexadecimal
Quick Example
Base
Decimal to Decimal (just for fun)
Decimal Octal
Binary Hexadecimal
Weight as
12510 100+25 100+20+5
power
=>12510 = 5 + 20 + 100
12510 => 5 x 100 = 5
2 x 101 = 20
1 x 102 = 100
125
Base
Binary to Decimal
Decimal Octal
Binary Hexadecimal
Binary to Decimal
• Technique
– Multiply each bit by 2n, where n is the “weight”
of the bit
– The weight is the position of the bit, starting
from 0 on the right
– Add the results
Example
Bit “0”
1010112 => 1 x 20 = 1
1 x 21 =
2
0 x 22 =
0
1 x 23 =
8
0 x 24 =
0
1 x 25 =
32
Octal to Decimal
Decimal Octal
Binary Hexadecimal
Octal to Decimal
• Technique
– Multiply each bit by 8n, where n is the “weight”
of the bit
– The weight is the position of the bit, starting
from 0 on the right
– Add the results
Example
7248 => 4 x 80 = 4
2 x 81 = 16
7 x 82 = 448
46810
Hexadecimal to Decimal
Decimal Octal
Binary Hexadecimal
Hexadecimal to Decimal
• Technique
– Multiply each bit by 16n, where n is the
“weight” of the bit
– The weight is the position of the bit, starting
from 0 on the right
– Add the results
Example
Decimal Octal
Binary Hexadecimal
Decimal to Binary
• Technique
– Divide by two, keep track of the remainder
– First remainder is bit 0 (LSB, least-significant
bit)
– Second remainder is bit 1
– Etc.
Example
12510 = ?2 2 125
2 62 1
2 31 0
2 15 1
2 7 1 Reverse Order
2 3 1
1 1
12510 = 11111012
Octal to Binary
Decimal Octal
Binary Hexadecimal
Octal to Binary
• Technique
– Convert each octal digit to a 3-bit equivalent
binary representation
Example
7058 = ?2
7 0 5
7058 = 1110001012
Hexadecimal to Binary
Decimal Octal
Binary Hexadecimal
Hexadecimal to Binary
• Technique
– Convert each hexadecimal digit to a 4-bit
equivalent binary representation
Example
10AF16 = ?2
1 0 A F
10AF16 = 00010000101011112
Decimal to Octal
Decimal Octal
Binary Hexadecimal
Decimal to Octal
• Technique
– Divide by 8
– Keep track of the remainder
Example
123410 = ?8
8 1234
8 154 2
8 19 2 Reverse Order
2 3
123410 = 23228
Decimal to Hexadecimal
Decimal Octal
Binary Hexadecimal
Decimal to Hexadecimal
• Technique
– Divide by 16
– Keep track of the remainder
Example
123410 = ?16
16 1234
16 77 2
Reverse Order
16 4 13 = D
0 4
123410 = 4D216
Binary to Octal
Decimal Octal
Binary Hexadecimal
Binary to Octal
• Technique
– Group bits in threes, starting on right
– Convert to octal digits
Example
10110101112 = ?8
1 3 2 7
10110101112 = 13278
Binary to Hexadecimal
Decimal Octal
Binary Hexadecimal
Binary to Hexadecimal
• Technique
– Group bits in fours, starting on right
– Convert to hexadecimal digits
Example
10101110112 = ?16
10 1011 1011
2 B B
10101110112 = 2BB16
Octal to Hexadecimal
Decimal Octal
Binary Hexadecimal
Octal to Hexadecimal
• Technique
– Use binary as an intermediary
Example
10768 = ?16
1 0 7 6
2 3 E
10768 = 23E16
Hexadecimal to Octal
Decimal Octal
Binary Hexadecimal
Hexadecimal to Octal
• Technique
– Use binary as an intermediary
Example
1F0C16 = ?8
1 F 0 C
1 7 4 1 4
1F0C16 = 174148
Exercise – Convert ...
Hexa-
Decimal Binary Octal decimal
33
1110101
703
1AF
Exercise – Convert …
Hexa-
Decimal Binary Octal decimal
33 100001 41 21
117 1110101 165 75
451 111000011 703 1C3
431 110101111 657 1AF
Answer
Fractions
• Decimal to decimal (just for fun)
Hexa-
Decimal Binary Octal decimal
29.8
101.1101
3.07
C.82
Exercise – Convert ...
Hexa-
Decimal Binary Octal decimal
29.8 11101.110011… 35.63… 1D.CC…
5.8125 101.1101 5.64 5.D
3.109375 11.000111 3.07 3.1C
12.5078125 1100.10000010 14.404 C.82
Answer
Questions or Suggestions
10 Minutes
Binary Math
Decimal Addition Example
1) Add 8 + 7 = 15
Add 3758 to 4657: Write down 5, carry 1
2) Add 5 + 5 + 1 = 11
111 Write down 1, carry 1
3758 3) Add 7 + 6 + 1 = 14
+ 4657 Write down 4, carry 1
8 415 4) Add 3 + 4 + 1 = 8
Write down 8
Decimal Addition Explanation
8 4 1 5
So when8the
41 5 of a column is equal to or greater than
sum
the base, we subtract the base from the sum, record the
difference, and carry one to the next column to the left.
Binary Addition Rules
Rules:
–0+0 =0
–0+1 =1
–1+0 =1 (just like in decimal)
1+1 = 210
= 102 = 0 with 1 to carry
1+1+1 = 310
= 112 = 1 with 1 to carry
Binary Addition Example 1
Col 1) Add 1 + 0 = 1
Example 1: Add Write 1
binary 110111 to 11100 Col 2) Add 1 + 0 = 1
Write 1
Col 3) Add 1 + 1 = 2 (10 in binary)
1 1 1 1 Write 0, carry 1
1 1 0 1 1 1 Col 4) Add 1+ 0 + 1 = 2
Write 0, carry 1
+ 0 1 1 1 0 0 Col 5) Add 1 + 1 + 1 = 3 (11 in binary)
Write 1, carry 1
1 0 1 0 0 1 1
Col 6) Add 1 + 1 + 0 = 2
Write 0, carry 1
Col 7) Bring down the carried 1
Write 1
Binary Addition Explanation
1 1 0 1 1 1 64 32 16 8 4 2 1
+ 0 1 1 1 0 0 1 0 1 0 0 1 1
1 0 1 0 0 1 1 = 64 + 16 + 2 +1
= 8310
Binary Addition Example 2
Example 2: Verification
Add 1111 to 111010. 1110102 5810
+0011112 + 1510
1 1 1 1 1 7310
1 1 1 0 1 0
+ 0 0 1 1 1 1 64 32 16 8 4 2 1
1 0 0 1 0 0 1
1 0 0 1 0 0 1
= 64 + 8 +1
= 7310
Decimal Subtraction
Example
8 0 2 5
- 4 6 5 7
3 3 6 8
So when you cannot subtract, you borrow from the
column to the left.
The amount borrowed is 1 base unit,
which in decimal is 10.
The 10 is added to the original column value,
so you will be able to subtract.
Binary Subtraction
Explanation
OR Operations
• OR Table
0 OR 0 = 0
0 OR 1 = 1
1 OR 0 = 1
1 OR 1 = 1
Logical OR Operation
Ex 1: 10010011
OR 0 0 0 0 1 1 1 1
1 0 0 1 1 1 1 1
Logical OR Examples
Ex 2: 11001001
OR 0 0 0 0 1 0 1 0
1 1 0 0 1 0 1 1
Ex 3: 0111
OR 0 0 1 0
0111
Logical XOR Rules
XOR Operations
Rules.
0 XOR 0=0
0 XOR 1=1
1 XOR 0=1
1 XOR 1=0
Logical XOR Examples
Ex 1: 10011001
XOR 0 0 0 0 1 1 1 1
10010110
Ex 2: 0111
XOR 0 0 1 0
0101
Logical AND Rules
AND Operations
Rules.
0 AND 0 = 0
0 AND 1 = 0
1 AND 0 = 0
1 AND 1 = 1
Logical AND Examples
Ex 1: 11010011
AND 00001111
00000011
Ex 2: 0111
AND 1 0 0 1
0001
Logical NOT
NOT Operations
• NOT is a separate operator for flipping the bits.
Rules.
NOT 0 = 1
NOT 1 = 0
Example. NOT 1 0 1 0 = 0 1 0 1
Shift and Rotate operations
This box is a
register
0 1 1 0 1 00 10 10
Lets
AndNow
So
AndNotice
the put
the
newthe
the
some
bits
bits
processor
emptythat
bits
shift
went
into
togets
spaces the
out
theleft
are an
register
of the
by with
filled 3 (8 zeros
bits)
registerthat
instruction
places we towon’t
are(because
dropped 8get
multiply the
because
is the 3correct
this of
rd
answer,
overflow
number
power because
of
by2)8 of overflow. If the
original number was smaller and had
three zeros on the left, then the
overflow would have only dropped
View
this
slide in
Negative Number
a slide
show!
Multiplication Overflow
For Negative numbers, be aware that
overflow will yield some strange
results
1 0 1 0 1 1 0 10
Themultiply
Let’s computer
Take thisbyerases
8-bit the
2. This bit binary
negative
means that
we left-shift by 1.
overflowed
number:and puts in =a -83
10101101 zero(or
on the right,
likepositive
it’s supposed
173) to. But the new number
is 01011010, which equals 90! This
happened because the lower limit of 8-bit
twos complement negative numbers is -
128. However, -83 * 2 would have gone
View
this Fancy Shifting Animation:
slide in
a slide Division
show!
Also called right-shifting
(look at the animation)
101 100 1 0 1 0 1 1
IfThe computer
Dividing
the Let’s
original drops
try number
dividing the
by powersbybits
was 4. that
2 is went
ofWhen
negative very
that outthen
(-85), of
theonly
the register
similar
happens, tothe
difference themultiplying.
to right.
wouldIfbe
number the
in original
Here,
that
the wecome in
register
ones
onnumber
thewill
leftwas
haveshift
side positive
our to original
instead (171),
the right bythen
ofbinary
zeros. the time
number
2 places.
This (4 our
computer
answer is in
is will
the
the-22. put
2ndregister.
Itpower zeros
should 2)on-21.75,
(10101011
of be the left.
=butThe
171 the
final answer
computer ORrounded
-85)is: 42. Notice
down again.thatJust
thisremember
isn’t a
totally
that when accurate
you round answer (it should
a negative be 42.75)
number
Because the computer dropped some bits we
Rotate Left operation
ROL
ROL (rotate left) shifts each bit one place to the left.
The original leftmost bit is shifted into the rightmost
position. No bits are lost.
Ex 1. ROL 1 1 0 1
1011
Ex 2. ROL 1100
=1001
Rotate Left – Multiple Bits
Ex 1: ROL 3 10011100
=11100100
Ex 2: ROL 2 11100110
=10011011
Rotate Right operation
ROR
ROR (rotate right) shifts each bit one place to the right.
The original rightmost bit is shifted into the leftmost
position. No bits are lost.
Ex 1. ROR 1 0 1 1
11 0 1
Ex 2. ROR 0 0 1 1
=1001
Rotate Right – Multiple Bits
Ex 1: ROR 3 10011100
=10010011
Ex 2: ROR 2 1 1 1 0 0 1 1 0
=10111001
Part 3
3-1 INTRODUCTION
i
An integer is normally stored in memory using
fixed-point representation.
Unsigned representation
An unsigned integer is an integer that can never be negative and can
take only 0 or positive values. Its range is between 0 and positive
infinity.
Solution
First change the integer to binary (100000010)2. Add seven 0s to
make a total of sixteen bits, (0000000100000010)2. The integer is
stored in the memory location.
Example 3.3
What is returned from an output device when it retrieves the bit
string 00101011 stored in memory as an unsigned integer?
Solution
Using the procedure shown in Chapter 2, the binary integer is
converted to the unsigned integer 43.
Figure 3.5 shows what happens if we try to store an integer that is
larger than 24 − 1 = 15 in a memory location that can only hold four
bits.
i
In sign-and-magnitude representation, the leftmost bit defines the
sign of the integer. If it is 0, the integer is positive. If it is 1, the
integer is negative.
Example 3.4
Store +28 in an 8-bit memory location using sign-and-magnitude
representation.
Solution
The integer is changed to 7-bit binary. The leftmost bit is set to 0.
The 8-bit number is stored.
Example 3.5
Store -28 in an 8-bit memory location using sign-and-magnitude
representation.
Solution
The integer is changed to 7-bit binary. The leftmost bit is set to 1.
The 8-bit number is stored.
Example 3.6
Retrieve the integer that is stored as 01001101 in sign-and-
magnitude representation.
Solution
Since the leftmost bit is 0, the sign is positive. The rest of the bits
(1001101) are changed to decimal as 77. After adding the sign,
the integer is +77.
Example 3.7
Retrieve the integer that is stored as 10100001 in sign-and-
magnitude representation.
Solution
Since the leftmost bit is 1, the sign is negative. The rest of the
bits (0100001) are changed to decimal as 33. After adding the
sign, the integer is −33.
One’s Complement Representation
One’s complement is another way to represent signed integers.
-(2(N-1) – 1) to + (2(N-1) – 1)
One’s Complement Comments
Still have the problem that there are two ways of
representing 0 (-0, and +0) . Mathematically speaking, no
such thing as two representations for zeros.
-5 + 5 = $ FA + $ 05 = $FF = -0
-2(N-1) to + 2(N-1) - 1
Note that negative range extends one more than positive range.
Two’s Complement Comments
Two’s complement is the method of choice for representing
signed integers.
-5 + 5 = $ FB + $ 05 = $00 = 0
0101 0111
59 in BCD (0 ~ 99)
because there are unused code words
87 in normal unsigned binary number (0 ~ 255)
Binary-Coded Decimal (BCD)
0010 = 2
9s’complement of 2 can be obtained by complementing
individual bits
1101 = (2+4+0+1) = 7
Excess-3 code
16
for a 4-bit decimal code, there are different ways
10
to choose 10 out of 16 4-bit code words, and 10!
ways to assign each different choice to the 10
digits. So there are
(16!/(10!*(16-10)!))*10! Or 29059430400
different 4-bit decimal codes.
Gray Code