Transcript chapter 2

1
DATA
STORAGE
1
1
Storage of Bits



Computers represent information as
patterns of bits
A bit (Binary Digit) is one of the two
digits 0 or 1
Storing a bit in the machine requires a
device that can be in one of two
states:On or Off , True or False , 0 or 1
2
GATES AND FLIP-FLOPS






There are several gates that perform
logical operations
The basic gates are:
AND
OR
EXLUSIVE-OR(X-OR)
NOT
3
AND Gate
Truth Table
A
B
Y
0
0
0
0
1
0
1
0
0
1
1
1
Logic Equation
Y= A.B
Logic Circuit
4
OR Gate
Truth Table
A B Y
0 0
0
0 1
1
1 0
1
1 1
1
Logic Circuit
Logic Equation:
Y=A+B
5
Exclusive OR (X-OR)
Truth Table
A B
Y
0
0
0
0
1
1
1
0
1
1
1
0
Logic Circuit
Logic Equation
Y=A + B
6
NOT Gate
Truth Table
A
Y
0
1
1
0
Logic Circuit
Logic Equation
Y= A
7

NAND Gate
8

NOR Gate
9
Example(1) Draw the logic circuit and find the truth table for
the following logic equation:
X=(A+B)C
A B C X
0 0 0 0
0
0
0
0
0
10
Example(1) Draw the logic circuit and find the truth table for
the following logic equation:
X=(A+B)C
A B C X
0 0 0 0
0 0 1 0
0
0
0
0
1
11
Example(1) Draw the logic circuit and find the truth table for
the following logic equation:
X=(A+B)C
A B C X
0 0 0 0
0 0 1 0
0 1 0 0
0
1
0
1
0
12
Example(1) Draw the logic circuit and find the truth table for
the following logic equation:
X=(A+B)C
A B C X
0 0 0 0
0 0 1 0
0 1 0 0
0 1 1 1
1 0 0 0
1 0 1 1
1 1 0 0
1 1 1 1
1
1
1
1
1
No. of States = 2No. Of Inputs
13
FLIP - FLOP
A flip-flop is a circuit that has one of two
output values; its output remains fixed
until a temporary pulse from another
circuit causes it to shift to other value
 The significance of a flip-flop is that it
stores the information
 There are several kinds of flip flops like:
 J-K flip-flop , S-R flip-flop, D flip-flop ,
T flip-flop

14
Numbering Systems




Decimal System 
Binary System 
Octal System

Hexadecimal
System
Decimal System
Consists of 10 digits
0,1,2,3,4,5,6,7,8,9
The base for this system
is 10
 To analyze any decimal
number:
652= 102x6 + 101x5 + 100x2
= 600 + 50 + 2 = 652
17
Binary System




Consists of two digits 0 and 1
The base for the binary system is 2
It is the system used to represent
information inside the computer system
It is important to be familiar with
conversion methods between the
different numbering systems
18
Binary System
Decimal -to- Binary conversion:
To convert (8)10from decimal to binary:
2
8
(8)10=(1000)2
2
4 0
LSB
2
2 0
2
1 0
2
0 1
MSB

19
Binary System
Binary -to- Decimal Conversion:
Convert (1011)2 into decimal number:

23x1 + 22x0 + 21x1 + 20x1=
8 + 0 + 2 + 1 = (13)10
20
Octal System



Consists of 8 digits:
0,1,2,3,4,5,6,7
The base for the octal system is 8
It has many applications in information
coding systems
21
Octal System
Decimal -to- Octal Conversion:
To convert (13)10 into Octal number:
(13)10=(15)8
8 13
8
1
5
0
1
 Octal -to- Decimal Conversion:
(15)8=

81x1 + 80x5= 8 + 5 = (13)10
22
Hexadecimal System
It consists of 16 digits:
0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
 The base for hexadecimal system is 16
 It is commonly used to describe all the
information in the computer system(the
information represented as binary
numbers and described by hexadecimal
system)

23
Hexadecimal System
Decimal -to- Hexadecimal Conversion:
Convert(302)10 into Hexadecimal notation:
16
302
(302)10=(12E)16
16
18 14
16
1 2
16
0 1

24
Hexadecimal System

Hexadecimal -to- Decimal Conversion:
(A4B)16=
162x10 + 161x4 + 160x11=
2560 + 64 + 11 =(2575)10
25
Hexadecimal System
Hexadecimal -to- Binary:
(140B)= (0001 0100 0000 1011)2
 Binary -to- Hexadecimal:
(10001001011111)2=( ? )16

