COA_Unit-1_Computer Data Representation.docx
COA_Unit-1_Computer Data Representation.docx
SEMESTER- 4
BRANCH- CSE
UNIT 1: INTRODUCTION
Number System:
It is a basis for counting various items.
The digit value in the number system is calculated using:
The digit
The index, where the digit is present in the number.
Finally, the base numbers, the total number of digits available in the number system.
Classification:
1. Binary Number System
2. Decimal Number System
3. Hexadecimal Number System
4. Octal Number System
Computer Architecture.
It deals with the conceptual design and fundamental operational structure of the computer.
It consists of:
CPU designing
Set of instructions CPU supports
Addressing modes
Data Format
(152)10=(10011000)2
(0.25)10=(.01)2
2. Excess-3 Codes
The excess-3 code is also treated as XS-3 code. The excess-3 code is a non-weighted
and self-complementary BCD code used to represent the decimal numbers.
We can easily get an excess-3 code of a decimal number by simply adding 3 to each
decimal digit. And then we write the 4-bit binary number for each digit of the decimal
number. We can find the excess-3 code of the given binary number by using the
following steps:
1. We find the decimal number of the given binary number.
COA (3140707) 2024 Page | 7
New L J Institute of Engineering and Technology Semester: IV (2024)
3. ASCII Codes
The ASCII stands for American Standard Code for Information Interchange. The ASCII
code is an alphanumeric code used for data communication in digital computers. The ASCII
is a 7-bit code capable of representing 27 or 128 number of different characters. The ASCII
code is made up of a three-bit group, which is followed by a four-bit code.
1. The ASCII Code is a 7 or 8-bit alphanumeric code.
2. This code can represent 127 unique characters.
3. The ASCII code starts from 00h to 7Fh. In this, the code from 00h to 1Fh is used for
control characters, and the code from 20h to 7Fh is used for graphic symbols.
4. The 8-bit code holds ASCII, which supports 256 symbols where math and graphic
symbols are added.
5. The range of the extended ASCII is 80h to FFh.
6. The ASCII characters are classified into the following groups
TOPIC 2: Complements
1’s Complement:
COA (3140707) 2024 Page | 8
New L J Institute of Engineering and Technology Semester: IV (2024)
We can find the 1's complement of the binary number by simply inverting the given number.
For example, 1's complement of binary number 1011001 is 0100110.
Example 1: 11010.1101
For finding 1's complement of the given number, change all 0's to 1 and all 1's to 0. So the
1's complement of the number 11010.1101 comes out 00101.0010.
2’s Complement:
If we want to calculate the 2's complement of the number 1011001, then firstly, we find the
1's complement of the number that is 0100110 and add 1 to the LSB. So, by adding 1 to the
LSB, the number will be (0100110)+1=0100111.
Example 1: 110100
For finding 2's complement of the given number, change all 0's to 1 and all 1's to 0. So the
1's complement of the number 110100 is 001011. Now add 1 to the LSB of this number,
i.e., (001011) +1=001100.
Let's take some examples to understand how we can calculate the r's and (r-1)'s
complement of binary, decimal, octal, and hexadecimal numbers.
Example 1: (1011000)2
This number has a base of 2, which means it is a binary number. So, for the binary numbers,
the value of r is 2, and r-1 is 2-1=1. So, we can calculate the 1's and 2's complement of the
number.
1's complement of the number 1011000 is calculated as:
={(27 )10-1}-(1011000)2
={(128)10-1}-(1011000)2
={(127)10}-(1011000)2
=11111112-10110002
=0100111
2's complement of the number 1011000 is calculated as:
=(27 )10-(1011000)2
=(128)10-(1011000)2
=100000002-10110002
=01010002
3. Input-output registers are represented by names such as DATA IN, DATA OUT and
so on.
4. The content of register or memory location is denoted by placing square brackets
around the name of the register or memory location.
Define and explain register transfer
The term Register Transfer refers to the availability of hardware logic circuits that can
perform a given micro-operation and transfer the result of the operation to the same or
another register.
Most of the standard notations used for specifying operations on various registers are stated
below.
1. The memory address register is designated by MAR.
2. Program Counter PC holds the next instruction's address.
3. Instruction Register IR holds the instruction being executed.
4. R1 (Processor Register).
5. We can also indicate individual bits by placing them in parenthesis. For instance,
PC (8-15), R2 (5), etc.
6. Data Transfer from one register to another register is represented in symbolic form
by means of replacement operator. For instance, the following statement denotes a
transfer of the data of register R1 into register R2.
R2 ← R1
7. Typically, most of the users want the transfer to occur only in a predetermined
control condition. This can be shown by following if-then statement:
If (P=1) then (R2 ← R1); Here P is a control signal generated in the control section.
8. It is more convenient to specify a control function (P) by separating the control
variables from the register transfer operation. For instance, the following statement
defines the data transfer operation under a specific control function (P).
P: R2 ← R1
9. The following image shows the block diagram that depicts the transfer of data from
R1 to R2.
10. Here, the letter 'n' indicates the number of bits for the register. The 'n' outputs of the
register R1 are connected to the 'n' inputs of register R2.
11. A load input is activated by the control variable 'P' which is transferred to the register
R2.
The n outputs of register R1 are connected to the n inputs of register R2. The letter n
will be used to indicate any number of bits for the register.
In the timing diagram, P is activated in the control section by the rising edge of a
clock pulse at time t.
The next positive transition of the clock at time t + 1 finds the load input active and
the data inputs of R2 are then loaded into the register in parallel.
P may go back to 0 at time t + 1; otherwise, the transfer will occur with every clock
pulse transition while P remains active.
The basic symbols of the register transfer notation are listed in Table below:
Registers are denoted by capital letters, and numerals may follow the letters.
Parentheses are used to denote a part of a register by specifying the range of bits or
by giving a symbol name to a portion of a register.
The arrow denotes a transfer of information and the direction of transfer.
A comma is used to separate two or more operations that are executed at the same
time.
The statement below, denotes an operation that exchanges the contents of two
registers during one common clock pulse provided that T = 1.
T: R2← R1, R1← R2
This simultaneous operation is possible with registers that have edge-triggered flip-
flops.
The following diagram demonstrates the construction of a bus system with three-state buffers
The outputs generated by the four buffers are connected to form a single bus line.
Only one buffer can be in active state at a given point of time.
The control inputs to the buffers determine which of the four normal inputs will
communicate with the bus line.
A 2 * 4 decoder ensures that no more than one control input is active at any given
point of time
The two selection lines S1 and S2 are connected to the selection inputs of all four
multiplexers. The selection lines choose the four bits of one register and transfer
them into the four-line common bus.
When both of the select lines are at low logic, i.e. S1S0 = 00, the 0 data inputs of all
four multiplexers are selected and applied to the outputs that forms the bus. This, in
turn, causes the bus lines to receive the content of register A since the outputs of this
register are connected to the 0 data inputs of the multiplexers.
Similarly, when S1S0 = 01, register B is selected, and the bus lines will receive the
content provided by register B.
The following function table shows the register that is selected by the bus for each
of the four possible binary values of the Selection lines.
Note: The number of multiplexers needed to construct the bus is equal to the number of
bits in each register. The size of each multiplexer must be 'k * 1' since it multiplexes 'k'
data lines. For instance, a common bus for eight registers of 16 bits each requires 16
multiplexers, one for each line in the bus. Each multiplexer must have eight data input
lines and three selection lines to multiplex one significant bit in the eight registers.
Memory Transfer
Most of the standard notations used for specifying operations on memory transfer are stated
below.
The transfer of information from a memory unit to the user end is called a Read
operation.
The transfer of new information to be stored in the memory is called a Write
operation.
A memory word is designated by the letter M.
We must specify the address of memory word while writing the memory transfer
operations.
The address register is designated by AR and the data register by DR.
Thus, a read operation can be stated as:
Read: DR ← M [AR]
The Read statement causes a transfer of information into the data register (DR) from
the memory word (M) selected by the address register (AR).
And the corresponding write operation can be stated as:
Write: M [AR] ← R1
The Write statement causes a transfer of information from register R1 into the
memory word (M) selected by address register (AR).
Question: A digital computer has a common bus system for 16 registers of 32 bits each.
(i) How many selection input are there in each multiplexer?
(ii) What size of multiplexers is needed?
(iii) How many multiplexers are there in a bus?
Solution:
(i) How many selection inputs are there in each multiplexer?
2n=No. of Registers; n=selection input of multiplexer
2n=16; here n=4
Therefore 4 selection input lines should be there in each multiplexer.
(ii) What size of multiplexers is needed?
size of multiplexers= Total number of register X 1= 16 X 1
Hence, Multiplexer of 16 x 1 size is needed to design the above defined common bus.
(iii) How many multiplexers are there in a bus?
No. of multiplexers = bits of register = 32
32 multiplexers are needed in a bus.
Note: The increment and decrement micro-operations are symbolized by '+ 1' and '? 1'
respectively. Arithmetic operations like multiply and divide are not included in the basic
set of micro-operations.
Binary Adder
The Add micro-operation requires registers that can hold the data and the digital
components that can perform the arithmetic addition.
A Binary Adder is a digital circuit that performs the arithmetic sum of two binary
numbers provided with any length.
A Binary Adder is constructed using full-adder circuits connected in series, with the
output carry from one full-adder connected to the input carry of the next full-adder.
The following block diagram shows the interconnections of four full-adder circuits
to provide a 4-bit binary adder.
The augend bits (A) and the addend bits (B) are designated by subscript numbers
from right to left, with subscript '0' denoting the low-order bit.
The carry inputs starts from C0 to C3 connected in a chain through the full-adders.
C4 is the resultant output carry generated by the last full-adder circuit.
The output carry from each full-adder is connected to the input carry of the next-
high-order full-adder.
The sum outputs (S0 to S3) generates the required arithmetic sum of augend and
addend bits.
The n data bits for the A and B inputs come from different source registers. For
instance, data bits for A input comes from source register R1 and data bits
for B input comes from source register R2.
The arithmetic sum of the data inputs of A and B can be transferred to a third register
or to one of the source registers (R1 or R2).
Binary Adder-Subtractor
The Subtraction micro-operation can be done easily by taking the 2's compliment of
addend bits and adding it to the augend bits
Note: The 2's compliment can be obtained by taking the 1's compliment and adding one
to the least significant pair of bits. The 1's compliment can be implemented with inverters,
and one can be added to the sum through the input carry.
The Arithmetic micro-operations like addition and subtraction can be combined into
one common circuit by including an exclusive-OR gate with each full adder.
The block diagram for a 4-bit adder-subtractor circuit can be represented as:
When the mode input (M) is at a low logic, i.e. '0', the circuit act as an adder and
when the mode input is at a high logic, i.e. '1', the circuit act as a subtractor.
The exclusive-OR gate connected in series receives input M and one of the inputs
B.
When M is at a low logic, we have B⊕ 0 = B. The full-adders receive the value of
B, the input carry is 0, and the circuit performs A plus B.
When M is at a high logic, we have B⊕ 1 = B' and C0 = 1. The B inputs are
complemented, and a 1 is added through the input carry. The circuit performs the
operation A plus the 2's complement of B.
0 0 0 B A+B
0 0 1 B A+B+1
0 1 0 B’ A + B’
0 1 1 B’ A + B’ + 1 = A –
B
1 0 0 0 A
1 0 1 0 A+1
1 1 0 1 A–1
1 1 1 1 A–1+1=A
The below diagram shows the truth table for all the 16 logic micro-operations mentioned
above. Here, x and y are the variables or registers in which the data is stored and F0, F1,..,
F15 are the outputs that occur after performing these logic micro-operations.
1. Clear: The Clear logic micro-operation is used to clear the register or set the bits of
the register to 0. To use this micro-operation, we need to feed 0 to the register. In
the above truth table, F0 represents the truth table of Clear logic micro-operation.
2. AND: The AND logic micro-operation performs the logical AND between the bits
of the data stored in the two registers. The symbol to represent the logical AND is
∧.
3. Transfer A: The Transfer A logic micro-operation transfers the contents of register
A (first register) to the output register.
4. Transfer B: The Transfer B logic micro-operation transfers the contents of register
B (second register) to the output register.
5. Exclusive OR: Also known as XOR, this logic micro-operation performs the logical
XOR between the data bits stored in the two registers. The logical XOR means either
x should be true or y but not both. The symbol to represent the Exclusive OR is ⊕.
6. OR: The OR logic micro-operation performs the logical OR between the data bits
stored in the two registers. The symbol to represent the logical OR is ∨.
7. NOR: The NOR logic micro-operation is simply the opposite of OR logic micro-
operation. As the name suggests, it is Not OR. The output of OR micro-operation is
1 when the value of either x register or y register or both x and y registers are true.
In contrast, in NOR, the output is 0 when the value of either x register or y register
or both x and y registers are true, and it is 1 when both x and y registers are false. In
the above truth table, F8 represents the truth table of NOR logic micro-operation.
8. Exclusive NOR: If we perform the Exclusive NOR micro-operation, the output will
be 1 when the values of both the x and y registers will be the same. They can be true
or false, but they have to be the same.
9. Complement B: The Complement B logic micro-operation transfers the
complemented contents of register B (second register) to the output register. First,
the content of the register is complemented and then moved to the desired register.
10. Complement A: The Complement A logic micro-operation transfers the
complemented contents of register A (first register) to the output register. First, the
content of the register is complemented and then moved to the desired register.
11. NAND: The NAND logic micro-operation is simply the opposite of AND logic
micro-operation. As the name suggests, it is Not AND. The output of AND micro-
operation is 1 when the value of both the x register and y register is true. In contrast,
in NAND, the output is 0 when the value of both x register and y register is true, and
it is 1 when either x is false, or y is false, or both are false.
12. Set to all 1’s: The set to all 1’s logic micro-operations is used to set all the register
bits to 1. To use this micro-operation, we just need to feed 1 to the register. In the
above truth table, F15 represents the truth table of Set to all 1’s logic micro-
operation.
Hardware Implementation
The hardware implementation of logic micro-operation requires that logic gates be
inserted for each bit or pair of bits in the registers to perform the required logic function.
Although there are 16 logic microoperation, most computers use only four—AND, OR,
XOR (exclusive-OR), and complement from which all others can be derived.
Below figure shows one stage of a circuit that generates the four basic logic micro-
operations.
Hardware implementation consists of four gates and a multiplexer.
Each of the four logic operations is generated through a gate that performs the
required logic.
The outputs of the gates are applied to the data inputs of the multiplexer.
The two selection inputs S1 and S0 choose one of the data inputs of the
multiplexer and direct its value to the output.
The diagram shows one typical stage with subscript i. For a logic circuit with n bits,
the diagram must be repeated n times for i = 0, 1, 2, . . . n - 1. The selection variables
are applied to all stages
Selective-Complement operation:
The selective-complement operation complements bits in A where there are
corresponding 1's in B.
It does not affect bit positions that have O's in B. For example:
1010 A before
1100 B (logical operand)
0110 A after
Again the two leftmost bits of B are 1's, so the corresponding bits of A are
complemented.
The exclusive-OR micro-operation can be used to selectively complement
bits of a register
Selective-Clear operation:
The selective-clear operation clears to 0 the bits in A only where there are
corresponding 1's in B. For example:
1010 A before
1100 B (logical operand)
0010 A after
Again the two leftmost bits of B are 1's, so the corresponding bits of A are
cleared to 0.
One can deduce that the Boolean operation performed on the individual bits
is AB'.
The corresponding logic micro-operation is A ← A ∧ B’.
Logical Shift: The logical shift micro-operation moves the 0 through the serial input. There
are two ways to implement the logical shift.
Logical Shift Left
Logical Shift Right
To implement the logical shift left micro-operation, we use the shl symbol.
For example, R1 -> shl R1.
This command means the 8 bits present in the R1 register will be logically shifted
left, and the result will be stored in register R1.
Moreover, the logical shift left micro-operation denotes the multiplication of 2. The
example we’ve taken above when converted into decimal forms the number 10 and
the result after the logical shift operation when converted to decimal forms the
number 20.
b) Logical Shift Right:
Each bit in the register is shifted to the right one by one in this shift micro-operation.
The least significant bit (LSB) is moved outside the register, and the place of the
most significant bit (MSB) is filled with 0.
For example, in the below data, there are 8 bits 00000101. When we perform a
logical shift right on these bits, all these bits will be shifted towards the right. The
LSB or the rightmost bit i.e. 1 will be moved outside, and at the leftmost place or
MSB, 0 will be inserted as shown below.
To implement the logical shift right micro-operation, we use the shr symbol.
For example, R1 -> shr R1.
This command means the 8 bits present in the R1 register will be logically shifted
right, and the result will be stored in register R1.
Logical right shift micro-operation generally denotes division by 2. The inputted bits
when converted into decimal form the number 5 and the outcome when converted
into decimal forms the number 2.
Arithmetic Shift:
The arithmetic shift micro-operation moves the signed binary number either to the left or to the right
position. There are two ways to implement the arithmetic shift:
a) Arithmetic Shift Left
b) Arithmetic Shift Right
a) Arithmetic Shift Left:
The arithmetic shift left micro-operation is the same as the logical shift left micro-
operation. Each bit in the register is shifted to the left one by one in this shift micro-
operation. The most significant bit (MSB) is moved outside the register, and the
place of the least significant bit (LSB) is filled with 0.
For example, in the below data, there are 8 bits 00100011. When we perform the
arithmetic shift left on these bits, all these bits will be shifted towards the left. The
MSB or the leftmost bit i.e. 0 will be moved outside, and at the rightmost place or
LSB, 0 will be inserted as shown below.
The given binary number (00100011) represents 35 in the decimal system and the
binary number after logical shift left (01000110) represents 70 in a decimal system.
Since 35 * 2 = 70. Therefore, we can say that the arithmetic shift left multiplies the
number by 2.
To implement the arithmetic shift left micro-operation, we use the ashl symbol.
For example, R1 -> ashl R1.
This command means the 8 bits present in the R1 register will be arithmetic shifted
left, and the result will be stored in register R1.
b) Arithmetic Shift Right:
Each bit in the register is shifted to the right one by one in this shift micro-operation.
The least significant bit (LSB) is moved outside the register, and the place of the
most significant bit (MSB) is filled with the previous value of MSB.
For example, in the below data, there are 8 bits 10100011. When we perform an
arithmetic shift right on these bits, all these bits will be shifted towards the right.
The LSB or the rightmost bit i.e. 1 will be moved outside, and at the leftmost place
or MSB, the previous MSB value, i.e. 1, will be inserted as shown below:
Circular Shift:
The circular shift, also known as the rotate shift, moves the bits in the register's sequence around
both ends, thus ensuring no loss of information. There are two ways to implement the circular shift.
To implement the circular shift left micro-operation, we use the cil symbol.
For example, R1 -> cil R1.
This command means the 8 bits present in the R1 register will be circular shifted
left, and the result will be stored in register R1.
To implement the circular shift right micro-operation, we use the cir symbol.
For example, R1 -> cir R1.
This command means the 8 bits present in the R1 register will be circular shifted
right, and the result will be stored in register R1.
The arithmetic, logic, and shift circuits are combined to one ALU with common selection
variables. The diagram below shows one stage of an arithmetic logic shift unit. The subscript
i designates a typical stage.
It should be noted that the circuit diagram only depicts one typical stage. For an n-
bit ALU, the circuit shown above must be repeated n times. The output that carries
Ci+1 of a given arithmetic stage must be connected to the input carry Ci of the next
stage in the sequence. The input carried to the first stage is the input carry Cin, which
provides a selection variable for the arithmetic operations.
The circuit whose one stage is specified in the diagram given above provides eight
arithmetic, four logical, and two-shift operations. Each operation is selected with
five variables S3, S2, S1, S0, and Cin. Here Cin is used for selecting an arithmetic
operation only.
The table given below is the function table of the Arithmetic Logic Shift Unit.
Operatio Function
S3 S2 S1 S0 Cin
n
0 0 0 0 0 F=A Transfer
A
0 0 0 0 1 F=A+1 Increment
A
0 0 0 1 0 F=A+B Addition
0 0 0 1 1 F = A + B Add with
+1 carry
0 0 1 0 0 F = A + B’ Subtract
with
borrow
0 0 1 0 1 F = A + B’ Subtractio
+1 n
0 0 1 1 0 F=A–1 Decreme
nt A
0 0 1 1 1 F=A Transfer
A
0 1 0 0 X F=A∧B AND
0 1 0 1 X F=A∨B OR
0 1 1 0 X F = A ⊕ B XOR
0 1 1 1 X F = A’ Complem
ent A
0 0 0 0 1 F=A+1 Increment
A