0% found this document useful (0 votes)
21 views73 pages

Chapter 1

The document outlines a course on Digital Logic, aimed at providing fundamental knowledge of digital computer systems and their design aspects. It includes course objectives, logistics, a detailed syllabus covering various topics such as combinational logic circuits, memory devices, and number systems, as well as the history and functioning of transistors. Additionally, it discusses digital processing systems, information representation, and arithmetic operations in binary systems.

Uploaded by

rajtimalsina2062
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views73 pages

Chapter 1

The document outlines a course on Digital Logic, aimed at providing fundamental knowledge of digital computer systems and their design aspects. It includes course objectives, logistics, a detailed syllabus covering various topics such as combinational logic circuits, memory devices, and number systems, as well as the history and functioning of transistors. Additionally, it discusses digital processing systems, information representation, and arithmetic operations in binary systems.

Uploaded by

rajtimalsina2062
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 73

Digital Logic

Suramya Sharma Dahal (SSD)


Associate Professor
(AMD X4 Proc; photo: Sc. Am, Jan. 2010)

1
Course Objectives
• Main objectives of this course is to provide the
student with the fundamental knowledge about the
basic building logical blocks of digital computer
systems.

• This course also aims at familiarizing the student to


design aspect of the logic elements of a computer
system.

2
Course Logistics
• Prerequisite:
– Basic concept of Digital Logic

• Textbook:
– "Logic and Computer Design Fundamentals,"
2nd Edition, by M. Mano and C. Kime, Pearson Education Asia,ISBN # 81-7808-
334-5
Reference Books:
– Book by M.Morris Mano/PHI
– Book by Hamachar/Zakie/McGraw Hill

3
Syllabus

Chapter 1: Digital Computers and Information


Chapter 2: Combinational Logic Circuits
Chapter 3: Combinational Logic Design
Chapter 4: Sequential Circuits
Chapter 5: Memory and Programmable Logic Devices
Chapter 6: Instruction Set Architecture
Chapter 7: Central Processing Unit
Chapter 8: The Input/output Communication

4
History of the transistor
• Around 1947, Bell Labs scientists discovered that
silicon was comprised two distinct regions differentiated
by the way in which they favored current flow.

• They are that favored positive current flow they named


“p” and the are that favored negative current flow they
named “n”.

5
Transistor
• Semiconductors: ability to
change from conductor to
insulator
• Can either allow current or
prohibit current to flow
• Useful as a switch, but also as an
amplifier
• Essential part of many
technological advances
6
The Transistor is Born
• Bell Labs (1947): Bardeen, Brattain, and
Shockley
• Originally made of germanium
• Current transistors made of doped silicon

7
How Transistors Work
• Doping: adding small amounts of other
elements to create additional protons or
electrons
• P-Type: dopants lack a fourth valence electron
(Boron, Aluminum)
• N-Type: dopants have an additional (5th)
valence electron (Phosphorus, Arsenic)
• Importance: Current only flows from P to N

8
Bipolar Junction Transistor (BJT)
• 3 adjacent regions of doped Si
(each connected to a lead):
– Base. (thin layer,less doped).
– Collector.
– Emitter.
• 2 types of BJT: npn bipolar junction transistor

– npn.
– pnp.
• Most common: npn (focus on
it).

Developed by
Shockley pnp bipolar junction transistor

(1947) 9
Digital Logic Circuit

• Computer= large number of simple


structures
• Intel 4004=2,300 transistors
• Intel Pentium 4= 42 million transistors
• Intel Core 2 Duo= 291 million
transistors
• Intel i7 = 731 million transistors

10
Moore’s Law

11
Introduction to Digital Logic
Deals with building blocks of digital systems

? Transistor

(Intel)

12
Digital Model of a Transistor
• We make abstraction of the signals: 0 or 1
• As a result a transistors can be considered a switch (on or off; 1 or 0)

13
Overview: you will learn
• Digital Computer
• Information Representation
• Number Systems [binary, octal and
hexadecimal]
• Base Conversion
• Negative Number Representation
• Decimal Codes [BCD (binary coded
decimal)]
• Alphanumeric Codes
• Parity Bit
• Gray Codes, Excess-3 Codes
14
Digital Processing System
• Takes a set of discrete information inputs
and discrete internal information (system
state) and generates a set of discrete
information outputs.