2
2
5
F
26
Fractions
Decimal -to-Binary:
Result Carry
(3.5)10=11.?
0.5x2=1.0
0.0
1
=11.1
1x2-1
(0.6)10=
0.6x2= 0.2
1
=(0.10011)2
0.2x2= 0.4
0
0.4x2= 0.8
0
1x2-1+1x2-4+1x2-5=
0.8x2= 0.6
1
0.5+0.0625+0.3125= 0.6x2= 0.2
1
0.59375
Round-off Problem 27

Storing Integers:
1. Excess Notation:
 It is easy to distinguish the patterns
that represent negative values from
those do not.
 Those that represent negative values
have a 0 as their most significant bit,
while those do not represent negative
values have a 1 as their MSB.
 The MSB is often called Sign Bit
28
1)Excess Notation:
The following is 3-bit , excess-4 notation:
Bit Pattern
Value represented
111
+3
110
+2
101
+1
100
0
011
-1
010
-2
001
-3
000
-4
29
2) Two’s Complement Notation



A notation used to represent both
positive and negative integers
It simplifies the arithmetic operations,
such as Addition and Subtraction , and
then Multiplication and Division
By using this notation, the subtraction
operation can be done in similar way
the addition performed
30
Two’s Complement:
To obtain two’s complement of a
decimal number, for example ( 5 ):
 Get the binary value 101, and to
represent that this is a positive number,
put a leading 0 as MSB 0101
 Get the 1’s complement of the above
value by inverting each digit: 0101
1010
 Add 1 to the result to get
+
1
------------2’s Complement 1011

31
Two’s Complement:
Example
0011
1100
1101
Perform 5 - 3.
Sol. Can be performed as 5 + (-3) using
2’s complement notation:
0101
1101 2’s complement of 3
------- +
1 0010 The result(+2)
Dropped
32
3) Floating- Point Notation:



A notation used to represent very large
or very small positive and negative
numbers
Consists of byte. The MSB represents
sign bit. 0 for positive and 1 for negative
The other bits divided as:
87654321
Sign
Bit
Exponent
Mantissa
33
Floating-Point Notation:
To convert 3 1/2 into F.P notation:
1) The number is +ve, the sign bit is 0
2) (3 1/2)10 is (11.1)2 , to represent it in F.P
the radix should be shift left two places,
the value becomes .111(which is the
mantissa) and the exponent is 2
3) Convert the exponent into excess-4
form by adding 4 to it (which results 6)
and convert it into binary 110 (which is
the exponent part)
4) The resulting F.P number is(01101110)

34
Floating-Point Notation:
Convert (10110101) from F.P notation
into decimal number:
1) Sign bit 1 , the No. is negative
2)The exponent is 011 which is 3 ,subtract
4 from it results (-1). This means the
radix should be shift left one place.
3)The mantissa is .0101 the radix shifted
one place left, the resulted value is
(00101) which is 1/8 + 1/32 = 5/32
4)The resulted decimal value is - (5/32)

35
Memory System
For purpose of storing data, a computer
contains a large collection of circuits,
each capable of storing a bit.
 The computer system contains two
main types of memory:
 Main Memory
 Secondary Memory(Mass Storage)

36
Main Memory:
The storage circuits in a machine’s
main memory are arranged in
manageable units called cells(or words)
, with a typical cell size being 8 bits
 Every 8 bits are called byte
 Every 1024 bytes called kilobyte(210
KB), and each 1024 KB is Megabyte …
 The main memory is divided to:
 Random Access Memory(RAM)
 Read Only Memory(ROM)

37
Mass Storage:
Secondary storage is a cheap and very
large (huge amount) storage area
 It is a permanent storage
 Classified into:
 Tapes
 Disks
 Compact Disks (CDs)

38
Communication Errors:
During the data transmission between
two points, we may lose data. To
resolve such a problem, a variety of
error detection and error correction
techniques have been developed such
as:
 Parity Bit
 Cyclic Redundancy Check(CRC)
 Hamming Distance
39
Parity Bit:



It is a bit added as MSB used to detect
errors without correcting them.
Is based on the principle that if each bit
pattern being manipulated has an odd
number of 1’s (Odd Parity)and a pattern
found with an even number of 1’s (Even
Parity)
This is achieved by adding an extra bit
for parity check. Thus an ASCII of 8 bits
40
becomes 9 bits
Parity Bit:
To obtain the odd parity for character(A):
1) From ASCII table,the hex code of A is 41,
in binary is : 0100 0001
2) Since the number of 1’s in the code is
even. The odd parity bit must be 1 to get
odd number of 1’s, and the complete code
becomes: 1 0100 0001
3)If an error happened in 3rd bit from right
,the received character becomes:
1 0100 0101 , the number of 1’s is even,
so the receiver detect that an error has
41
been occurred

Parity Bit:
4) This method is used to detect single
error and never correct it
5) It fails to detect the error if it happens in
the parity bit itself
42