0% found this document useful (0 votes)
18 views21 pages

Lecture 5 - The Digital Logic Level - Revision

Uploaded by

cloverfairbank
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)
18 views21 pages

Lecture 5 - The Digital Logic Level - Revision

Uploaded by

cloverfairbank
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/ 21

Lecture 5: The Digital

Foundations of Computing
Logic Level – Revision
Foundations of Computing: Technical Strand
João Filipe Ferreira

1
Basic Gates
• There are several gates to remember:
• NOT, AND, OR, NAND, NOR, XOR, XNOR
• You will need to know the following about each of these:
• Logical symbol / how it is represented in algebra

Foundations of Computing
• Gate symbol
• Truth table and operation of gate
NOT Gate
A O
A O 0 1 Written as: A
1 0

2
Basic Gates
AND Gate
A B O
A
0 0 0
O 0 1 0
Written as A . B
B 1 0 0
1 1 1

Foundations of Computing
OR Gate
A B O
A 0 0 0
O 0 1 1 Written as A + B
B 1 0 1
1 1 1

NOT (high)
3
Order of precedence:
AND
OR (low)
Basic Gates
NAND Gate
XOR Gate

A A
O O
B A B O
B A B O
0 0 1 0 0 0

Foundations of Computing
0 1 1 0 1 1
1 0 1 1 0 1
1 1 0 1 1 0
XNOR Gate
NOR Gate
A A
O O
B A B O B A B O
0 0 1 0 0 1
0 1 0 0 1 0 4
1 0 0 1 0 0
1 1 0 1 1 1
Combining Gates
A

B
O
C

Foundations of Computing
E

• Gates can be linked together to form circuits.


• This can be represented by using an expression to describe the function
of the circuit. e.g.

O = A.(B+C) + D.E
• In the class test, you will be asked to work out both the circuit from an
expression and how to represent a circuit as an expression. 5
• An example question could be to draw the following circuit: A+ A.(B.C) +D
Combining Gates Have a go!

• Draw: A+ A.(B.C) +D

Foundations of Computing
6
Boolean Expressions Have a go!
• Calculate the non-simplified Boolean expression for this truth table

Foundations of Computing
A B C O
O = 1 if A = 0 AND B = 0 AND C = 1
0 0 0 0 (mandatory to state!)
0 0 1 1 * OR A = 0 AND B = 1 AND C = 0
0 1 0 1 * OR A = 1 AND B = 0 AND C = 0
0 1 1 0 OR A = 1 AND B = 1 AND C = 1
1 0 0 1 *
1 0 1 0 Build corresponding expression:
1 1 0 0 If the variable is a 0, we write it with
1 1 1 1 * an over-score, or a dash after it 7
__ _ _ __
O = A.B.C + A.B.C + A.B.C + A.B.C
Boolean Algebra (laws)
• In lecture 3, we covered Boolean Algebra.
• You will need to know the different laws (to help in the simplification
of Boolean algebra).
• Commutative Law: A+B=B+A A.B=B.A
• Associative Law: (A+B)+C=A+(B+C) (A.B).C=A.(B.C)

Foundations of Computing
• Distributive Law: A.(B+C)=(A.B)+(A.C) A+(B.C)=(A+B).(A+C)
• Identity Law (1): A+A=A A.A=A
• Identify Law (2): A.B+A.B=A (A+B).(A+B)=A
• Redundancy Law(1): A+A.B = A A.(A+B)=A
• Redundancy Law(2): 1+A = 1 1.A = A
• Redundancy Law(3): 0+A=A 0.A = 0
• Redundancy Law(4): A+A=1 A.A = 0 8
• DeMorgan’s Laws: (A+B) = A . B (A.B) = A + B
Have a go!
Simplifying Expressions
• You will encounter questions which will require you to simplify
expressions _
• Simplify: (XY)+(XY)
_
Distributive Law
_ A.(B+C)=(A.B)+(A.C)
(XY)+(XY) = X.(Y + Y) Redundancy Law (4)
_

Foundations of Computing
(XY)+(XY)
_
= X.(1) A+A = 1
Redundancy Law (2)
(XY)+(XY) = X 1.A = A
We can verify
this by: _ _
X Y (X.Y) (X.Y) (X.Y)+(X.Y)
0 0 0 0 0
0 1 0 0 0 9
1 0 0 1 1
1 1 1 0 1
Binary
• You will need to know how to represent numbers in each of the
following:
• Binary
• Hexadecimal
• You will be required to convert between decimal -> binary (and

Foundations of Computing
vice versa) as well as for binary -> hexadecimal.
• What is Binary?
• Base 2 number system which only can have values of 1 or 0.
• Position / weighting of column is twice the previous (found by 2n
where n = position)
• For example:
• 87510= 11011010112 10
• How do we convert between the bases?
Converting from Decimal (1)
• There are two ways for converting a
number from decimal to binary.
• Method 1: Division Method E.g. Convert 15510 to binary
• Steps / algorithm: 15510 / 210 = 7710 77.5 77(r 1)
1. Divide the decimal number by 2 (i.e. the

Foundations of Computing
7710 / 210 = 3810 38.5 38(r 1)
number base you want to convert to).
3810 / 210 = 1910 19 19(r 0)
2. If there is a fraction left over (i.e. 0.5) then
set remainder bit (r) to 1, otherwise (i.e. no 1910 / 210 = 910 9.5 9(r 1)
fraction left over), set remainder bit (r) to 0. 910 / 210 = 410 4.5 4(r 1)
3. Set new decimal number to the lowest
410 / 210 = 210 2 2(r 0)
whole number from the division
4. If decimal number not equal to 0, repeat 210 / 210 = 110 1 1(r 0)

