Professional Documents
Culture Documents
L2ACM501
L2ACM501
L2ACM501
ACM 501
Computers
• A computer is a device which can
– input and store data
– input and store instructions for how to process the data
– process the data according to the instructions
– output the results of the data processing
• An element has two states, so can represent only two data items
– data is represented using a combination of elements
– many representation schemes are possible
Examples of Data Representation
• Using 10 elements to represent a decimal digit, 0 - 9
– 0 - 99 can be represented using 2 sets of 10 elements
– 0 - 999 can be represented using 3 sets of 10 elements
• remember zero requires an explicit representation
Examples of Data Representation
• How would we represent text characters?
– we do not want to add an extra element for each character
– use more than one element of the set at a time
• punched card including characters
Number of Elements Needed
• Each element has two states
– on or off, hole or no hole, voltage high or low
– let us call one state 0 and the other 1 for convenience
• positive logic uses high voltage as 1
• negative logic uses low voltage as 1
– Each element can be called a binary digit, or BIT
0 0
0 1
00, 01, 10, 11 four possible data items
1 0
0 1 2 3
1 1 A b $ d
Number of Elements Needed
• n elements will have 2n different states
– each state can represent one character
}
n bits total
0 1 1 1 0
2 x 2 x 2 … 2 x 2 = 2n
ASCII Character Set
• The ASCII code uses 7 bits to represent data
– can represent 128 characters
– includes some control characters which are not printed
• instruct the device to add a tab space, or begin a new line
– represents digits 0 – 9, A – Z, a – z, and special characters like !, $, @
1 0 0 1 1 0 1 1
• It is a positional system
– the value of a digit depends on its position
– when we write the number 4256
• the digit 4 denotes 4000
• the 2 denotes 200
• the 5 is 50
• the digit 6 is 6 itself.
The Roman System
• The positional system is in contrast to the Roman system
– certain numbers are assigned letter symbols
• I denotes 1, V = 5, X = 10, L = 50, C = 100, D = 500. M = 1000
– numbers without symbols are created by combining the symbols
• II = 2, XV = 15, XVI = 16
– a smaller number to the left can be subtracted from that on the right
• IV = V – I = 4, IX = X – I = 9, XC = 90
• this is done to shorten the representation
– very large numbers, greater than 4000
• can be written with a bar above the symbol to denote 1000 times
V = 5000
– there is no easy way to add, subtract, multiply or divide
• What is MDIX – XVII
• What is MCMD times XVIII
Advantages of Positional System
• The positional system allows for ease of operations
Carry 1 1
First no. 5 3 2 9
Second no. 9 6 5 4
---------------
Sum 14 9 8 3
• Disregard the whole number part and multiply the new fraction by 2
– the new whole number part is the second binary digit after the point
0.5 x 2 = 1.0
00001101 Quotient
Divisor 1011 10010011 Dividend
1011
001110
Partial 1011
Remainders
001111
1011
100 Remainder
Computer Representation
• Computers use binary format to store numbers
– based on 0 and 1, like the binary states of elements
– each element represents one binary digit, called BIT
– earlier representations included binary coded decimals
• Sign Magnitude
– the leftmost bit can be treated as the sign bit
• 0 for positive, 1 for negative
– if we are using 1 byte to represent an integer
• +18 = 00010010
• -18 = 10010010
• Using sign and magnitude notation, half the numbers have negative sign
– we can represent +0 to +127 positive, and -0 to -127 negative integers
• To write -28
28 = 00011100 if we use 1 byte to represent integers
inverting the digits gives 11100011
adding 1 gives 11100100
-28 = 11100100
8 + (-4) = 100000100
so 8 + (-4) = 00000100 = 4
• -128 is 10000000
28-1 = 27 = 128
• -128 maps to 0
0.000000000000015, or 150000000000000
• Examples
– 300.1 = 3.001 x 102
– 0.0011 = 1.1 x 10-3
– 1.5 x 10-23
– 1.5 x 1035
• n = f × 2e
– f is the significand or mantissa
– e is the exponent (a positive or negative integer) in biased format
• easier to compare exponents during operations
• Since the only digits are 0 and 1, the first digit of f is always 1
– The first digit is implicit
– Allows bits to be used for more places after the decimal
– Format cannot be used to represent 0 directly
32-bit Floating Point Representation
• Accuracy
– The effect of changing least significant bit of mantissa
– 23 bit mantissa 2-23 ≈ 1.2 x 10-7
– About 6 decimal places
• Using 32 bits for floating point still represents the same number of
unique numbers, but the numbers are spread out over a different
range than the integers.
Floating Point Ranges
Floating Point Arithmetic
• Significand can have underflow or overflow
– overflow occurs when you exceed the maximum positive or minimum negative limit
– Underflow occurs when the magnitude is less than the smallest possible magnitude
Eight-input multiplexer
• parallel to serial conversion
Example: Decoder
A 4-bit comparator
Example: One BIT Half Adder
Example: One BIT Full Adder
Example: One BIT ALU
Example: 8-BIT ALU
Equivalence of Circuits
Boolean Logic
• Need formal tools for design and analysis of circuits
– to minimize the number of gates
– to minimize the layers so as to get the fastest circuit
• each gate introduces some delay
X = AB + AC + B(A+C) + C
– X=X+X X = X.X
– 1=X+1 0 = X.0
– X = X(X+Y) X = X +X.Y
De Morgan's Law