Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
36 views23 pages

Chapter 2 OfArch

Uploaded by

meliha hawi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views23 pages

Chapter 2 OfArch

Uploaded by

meliha hawi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 23

Sequential Circuits

Combinational circuits implement the essential functions of a digital computer.


However, except for the special case of ROM, they provide no memory or state
information, elements also essential to the operation of a digital computer. For the
latter purposes, a more complex form of digital logic circuit is used: the sequential
circuit. The current output of a sequential circuit depends not only on the current
input, but also on the past history of inputs. Another and generally more useful
way to view it is that the current output of a sequential circuit depends on the
current input and the current state of that circuit.

In this section, we examine sequential circuits taking flip-flops as example. As will


be seen, the sequential circuit makes use of combinational circuits.

Flip-Flops

The simplest form of sequential circuit is the flip-flop. There are a variety of flip
flops, all of which share two properties:

 The flip-flop is a bi-stable device, i.e. has two stable states. It exists in one
of two states and, in the absence of input, remains in that state. Thus, the
flip-flop can function as a 1-bit memory.
 The flip-flop has two outputs, which are always the complements of each
other. These are generally labeled Q and . Q

The S–R flip-flop


The circuit has two inputs, S (Set) and R (Reset), and two outputs, Q and , and
consists of two NOR gates connected in a feedback arrangement.

Q
First, let us show that the circuit is bistable. Assume that both S and R are 0 and
that Q is 0. The inputs to the lower NOR gate are and Thus, the output means that
the inputs to the upper NOR gate are Q = 0 and S = 0. Thus the output =1
Q the inputs to the upper NOR gate are
means that = 1 and R = Q0 which has the
output Q = 0. Thus, the state of the circuit is internally consistent and remains
stable as long as S = R = 0. A similar line of reasoning shows that the state Q = 1,
= 0 is also stable
Q for R = S = 0.
Thus, this circuit can function as a 1-bit memory. We can view the output Q as the
“value” of the bit. The inputs S and R serve to write the values 1 and 0,
Q
1

Q
respectively, into memory. To see this, consider the state Q = 0, = 1, S = 0, R =
0. Suppose that S changes to the value 1. Now the inputs to the lower NOR gate
are S = 1, Q = 0. After some time delay Δt, the output of the lower NOR gate will
be Q = 0 (see Figure 1-14). So, at this point in time, the inputs to the upper NOR
gate become R = 0, = 0.

The S–R latch can be defined with a table similar to a truth table, called a
characteristic table, which shows the next state or states of a sequential circuit as a
function of current states and inputs. In the case of the S–R latch, the state can be
defined by the value of Q. Table 1-6a shows the resulting characteristic table.
Observe that the inputs S = 1, R = 1 are not allowed, because these would produce
an inconsistent output (both Q and equal 0).

Simplified Characteristics Table


S R Qn+1
0 0 Qn
0 1 0
1 0 1
1 1 -

D Flip-Flop
One problem with S–R flip-flop is that the condition must be avoided. One way to
do this is to allow just a single input. The D flip-flop accomplishes this.
The D flip-flop is sometimes referred to as the data flip-flop because it is, in effect,
storage for one bit of data. The output of the D flip-flop is always equal to the most
recent value applied to the input. Hence, it remembers and produces the last input.

It is also referred to as the delay flip-flop, because it delays a 0 or 1 applied to its


input for a single clock pulse. We can capture the logic of the D flip-flop in the
following truth table:

D Qn+1
0 0
1 1

2
J–K Flip-Flop

Like the S–R flip-flop, it has two inputs. However, in this case all possible
combinations of input values are valid. Note that the first three combinations are
the same as for the S–R flip-flop. With no input asserted, the output is stable. If
only the J input is asserted, the output is stable. If only the J input is asserted, the
result is a set function, causing the output to be 1; if only the K input is asserted,
the result is a reset function, causing the output to be 0.When both J and K are 1,
the function performed is referred to as the toggle function: the output is reversed.
Thus, if Q is 1 and 1 is applied to J and K, then Q becomes 0.