15
Digital System Example:
A Digital Counter (e. g., odometer):

Count Up
Reset 0 0 1 3 5 64

Inputs: Count Up, Reset


Outputs: Visual Display
State: "Value" of stored digits

16
A Generic Digital Computer

17
A Generic Digital Computer
• Data Path:
– Performs calculations and comparisons (data changed)[Data
Processing and arithmetic operation specified by the program]
• CU (control unit): performs fetch/execute cycle
– Functions:
• Moves data to and from CPU registers and other hardware
components (no change in data)
• Accesses program instructions and issues commands to the ALU
– Subparts:
• Memory management unit: supervises fetching instructions and data
• I/O Interface: sometimes combined with memory management unit
as Bus Interface Unit
• FPU: like CPU, except its data path and Control Unit are designed to perform
floating-point operations
• Cache: memory that allow the CPU and FPU to get at the data to be
processed much faster than RAM alone.

18
INFORMATION REPRESENTATION
• Information variables represented by physical
quantities.
• For digital systems, the variables take on
discrete values.
• Two levels or binary values are the most
prevalent values in digital systems.
• Binary values are represented abstractly by:
– digits 0 and 1
– words (symbols) False (F) and True (T)
– words (symbols) Low (L) and High (H)
– and words Off and On.

19
Signal Examples Over Time

Time
Continuous
Analog in value &
time

Digital Discrete in
value &
Asynchronous
continuous
in time

Synchronous Discrete in
with the clock value &
time20
Advantages of Digital System
Reproducibility ( Hi-Fi-> high fidelity)

Not effected by noise means quality (Better Noise


Immune)

Data protection( Encryption)

Programmable (Storage)

Speed (High Speed)

Economy (Mass Production)

21
Immunity to noise: Noise Margin

VOH
NMH
VIH
Forbidden
VIL
NML
VOL

Threshold
Region

NMH=VOH-VIH NML=VIL-VOL
We cannot violate the Noise Margins, otherwise our digital assumption
is not valid: thus Vo must be > VOH or < VOL.
22
Binary Values: Other Physical Quantities
• What are other physical quantities
represent 0 and 1?
– Logic Gates, CPU: Voltage

– Disk Magnetic Field Direction

– CD Surface Pits/Light

– Dynamic RAM

Electrical Charge 23
Number Systems
• Positive radix, positional number systems
• Examples:
– Decimal (radix r =10)
Ex: 24.3 = 2x101 + 4x100+3x10-1
– Binary (radix r =2)
Ex: 1101.01 = ( . )10 Digits (0-9)

– Octal (radix r = )
Digits: 0,1,2,3,4,5,6,7
– Hexadecimal (r = )
Digits: 0,1,2,…9, A, B, C, D, E, F
24
Powers of 2: 2 n

It will be convenient to remember these powers

n 2n n 2n
0 1
1 2 -1 0.5
2 4 -2 0.25
3 8 -3 0.125
4 16
5 32
6 64
7 128
8 256
9 512
10 1024

25
Special Powers of 2
210 (=1024) is Kilo, denoted "K"

220 (=1,048,576) is Mega, denoted "M"

230 (1,073, 741,824) is Giga,


? denoted "G"

240 (1,099,511,627,776 ) is Tera, denoted “T"


• Note: 8 bits (b) are also called a byte (B)
Exercise: what is (1111 1111)2 equal to in decimal?
Also what is the maximum number (in decimal) a two bytes
long word can represent?
26
Exercise

• (146.A)16 = ( ? )10

• (247.4)8 = ( ? )10

27
Range of numbers
• Binary number: ex. a 3-bit number: n=3
– 000, 001 … ,111 or in decimal system: 0,
1…7
• Total of 8 numbers (=2 3) 2m-1/2m
• Range: from 0 to 7 (0 to 2 3-1)
Proof: A-12-1 + A-22-2
– In general a n-bit number represents:
• 2n different numbers
+ …. A-m2-m)
• Min: 0 = 2-m (A-12m-1 + A-22m-
• Max number: 2n-1 2
+… A-m20)
• For fractions: m bits after the radix = 2-m (2m -1)
point:
– Min: 0
– Max number: (2m -1)/2m

