Vous êtes sur la page 1sur 7

Our Project: We have to design an ALU that takes 2 four bit numbers as input and do the following functions:

y y y y y y y Add Subtract Multiply Compare Shift Rotate Bit wise operation of AND,OR, XOR, NOT

This is the schematics of our ALU. The output registers are used in order to store the output values of different operations. This is done by using the D latch.

Functionality of ALU:The above shown ALU has 8 inputs i.e. 2 four bit input numbers. There is also an enable input in order to control the functionality of the D-latches. There is also an input along with the 2 four bit number inputs which controls the addition and the subtraction. When the input is 0, the circuit will do addition and when the input is 1, the circuit will do subtraction. There are other inputs as well which control the outputs of shifting, rotation and bit wise logic operation of AND,XOR, NOT and OR. In figure 2, the inputs determine the amount of bits that are to be rotated. When the inputs are 0 0, there will be no rotation. When the inputs are 0 1, there will be 1 bit rotation. When the inputs are 1 0, there will be a rotation of 2 bits and when the inputs are 1 1, first three inputs will be rotated.

Figure 3 shows the inputs of bite wise logic operations. It determines whether the operation should be bit wise AND, OR, XOR or NOT. When the inputs are 0 0, the output operation is AND. When the inputs are 0 1, the output operation is OR. When the inputs are 1 0, the output operation is NOT of the A input and when the inputs are 1 1, the output operation is XOR. Figure 4 shows the inputs of the shifting operation. In this, the clock is used which is connected to the D-edge triggered flip flop. The input shown in red controls whether the shifter should do shifting or transfer the original number to the output. The input shown in blue is the number which is shifted when the enable input is at state 1. Every circuit output is connected to a D-latch in order to store the output.

Figure 1 Inputs

Figure 2 Rotation inputs

Figure 3 bit wise operation inputs

Operation performed by ALU: Following are the operations performed by this ALU: y y y y y y y Addition Subtraction Multiplication Comparator Bit wise AND, OR, NOT,XOR operation Bit Shifting Bit Rotation

Figure 4 shifting operation inputs

These operations along with their circuits are explained below: Addition and Subtraction: Both the addition and subtraction operations are performed by using this circuit. There are four full adders that are used in this circuit. Each full adder consists of 2 XOR gates, 3 AND gates and an OR gate. The 3 AND gates are connected to the OR gate which gives the carry output. The sum output is achieved by the combination of two XOR gates. There is also a carry input M . When the carry input M is 0, the circuit performs addition operation and when the M input is 1, the circuit performs subtraction. Each input of second four bit number i.e. B is connected to the XOR gate along with the input M . when M is 0, the output of these XOR gates will be the same as that of the inputs of B and the circuit will perform addition. But when M is 1, the output of these XOR gates will the 1s complement of the inputs of B . M acts as the carry input to the circuit i.e. it adds to the first bit of B i.e. B0, converting the 1s complement of B into 2s complement. Now we can add this 2s complement to the 1st four bit

number A and achieve the subtraction operation. The functions used are: Sum= A(XOR)B(XOR)Cin COUT=A.B+A.C+B.C The registers are used at the end to store the value of the output. Multiplication: Multiplication is done in two steps. In the first step, all the inputs of the two four bit numbers are multiplied with each other using AND gate. Since, in binary multiplication, the output is 1 when both the numbers are 1, whereas in all other cases it is 0. So this can be achieved by the use of AND gates. In the next step, both full and half adders are used to achieve the final output. In this circuit, 7 full adders and 3 half adders are used to sum the first multiplication outputs. The final output is of 8 bits.

Comparator: Comparator circuit compares whether the 1st input number A is equal to 2nd input number B , A is greater than B or A is less than B . Following are the functions of this circuit:

A=B:

A>B:


A<B:
 

The binary variable (A=B) is equal to 1 only if all pairs of digits of the two numbers are equal. The symbols (A>B) and (A<B) are binary output variables that are equal to 1 when A>B and A<B, respectively.

Bit wise AND, OR, NOT, XOR operations: These operations were very simple to perform. We used simple gates between the two bit, on which bitwise operation was to be performed (single bit in case of NOT). The outputs of these gates were given to the multiplexer. Then by changing the selection inputs of the multiplexer, the desired operation can be achieved.

Bit shifting: Bit shifting is achieved by using shift registers. This shift register is known as parallel in-parallel out register. This is used due to the fact that we have to shift the bit from the left most side to the right side.

Bit rotation: Bit rotation means that the bits from the right side are shifted to the left side of the number or vice versa. The number of bits rotated depends on the type of bit rotation. In this circuit we have used left rotation. The bit shifting is achieved by using multiplexers. Each of the four multiplexers is given input from the same four bits but in different orders. For example, the first multiplexer is given input in the order A3A2A1A0 but the next is given A2A1A0A3 and so on. In this way, if both the select lines are OFF then we get normal output i.e. equal A3A2A1A0, but for S1=0 and S0=1, we get A2A1A0A3 and so on.

Vous aimerez peut-être aussi