Binary_Code-1
Binary_Code-1
Binary Representation
The Binary Code
At the most fundamental level, computers
only understand zeros and ones.
A single 0 or 1 is called a
bit, which is a contraction of binary digit.
So how does a computer go from zeros
and ones to colourful graphical interfaces
with buttons and web browsers?
Number Systems
Number system
Is a system of writing used to express numbers in different
forms.
Number
A mathematical value used to count, measure, and perform
various arithmetic calculations.
Decimal VS
1, 2, 3, 4, 5, 6, 7, 8, and 9). 0 and 1).
Binary
powers of 10.
In binary, base 2, there are only two
The positions of successive digits to digits (0 and 1), and each place is
the left of the decimal point represent worth two times the place to its right
units, tens, hundreds, thousands, and (1, 2, 4, 8, 16, 32, 64, 128, 356).
so on.
Number
Example: (123)10 in powers of 10 is
expressed as:
Example: (1011)2 is expressed in power
s of 2 as: Systems
(1 × 102) + (2 × 101) + (3 × 100) = (1 × 23) + (0 × 22) + (1 × 21) + (1 × 20) =
1 ×100 + 2 × 10 + 3 × 1 = (1 × 8) + (0 × 4) + (1 × 2) + (1 × 1) =
100 + 20 + 3 = 123 8 + 0 + 2 + 1 = 11
Decimal
number
Binary
number
Binary to
1 01 Decimal Conversion
2 10 We can convert a number from any number system into any of
the other three number systems.
3 11
To convert a binary number into a decimal number, multiply
4 100 each digit of the binary number by the power of 2.
5 101 If B = an-1…a3a2a1a0 is a binary number that has n digits, then
the respective decimal number will be
6 110
7 111
D = (a n-1 × 2n-1) +…+(a3 × 23 ) + (a 2 × 22 ) + (a 1 × 21 ) + (a 0 × 20 )
8 1000
9 1001
10 1010
Conversion of Binary to Decimal
Example 1: Convert (11001)2 to a decimal number.
2 10
10 1010 2 1 1
2 23 0
2 11 1
2 5 1
2 2 1
2 1 0
Bit 1 21 = 2 0, 1
Byte 8 28 = 256 0000, 0001, 0010, 0100, 1000, 0011, 0101, 1001,...
Logic diagram a b ab
0 0 0
0 1 0
Boolean expression 1 0 0
Y=A·B
1 1 1
OR Gate
The OR logic operation returns true if either of its inputs are true. If all inputs are
false, the output is also false.
0 1 1
Boolean expression 1 0 1
Y=A+B
1 1 1
NOT Gate
NOT gate is also known as Inverter. It has one input A and one output Y. The Logic
NOT Function output is true when its single input is false, and false when its single
input is true.
Logic diagram a Y
0 1
1 0
Boolean expression
A=
Logic NOT Function Equivalents
Logic NOT gates or “Inverters” as they are more commonly called, can be connected
with standard AND and OR gates to produce NAND and NOR gates respectively.
NAND NOR
Logic diagram
a) b)
Practice
Draw a logic gate circuit for this function.
a) b)
Practice
Complete the truth tables for these two Boolean expressions:
a) b)
Introduction of K-Map
(Karnaugh Map)
In many digital circuits and practical problems we
need to find expression with minimum variables.
We can minimize Boolean expressions of 3, 4
variables very easily using K-map without using any
Boolean algebra theorems.
K-map is table like representation but it gives more
information than TRUTH TABLE.
We fill grid of K-map with 0’s and 1’s then solve it
by making groups.
Example: Burglar Alarm
Consider the design of a Burglar Alarm for a house. This alarm will be
activated if an unauthorized person is detected by a Window Sensor
or a Motion Detector.
STEP 1: Identify the Inputs and Outputs
INPUTS OUTPUTS
Burglar alarm: Alarm:
1 – Alarm On 1 – On
0 – Alarm Off 0 – Off
Window Sensor:
0– Closed
1 – Open
Motion Detector:
1 – Motion
0 – No Motion
Example: Burglar Alarm
Consider the design of a Burglar Alarm for a house. This alarm will be
activated if an unauthorized person is detected by a Window Sensor
or a Motion Detector.
STEP 2: Select an appropriate Truth Table
Example: Burglar Alarm
Consider the design of a Burglar Alarm for a house. This alarm will be
activated if an unauthorized person is detected by a Window Sensor
or a Motion Detector.
STEP 3: Fill in the Truth Table
B W M A INPUTS OUTPUTS
0 0 0 Burglar alarm (B) Alarm (A)
0 0 1 1 – Alarm On 1 – On
0 – Alarm Off 0 – Off
0 1 0
Window Sensor (W)
0 1 1
0 – Closed
1 0 0
1 – Open
1 0 1
Motion Detector (M)
1 1 0
1 – Motion
1 1 1 0 – No Motion
Example: Burglar Alarm
Consider the design of a Burglar Alarm for a house. This alarm will be
activated if an unauthorized person is detected by a Window Sensor or a
Motion Detector.
STEP 4: Identify the inputs that cause the output to be 1.
0 1 1 0
1 0 0 0
1 0 1 1
1 1 0 1
1 1 1 1
Example: Burglar Alarm
Consider the design of a Burglar Alarm for a house. This alarm will be
activated if an unauthorized person is detected by a Window Sensor or a
Motion Detector.
STEP 4: Solutions can be simplified using Karnaugh Mapping.
A=BWM+BWM+BWM
WM 00 01 11 10
B
0 0 0 0 0
1 0 1 1 1
Example: Burglar Alarm
Consider the design of a Burglar Alarm for a house. This alarm will be
activated if an unauthorized person is detected by a Window Sensor or a
Motion Detector.
STEP 4: Solutions can be simplified using Karnaugh Mapping.
WM 00 01 11 10
B
0 0 0 1 0
1 1 1 1 0
Example: Burglar Alarm
Consider the design of a Burglar Alarm for a house. This alarm will be
activated if an unauthorized person is detected by a Window Sensor or a
Motion Detector.
STEP 4: Solutions can be simplified using Karnaugh Mapping.
WM 00 01 11 10
B
0 0 0 1 0
1 1 1 1 0
F 1 = BWM + BWM = BW (M + M) = BW
1
Example: Burglar Alarm
Consider the design of a Burglar Alarm for a house. This alarm will be
activated if an unauthorized person is detected by a Window Sensor or a
Motion Detector.
STEP 4: Solutions can be simplified using Karnaugh Mapping.
WM 00 01 11 10
B
0 0 0 1 0
1 1 1 1 0
F 1 = BWM + BWM = BW (M + M) = BW
1
F 1 = BWM + BWM = WM (B + B) = WM
1
Example: Burglar Alarm
Consider the design of a Burglar Alarm for a house. This alarm will be
activated if an unauthorized person is detected by a Window Sensor or a
Motion Detector.
STEP 4: Solutions can be simplified using Karnaugh Mapping.
WM 00 01 11 10
B
0 0 0 1 0
1 1 1 1 0
F 1 = BWM + BWM = BW (M + M) = BW
1
F 1 = BWM + BWM = WM (B + B) = WM
1
A = WM + BW = W (B +MB)
Car Logic Circuit
An automotive engineer wants to design a logic circuit that
prohibits the engine in a car from being started unless the driver
is pressing the clutch pedal while turning the ignition switch to
the “start” position. The purpose of this feature will be to prevent
the car from moving forward while being started if ever the
transmission is accidentally left in gear.
Suppose we designate the status of the ignition switch “start”
position with the Boolean variable S (1 = start; 0 = run or off), and
the clutch pedal position with the Boolean variable C (1 = clutch
pedal depressed; 0 = clutch pedal in normal, unpressed position).
Write a Boolean expression for the starter solenoid status, given
the start switch (S) and clutch (C) statuses. Then, draw a logic
gate circuit to implement this Boolean function.