28
Number of Bits Required
 Given M elements to be represented by a
binary code, the minimum number of bits,
n, needed, satisfies the following
relationships:
2n ³ M > 2(n – 1)
n = log2 M where x , called the ceiling
function, is the integer greater than or
equal to x.
 Example: How many bits are required to
represent decimal digits with a binary
code?
29
Exercise
• 16 Gbyte (= 16 GB) of memory
– How many (address) bits are required to
address each byte?

30
Exercise
• Digital camera has 2048x2048 pixels, and
each pixel stores 8 bits of information:

– a. How many Mega pixels?


– b. How many bits are stored?
– c. How many different intensity levels can be
represented by each pixel?

31
Use of HEX system
• Short hand notation of large binary numbers:
– Each HEX digits can be represented by exactly 4 bits
(16=24)
– Thus (10011110.0101)2

9 E . 5

Conversion from binary to HEX and HEX to binary is


very easy:
(10011101)2 = ( )16
(1010110110.11)2 = ( )16
B39.716 = ( )2
32
Octal system
• Radix r = 8
• 8 digits:
– 0, 1, 2,…7
• Ex: 2758 = 2x82 + 7x8 + 5x1 = 128 + 56 + 5
= 18910
• Each octal digit can be represented by 3 bits

33
Conversion Between Bases

To convert from one base to another:

1) Convert the Integer Part


2) Convert the Fraction Part
3) Join the two results with a radix point

34
Conversion from Decimal to new Radix
• To Convert the Integral Part:
Repeatedly divide the number by the new radix and
save the remainders. The digits for the new radix
are the remainders in reverse order of their
computation.
• To Convert the Fractional Part:
Repeatedly multiply the fraction by the new radix
and save the integer digits that result. The digits
for the new radix are the integer digits in order of
their computation. If the new radix is > 10, then
convert all integers > 10 to digits A, B, …
35
Example: convert (325.65)10 to hex
• Integer part: 32510 = ( . )16
325/16 = 20 and rem = 5 Least significant digit
20/16 = 1 and rem = 4
1/16 = 0 and rem = 1
Most significant

Thus 32510 = 14516


• Fractional part: .65
0.65x16 = 10.4 thus int = 10= A Most significant
0.4x16 = 6.4 thus int = 6
0.4x16 = 6.4 thus int = 6
Etc. Least significant

Thus .6510 = A6616


325.6510 = 145.A6616
36
Example: Convert 54.687510 To Base 2

• Convert 54 to Base 2

• Convert 0.6875 to Base 2:

• Join the results together with the


radix point:
37
Conversions from Binary to Octal and Hexadecimal

Grouping in groups of 3 or 4 bits


Convert 10001011 into octal and hexadecimal:

Octal: Hexadecimal
10001011 10001011
2 1 38 8 B16

38
Octal to Hexadecimal via Binary
Conversion from Octal to Hexadecimal and vice versa

Convert 2138 into an hexadecimal number:

2138

10001011

8 B16

39
Exercise: Octal Hexadecimal
• Exercise: Hexadecimal to Octal:
3A.5 16 = ( )8

• Octal to Binary to Hexadecimal


6 3 5.1778 = ( )16

40
Conversion - Summary
Divisions (or x) by 16

Ai.16i Hexadecimal
Decimal Di
vis
on
sb
S A
y2 Group in
.2 i bits of 4
Div

i
Binary
iso
ns

Octal Hex:
Group in
by

through the binary


 Ai.8i bits of 3
8

representation
Octal

41
Arithmetic Operations
Single Bit Binary Addition with Carry
Multiple Bit Binary Addition
Single Bit Binary Subtraction with Borrow
Multiple Bit Binary Subtraction
Multiplication

42
Single Bit Binary Addition with Carry
Given two binary digits (X,Y), a carry in (Z) we get the
following sum (S) and carry (C):
Carry in (Z) of 0: Z 0 0 0 0
X 0 0 1 1
+Y +0 +1 +0 +1
CS 00 01 01 10

