E1121 Digital Logic (A) : FALL 2018
E1121 Digital Logic (A) : FALL 2018
FALL 2018
Lecture 1
Number System
Course information
Lecture Schedule Th. 11.30AM – 1.10 PM
Instructor
Dr. Marwa Abdelrazik Elmenyawi
[email protected]
Office Hours: Tuesday 1.30-2.30 PM.
Teaching Assistants
Eng. Nada
Eng Eman
Eng. Mariam
Course information
Grading
Section & lab 10% (typically every week)
Midterm 25% ( at 9 th week)
Detail: We will try to explain every construct used in this course in sufficient detail for
real understanding
There is no “magic”
Utility: We will try to explain only useful concepts, constructs, and techniques
We will not try to explain every obscure detail
Completeness: The concepts, constructs, and techniques can be used in combination to
construct useful programs
There are, of course, many useful concepts, constructs, and techniques beyond what is taught here
Simplicity: The examples used are among the simplest realistic ones that illustrate the
concepts, constructs, and techniques
Your exercises and projects will provide more complex examples
Why are we here?
Obvious reasons
Course is “required”, prerequisite for some courses such as
E1222 Computer Architecture
E1321 Microprocessors I , E1322Microprocessors II
Digital systems are widespread in use.
Integrated Circuits that operate on digital data are in 95% of every electrical powered device
in the U.S.
Use basic digital tools and devices such as FPGA and VHDL.
Use Boolean Algebra and resulting logic for control and data paths
Do simple design with basic digital building blocks such as multiplexors, decoder, adder…etc
Use industry standard CAD software that implements VHDL and can be used to program
devices.
Synthesize a given system starting with problem requirements, identifying and designing the building
blocks, and then integrating blocks designed earlier
Course Topics
Number Systems
Logic Gates
Boolean Algebra
Karnaugh Map
Combinational circuits
Boolean function, truth table, circuit
Decoder/Encoder
Multiplexer/Demultiplexer
Adder/Subracter/Multiplier
We are all familiar with the decimal number system (Base 10). Some
other number systems that we will work with are:
Binary
Octal
Hexadecimal
Binary numbers?
2
14
Numbers
4
5) When 1 is added to the largest basic digit, a sum of zero and a carry of one results.
6) Numeric values are determined by the implicit positional values of the digits.
Common Number Systems
6
Used by Used in
System Base Basic digit humans? computers?
Decimal 10 0, 1, … 9 Yes No
Binary 2 0, 1 No Yes
Octal 8 0, 1, … 7 No No
Hexadecimal 16 0, 1, … 9, No No
A, B, … F
Quantities/Counting
7
Decimal Binary Octal Hex
00 0000 00 0
01 0001 01 1
02 0010 02 2
03 0011 03 3
04 0100 04 4
05 0101 05 5
06 0110 06 6
07 0111 07 7
08 1000 10 8
09 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
16 10000 20 10
17 10001 21 11
Outline of Chapter 1
Number Systems
Number-base Conversions
Arithmetic Operations
Complements
Signed Binary Numbers
Binary Codes
Bridging the Digital Divide
8
Decimal-to-Binary
Conversion
Binary-to-Decimal
Conversion
Number Base Conversions
9
Evaluate
Magnitude
Octal
(Base 8)
Evaluate
Magnitude
Decimal Binary
(Base 10) (Base 2)
Hexadecimal
(Base 16)
Evaluate
Magnitude
Base R to decimal conversion
10
A number expressed in base R can be converted to its decimal equivalent by using the
Positional representation rule [ multiplying each digit to R power of the digit place and
adding]
N=
Examples:
4 3 2 1 0 -1-2
(11010. 1 1)2 ( ? )10
N = 124 + 123 + 022 + 121 + 020 + 12-1 + 12-2 = (26.75)10
2 1 0 -1
(628.4)9 ( ? )10
N = 692 + 291 + 890 + 49-1 = (512.1111)10
2 1 0 -1
(95A.D)16 ( ? )10
N = 9162 + 5161 + 10160 + 1316-1 = (2394.8125)10
Converting Decimal to Base R
11
To convert a decimal integer into base R, keep dividing by R until the quotient is 0.
Collect the remainders in forward order
To convert a fraction, keep multiplying the fractional part by R until it becomes 0.
Collect the integer parts in reverse order
Example: (162.375)10 = (10100010.011)2
162 0.375 x 2 = 0.750
81 0 0.750 x 2 = 1.500
40 1 0.500 x 2 = 1.000
20 0
10 0
5 0
2 1
1 0
0 1
Binary and Octal Conversions
12
Converting from octal to binary: Replace each octal digit with its 421
equivalent 3-bit binary sequence
( 2 6 . 2 )8 Octal Binary
0 000
1 001
( 0 1 0 1 1 0 . 0 1 0 )2
Converting from binary to octal: Make groups of 3 bits, starting 2 010
from the binary point. Add 0s to the ends of the number if needed. 3 011
Convert each bit group to its corresponding octal digit.
Assume Zeros 4 100
5 101
( 1 0 1 1 0 . 0 1 )2
6 110
7 111
( 2 6 . 2 )8
Binary and Hex Conversions
13
Converting from hex to binary: Replace each hex digit with its 8421
equivalent 4-bit binary sequence Hex Binary
( 2 B . 4 )16 0 0000
1 0001
2 0010
( 0010 1011 . 0100 )2 3
4
0011
0100
5 0101
6 0110
Converting from binary to hex: Make groups of 4 bits, starting 7 0111
from the binary point. Add 0s to the ends of the number if needed. 8 1000
9 1001
Convert each bit group to its corresponding hex digit A 1010
Assume Zeros B 1011
C 1100
( 1 0 1 011 . 0 1 )2 D 1101
E 1110
F 1111
( 2 B . 4 )16
Base Conversion
14
Answer
Verification
You can always check your answer by
converting the figures to decimal, doing 1101112 5510
the addition, and comparing the +0111002 + 2810
answers.
8310
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
Hexadecimal Addition
22
4 17 20 15
4 1 4 F 4 1 4 15
For sums greater than 15, subtract 16 and carry 1 to the next position.
Decimal Subtraction Example
23
1) Try to subtract 5 – 7 can’t.
Subtract Must borrow 10 from next column.
Add the borrowed 10 to the original 5.
4657 from 8025:
Then subtract 15 – 7 = 8.
2) Try to subtract 1 – 5 can’t.
7 9 11 Must borrow 10 from next column.
8 10 2 15 But next column is 0, so must go to
- 4 6 5 7 column after next to borrow.
Add the borrowed 10 to the original 0.
3 3 6 8 Now you can borrow 10 from this column.
Add the borrowed 10 to the original 1..
Then subtract 11 – 5 = 6
3) Subtract 9 – 6 = 3
4) Subtract 7 – 4 = 3
Decimal Subtraction Explanation
24
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 2.
Verification
Subtract binary
11100 from 110011: 1100112 5110
- 111002 - 2810
2 1
0 0 2 2 2310
1 1 0 0 1 1 64 32 16 8 4 2 1
- 1 1 1 0 0 1 0 1 1 1
1 0 1 1 1 = 16 + 4 + 2 + 1
= 2310
Hexadecimal Subtraction
28
C 1 7 12 1 7
To subtract the least significant digit, borrow base (16) from the
previous position
Feedback request