Ministry of Higher Education and Scientific Research
Technology University
Department of Control Engineering and Systems
2019
DIGITAL COMPUTER
A block diagram of Digital Computer is show below:
Memory Storage Unit
central processing unit (CPU)
control unit processor unit
(CU) (ALU)
Input Output
Device Device
1
Number Base Conversion
we present a general procedure for converting a decimal number to a number in base r .
If the number include a radix point , it is necessary to seperate the number into an integer
part and fraction part , Since each part must be converted differently .
Decimal to Binary Conversion :
Example 1 / convert the decimal number (41) to Binary
sol /
integer reminder
41 2 1 LSB
d 20 2 0 x
10 10 2 0
d 5 2 1
d 2 2 0
> 1 2 1 MSB
(41)10 = (101001)2
2
Example 2 / convert the decimal number (153) to Binary
Sol /
integer reminder
153 2 1 LSB
d 76 2 0
x 38 2 0
d 19 2 1
d 9 2 1
> 4 2 0
F 2 2 0
E 1 2 1 MSB
D 0
(153)10 = (10011001)2
Example 3 / convert the decimal number (50) to Binary
sol /
integer reminder
50 2 0 LSB
d 25 2 1 x
12 12 2 0
d 6 2 0
d 3 2 1
> 1 2 1
F 0
E MSB
D
(50)10 = (110010)2
3
Example 4 / convert (0.6875)10 to Binary
sol / 0.6875 × 2 = 1.375 1 MSB
D 0.375 × 2 = 0.75 0
G 0.75 × 2 = 1.5 1
E 0.5 × 2 = 1.0 1 LSB
(0.6875)10 = (.1011)2
Example 5 / convert (25.25)10 to Binary
sol /
integer reminder
25 2 1 LSB 0.25 × 2 = 0.5 0 MSB
12 2 0 0.5 × 2 = 1 1 LSB
6 2 0
3 2 1
1 2 1 MSB
( 25.25 )10 = (11001.01)2
4
Example 5 / (28.26)10 = (?)2
sol /
integer reminder
28 2 0 LSB 0.26 × 2 = 0.52 0 MSB
14 2 0 0.52 × 2 = 1.04 1
7 2 1 0.04 × 2 = 0.08 0
3 2 1 0.08 × 2 = 0.16 0 LSB
1 2 1 MSB
0
( 28.26 )10 = (11100.0100)2
Binary to Decimal Conversion :
Example / convert Binary numbers to Decimal
1. (110)2
2. (0.101)2
3. (1010.011)2
sol / 1. (110)2 = 1× 22 + 1 × 21 + 0 × 20 = 4 + 2 + 0 = ( 6 )10
2. (0.101)2 = 1× 2-1 + 0 × 2-2 + 1 × 2-3 = 0.5 + 0 + 0.125 = ( 0.625 )10
3. (1010.011)2 = 1× 23 + 0 × 22 + 1 × 21+ 0× 20+0× 2-1 +1× 2-2 + 1× 2-3
= 8 + 2 +0.25 + 0.125
= (10.375)10
NOTE / The conversion from decimal to any base-r- system similar to the previous
. examples , except that division is done by (r) instead of 2
5
Octal to Decimal Conversion :
(2374)8 = (?)10
= 2 × 83 + 3 × 82 +7 × 81 +4 × 80
= 1024 + 192 + 56 + 4 = (1276)10
(27)8 = (?)10
= 2 × 81 + 7 × 8 0
= 16 + 7 = (23)10
Decimal to Octal Conversion :
(359)10 = (?)8
359 8 0.875 × 8 =7
? 44 8 0.5 × 8 = 4
5 8 0.625 × 8 = 5
0
(359)10 = (547)8
Octal to Binary Conversion :
(27)8 = (?)2
( 010 111)
Binary to Octal Conversion :
(a) 110101 (b) 101111001 (c) 100110011010
sol /
(a) 110 101 = (65)8
6 5
(b) 101 111 001 = (571)8
5 7 1
(c) 100 110 011 010 = (4632)8
4 6 3 2
6
Binary to hexadecimal Conversion :
(a) 110010100111 (b)111100111100
sol/
(a) (1100 1010 0111)2 = (C57)16
c 5 7
(b) (1111 0011 1100)2 = (F3c)16
f 3 c
hexadecimal to Binary Conversion :
(a) (10A4)16 (b)(CF8E)16 (c)(9742)16
sol/
(a) (10A4)16 = (0001 0000 1010 0100)2
(b)(CF8E)16 = (1100 1111 1000 1110)2
(c)(9742)16 = (1001 0111 0100 0010)2
hexadecimal to Decimal Conversion :
(a) (1C)16 (b)(A85)16
sol /
(a)(1C) 16 = (0001 1100)2 = 24 + 23+22 = 16+8+4=(28)10
(b)(A85) 16 = (1010 1000 0101)2 = 211 + 29+27+22+20 = (2693)10
Example / convert the decimal number (650) to hexadecimal
650 16 0.625 × 16 = 10 =A
40 16 0. 5 × 16 = 8 =8
2 16 0.125 × 16 = 2 =2
(650)10 = (28A)16
7
LOGIC GATES
1.Inverter :- The inverter ( NOT CIRCUIT ) performs the operation called inversion or
complementation . The inverter change one logic level to the opposite level . In terms
of bits , it changes (1) to (0) and (0) to (1) .
Standard logic symbols for inverter are show below :-
A X
The logic expression is :-
x=A
The truth table is :-
A X
0 1
1 0
8
2.AND gate :- The AND gate is one of the basic gates that can be combined to form any
logic function . AND gate can have two or more input and performs what is known as
a logic multiplication .
The standard logic symbols is shown below :-
A
X
B
The logic expression is :-
x=A.B
The truth table is :-
I/P O/P
A B X
0 0 0
0 1 0
1 0 0
1 1 1
The number of possible combinations of binary inputs to a gate is determined by the
following formula :-
N = 2n
where N : is the number of possible input combination .
n : is the number of input variables .
9
3.OR gate :- The OR gate is another of the basic gates form which all logic function are
constructed . An OR gate can have two or more inputs and performs what is known as
logical addition .
The standard logic symbols is shown below :-
A
X
B
The logic expression is :-
x=A+B
The truth table is :-
I/P O/P
A B X
0 0 0
0 1 1
1 0 1
1 1 1
For two input variable : N= 22 = 4 combinations
For three input variable : N= 23 = 8 combinations
For four input variable : N= 24 = 16 combinations
10
4.NAND gate :- The NAND gate is a popular logic element because it can be used as a
universal gate , That is NAND gate can be used in combination to perform AND , OR
and inverter operation .
The standard logic symbols is shown below :-
A
X
B
The logic expression is :-
x=A.B
The truth table is :-
I/P O/P
A B X
0 0 1
0 1 1
1 0 1
1 1 0
11
Construct NOT gate from NOR gate :-
1.
A x=A
X
2. AND gate
A
A
X x = A+B =A.B
B
Construct NOT gate from NAND gate :-
1.
A
X x=A
2. OR gate
A A
X x = A.B =A+B
B
B
12
BOOLEAN OPERATION & EXPRESSIONS
Boolean algebra is the mathematics of digital system. Variable, complement ,and literal
are terms used in Boolean algebra
Law of Boolean algebra
The basic law of Boolean algebra _ The commutative laws for addition and
multiplication , The associative law for addition and multiplication ,and distributive law.
1. Commutative Law:- The commutative law of addition for two variables is written
as :
A+B=B+A
The commutative Law of multiplication is :-
A.B=B.A
2. Associative Law:- The associative law of addition is written as :
A + (B+C) =(A+ B )+C
The associative Law of multiplication is :-
A (BC) = (AB)C
13
3. Distributive Law:- The distributive Law is written for three variables as follows:
A (B+C) = AB+AC
Rules of Boolean algebra:-
1. A + 0 = A
2. A + 1 = 1
3. A . 0 = 0
4. A . 1 = A
5. A + A = A
6. A + A = 1
7. A . A= A
8. A . A = 0
9. A = A
10. A + AB = A ( 1 + B ) = A . 1 = A
11. A + A B = (A + A B) + A B = A A + A B + A A + A B
= A(A+ A) + B (A + A )
=A+B
14
De Morgan's Theorem:-
De Morgan's theorem , proposed two theorems that are important part of Boolean algebra
.
1- The complement of a product of variables is equal to the sum of complement of the
variables .
xy=x+y
2- The complement of a sum of variables is equal to the product of complement of the
variables .
x+y=x.y
Example 1 /
(A+B)(A+C) = A + BC
AA+AC+AB+BC
A+AC+AB+BC
A(1+C)+AB+BC
A+AB+BC
A(1+B)+BC
A+BC
15
Example 2 / Implement the following expression using NAND gate only ?
F = (A+B)(B+C)
sol/
F= (A+B) (B+C) = (A+B) (B+C) = A . B + B . C = (A . B).(B . C)
A B C
B C (A.B)
A
(A.C)
Example 3/ Simplify the following expression, and implement using NOR
gate only
ABC+AC+ACD
A(C+C B) + A C D
A(C + C) (C + B )+ A C D
AC+AB+ACD
C(A + A D )+ A B
C (A + A) (A + D)+ AB
C(A + D)+ AB
A C +C D + A B
16
Example 4/ Implement this Boolean expression using NOR gate using de morgan's
theorem
A C + C D + A B = A C . C D . A B = (A + C)(C + D)(A + B)
=(A + C)+(C + D)+(A + B)
A (A+C)
A
B (A+B)
C
C (C+D)
17
The XOR gate :-
The X-OR gates are formed by a combination of other gates .
The standard logic symbols is shown below :-
A
X
B
The logic expression is :-
x=A B
or
x = AB+AB
The truth table is :-
I/P O/P
A B X
0 0 0
0 1 1
1 0 1
1 1 0
18
The X-NOR gate :-
The X-NOR gates are formed by a combination of other gates .
The standard logic symbols is shown below :-
A
X
B
The logic expression is :-
x=A B
or
x = AB+AB
The truth table is :-
I/P O/P
A B X
0 0 1
0 1 0
1 0 0
1 1 1
19
Applications of X-OR gate
The X-OR functions are very useful in systems require by error detection and correction
codes . A parity bit is used for purpose of detecting errors during transmission of binary
information . A parity bit is an extra bit included with a binary message to make a number
of 1's either odd or even .
The circuit that generates the parity bit in the transmitter is called a parity generator which
can be implemented using X-OR gate .
Example / Design a 3- bit even parity generator circuit .
P=xyz+xyz+xyz+xyz x y z p
= x ( y z + y z )+ x (y z + y z) 0 0 0 0
M M 0 0 1 1
M=y z 0 1 0 1
0 1 1 0
P=x M + x M= x M=x y z 1 0 0 1
1 0 1 0
1 1 0 0
1 1 1 1
y P
20
Controlled inverter :-
The controlled inverter is used in the computer for subtraction :
A B C
x y z
z
The control signal (s)
* IF s = 0 x=A,y=B,z=C
* IF s = 1 x=A,y=B,z=C
Binary to Gray conversion :-
Gray code is unweighted code , not suited to arithmatic but useful for I/P , O/P devices
such as shaft encoder, Analogue to digital convertor .
One of the main problem in binary number system is when going from one number to
the next , more than one digit position may change at the same time.
But in Gray code every number differs from the preceding number by a single bit .
21
How to convert from Binary to Gray :-
1.Gray digit is the same as the first Binary digit .
2. Add the list Binary to second Binary digit discard carries .
A B C D
y1 y2 y3 y4
Binary to Gray circuit
Example / convert (1001)2 Gray
sol/ A + B + C + D
1 0 0 1
1 1 0 1
y1 y2 y3 y4
22
Gray to Binary conversion :-
A B C D
y1 y2 y3 y4
Example / convert (1101) Gray Binary
sol/ A B C D
1 1 0 1
+ + +
1 0 0 1
y1 y2 y3 y4
23