Carry in (Z) of 1: Z 1 1 1 1
X 0 0 1 1
+Y +0 +1 +0 +1
CS 01 10 10 11

43
Multiple Bit Binary Addition

• Extending this to two multiple bit


examples:
Carries 0 0
Augend 01100 10110
Addend +10001 +10111
Sum
• Note: The 0 is the default Carry-In to the
least significant bit.
44
Single Bit Binary Subtraction with Borrow
 Given two binary digits (X,Y), a borrow in (Z) we get
the following difference (S) and borrow (B):
 Borrow in (Z) of 0: Z 0 0 0 0
X 0 0 1 1
-Y -0 -1 -0 -1
BS 00 11 01 00
 Borrow in (Z) of 1:
Z 1 1 1 1
X 0 0 1 1
-Y -0 -1 -0 -1
BS 11 10 00 11
45
Multiple Bit Binary Subtraction
• Extending this to two multiple bit examples:
Borrows 0 1
Minuend 10110 10110
Subtrahend - 10010 - 10011
Difference

46
Binary Multiplication
The binary multiplication table is simple:
00=0 | 10=0 | 01=0 | 11=1
Extending multiplication to multiple digits:
Multiplicand 1011
Multiplier x 101
Partial Products 1011
0000 -
1011 - -
Product 110111

47
Negative Binary Number
• In decimal we are quite familiar with placing
a
“-” sign in front of a number to denote that it
is negative
• The same is true for binary numbers a
computer won’t understand that
• What happens in memory then?

48
Negative Binary Number
• There are several representations
- Signed magnitude
- One’s complement
- Two’s complement
• Two’s complement is the system used in
microprocessors
• Most significant bit becomes important

49 49
Sign Magnitude
• Represent the decimal number as binary
• Left bit (MSB) used as the sign bit
• Only have 7 bits to express the number

• 1210 = 00001100
• -1210 = 10001100

50 50
1’s Complement

• Method: Invert the ones and zeros

• 1110 = 00001011
• -1110 = 11110100

• 0 in MSB implies positive


• 1 in MSB implies negative

51 51
2’s Complement
• Method: Take the one’s complement and add
1
• 1110 = 00001011
• -1110 = 11110100 one’s comp
• -1110 = 11110101 two’s comp

52 52
2’s Complement Subtraction
• Only need one type of hardware/process to add
both signed and unsigned numbers.

POS 9 NEG (-9)


+ POS  + 5 + POS  + 5
POS 14 NEG -4

POS 9 NEG (-9)


+ NEG  + (-5) + NEG  + (-5)
POS 4 NEG - 14
53 53
POS + POS → POS Answer
If no 2’s complement is needed, use regular binary
addition.

54 54
POS + NEG → POS Answer
Take the 2’s complement of the negative number and use
regular binary addition

55 55
POS + NEG → NEG Answer
Take the 2’s complement of the negative number and use
regular binary addition.

56 56
NEG + NEG → NEG Answer
Take the 2’s complement of both negative numbers and
use regular binary addition.

57 57
Binary Codes
• A n-bit binary code is a n-bit word
which can represent up to 2n different
elements.
• Example: 3-bit code can represent up
to 8 different elements”

58
Binary Codes
• Example: A
binary code Color Binary Number
Red 000
for the seven
Orange 001
colors of the Yellow 010
rainbow Green 011
Blue 101
Indigo 110
Violet 111

• Given n binary digits (called bits), a binary


code is a mapping from a set of represented
elements to a subset of the 2n binary
numbers or elements.
59
Decimal Codes>>Binary Coded Decimal (BCD)

• The BCD code is the 8,4,2,1 code.


• This code only encodes the first ten values
from 0 to 9.
• Each decimal digit is coded separately by 4
bits
• Example:
– (325)10 = (0011 0010 0101)BCD
3 2 5

• Exercise: (856)10 = ( )BCD


