Академический Документы
Профессиональный Документы
Культура Документы
One easy direct method in Decimal to binary conversion for integer part is to first write the
place values as:
Step 1: Take the integer part e.g. 43, find the next lower or equal binary place value number, in
this example it is 32. Place 1 at 32.
Step 2: Subtract the place value from the number, in this case subtract 32 from 43, which is 11.
Step 3: Repeat the two steps above till you get 0 at step 2.
Step 4: On getting a 0 put 0 at all other place values.
ALPHANUMERIC REPRESENTATION
A set containing alphabets (in both cases), the decimal digits (10 in number) and special
characters (roughly 10-15 in numbers) consist of at least 70-80 elements. ASCII One
such standard code that allows the language encoding that is popularly used is ASCII
(American Standard Code for Information Interchange).
This code uses 7 bits to represent 128 characters, which include 32 non-printing control
characters, alphabets in lower and upper case, decimal digits, and other printable
characters that are available on your keyboard. ASCII was extended to 8 bits to represent
256 characters (called Extended ASCII codes).
The major strength of ASCII is that it is quite elegant in the way it represents characters.
It is easy to write a code to manipulate upper/lowercase ASCII characters and check for
valid data ranges because of the way of representation of characters. In the original ASCII
the 8th bit (the most significant bit) was used for the purpose of error checking as a
check bit.
Developed by: Thilak Reddy, CSE Dept, RGUKT Page 5
EBCDIC Extended Binary Coded Decimal Interchange Code (EBCDIC) is a character-
encoding format used by IBM mainframes. It is an 8-bit code and is NOT Compatible to
ASCII. It had been designed primarily for ease of use of punched cards. This was
primarily used on IBM mainframes and midrange systems such as the AS/400.
words to obtain 1’s complement of a binary number, we only have to change all the 1’s of the
number to 0 and all the zeros to 1’s. This can be done by complementing each bit of the binary
number.
The 1’s complement of 1010 is
2’s complement: 2's complement of a binary number is 1 added to the 1's complement of the
binary number. Examples: 2's complement of "0111" is "1001" 2's complement of "1100" is
"0100"
Adding 1 in 1’s complement will generate the 2’s complement
Arithmetic addition:
The complexity of arithmetic addition is dependent on the representation, which has
been followed. Let us discuss this with the help of following example.
Example:
Add 25 and -30 in binary using 8 bit registers, using:
• Signed magnitude representation
• Signed 1’s complement
• Signed 2’s complement
To do the arithmetic addition with one negative number only, we have to check the
magnitude of the numbers.
The number having smaller magnitude is then subtracted from the bigger number and
the sign of bigger number is selected.
The implementation of such a scheme in digital hardware will require a long sequence of
control decisions as well as circuits that will add, compare and subtract numbers.
Adder:
An adder is a kind of calculator that is used to add two binary numbers. When I say, calculator, I
don’t mean one with buttons, this one is a circuit that can be integrated with many other
circuits for a wide range of applications. There are two kinds of adders;
1. Half adder
2. Full adder
Half Adder
Developed by: Thilak Reddy, CSE Dept, RGUKT Page 15
With the help of half adder, we can design circuits that are capable of performing simple
addition with the help of logic gates.
Let us first take a look at the addition of single bits.
0+0 = 0
0+1 = 1
1+0 = 1
1+1 = 10
These are the least possible single-bit combinations. But the result for 1+1 is 10. Though this
problem can be solved with the help of an EXOR Gate, if you do care about the output, the sum
result must be re-written as a 2-bit output.
Thus the above equations can be written as
0+0 = 00
0+1 = 01
1+0 = 01
1+1 = 10
Here the output ‘1’of ‘10’ becomes the carry-out. The result is shown in a truth-table below.
‘SUM’ is the normal output and ‘CARRY’ is the carry-out.
INPUTS OUTPUTS
A B SUM CARRY
0 0 0 0
0 1 1 0
1 0 1 0
1 1 0 1
From the equation, it is clear that this 1-bit adder can be easily implemented with the help of
EXOR Gate for the output ‘SUM’ and an AND Gate for the carry. Take a look at the
implementation below.
Full Adder
This type of adder is a little more difficult to implement than a half-adder. The main difference
between a half-adder and a full-adder is that the full-adder has three inputs and two outputs.
The first two inputs are A and B and the third input is an input carry designated as CIN. When a
full adder logic is designed we will be able to string eight of them together to create a byte-wide
adder and cascade the carry bit from one adder to the next.
The output carry is designated as COUT and the normal output is designated as S. Take a look at
the truth-table.
INPUTS OUTPUTS
A B CIN COUT S
0 0 0 0 0
0 0 1 0 1
0 1 0 0 1
0 1 1 1 0
1 0 0 0 1
1 0 1 1 0
1 1 0 1 0
1 1 1 1 1
From the above truth-table, the full adder logic can be implemented. We can see that the output
S is an EXOR between the input A and the half-adder SUM output with B and CIN inputs. We
must also note that the COUT will only be true if any of the two inputs out of the three are HIGH.
Thus, we can implement a full adder circuit with the help of two half adder circuits. The first
will half adder will be used to add A and B to produce a partial Sum. The second half adder logic
can be used to add CIN to the Sum produced by the first half adder to get the final S output. If
any of the half adder logic produces a carry, there will be an output carry. Thus, COUT will be an
Using ripple carry adder, this addition will be carried out as shown by the following logic
diagram-
The multiplier and multiplicand bits are loaded into two registers Q and M.
A third register A is initially set to zero.
C is the 1-bit register which holds the carry bit resulting from addition.
Now, the control logic reads the bits of the multiplier one at a time. If Q 0 is 1, the
multiplicand is added to the register A and is stored back in register A with C bit used for
carry.
Then all the bits of CAQ are shifted to the right 1 bit so that C bit goes to An-1, A0 goes to
Qn-1 and Q0 is lost. If Q0 is 0, no addition is performed just do the shift.
The process is repeated for each bit of the original multiplier. The resulting 2n bit
product is contained in the QA register.
Multiplier and multiplicand are placed in Q and M register respectively. There is also one
bit register placed logically to the right of the least significant bit Q 0 of the Q register and
designated as Q-1.
The result of multiplication will appear in A and Q resister.
A and Q-1 are initialized to zero if two bits (Q0 and Q-1) are the same (11 or 00) then all
the bits of A, Q and Q-1 registers are shifted to the right 1 bit.
If the two bits differ then the multiplicand is added to or subtracted from the A register
depending on weather the two bits are 01 or 10.
Following the addition or subtraction the arithmetic right shift occurs. When count
reaches to zero, result resides into AQ in the form of signed integer [-2n-1*an-1 + 2n-2*an-2 +
…………… + 21*a1 + 20*a0].
Division Algorithm
Division is somewhat more than multiplication but is based on the same general
principles. The operation involves repetitive shifting and addition or subtraction.
The bits of the dividend are examined from left to right, until the set of bits examined
represents a number greater than or equal to the divisor; this is referred to as the divisor
being able to divide the number.
Until this event occurs, 0s are placed in the quotient from left to right. When the event
occurs, a 1 is placed in the quotient and the divisor is subtracted from the partial
dividend. The result is referred to as a partial remainder.
Algorithm:
Step 1: Initialize A, Q and M registers to zero, dividend and divisor respectively and counter to n
where n is the number of bits in the dividend.
Step 2: Shift A, Q left one binary position.
Step 3: Subtract M from A placing answer back in A. If sign of A is 1, set Q0 to zero and add M
back to A (restore A). If sign of A is 0, set Q0 to 1.
Step 4: Decrease counter; if counter > 0, repeat process from step 2 else stop the process. The
final remainder will be in A and quotient will be in Q.