CA - Unit 1 - SEP
CA - Unit 1 - SEP
UNIT – I
2
Decimal Number System
Decimal number system is a base 10 number system having 10 digits from 0
to 9.
This means that any numerical quantity can be represented using these 10
digits.
Decimal number system is also a positional value system.
This means that the value of digits will depend on its position
Say we have three numbers – 734, 971 and 207. The value of 7 in all three
numbers is different−
In 734, value of 7 is 7 hundreds or 700 or 7 × 100 or 7 × 102
In 971, value of 7 is 7 tens or 70 or 7 × 10 or 7 × 101
In 207, value 0f 7 is 7 units or 7 or 7 × 1 or 7 × 100
3
Binary Number System
4
Octal Number System
Octal number
system has eight
digits – 0, 1, 2, 3, 4, 5,
6 and 7.
Octal number system
Decimal equivalent of any octal number is sum of
is also a positional
product of each digit with its positional value.
value system with 7268 = 7×82 + 2×81 + 6×80
where each digit has = 448 + 16 + 6
its value expressed in = 47010
powers of 8
5
Hexadecimal Number System
Hexadecimal number
system has 16 symbols – 0
to 9 and A to F where A is
equal to 10, B is equal to 11
and so on till F.
6
Number System Conversions
Binary to Decimal
Decimal conversion is The binary number
done to convert a system is used in
number given in the computers and
binary number electronic systems
system to its to represent data
equivalent value in and it consists of
the decimal number only two digits
The binary number which are 0 and 1.
system.
system has a base of 2
because it has only two
digits to represent any
number.
8
Binary to Decimal
Step 2: Now multiply each digit in the binary number starting from the right with
its respective weight based on its position and evaluate the product.
Step 3: Now, express the binary number as a decimal number: 1011012 = 4510
9
Exercises
Convert 11102, from binary to decimal using the binary to decimal
formula.
Convert 11112, from binary to decimal using the binary to decimal
formula.
Convert 10102, from binary to decimal using the binary to decimal
formula.
10
Decimal to Binary Then, the
Decimal to remainders are
binary conversion is noted down till we
done through get 0 as the final
various methods. quotient. After this
One of the methods step, these
to convert decimal remainders are
to binary is by written in reverse
dividing the given order to get the
decimal number binary value of the
recursively by 2. given decimal
number.
11
Decimal to binary conversion
To convert numbers
from decimal to binary,
the given decimal
number is divided
repeatedly by 2 and
the remainders are
noted down till we get
0 as the final quotient.
12
Exercises
25
39
72
55
13
Decimal to Octal
In the number system, each of the types has its own base number i.e. octal
number has a base number of 8 and the decimal number has a base number of
10.
To convert decimal to octal, we need to divide the decimal number by the octal
base number 8 and write the acquired remainder in reverse to derive at the
equivalent octal number.
14
Convert Decimal to Octal
15
Example
Convert the decimal number (85)10 to an octal number.
Step 1: Check if the decimal number is less than 8. If yes, the octal number is
the same. If no, then proceed forward. In this case, 85 is more than 8 so let's go
to step 2.
Step 2: Divide 85 by 8 (octal base number).
Note down the quotient and the remainder in the quotient-remainder form.
Repeat this process (dividing the quotient again by 8) until we get the quotient
to be less than 8.
16
Example
17
Exercises
67
99
350
18
Octal to decimal
19
20
Exercises
(121)8
(454)8
21
Hexadecimal Number System
22
Conversion from Hex to Decimal
Convert 7CF (hex) to decimal.
Given hexadecimal number is 7CF.
In hexadecimal system,
7=7
C = 12
F = 15
To convert this into a decimal number system, multiply each digit with the powers
of 16 starting from units place of the number.
7CF = (7 × 162) + (12 × 161) + (15 × 160)
= (7 × 256) + (12 × 16) + (15 × 1)
= 1792 + 192 + 15
= 1999
23
Convert (1DA6)16 to decimal.
Convert (E8B)16 to decimal system.
(2bf)16
24
Conversion from Decimal to Hexadecimal number
system
25
Convert 60010 into a hexadecimal number.
26
Binary to octal Conversion
27
Octal to Binary Conversion
28
Hexa Decimal to Binary Conversion
29
Binary to Hexa Decimal Number
(1000101)2
30
Octal to Hexa Decimal Number
Step1: Convert Octal to Binary
Group 4 bits together and represent equivalent hexa decimal digit
31
Hexa decimal to Octal conversion
Step1: Convert Hexa decimal to binary
Step2: Regrouping the bits into 3 bits
32
Complements
Complements
complement number system An alternative representation of numbers in
a fixed-radix number system
Complements are used in the digital computer in order to simplify the
subtraction operation and for logical manipulation.
For Each Radix system( Radix r represents the number system)
There are 2 types of Complements(r, r-1) complements
r-radix complement,r-1=Diminished radix complement.
34
Binary system Complements
There are 2 complements in Binary System
1. 1’s Complement
2. 2’s complement
35
1’s Complement
To generate a 1’s complement for any given binary number, you only
need to invert that number.
For a binary number like 110010, the 1’s complement would be 001101.
36
2’s complement
To generate a 2’s complement for any given binary number, you need to invert
it. Then you need to add 1 to the LSB (Least Significant Bit) of the generated
result.
1’s complement + 1
37
Complements of numbers
The r and r-1’s complement can be found for all the number systems.
Basically there are 4 number systems and hence r and r-1’s complements can
be found for only these 4 number systems.
r-1 )’s Complement
•Given a number N in base r having n digits,
•the (r- 1)’s complement of N is defined as
(rn - 1) - N
•For decimal numbers the
base or r = 10 and r- 1= 9,
•so the 9’s complement of N 9 9 9 9 9
is (10n-1)-N
•99999……. - N
- Digit
n
Digit
n-1
Next
digit
Next
digit
First
digit
9’s complement Examples
546700= 453299 4 5 3 2 9 9
- 1 2 3 8 9
8 7 6 1 0
Note: Similarly we can find the r and (r-1)’s complements for any given number of
octal and hexadecimal numbers also
r’s Complement
•100000……. - N
Number Systems Arithmetic
Binary Arithmetic
42
Binary Addition
43
Addition using 2’s complement
The 2’s complement is most commonly used code for processing positive
and negative binary numbers. There are 4 different cases
1. Both the numbers are positive
2. Larger of 2 numbers are positive
3. The larger of 2 numbers are negative
4. Both the numbers are negative
44
Case 2: Larger of 2 numbers are positive
Example: 1101 and -1001
First, find the 2's complement of the negative number 1001. So, for finding 2's complement,
change all 0 to 1 and all 1 to 0 or find the 1's complement of the number 1001. The 1's
complement of the number 1001 is 0110, and add 1 to the LSB of the result 0110. So the 2's
complement of number 1001 is 0110+1=0111
Add both the numbers, i.e., 1101 and 0111;
1101+0111=1 0100
By adding both numbers, we get the end-around carry 1. We discard the end-around carry. So,
the addition of both numbers is 0100.
45
Case 3: The larger of 2 numbers are negative
Example: 1101 and -1110
First, find the 2's complement of the negative number 1110. So, for finding 2's
complement, add 1 to the LSB of its 1's complement value 0001.
0001+1=0010
Add both the numbers, i.e., 1101 and 0010;
1101+0010= 1111
Find the 2's complement of the result 1110 that is the final result. So, the 2's complement
of the result 1110 is 0001, and add a negative sign before the number so that we can
identify that it is a negative number.
46
Case 4: Both the numbers are negative
Example: -1101 and -1110 in five-bit register
Firstly find the 2's complement of the negative numbers 01101 and 01110. So, for finding
2's complement, we add 1 to the LSB of the 1's complement of these numbers. 2's
complement of the number 01110 is 10010, and 01101 is 10011.
We add both the complement numbers, i.e., 10001 and 10010;
10010+10011= 1 00101
By adding both numbers, we get the end-around carry 1. This carry is discarded and the
final result is the 2.s complement of the result 00101. So, the 2's complement of the result
00101 is 11011, and we add a negative sign before the number so that we can identify
that it is a negative number.
47
Binary Subtraction
Binary subtraction is one of the four binary operations, where we perform the
subtraction method for two binary numbers (comprising only two digits, 0 and
1).
This operation is similar to the basic arithmetic subtraction performed on
decimal numbers in Maths.
Binary Subtraction
0–0=0
1–0=1
1–1=0
0 – 1 = 1 (Borrow 1)
48
Case i) Binary subtraction without borrowing
Case ii) Binary subtraction with borrowing
49
Case ii) Binary subtraction with borrowing:
50
Binary Subtraction Using 2's
Complement
Step 1: Determine the 2’s complement of the smaller number
Step 2: Add this to the larger number.
Step 3: Omit the carry. Note that there is always a carry in this case.
51
Binary Multiplication
The binary multiplication is very much similar to the usual multiplication method of
integers.
First, we need to multiply each digit of one binary number to each digit of another binary
number.
52
Binary Division
The binary division operation is similar to
the base 10 decimal system, except the base 2.
The division is probably one of the most
challenging operations of the basic arithmetic operations.
Solve 01111100 ÷ 0010
53
Octal Arithmetic
Octal rules are similar to the decimal or binary arithmetic.
This number system is normally used to enter long strings of binary data into a
digital system like a microcomputer.
The information can be handled only in binary form in a digital circuit and
it Is easier to enter the information using hexadecimal number system.
Introduction:
Although binary data is the most efficient storage scheme;
every bit pattern represents a unique, valid value. However,
some applications may not be desirable to work with binary
data.
For instance, the internal components of digital clocks keep
track of the time in binary. The binary value must be
converted to decimal before it can be displayed.
Binary Coded Decimal
Add 6 to
Answer is sum to Add 6 to
correct no get sum to
correction correct get
required answer correct
answer
BCD arithmetic
BCD Addition
BCD subtraction
Two methods:
1. 9’s complement method
2. 10’s complement method
BCD subtraction using 9’s
complement
Perform BCD subtraction using 9’s
complement method (A)10 - (B)10
1. Obtain 9’s complement of no. B
3. If carry is generated in step 2 then add it to sum to obtain final result. The
4. If carry is not produced then the result is negative hence take 9’s complement
of the result.
Examples
Perform (8)10 - (3)10
8
9’s complement
of 3
Ex.
Ex.
Ex.
Solve following subtraction of decimal
numbers using 9’s complement method.
Digital data is represented, stored and transmitted as groups of binary digits also known as binary
code.
Weighted codes: In weighted codes, each digit is assigned a specific weight according to its position.
Non-weighted codes: In non-weighted codes are not appositionally weighted.
Reflective codes: A code is reflective when the code is self complementing. In other words, when the code for 9 is the
complement the code for 0, 8 for 1, 7 for 2, 6 for 3 and 5 for 4.
Sequential codes: In sequential codes, each succeeding 'code is one binary number greater than its preceding code.
Alphanumeric codes: Codes used to represent numbers, alphabetic characters, symbols
Error defecting and correcting codes: Codes which allow error defection and correction are called error detecting and'
correcting codes.
BCD Code
A number with k decimal digits will require 4k bits
84
in BCD.
Decimal 396 is represented in BCD with 12bits as
0011 1001 0110, with each group of 4 bits
representing one decimal digit.
A decimal number in BCD is the same as its
equivalent binary number only when the number is
between 0 and 9.
The binary combinations 1010 through 1111 are
not used and have no meaning in BCD.
Example: Consider decimal 185 and its corresponding value in BCD and binary:
BCD addition
Binary Codes - Other Decimal Codes
85
Binary Codes - Gray Code
000 001
010 011
100 101
110 111
1-1 and onto!!
Alphanumeric codes
Computers work with only 0’s and 1’s. However, there is a need for
more advanced forms of communication with machines. This is why
alphanumeric code is important. It includes 26 characters for the letters
of the alphabet, and 10 more for symbols like !@#$%^&.
1-5 ALPHANUMERIC CODES - ASCII Character Codes
Chapter 1
88
Alphanumeric code represents both numbers and alphabetical characters. The most
common types of alphanumeric code are EBCDIC and ASCII.
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)
Other non-printing characters are used for record marking and flow control (e.g.
STX and ETX start and end text areas).
ASCII Character Codes and Properties
89 American Standard Code for Information Interchange (Refer to Table 1.7)
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).
Other non-printing characters are used for record marking and flow control (e.g. STX and
ETX start and end text areas).
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 .
ASCII Character Code
90
EBCDIC
EBCDIC stands for Extended Binary Coded Decimal Interchange Code. EBCDIC code is an 8-bit code that is mainly used
in IBM mainframe and IBM midrange computer operating systems.
UNICODE
Unicode is an international character encoding standard that provides a unique number for every character across
languages and scripts, making almost all characters accessible across platforms, programs, and devices.
Unicode is a universal character encoding standard. This standard includes roughly 100000 characters to represent
characters of different languages. While ASCII uses only 1 byte the Unicode uses 4 bytes to represent characters. Hence, it
provides a very wide variety of encoding. It has three types namely UTF-8, UTF-16, UTF-32. Among them, UTF-8 is used
mostly it is also the default encoding for many programming languages.
Error detection and correction code plays an important role in the transmission of
data from one source to another. The noise also gets added into the data when it
transmits from one system to another, which causes errors in the received binary
data at other systems. The bits of the data may change(either 0 to 1 or 1 to 0)
during transmission.
It is impossible to avoid the interference of noise, but it is possible to get back the
original data. For this purpose, we first need to detect either an error z is present
or not using error detection codes. If the error is present in the code, then we will
correct it with the help of error correction codes.
Error-Detecting Code
95
100
101
A Digital Computer Example
Memory
Control
CPU unit Datapath
Synchronous or
Asynchronous?
Transfer of information
102
Digital
Concerned with the interconnection among digital components and modules
Best Digital System example is General Purpose
Computer
Logic Design
Deals with the basic concepts and tools used to design digital hardware
consisting of logic circuits
Circuits to perform arithmetic operations (+, -, x, ÷)
Digital Signal : Decimal values are difficult to represent in electrical systems. It
106 is easier to use two voltage values than ten.
on off
Power switches have labels “1” for on and “0” for off.
Binary Logic
107
Definition of Binary Logic
Binary logic consists of binary variables and a set of logical operations.
The variables are designated by letters of the alphabet, such as A, B, C, x, y, z, etc, with
each variable having two and only two distinct possible values: 1 and 0,
Three basic logical operations: AND, OR, and NOT.
Binary Logic gates
Truth Tables, Boolean Expressions, and Logic Gates
AND OR NOT
x y z x y z x z
0 0 0 0 0 0 0 1
0 1 0 0 1 1 1 0
1 0 0 1 0 1
1 1 1 1 1 1
z=x•y=xy z=x+y z = x = x’
x x x
y z y z z
Universal Gate
NAND and NOR Gates are called Universal Gates because AND, OR
and NOT gates can be implemented &created by using these gates.
Logic gates
Example of binary signals
3
Logic 1
2
Un-define
1
Logic 0
0
Boolean Algebra
{(1,0), Var, (NOT, AND, OR), Thms}
Basic functions
• AND Z=X Y or Z=XY
Z=1 if and only if X=1 and Y=1, otherwise Z=0
• OR Z=X + Y
Z=1 if X=1 or if Y=1, or both X=1and Y=1. Z=0 if and only if X=0 and Y=0
• NOT Z=X or
115
Z=1 if X=0, Z=0 if X=1
116
Boolean Operations and Expressions
Boolean Addition
Logical OR operation
Ex 4-1) Determine the values of A, B, C, and D that make the sum term
A+B’+C+D’
Sol) all literals must be ‘0’ for the sum term to be ‘0’
A+B’+C+D’=0+1’+0+1’=0 A=0, B=1, C=0, and D=1
Boolean Multiplication
Logical AND operation
Ex 4-2) Determine the values of A, B, C, and D for AB’CD’=1
Sol) all literals must be ‘1’ for the product term to be ‘1’
AB’CD’=10’10’=1 A=1, B=0, C=1, and D=0
117
Basic Identities of Boolean Algebra
118
Laws of Boolean Algebra
Commutative Law: the order of literals does not matter
A+ B = B +A AB =BA
119
Rules of Boolean Algebra
A+0=A In math if you add 0 you have changed nothing in Boolean Algebra
ORing with 0 changes nothing
A•0=0 In math if 0 is multiplied with anything you get 0. If you
AND anything with 0 you get 0
A•1 =A ANDing anything with 1 will yield the anything
A+A = A ORing with itself will give the same result
A+A’=1 Either A or A’ must be 1 so A + A’ =1
A•A = A ANDing with itself will give the same result
A•A’ =0 In digital Logic 1’ =0 and 0’ =1, so AA’=0 since one of the inputs must
be 0.
A = (A’)’ If you not something twice you are back to the beginning
120
A + A’B = A + B
If A is 1 the output is 1 If A is 0 the output is B
A + AB = A
(A + B)(A + C) = A + BC
• DeMorgan’s Theorem
– F(A,A, , + , 1,0) = F(A, A, + , ,0,1)
– (A • B)’ = A’ + B’ and (A + B)’ = A’ • B’
– DeMorgan’stheorem will help to simplify digital circuits using NORs and
NANDs his theorem states
121
Boolean Analysis of Logic Circuits
Constructing a Truth Table for a Logic Circuit
Convert the expression into the min-terms containing all the input literals
Get the numbers from the min-terms
Putting ‘1’s in the rows corresponding to the min-terms and ‘0’s in the remains
Ex) A(B+CD)=AB(C+C’) (D+D’) +A(B+B’)CD =ABC(D+D’) +ABC’(D+D’)
+ABCD+AB’CD =ABCD+ABCD’+ABC’D+ABC’D’ +ABCD+AB’CD
=ABCD+ABCD’+ABC’D+ABC’D’ +AB’CD
=m11+m12+m13+m14+m15=(11,12,13,14,15)
A(B+CD) = m11+m12+m13+m14+m15 =(11,12,13,14,15)
122
Standard Forms of Boolean Expressions
The Sum-of-Products(SOP) Form Ex) AB+ABC, ABC+CDE+B’CD’
The Product-of-Sums(POS) Form Ex) (A+B)(A+B+C), (A+B+C)(C+D+E)(B’+C+D’)
Principle of Duality : SOP POS
Domain of a Boolean Expression : The set of variables contained in the expression
Ex) A’B+AB’C : the domain is {A, B, C}
123
Standard POS Form (Canonical POS Form)
– For all the missing variables, apply (x’x)=0 to the OR terms of the
expression
– List all the max-terms in forms of the complete set of variables in
ascending order
124
Converting Standard SOP to Standard POS
Step 1. Evaluate each product term in the SOP expression. Determine the
binary numbers that represent the product terms
Step 2. Determine all of the binary numbers not included in the evaluation
in Step 1
Step 3. Write in equivalent sum term for each binary number Step 2 and
expression in POS form
127
Karnaugh Map (K- Map) Steps
1. Sketch a Karnaugh map grid for the given problem.in power of 2 N Squares
2. Fill in the 1’s and 0’s from the truth table of sop or pos Boolean function
3. Circle groups of 1’s.
Circle the largest groups of 2, 4, 8, etc. first.
Minimize the number of circles but make sure that every 1 is in a circle.
4. Write an equation using these circles.
128
Four-Variable K-Map : 16 minterms : m0 ~ m15
Rectangle group
2-squares(minterms) : 3-literals product term
4-squares : 2-literals product term
8-squares : 1-literals product term
16-squares : logic 1
129
F(W, X,Y,Z)=m(0,2,7,8,9,10,11) = WX’ + X’Z’ + W’XYZ
Sol) B’+A’C
130
Ex Minimize the following expression
B’C’D’+A’BC’D’+ABC’D’+A’B’CD+AB’CD+A’B’CD’+A’BCD’
+ABCD’+AB’CD’
Sol) D’+B’C
131
Ex K- Map for POS (B+C+D)(A+B+C’+D)(A’+B+C+D’)(A+B’+C+D)
(A’+B’+C+D)
Sol) (B+C+D)=(A’A+B+C+D)=(A’+B+C+D)(A+B+C+D)
(1+0+0+0)(0+0+0+0)(0+0+1+0)
(1+0+0+1)(0+1+0+0)(1+1+0+0)
F=(C+D)(A’+B+C)(A+B+D)
132
133
Thank You