60
BCD Addition
Given a BCD code, we use binary arithmetic to add the digits:
8 1000 Eight
+5 +0101 Plus 5
13 1101 is 13 (> 9)
Note that the result is MORE THAN 9, so must be
represented by two digits!
To correct the digit, add 6 to the result.
8 1000 Eight
+5 +0101 Plus 5
13 1101 is 13 (> 9)
+0110 so add 6
carry = 1 0011 leaving 3 + cy
0001 | 0011 Final answer (two digits)

61
Exercise
Add 448BCD to 489BCD showing carries and digit
corrections.

62
ALPHANUMERIC CODES - ASCII Character Codes
• American Standard Code for Information
Interchange
• This code is a popular code used to
represent information sent as character-
based data. It uses 7-bits to represent:
– 94 Graphic printing characters.
– 34 Non-printing characters
• Some non-printing characters are used for
text format (e.g. BS = Backspace, CR =
carriage return)

63
ASCII Code: B7B6B5 B4B3B2B1

H=(1001000)

64
ASCII Properties
ASCII has some interesting properties:
 Digits 0 to 9 span Hexadecimal values 3016 to 3916 .
 Upper case A - Z span 4116 to 5A16 .
 Lower case a - z span 6116 to 7A16 .
• Lower to upper case translation (and vice versa)

occurs by flipping bit 6.


 Delete (DEL) is all bits set, a carryover from when

punched paper tape was used to store messages.

65
PARITY BIT Error-Detection Codes
• Redundancy (e.g. extra information), in the form of
extra bits, can be incorporated into binary code words
to detect and correct errors.
• A simple form of redundancy is parity, an extra bit
appended onto the code word in the most significant
position to make the number of 1’s odd or even. Parity
can detect all single-bit errors and some multiple-bit
errors.
A code word has even parity if the
number of 1’s in the code word is 7
even. TX RX
A code word has odd parity if the Parity bit
number of 1’s in the code word is
odd.
66
ASCII Parity Code Example
7
TX At the receiver side:
RX
Parity bit If an even parity is
detected, send an
Transmit Ha in ascii: ACK control =
1001000 1100001 00000110
Transmit with even parity: If error was detected
01001000 11100001 send negative
acknowledge NAK =
10010101
added parity bit

67
4-Bit Parity Codes

 Fill in the even and odd parity bits:


Even Parity Odd Parity
Message - Parity Message - Parity

000 - 000
-
001 - 001
-
010 - 010
-
011 - 011
-
100 - 100
-
101 - 101
-
110 - 110
-
 The codeword "1111" has even parity
111 - 111
- and the
codeword "1110" has odd parity. Both can be used
to represent 3-bit data.

68
GRAY CODE

Binary Gray
000 000
001 2 bit changes 001
010 011
011 2 bit changes 010 Only 1 bit changes
100 110
101 2 bit changes 111
110 101
111 100

What special property does the Gray code have in


relation to adjacent decimal digits?

69
Binary to Gray Code( Vice-Versa)
E.g. Conversion of Binary number 10110 to Gray
Code
1+0+1+1+0 Binary

1 1 1 0 1
Conversion of Gray Code 11101 to Binary Number
1 1 1 0 1
+ + + +
1 0 1 1 0

70
Excess 3 Code
Decimal Excess 3
0 0011
1 0100
2 0101
3 0110
4 0111
5 1000
6 1001
7 1010
8 1011
9 1100

What interesting property is common to these two


codes?
71
Warning: Conversion or Coding?
 Do NOT mix up conversion of a
decimal number to a binary number
with coding a decimal number with a
BINARY CODE.
 1310 = 11012 (This is conversion)
 13  0001|0011 (This is coding)

72
Problem:

You have to design a display system for a thermometer. The


minimum temperature that your display will have to output is 0
degree and the maximum is 99 degrees.
1. What is the minimum number of bits that is required to represent
the temperature in binary?
2. Convert 95 degrees in decimal to binary, octal and hexadecimal.
3. Convert 95 degrees in decimal to BCD representation.
4. Convert 111 in octal to hexadecimal.
5. If you were required to represent both positive and negative
temperatures in the range from -99 degrees to 99 degrees, how
many bits do you need to represent the temperature in binary?

73

You might also like