COA Module 2
COA Module 2
Tech
Module 2: Data
Representation and
Operations
Course Name: Computer Architecture and
organization[22CSE104]
Total Hours : 8
Table of Content
• Aim
• Objectives
• Data Types
• Complements
• Fixed Point Representations
• Floating Point Representations
• Other Binary Codes
• Error Detection Codes
• Register Transfer Language
• Register Transfer
• Bus and Memory Transfers
• Arithmetic Microoperations
• Logic Microoperations
• Shift Microoperations
• Arithmetic Logic Shift Unit
Table of Content
• Self Assessments
• Activities
• Did You Know
• Summary
• Terminal Questions
Aim
Objective
Register Transfer & -operations
• Typically,
• What operations are performed on the data in the registers
• What information is passed between registers
DATA
REPRESENTATION
Data Types
Complements
REPRESENTATION
* Data
- Numeric Data
Numbers( Integer, real)
- Non-numeric Data
Letters, Symbols
* Program(Instruction)
NUMERIC DATA Data Types
REPRESENTATION
Data
Numeric data - numbers(integer, real)
Non-numeric data - symbols, letters
Number System
Non positional number system
- Roman number system
Positional number system
- Each digit position has a value called a weight
associated with it
- Decimal, Octal, Hexadecimal, Binary
Base (or radix) R number
- Uses R distinct symbols for each digit
- Example AR = an-1 an-2 ... a1 a0 .a-1…a-m
n 1 Radix point(.) separates the integer
- V(AR ) = a R
i m
i
i
portion and the fractional portion
EXAMPLE
Fraction = 0.6875
Convert 41.687510 to base 2.
0.6875
Integer = 41 x 2
41 1.3750
20 1 x 2
10 0 0.7500
5 0 x 2
2 1 1.5000
1 0 x 2
0 1 1.0000
(41)10 = (101001)2 (0.6875) 10 = (0.1011)2
(41.6875)10 = (101001.1011)2
Exercise
Convert (63)10 to base 2: ?
Convert (1863)10 to base 8: ?
Convert (0.63671875)10 to hexadecimal: ?
Complements
COMPLEMENT OF NUMBERS
Example
- 10's complement of 83510 is 16410 + 1 = 16510
- 2's complement of 10102 is 01012 + 1 = 01102
Fixed Point Representations
REPRESENTATIONS
Complement
Signed magnitude: Complement only the sign bit
Signed 1's complement: Complement all the bits including sign bit
Signed 2's complement: Take the 2's complement of the number,
Signed Magnitude
Max: 2n - 2-m 011 ... 11.11 ... 1
Min: -(2n - 2-m) 111 ... 11.11 ... 1
Zero: +0 000 ... 00.00 ... 0
-0 100 ... 00.00 ... 0
Signed 2’s Complement
Signed 1’s Complement
Max: 2n - 2-m 011 ... 11.11 ... 1
Max: 2 - 2
n -m
011 ... 11.11 ... 1 Min: -2n 100 ... 00.00 ... 0
Min: -(2n - 2-m) 100 ... 00.00 ... 0 Zero: 0 000 ... 00.00 ... 0
Zero: +0 000 ... 00.00 ... 0
-0 111 ... 11.11 ... 1
Fixed Point Representations
ARITHMETIC ADDITION: SIGNED
MAGNITUDE
[1] Compare their signs
[2] If two signs are the same ,
ADD the two magnitudes - Look out for an overflow
[3] If not the same , compare the relative magnitudes of the numbers and
then SUBTRACT the smaller from the larger --> need a subtractor to add
[4] Determine the sign of the result
6+9 -6 + 9
6 0110 9 1001
+) 9 1001 -)6 0110
15 1111 -> 01111 3 0011 -> 00011
6 + (- 9) -6 + (-9)
9 1001 6 0110
-) 6 0110 +) 9 1001
- 3 0011 -> 10011 -15 1111 -> 11111
Overflow 9 + 9 or (-9) + (-9)
9 1001
+) 9 1001
overflow (1)0010
ARITHMETIC ADDITION: SIGNED 2’s
Fixed Point Representations
COMPLEMENT
Add the two numbers, including their sign bit, and discard any carry out of
leftmost (sign) bit
Example
6 0 0110 -6 1 1010
+) 9 0 1001 +) 9 0 1001
15 0 1111 3 0 0011
6 0 0110 -9 1 0111
+) -9 1 0111 +) -9 1 0111
-3 1 1101 -18 (1)0 1110
x’n-1y’n-1sn-1
(cn-1 cn)
9 0 1001 overflow
+) 9 0 1001
18 1 0010 2 operands have the same sign
xn-1yn s’n-1 and the result sign changes
xn-1yn-1s’n-1 + x’n-1y’n-1sn-1
(cn-1 cn)
ARITHMETIC ADDITION: SIGNED 1’s
Fixed Point Representations
COMPLEMENT
-9 1 0110 9 0 1001
+) -9 1 0110 +) 9 0 1001
(1)0 1100 1 (1)0010
+) 1
0 1101
overflow
(cn-1 cn)
Fixed Point Representations
COMPARISON OF REPRESENTATIONS
* Hardware
* Speed of Arithmetic
* Recognition of Zero
SUBTRACTION
(A)-(-B) =( A)+ B
(A)- B=(A)+( -B)
FLOATING POINT NUMBER Floating Point Representation
REPRESENTATION
F = EM
- Mantissa
Signed fixed point number, either an integer or a fractional number
- Exponent
Designates the position of the radix point
Decimal Value
Example
A binary number +1001.11 in 16-bit floating point number representation
(6-bit exponent and 10-bit fractional mantissa)
0 0 00100 100111000
Sign Exponent Mantissa
or
0 0 00101 010011100
CHARACTERISTICS OF FLOATING POINT NUMBER
Floating Point Representation
REPRESENTATIONS
Normal Form
Representation of Zero
- Zero
Mantissa = 0
- Real Zero
Mantissa = 0
Exponent
= smallest representable number
which is represented as
00 ... 0
<-- Easily identified by the hardware
INTERNAL REPRESENTATION AND EXTERNAL
REPRESENTATION
Another
Computer External
Representation
External Internal
Representation Human
Representation
CPU
Memory
External
Device Representation
EXTERNAL REPRESENTATION
Numbers
Most of numbers stored in the computer are eventually changed
by some kinds of calculations
--> Internal Representation for calculation efficiency
--> Final results need to be converted to as External Representation
for presentability
BCD: d3 x 8 + d2 x 4 + d1 x 2 + d0 x 1
==> 8421 code.
2421: d3 x 2 + d2 x 4 + d1 x 2 + d0 x 1
84-2-1: d3 x 8 + d2 x 4 + d1 x (-2) + d0 x (-1)
Excess-3: BCD + 3
BCD: It is difficult to obtain the 9's complement.
However, it is easily obtained with the other codes listed above.
==> Self-complementing codes
Other Binary codes
GRAY CODE
* Characterized by having their representations of the binary integers differ
in only one digit between consecutive integers
gi = bi bi+1 , 0 i n-1
gn = bn Reflection of Gray codes
and
0 0 0 0 00 0 000
bn-i = gn gn-1 . . . gn-i 1 0 1 0 01 0 001
bn = gn 1 1 0 11 0 011
1 0 0 10 0 010
1 10 0 110
1 11 0 111
1 01 0 101
Note: 1 00 0 100
1 100
The Gray code has a reflection property 1 101
- easy to construct a table without calculation, 1 111
- for any n: reflect case n-1 about a 1 010
1 011
mirror at its bottom and prefix 0 and 1 1 001
to top and bottom halves, respectively 1 101
1 000
Other Binary codes
MSB (3 bits)
0 1 2 3 4 5 6 7
Parity System
Even Parity
- One bit is attached to the information so that
the total number of 1 bits is an even number
1011001 0
1010010 1
Odd Parity
- One bit is attached to the information so that
the total number of 1 bits is an odd number
1011001 1
1010010 0
PARITY BIT GENERATION
Validate
Update
User Info
Enter/Update/ Delete
Update/Delete User Info
User Info
Error Detecting codes
b6
b5 beven
b4
b3
b2
b1
b0
Parity Checker
beven
b6
b5
b4
b3
b2 Even Parity
b1 error indicator
b0
Register Transfer & -operations
• Register Transfer
• Arithmetic Microoperations
• Logic Microoperations
• Shift Microoperations
MICROOPERATIONS (1)
MICROOPERATION (2)
R f(R, R)
f: shift, load, clear, increment, add, subtract, complement,
and, or, xor, …
Register Transfer & -operations Register Transfer Language
- Microoperations set
DESIGNATION OF REGISTERS
MAR
DESIGNATION OF REGISTERS
• Designation of a register
- a register
- portion of a register
- a bit of a register
REGISTER TRANSFER
R2 R1
REGISTER TRANSFER
R3 R5
CONTROL FUNCTIONS
P: R2 R1
Load
Transfer occurs here
• The same clock controls the circuits that generate the control function
and the destination register
• Registers are assumed to use positive-edge-triggered flip-flops
Register Transfer & -operations Register Transfer
SIMULTANEOUS OPERATIONS
P: R3 R5, MAR IR
CONNECTING REGISTERS
Bus lines
B1 C1 D 1 B2 C2 D 2 B3 C3 D 3 B4 C4 D 4
0 0 0 0
4 x1 4 x1 4 x1 4 x1
MUX MUX MUX MUX
x
select
y
4-line bus
Register Transfer & -operations Bus and Memory Transfers
Bus lines
Load
Reg. R0 Reg. R1 Reg. R2 Reg. R3
D 0 D1 D2 D 3
z E (enable)
Select 2x4
w
Decoder
S0 0
Select 1
S1 2
Enable 3
Register Transfer & -operations Bus and Memory Transfers
MEMORY (RAM)
• Memory (RAM) can be thought as a sequential circuits
containing some number of registers
• These registers hold the words of memory
• Each of the r registers is indicated by an address
• These addresses range from 0 to r-1
• Each register (word) can hold n bits of data data input lines
• Assume the RAM contains r = 2k words. It needs the
n
following
• n data input lines address lines
• n data output lines k
RAM
• Read
k address lines unit
• A Read control line Write
• A Write control line n
data output lines
Register Transfer & -operations Bus and Memory Transfers
MEMORY TRANSFER
• Collectively, the memory is viewed at the register level
as a device, M.
• Since it contains multiple locations, we must specify
which address in memory we will be using
• This is done by indexing memory references
MEMORY READ
MEMORY WRITE
M[MAR] R1
MICROOPERATIONS
ARITHMETIC MICROOPERATIONS
• The basic arithmetic microoperations are
• Addition
• Subtraction
• Increment
• Decrement
Binary Adder C3 C2 C1 C0
FA FA FA FA
C4 S3 S2 S1 S0
Binary Adder-Subtractor
B3 A3 B2 A2 B1 A1 B0 A0
C3 C2 C1 C0
FA FA FA FA
C4 S3 S2 S1 S0
Binary Incrementer A3 A2 A1 A0 1
x y x y x y x y
HA HA HA HA
C S C S C S C S
C4 S3 S2 S1 S0
Register Transfer & -operations Arithmetic Microoperations
ARITHMETIC CIRCUIT
Cin
S1
S0
A0 X0 C0
S1 D0
S0 FA
B0 0 4x1 Y0 C1
1 MUX
2
3
A1 X1 C1
S1 FA D1
S0
B1 0 4x1 Y1 C2
1 MUX
2
3
A2 X2 C2
S1 FA D2
S0
B2 0 4x1 Y2 C3
1 MUX
2
3
A3 X3 C3
S1 D3
S0 FA
B3 0 4x1 Y3 C4
1 MUX
2
3 Cout
0 1
LOGIC MICROOPERATIONS
• Specify binary operations on the strings of bits in registers
• Logic microoperations are bit-wise operations, i.e., they work on the
individual bits of data
• useful for bit manipulations on binary data
• useful for making logical decisions based on the bit value
• There are, in principle, 16 different logic functions that
can be defined over two binary input variables
A B F0 F1 F2 … F13 F14 F15
0 0 0 0 0 … 1 1 1
0 1 0 0 0 … 1 1 1
1 0 0 0 1 … 0 1 1
1 1 0 1 0 … 1 0 1
Ai
0
Bi
1
4X1 Fi
MUX
2
3 Select
S1
S0
Function table
S1 S0 Output -operation
0 0 F=AB AND
0 1 F = AB OR
1 0 F=AB XOR
1 1 F = A’ Complement
Register Transfer & -operations Logic Microoperations
• Selective-set A A+B
• Selective-complement A AB
• Selective-clear A A • B’
• Mask (Delete) A A•B
• Clear A AB
• Insert A (A • B) + C
• Compare A AB
• ...
Register Transfer & -operations Logic Microoperations
SELECTIVE SET
1 1 0 0 At
1 0 1 0B
1 1 1 0 At+1 (A A + B)
SELECTIVE COMPLEMENT
1 1 0 0 At
1 0 1 0B
0 1 1 0 At+1 (A A B)
SELECTIVE CLEAR
1 1 0 0 At
1 0 1 0B
0 1 0 0 At+1 (A A B’)
MASK OPERATION
1 1 0 0 At
1 0 1 0B
1 0 0 0 At+1 (A A B)
CLEAR OPERATION
1 1 0 0 At
1 0 1 0B
0 1 1 0 At+1 (A A B)
Register Transfer & -operations Logic Microoperations
INSERT OPERATION
• An insert operation is used to introduce a specific bit pattern
into A register, leaving the other bit positions unchanged
• This is done as
• A mask operation to clear the desired bit positions,
followed by
• An OR operation to introduce the new bits into the
desired positions
• Example
• Suppose you wanted to introduce 1010 into the low
order four bits of A: 1101 1000 1011 0001 A
(Original) 1101 1000
1011 1010 A (Desired)
SHIFT MICROOPERATIONS
• There are three types of shifts
• Logical shift
• Circular shift
• Arithmetic shift
• What differentiates them is the information that goes
into the serial input
Serial
• A left shift operation input
Register Transfer & -operations Shift Microoperations
LOGICAL SHIFT
• In a logical shift the serial input to the shift is a 0.
CIRCULAR SHIFT
• In a circular shift the serial input is the bit that is shifted
out of the other end of the register.
ARITHMETIC SHIFT
• An arithmetic shift is meant for signed binary numbers
(integer)
• An arithmetic left shift multiplies a signed number by two
• An arithmetic right shift divides a signed number by two
• The main distinction of an arithmetic shift is that it must
keep the sign of the number the same as it performs the
multiplication or division
• A right arithmetic shift operation:
sign
bit
0
sign
bit
Register Transfer & -operations Shift Microoperations
ARITHMETIC SHIFT
• An left arithmetic shift operation must be checked for the
overflow
0
sign
bit
S
MUX H0
0
1
A0
A1 S
MUX H1
0
A2 1
A3
S
MUX H2
0
1
S
MUX H3
0
1
Serial
input (IL)
Register Transfer & -operations Shift Microoperations
Arithmetic D i
Circuit
Select
Ci+1
0 4x1 Fi
1 MUX
2
3
Ei
Logic
Bi
Ai
Circuit
Ai-1 shr
Ai+1 shl
Outcomes:
a. Discuss the theory Data Representation methods
b. Discuss the impact of data types and register data
transfer operations on computing system performance.
c. Illustrate the different error detection codes
Terminal Questions
1) What are the different data types?
2) What are the different Arithmetic Micro operations, logic micro operations, Shift micro
operations?
Reference Links
• https://www.geekforgeeks.org/computer organization
Reference Material:
• M. Moris Mano, “Computer Systems Architecture”, 4th Edition, Pearson/PHI,
ISBN:10:0131755633
Thank you