Characteristics table of JK flip flop

T flip flop

Another type of flip flop found in sequential circuit is toggle flip flop. This flip
flop is obtained from a JK type when inputs J and K are connected to provide a
single input designated by T. the T flip flop therefore has only two conditions.
When T= 0(J=K=0) a clock transition does not change the state of the flip flop.
When T=1(J=K=1) a clock transition complements the state of the flip flop. These
conditions can be expressed by a characteristics equation:

3
Basic flip-flops

Registers
As an example of the use of flip-flops, let us first examine one of the essential
elements of the CPU: the register. As we know, a register is a digital circuit used
within the CPU to store one or more bits of data. Two basic types of registers are
commonly used: parallel registers and shift registers.

4
PARALLEL REGISTERS A parallel register consists of a set of 1-bit memories
that can be read or written simultaneously. It is used to store data.
SHIFT REGISTER A shift register accepts and/or transfers information serially.
Shift registers can be used to interface to serial I/O devices. In addition, they can
be used within the ALU to perform logical shift and rotate functions.
Counters
Another useful category of sequential circuit is the counter. A counter is a register
whose value is easily incremented by 1 modulo the capacity of the register; that is,
after the maximum value is achieved the next increment sets the counter value to 0.
Thus, a register made up of n flip-flops can count up to An example of a
counter in the CPU is the program counter.

RIPPLE COUNTER An asynchronous counter is also referred to as a ripple


counter, because the change that occurs to increment the counter starts at one end
and “ripples” through to the other end.
SYNCHRONOUS COUNTERS The ripple counter has the disadvantage of the
delay involved in changing value, which is proportional to the length of the
counter. To overcome this disadvantage, CPUs make use of synchronous counters,
in which all of the flip-flops of the counter change at the same time. In this
subsection, we present a design for a 3-bit synchronous counter. In doing so, we
illustrate some basic concepts in the design of a synchronous circuit.
Programmable Logic Array
The PLA is based on the fact that any Boolean function (truth table) can be
expressed in a sum-of-products (SOP) form, as we have seen. The PLA consists of
a regular arrangement of NOT, AND, and OR gates on a chip. Each chip input is
passed through a NOT gate so that each input and its complement are available to
each AND gate. The output of each AND gate is available to each OR gate, and the
Output of each OR gate is a chip output. By making the appropriate connections,
arbitrary SOP expressions can be implemented.

5
Chapter 2

Data Representation
Data in computers is represented in binary form. The represented data can be
number, text, movie, color (picture), sound, or anything else. It is up to the
application software that presents the data to portray the data accordingly. We
enter data into a computer using letters, digits & special symbols. But inside the
computer, there is no color, letter, digit or any other character inside the computer
system unit.

Just like any other electrical device, computers understand and respond to only the
flow of electrical charge. They also have storage devices that work based on
magnetism. This shows that the overall structure of computers work only in binary
conditions (the semi-conductors are conducting or not conducting, a switch is
closed or opened, a magnetic spot is magnetized or demagnetized). Hence, data
must be represented in the form of binary code that has a corresponding electrical
signal.

The form of binary data representation system we are seeking is similar to the
binary number system in mathematics. Nevertheless we humans are not
accustomed to the use of binary numbers. The main focus of this chapter is on how
data is represented in computers. Since understanding of binary number system is
essential to understand binary data representation, conversion of numbers from a
given number base to another base, is also discussed here. The number systems
(bases) we will discuss are: decimal, binary, octal, and hexadecimal.

UNITS OF DATA REPRESENTATION

When data is stored, processed or communicated within the computer system, it is


packed in units; arranged from the smallest to the largest, the units are called bit,
byte and word; these units are based on the binary number system;

6
BIT

 On a magnetic disk, the same information is stored by changing the polarity


or magnetized particles on the disk’s surface;
 Bits are the smallest units and can convey only two possible states 0 or 1;
bit stands for binary digits
 In the computer “ON” is represented by the existence of current and “OFF”