step 1, otherwise finish. 110 / 210 = 010 0.5 0(r 1)


• To see the binary conversion, need to read 11
From bottom to top we
from bottom to top. get: 100110112
Converting from Decimal (2)
• There are two ways for converting a number from decimal to
binary.
• Method 2: Subtraction Method
• Example: convert 17210 to binary

Foundations of Computing
128 64 32 16 8 4 2 1 172 – 128 = 44 (set r = 1)
44 – 64 = -ve number (set r = 0)
1 0 1 0 1 1 0 0
44 – 32 = 12 (set r = 1)
12 – 16 = -ve number (set r = 0)
MSB 17210 = 101011002 LSB 12 – 8 = 4 (set r = 1)
4 – 4 = 0 (set r = 1)
0 – 2 = -ve number (set r = 0)
0 – 1 = -ve number (set r = 0) 12
Binary Addition
• 2 bit binary addition basic rules:
• 02 + 02 = 010 = 002
• 02 + 12 = 110 = 012
• 12 + 02 = 110 = 012
• 12 + 12 = 210 = 102

Foundations of Computing
0000 0101
• Example: 510 + 410 = 910 0000 0100+
0000 1001

• Additional multiples & overflow:


• Could have the problem of having more than 2 bits to add (e.g. a 3 rd
overflow bit). We still treat this normally, e.g.110+110+110 = 310 = 112 13

• If a number of bits is not given, or a –ve or 2s complement are


specified, then you are allowed to use as many bits as you need
Two’s Complement
• To do subtractions (or additions of –ve numbers) we have to
convert the –ve numbers to two’s complement.
• To perform two’s complement, we need to work on a fixed precision
(i.e. fixed number of bits) between all values.
• We need to do the following steps:

Foundations of Computing
• 1. convert the positive number representation to binary
• 2. invert all of the binary digits
• 3. add one
• This converts a positive number to a negative number which means
we can now use this in addition.
• For example: convert 19 to -19 using 8 bits
• 1) 1910 = 000100112 (using a fixed precision of 8 bits)
• 14
2) invert = 11101100
• 3) +1 = 11101101
• Therefore, -1910 = 111011012
Two’s Complement Addition
• Needs to have all values using a common fixed length.
• Can do both subtraction and addition.
• Can handle negative numbers:
• E.g. -5310 + 7810 using 8 bits

Foundations of Computing
• Need to use two’s complement to work out -5310 to make the sum 7810+
(-5310)
• Now can add numbers together to find answer

7810 010011102
5310- 110010112+
2510 ×1000110012
15
Have a go!

Two’s Complement Addition


• Subtraction is the same as addition if we apply two’s
complement.
• e.g. 4110 – 2110 = 4110 + (-2110)
• must use a fixed length.
• Example: 4110 - 2110 as 8 bit binary numbers

Foundations of Computing
• +2110 = 0001 01012
• -2110 = 1110 10112 (invert the bits and add one)
• +4110 = 0011
411011112 001010012 Addition not subtraction
2110 - 111010112 + 4110 + (-2110)
2010 000101002

16
• Therefore, 000101002 = 2010
Binary Multiplication (i)
• Binary multiplication is:
• Multiple additions
• Shifting the number
10112 1110
Current bit is: 1
0

Foundations of Computing
11012 x 1310
Add the value: 11012 11012
Add the value: 11012 11010 2 Shift left one position

000000 2 Shift left one position


Add the value: 11012
1101000 2  Shift left one position
17
10001111 2 14310
Other things to remember…
• From this week:
• Fractional Binary numbers.
• Hexadecimal
• For each of these you will need to be able to convert from
decimal and back again.

Foundations of Computing
18
Example Questions
1. Represent 830510 as a binary number.
2. Represent 102210 as a hexadecimal number.
3. What is 10011011112 in decimal?
4. What is 100100112 in hexadecimal?

Foundations of Computing
5. What is the symbol and truth table for an XOR gate?
6. What is the truth table for Y=A.B+C.(A+E)?
7. What is the Boolean expression and truth table for this
circuit?

19
Example Questions
8. Express the following sum in binary: 19110 + 3810
9. Express the following sum in binary -12910 + 20210
10. Express the following subtraction in binary: 17110 – 11910
11. Multiply 5310 * 610

Foundations of Computing
12. Multiply 11100112 * 101112
13. Express the following in binary floating point: 45.435
14. Express the following in binary floating point: 1.23
15. What is 11011.1110012 in decimal?

20
Good Luck!

Foundations of Computing
21

You might also like