is represented by the non-existence of current
 A bit is a single element in the computer, on a disk that stands for either
“ON” indicating 1 or “OFF” indicating 0;

BYTE

This large unit is called a byte and is the basic “unit of data representation”
in a computer system
Bits can be organized into large units to make them represent more and
meaningful information;
The commonly used byte contains 8 bits
Since each bit has two states and there are 8 bits in a byte, the total amount
of data that can be represented is 28 or 256 possible combinations;
Each byte can represent a character (a character is either a letter, a number or
a special symbol such as +,-,?,*, $, etc
A byte is then used as a unit of measurement in the computer memory,
processing unit, external storage and during communication;
If the computer memory is 524288 byte, this is expressed in short by saying
512KB, where KB stands for kilobyte.
 1 Kilobyte(1KB) is 210 or 1024 bytes
 1 Megabyte(MB) is 220 bytes or 210 kilobytes
 1 Gigabyte(GB) is 230 bytes or 220 kilobytes or 210 megabytes

WORD

7
Word refers the number of bits that a computer process at a time or a
transmission media transmits at a time
Although bytes can store or transmit information, the process can even be
faster if more than one byte is processed at a once;
A combination of bytes, then form a “word”
A word can contain one, two, three or four bytes based on the capacity of the
computer
Word length is usually given in bits
We say that a computer is an 8-bits, a 16 bit, a 32 bit or a 64 bit computer to
indicate that the amount of data it can process at a time;
The large the word length a computer has the more powerful and faster it is.

2.1 Number systems

Basically, there are two types of number systems.

I. Non-positional number system: The symbols of the number have the same
value regardless of its position in the number. The value of a symbol (digit) in a
number does not depend on the position of the digit in number.

II. Positional number system: The value of a symbol in the number is determined
by its position, the symbol and the base of the number system. In all positional
number systems, the base has the following properties

1. It determines the number of different symbols it has. For example, there are
10 different symbols in base 10 (decimal) number system and there are 2
symbols in base 2 (binary) number system.
2. The maximum value of a single digit is one less than the base value. For
example, the largest single digit number in the decimal (base 10) number
system is 9.
3. The positional value of each symbol is expressed by the power of the base.
For example, the value of the symbol 7 in the decimal number 75 is 70
(7×101) while the value of 7 in the decimal number 756 is 700 (7×10 2). The
source of the variation is the position of the digit in the number and this
value is expressed as a multiple of powers of the base.

In positional number system, the base of a number is indicated by writing it as a


subscript at the right side of the number. For instance the number 251 10 is the
8
decimal number two hundred fifty one, and 2518 is two-five-one octal (note that it
is not read as two hundred fifty one octal). Often the base of a decimal number is
not indicated. If the base of a number is not shown, it is assumed to be a decimal
number.

Decimal number system

The decimal number system, also called the base 10 number system, is the number
system we use in our day-to-day life. The preference of this number system by
humans is attributed to their nature that humans have 10 fingers. It is believed that
humans start counting using their fingers. This fact is the basis for the preference
of the decimal number system by humans.

The decimal number system has 10 different symbols identified as 0, 1, 2, 3, 4, 5,


6, 7, 8, and 9. All decimal numbers are written as a combination of these 10 digits.

Binary number system

Although the number system is easily understood by humans, it cannot be used to


represent data in computers because there are only two (binary) states in a
computer system. On the other hand, the binary number system, also known as
base 2 number system, has two digits 0 and 1. This makes it useful for data
representation in computers. The two digits of the binary number system
correspond to the two distinct states of the digital electronics. A binary digit is
referred to as a bit.

We can associate the two digits of the binary number system with two states of
electrical systems, magnetic systems, and switches. The following table shows the
conventional association. It is also possible to exchange the association but it
becomes confusing since it is the opposite of the convention (what is agreed on).

0 1
Electronic No current There is
current
Magnetic Demagnetized Magnetized
Switch Off On

9
Data representation using the binary number system results in a large string of 0s
and 1s. This makes the represented data large and difficult to read. Writing such a
binary string becomes tedious as well. For the sake of writing the binary strings in
a short hand form and make them readable, the octal and the hexadecimal number
systems are used.

Octal number system

Octal number system, also called base 8 number system, has 8 different symbols:
0, 1, 2, 3, 4, 5, 6, and 7. The octal number system is used to write binary numbers
in short form. An octal number has about one-third of the digits in its binary
equivalent.

Hexadecimal number system

The hexadecimal number system, also called base 16 number system, has 16
different symbols 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, and F. The hexadecimal
number system is usually referred as hex for short. It is used to write binary
numbers in short form. A hex number has about one-fourth of the digits in its
binary equivalent. Memory addresses and MAC addresses are usually written in
hex.

2.1.1 Converting from one base to another

I. Conversion from Decimal to Base m

Step 1: Divide the given decimal number by m (the desired base). The result will
have a quotient and a remainder.
Step 2: Divide the quotient by m. Still you get a quotient and a remainder.
Step 3: Repeat step 2 until the quotient becomes 0. You should note that we are
conducting integer division. In integer division n/m, the quotient is 0
whenever n < m.
Step 4: Collect and arrange the remainders in such a way that the first remainder is
the least significant digit and the last remainder is the most significant digit
(i.e., RnRn-1 … R2R1).
Example: Convert the following decimal number 47 into binary, octal, and
hexadecimal.
a. Conversion to binary
10
In order to convert the given decimal numbers into binary (base 2), they are
divided by 2.
Quotient Remainder
47 ÷ 2 23 1
23 ÷ 2 11 1
11 ÷ 2 5 1
5÷2 2 1
2÷2 1 0
1÷2 0 1

Since the quotient becomes 0 at the last division, the division has to stop and we
should collect the remainders starting from the last one. Hence the result is
1011112. Note that, starting from the second division, at each consecutive division
the quotient of the previous division is used as the dividend.

b. Conversion to octal
Here the numbers are divided by 8 because the required base is octal (base 8).
Quotient Remainder
47 ÷ 8 5 7
5÷8 0 5

Therefore, 47 = 578

c. Conversion to hexadecimal
Since the conversion now is into hexadecimal (base 16) the given decimal numbers
are divided by 16.
Quotient Remainder
47 ÷ 16 2 15
2 ÷ 16 0 2

Remember that the remainders are all in decimal and when you write the result in
the required base, the remainders has to be converted into that base. The
hexadecimal equivalent for the decimal 15 is F and that of 2 is 2. For conversion of
decimal numbers into binary and octal or vice versa, there is no problem of looking
for the equivalent of each remainder. You need such conversion of a remainder
only when the remainder is a double digit number. Therefore, 47 = 2F16

II. Conversion from Base m to Decimal

11
Step 1: Multiply each digit by its positional value.
Step 2: Calculate the sum of the products you get in step 1. The resulting sum you
get is the decimal equivalent for the given number in base m.

Example 1: Convert the binary number 110001 into decimal.

1100012 = (1 × 25) + (1 × 24) + (0 × 23) + (0 × 22) + (0 × 21) + (1 × 20)


= (1 × 32) + (1 × 16) + (0 × 8) + (0 × 4) + (0 × 2) + (1 × 1)
= 32 + 16 + 0 + 0 + 0 + 1
= 49

Therefore, 1100012 = 49

It is evident that calculating the product of 0s since the product is 0 and do not
contribute anything to the final result. However, you should remember to skip the
positional value as well.

Example 2: Convert the octal number 22 into decimal.

228 = (2 × 81) + (2 × 80)


= (2 × 8) + (2 × 1)
= 16 + 2
= 18

Therefore, 228 = 18

Example 3: Convert the hexadecimal number D1 into decimal.

D116 = (13 × 161) + (1 × 160); you should be aware that the calculations are in
decimal thus the hex digit D must first be converted into
its decimal equivalent (13).
= (13 × 16) + (1 × 1)
= 208 + 1
= 209

Therefore, D116 = 209

III. Conversion from Binary to Octal

12
It is possible to use decimal number system as an intermediate base to convert
from any base to any other base. However, for conversion from binary to octal or
vice versa, there is a very simple method.

Step 1: Group the binary digits (bits) starting from the rightmost digit. Each group
should contain 3 bits. If the remaining bits at the leftmost position are fewer
than 3, add 0s at the front.
Step 2: For each 3-bit binary string, find the corresponding octal number. Table 3-1
shows the conversion equivalents.

Example: Convert the binary numbers 110011 and 1101111 to octal.

A. 110011

110 011
6 3

The bits are grouped in three with the equivalent octal digit given below the three
bit group. Thus, 1100112 = 638

B. 1101111

001 101 111


1 5 7

Since we are left with a single bit at the leftmost position, two 0s are added at the
front to make create a three-bit group. The result shows that 11011112 = 1578.

IV. Conversion from Octal to Binary

Step 1: For each octal digit, find the equivalent three digit binary number.
Step 2: If there are leading 0s for the binary equivalent of the leftmost octal digit,
remove them.

Example: Find the binary equivalent for the octal numbers 73 and 160.
13
A. 73
7 3
111 011

Since there are no leading 0s at the leftmost position (the bits for octal 7), there is
no 0 to remove. Therefore, 738 = 1110112

B. 160
1 6 0
001 110 000

The binary equivalent for the leftmost octal digit 1 has two 0s. To get the final
result, remove them and concatenate the rest. Thus, 1608 = 11100002

V. Conversion from Binary to Hexadecimal

One possible way to convert a binary number to hexadecimal, is first to convert the
binary number to decimal and then from decimal to hex. Nevertheless, the simple
way to convert binary numbers to hex is by grouping as used in conversion to
octal. Here a single group has 4 bits.

Step 1: Starting from the rightmost bit, group the bits in 4. If the remaining bits at
the leftmost position are fewer than 4, add 0s at the front.
Step 2: For each 4-bit group, find the corresponding hexadecimal number. You can
use Table 3-1 to find conversion equivalents.

Example: Convert the binary numbers 1110110001 and 10011110 to hexadecimal.

A. 1110110001
0011 1011 0001
2 B 1

Therefore, 11101100012 = 2B116

B. 10011110
1001 1110
9 E

Therefore, 100111102 = 9E16

14
VI. Conversion from Hexadecimal to Binary

Step 1: For each hexadecimal digit, find the equivalent four digit binary number.
Step 2: If there are leading 0s for the binary equivalent of the leftmost
hexadecimal digit, remove them.

Example: Find the binary equivalents for the hexadecimal numbers 1C and 823.

A. 1C
1 C
0001 1100

After removing the leading 0s for the binary equivalent of the leftmost
hexadecimal number 1, the result becomes 11100. Thus, 1C16 = 111002

B. 823
8 2 3
1000 0010 0011

There is no leading 0s for the binary equivalent of the hexadecimal number 8, we


simply concatenate the binary digits to get the final result. Hence, 823 16 =
1000001000112

VII. Conversion from Octal to Hexadecimal of Vice Versa

The decimal number system can be used as an intermediate conversion base. As it


is shown in the above sections, however, it the binary number system is quite
convenient for conversion to or from octal and hexadecimal. To convert an octal
number to a hexadecimal number or from hexadecimal to octal, the binary number
system is used as an intermediate base.

Step 1: Convert the given number into binary.


Step 2: Convert the binary number you got in step 1 into the required base.
Example: Convert the octal number 647 to hexadecimal.
Convert 6478 to binary
6 4 7
110 100 111

15
Convert 1101001112 to hexadecimal

0001 1010 0111


1 A 7

Therefore, 6478 = 1A716

Example 2: Find the octal equivalent for the hexadecimal number 3D5
Convert 3D516 to binary
3 D 5
0011 1101 0101

Convert 11110101012 to octal

001 111 010 101


1 7 2 5

Therefore, 3D516 = 17258

2.2 Representation of Integers

If the numbers we want to represent are only positive (unsigned) integers, the
solution is straight forward; simply represent the unsigned integer with its binary
value. For example, 34 is represented as 00100010 in 8 bits. In this section, the
discussion is on representation of signed integers. Signed integers can be are
represented in several alternative ways. These alternatives are used for various
purposes based on their convenience for the applications.

Computer storage has a limited capacity to hold data. The number of bits available
for data representation determines the range of integers we can represent. With 4
bits, it is possible to represent a total of 16 integers. If the number of available bits
increases to 5, we can represent 32 integers. In fact with every bit added, the
number of possible integers we can represent is doubled. In general, the number of
integers we can represent with n bits is 2 n. Singed integers include positive
integers, negative integers, as well as zero. The 2 n places are partitioned among the
negative, positive, and zero. For example, with 8 bits, it is possible to represent 256
different integers. Typically, 128 of them are positive integers and zero while the
rest 128 of them are negative integers.

16
Signed integer representations discussed in this section are sign magnitude, 1’s
complement, 2’s complement, and excess-N. We assume the number of bits
available for representation is 8 unless explicitly specified.

2.2.1 Sign-Magnitude Representation

In mathematics, positive integers are indicated by a preceding + sign (although


usually it is avoided) an a preceding – sign identify the integer as a negative
number. In computers, there is no place for a + or a – sign; there are only 0s and
1s. A similar way of representing + and – signs is to treat the most significant bit as
a sign bit the remaining bits are used to represent the magnitude of the integer. By
convention a 0 on the sign bit indicate the integer is positive and a 1 indicate the
integer is a negative.

A problem of this representation method is that there are two representations for 0;
a positive 0 and a negative 0. An integer with all the magnitude bits and the sign
bit set to 0 is a positive 0 while an integer with all the magnitude bits set to 0 and a
1 on its sign bit is a negative 0. This type of ambiguous representation is
undesirable and as a solution, the negative zero can be ignored. The biggest
problem of this representation method is, however, its inconvenience in binary
arithmetic. Early computers, for instance IBM 7090, used this representation.

As example, the sign-magnitude representation of 79 and -79 in 8 bits are


01001111 and 11001111 respectively. The only difference is on the sign (first) bit;
for 79 it is 0 while for -79 it is 1. Figure 3-1, shows the representation scheme with
8 bits. In sign magnitude, the lower half range of values represent the positive
integers starting at positive 0 while the higher half values represent negative
integers starting at negative 0.

17
0
1
2

20

126
127
128
129
130

236

254
255
... ... . . . (a)
. . .
00000000
00000001
00000010

01111110
01111111
10000000
10000001
10000010

11101100

11111110
11111111
00010100
. . . ... ... . . . (b)

. . . ... ... . . . (c)

-0
-1
-2

-108

-126
-127
0
1
2

20

126
127
Figure 2-1: Sign-magnitude representation number line; (a) the unsigned decimal
value of the binary number, (b) the binary numbers, (c) the actual value
the binary numbers represent in sign-magnitude representation

2.2.2 One’s Complement Integer Representation

Every number system has two complement systems. For a given base n the
complements are n’s complement and (n-1)’s complement. Thus, in decimal
numbers system (base 10), the complement systems are 10’s complement and 9’s
complement. Similarly in binary number system, the complements are 2’s
complement and 1’s complement. Using complements in binary number systems
makes subtraction and logical negation very simple. Calculating the complement of
a binary integer is trivial. Furthermore, using complements makes arithmetic
operations simple.

The one’s complement of a binary integer is found by inverting all 0s to 1s and all
1s to 0s. This makes complementing operation simple at hardware level. In one’s
complement integer representation, the negative of an integer is represented by its
complement. For example, the one’s complement representation of 16 and -16 in 8
bits are 00010000 and 11101111 respectively.

As with sign-magnitude representation, there are two representations for 0. A one’s


complement representation with all 0s is a positive 0 while one with all 1s is a
negative 0. Still representations for positive integer s begin with 0 while that of
negative integers start with 1. The arrangement of numbers on the number line is in
such a way that it starts with positive 0, puts positive numbers starting with 1,
arranges negative numbers beginning with the smallest one (with the highest
magnitude) and ends with negative 0. Figure 2-2 shows the arrangement of integers
with one’s complement representation on the number line.

18
0
1
2

20

126
127
128
129
130

236

254
255
... ... . . . (a)
. . .
00000000
00000001
00000010

01111110
01111111
10000000
10000001
10000010

11101100

11111110
11111111
00010100
. . . ... ... . . . (b)

. . . ... ... . . . (c)

-127
-126
-125

-19

-1
-0
0
1
2

20

126
127
Figure 2-2: One’s complement number line; (a) the unsigned decimal value of the
binary number, (b) the binary numbers, (c) the actual value the binary
numbers represent in one’s complement representation

2.2.3 Two’s Complement Integer Representation

The two’s complement of an integer is found by adding 1 to its one’s complement.


As a reminder, in binary arithmetic, 0+1 = 1 and 1+1 = 0 with a carry of 1 to the
next higher significant bit. A shortcut method to find the two’s complement of a
number is to keep all the bits up to and including the first 1 from the right and
invert all the others. Two’s complement representation of 19 and -19 in 8 bits are
00010011 and 11101101 respectively.

There is only one representation for 0 where all the bits are set to 0. The
consequence is that the number of negative integers is one more than their positive
counterparts. The arrangement of two’s complement integers on the number line is
similar to that of one’s complement except that the last value is -1 rather than -0.
Figure 2-3 shows this.
0
1
2

20

126
127
128
129
130

236

254
255

... ... . . . (a)


. . .
00000000
00000001
00000010

01111110
01111111
10000000
10000001
10000010

11101100

11111110
11111111
00010100

. . . ... ... . . . (b)

. . . ... ... . . . (c)


-128
-127
-126

-20

-2
-1
0
1
2

20

126
127

Figure 2-3: Two’s complement number line; (a) the unsigned decimal value of the
binary number, (b) the binary numbers, (c) the actual value the binary
numbers represent in two’s complement representation
19
2.3 Floating Point Numbers

In this representation decimal numbers are represented with a fixed length format.
In order not to waste bits, the representation will normalize all the numbers. For
example, 0.000123 wastes three zeroes on the left before non -zero digits. There
zeroes have no meaning except to indicate the position of the Decimal point.
Normalizing this number result in .123x10-3 .123 is the normalized mantissa; -3 is
the exponent. We have normalized this by eliminating all the meaningless zeroes
to the left of the first non-zero digit and by adjusting the exponent.

Ex1: 22.1 is normalized as .221x102.

The general form of floating point representation is Mx10 E where M is the


mantissa, and E is the exponent . It can be seen that a normalized number is
characterized by a mantissa less then 1 and greater than or equal to.1 all cases
when the number is not zero.

Ex2 111.01 is normalized as .11101x23.

The mantissa is 11101. The exponent is 3.

The general structure of floating point is

Sign Exponent Mantissa

In representing a number in floating point we use 1 bit for sing, some bits for
exponent and the remaining bit for mantissa.

In floating point representation the exponent is represented by a biased exponent


(Characteristic).

Biased exponent = true exponent + excess 2n-1, where n is the number of bits
representing the exponent.

20
Ex1.
Represent –234.375 in floating point using 7 bit for exponent and 16 bit for
mantissa.
First we have to change to normalized binary
i. e 234 = 11100010
0.375= 0.011
234.375 = 11100010.011 = 0.11100010011x28
True exponent = 8
Excess 2n-1 = 27-1= 26= 64
Biased exponent = 8+26 = 8+64 = 72
= 100 1000 2
Therefore –234.375 is represented as
1 1001000 1110001001100
000

Sign 7-bits 16 bits

Ex2. Represent 34.25 in floating point using 7 bit for exponent and 24 bits
for mantissa.
34.25 = 1000 10.0 12
The normalized form of 34.25 = .10001001x 26
True exponent = 6; 2n-1 = 27-1= 6+26
=6+64=70
70 = 10001102

Therefore, 34.25 is represented as


0 1000110 100010010000
…..0

To represent a number in floating point:


 Represent the number in normalized binary form.
 Find the biased exponent
 Change the biased exponent to binary
 Write the sing, the exponent in the exponent part and the mantissa in the
mantissa form
 If there are fewer digits in the exponent add zeros to the left and for mantissa
add zeros to the right.

Floating-point Arithmetic

21
To perform floating-point arithmetic:
 First correct the numbers to normalized binary of the same exponent
 Apply the operator
 If necessary normalize the result

Ex1. Find 23.375+ 41.25 using 7-bit for exponent and 10 bit for mantissa.

23.375 = (10111.011)2 = 0.1011101x25 = 0.010111011x26


41.25 = (111001.01)2 = 0.11100101x26

23.37+41.25 = 0.01011101x26+0.1110010x26
= (0.010111011+0.11100101)26
= 0.1010000101x26

2.4 Other Binary Codes

2.4.1 Binary Coded Decimal (BCD)

For systems with much I/O and little computation of numbers, it is efficient to use
a mechanism in which each digit of a number is represented in their binary
equivalent. The BCD (Binary Coded Decimal), also called packed decimal,
representation is based on this idea. In order to have representations for the ten
digits of the decimal number system, we need a four bit string. Thus 0 = 0000, 1 =
0001, 2 = 0010… and 9 = 1001. In BCD, multiples of 8 bits, in which the bits are
grouped in 4, are used to represent decimal numbers. Thus the decimal number 461
is represented as 0000 0100 0110 0001.

Although BCD avoids complex conversions of binary numbers to decimal and vice
versa, it is inefficient in memory space usage. As the total number of unique
combinations with 4 bit strings is 16, 10 of them are used to represent the numbers.
Two more bit strings can be used to represent positive and negative signs (although
the bit string for 0 and 9 are used as positive and negative signs respectively). The
remaining bit strings are wasted. Performing arithmetic in BCD is similar to that of
other representations but the circuitry needs is also much complex. Sign-magnitude
as well as complement systems can be used in BCD. The complement system is
either 9’s complement or 10’s complement. Since complements have the advantage
of simplicity in arithmetic, they are preferred.

22
2.4.2 Characters

Text documents contain strings of characters. Characters refer to letters of the


alphabet, the ten digits (0 through 9), punctuation marks, characters that are used to
format the layout of text on pages such as the newline, space, and tab characters,
and other characters that are useful for communication. The most widely used
character code is the International Reference Alphabet (IRA). The American
version of IRA is called American Standard Code for Information Interchange
(ASCII). Even though IRA used 8 bits, each character is represented by 7 bits;
hence a total of 128 characters are represented. The eighth bit is used for parity
(error detection). The ASCII character set is given in the Appendix.

Another character encoding system is the EBCDIC (Extended Binary Coded


Decimal for Interchange Code) is used on IBM mainframe. It uses 8 bits per
character (and a ninth parity bit), thus represents 256 characters. As with IRA,
EBCDIC is compatible with BCD. In the case of EBCDIC, the codes 11110000
through 11111001 represent the digits 0 through 9.

ASCII is a standard for use in the United States. Many countries adapted their own
versions of ASCII. There are also 8-bit versions of ASCII which allow having
additional 128 rooms for more characters, especially of those languages based on
the Latin character. To allow encoding of characters of all the languages in the
world, a character set known as the Unicode is devised. The Unicode character has
variants known as UTF-8, UTF-16, and UTF-32. UTF-8 is the same as ASCII.
UTF-16 and UTF-32 use 16-bit and 32-bit per character respectively, thus, have
incorporated much more characters. For backward compatibility with ASCII, the
first 128 characters of UTF-16 and UTF-32 are similar to those of ASCII.

23

You might also like