You are on page 1of 7

Design and simulation of 32 bit Floating Point ALU using Verilog

Aravinth R Balachandar V and Edwin Gerald A

Department of Electronics and Communication Engineering, BCET, Karaikal, India

Abstract

The Arithmetic Logic Unit is one of the essential component of a computer. It performs
arithmetic operations such as addition, subtraction, multiplication, division and various logical
functions. The Aim of this paper is to simulate an ALU and to analyze the various parameters
such as speed, power and number of logical blocks used by that ALU. The Floating point
numbers in this paper are represented according to the IEEE standard 754. The Arithmetic
operations such a s addition, subtraction, multiplication, division and the logical operations are
realized using Verilog HDL. Xilinx 7.1i software is used for writing the verilog codes and the
simulation is carried out with ModelSim 5.5f simulator.

1. INTRODUCTION

For the efficient way of representing real arithmetic operations like addition,
numbers the floating point numbers are subtraction, multiplication and division etc.
used. It is used when there is a need of
representing a number which is very large or 1.1 Single Precision IEEE 754 Format
very small but representation of such All the floating point numbers are composed
numbers are cannot be done without paying
by three components:
a price for it like as power, speed, accuracy,
ease of implementation and the memory of  Sign: it indicates the sign of the number (0
the system. positive and 1 negative)
 Mantissa: it sets the value of the number
In the various fields of science such as
 Exponent: it contains the value of the base
physics and biology etc. the need of
measuring the dimensions of objects are power (biased)
essential for analyzing its characteristics. In If a Simple Precision format is used the bits
physics measuring the distance between
will be divided in that way:
stars or the size of an electron cannot be
done with the range of fixed numbers hence  The first bit (31st bit) is set the sign (S) of the
we are in need of floating point numbers. number (0 positive and 1 negative)
 Next w bits (from 30th to 23rd bit) represent
The Arithmetic Logic Unit is the basic
building block of a CPU which does various the exponent (E)
 The rest of the string, t, (from 22nd to 0) is
Conversion of Decimal to Floating point 32
reserved to save the mantissa.
bit format is explained with an example.
Suppose the decimal number considered is
129.85. Before converting into floating
format this number is converted into binary
value which is 10000001.110111. After
conversion the radix point is moved to the
left such that there will be only one bit
towards the left of the radix point and this
Figure 1.1 Floating point number format
bit must be 1. This bit is known as “hidden
bit”.
Standard IEEE 754 specifies formats and
The binary value now can be represented
methods in order to operate with floating
as 1.00000011101110000000000. The
point arithmetic. These methods for
number which is after the radix point is
computational with floating point numbers
called the mantissa which is of 23 bits and
will yield the same result regardless the
the whole number is called significand
processing is done in hardware, software or
which is of 24 bits(including the hidden bit).
a combination for the two or the
Now the number of times the radix point is
implementation.
shifted (say x) is counted. In above case
there is 7 times shifting of radix point to the
The standard specifies:
left. This value must be added to 127 to get
 Formats for binary and decimal floating the exponent value i.e. original exponent
point data for computation and data value is 127 + “x”. Thus the exponent
interchange becomes 127 + 7 = 134 which is 10000110.
 Different operations as addition, Sign bit i.e. MSB is “0” because number is +
ve. Now the result is assembled into 32 bit
subtraction, multiplication and other
format which is sign, exponent, mantissa:
operations 01000011000000011101110000000000.
 Conversion between integer-floating
2. LITERATURE SURVEY
point formats and the other way around
 Different properties to be satisfied when In recent years, Floating-point numbers are
rounding numbers during arithmetic and widely adopted in many applications due to
conversions its high dynamic range and good robustness
 Floating point exceptions and their
against quantization errors, capabilities.
handling (NaN, ±∞ or zero).
Floating-point representation is able to
retain its resolution and accuracy.
1.2 Conversion of Decimal to Floating Point
IEEE specified standard for floating-point provides a high performance. With
representation is known as IEEE 754 pipelining concept ALU execute multiple
standard. This standard specifies interchange instructions simultaneously (Suchita Pare et.
and arithmetic formats and methods for al, 2012) .
binary and decimal floating-point arithmetic
3. METHODOLOGY
in computer programming environments.
(IEEE 754-2008) The entire design is implemented by the
following steps in progression.
The main objective of implementation of
 Conversion of the Floating Point
floating point operation on reconfigurable
Number into a novel integral
hardware is to utilize less chip area with less representation.
combinational delay (Karan Gumber et.al,
 Conversion of the binary integer to its
May 2012) which means less latency i.e.
IEEE754 format.
faster speed. A parameterizable floating
point adder and multiplier implemented  Pre-normalization of the operands
using the software-like language Handel-C,
using the Xilinx XCV1000 FPGA, a five  Performing the selected operation.

stages pipelined multiplier achieved


 Post-normalize the output obtained.
28MFlops (A. Jaenicke et. Al, 2001). The
hardware needed for the parallel 32-bit  Detecting and handling the exceptions
multiplier is approximately 3 times that of encountered.

serial.

A single precision floating point multiplier


that doesn’t support rounding modes can be
implemented using a digit serial multiplier
(L.Louca et. al, 1996). The ALU is a
fundamental building block of the central
processing unit of a computer, and even the
simplest microprocessors contain one for
purposes such as maintaining timers. By
using pipeline with ALU design, ALU
Figure 3.1 Flow diagram of Arithmetic Logic Unit
input exponents. Three extra bits the guard
bit, the round bit, and the sticky bit are
added to both mantissas to increase the
Figure 3.2 Block diagram of adder/subtractor accuracy of the performed operation
(addition or subtraction) and to be used in
the rounding process. Sticky bit is the
logical "Or"ing of any bits that are dropped
Figure 3.3 Block diagram of multiplier during the pre-normalization of operand B.
Post Normalize: The resultant mantissa is
normalized after the leading one is detected
using the LOD method. The resultant
Figure 3.4 Block diagram of divider exponent is adjusted accordingly.
Unpack: The sign, exponent and mantissa Rounding: The resultant mantissa is
of both operands are separated. A flag, rounded using the REN technique. The final
aequalb flag, is set if both inputs are equal. output is given in IEEE format.
The aequalb flag will be used if the effective Adder/Subtracter: The effective operation
operation, determined in the adder/subtracter to be performed is calculated according to
module, was subtraction to set a flag the signs of operands A & B, the input
indicating a zero output. This prevents operation and the swap flag. The effective
unnecessary addition/subtraction and pre operation is performed and the zero flag is
normalization operations from taking place. updated if the effective operation is
Swap: Inputs are swapped if necessary such subtraction and the aequalb flag is set.
that operand A carries the larger floating Block Multiplier: Multiplies the two 24 bit
point number and operand B is the smaller mantissa of operands A and B. the bottle
operand to be pre-normalized. A swap flag is neck of the design is the 24*24 bit multiplier
set if the operands were swapped to be used used to calculate the resulting 48 bit
in determining the effective operation in the mantissa. To increase the maximum
adder/subtracter module. operating speed of the multiplier, the
Pre-normalize: The smaller mantissa, of proposed design breaks up the 24*24 bit
operand B, is pre-normalized, that is it's multiplication of operands A and B into nine
shifted by the difference between the two 8*8 bit multiplications where each mantissa
is sliced into three 8-bit slices such that INPUT B:
A=A2A1A0, B=B2B1B0. Then, B0 is 00000100000001000100001100000011
multiplied in A2, A1 and A0. Each of these RESULT:
three 8*8 bit multiplications gives a 16 bit 00001000000001100100011101000110
result. The three 16 bit results are properly
manipulated to give a 32 bit result Ro of the
24*8 bits multiplication operation (i.e.
A*B0). In a similar manner B1 and B2 are
multiplied in A2, A1 and A0 to give R1 and
R2. R1 and R2 are properly shifted to be
added to R0 thus giving the 48 bit result
mantissa. The result sign is determined
Figure 4.1 Result of Floating point addition
through a simple XOR operation.
Divider:
4.2 Subtraction
 First shift left the dividend by 1. INPUT A:
 Subtract the divisor. If the carry is 1 do 00001000000001100100001100000011
not restore. If carry is 0 i.e. answer is INPUT B:
negative then restore by adding back to 00000100000001000100001100000011
the divisor. RESULT:

 Place the carry as the LSB of the 00001000000001100011111011000000

intermediate answer.

 Do this procedure up to n –iterations,


where n is number of bits in the divisor.
Here n is 24 bits for single precision and
53 bit for double precision.
4. SIMULATION RESULTS
4.1 Addition
INPUT A:
00001000000001100100001100000011 Figure 4.2 Result of Floating point subtraction
4.3 Multiplication
INPUT A:
00001000000001100100001100000011
INPUT B:
00000100000001000100001100000011
RESULT:
000011000000000000110101010111110101 Figure 4.4 Result of Floating point division

0001001001000001001

Figure 4.5 FPGA Spartan 6 kit


5. CONCLUSION

Figure 4.3 Result of Floating point Multiplication


Thus the 32 bit Floating point Arithmetic
Logic Unit was designed to perform the

4.4 Divider operations like addition, subtraction,

INPUT A: multiplication and division . IEEE 754

00001000000001100100001100000011 standard based floating point representation

INPUT B: is used. The programs are coded in Verilog

00000100000001000100001100000011 HDL. The simulation is done with

RESULT: Modelsim 5.5f and the programming is done

00000100000000000000000000000001 using Xilinx 7.1i.


Table5.1: Device Utilization Summary: Comparison with Booth Algorithm (Radix-
2) ” Research India Publications,2013.
Number of Slice Registers 123
Number of Slice LUTs 304
[4] Geetanjali and Nishant Tripathi, "VHDL
Number used as Logic 304
Number of LUT Flip Flop pairs 102 Implementation of 32-Bit Arithmetic Logic
used Unit (ALU)“, International Journal of
Number with an unused Flip 223
Computer Science and Communication
Flop
Number with an unused LUT 5416 Engineering,2012 .
Number of fully used LUT-FF 102
[5] D. Jackuline moni and P. Eben Sophia,”
pairs
Number of IOs 100 Design of low power and high speed
Number of bonded IOBs 98% configurable booth multiplier”, IEEE, 2011.
[6] Kiseon cho and Minkyu song, “Design
Reference:
Methodology of a 32-bit Arithmetic Logic
[1] Aarthy.M and dave omkar.R,” Asic
Unit with an Adaptive Leaf-cell Based
implementation of 32 and 64 bit floating
Layout Technique” VLSI Design, 2002.
point ALU using pipelining”, International
[7] Sukhmeet Kaur, Suman and Manpreet
journal of computer applications, May
Signh Manna, “Implementation of Modified
2014.
Booth Algorithm (Radix 4) and its
[2] Kavita katole, Ashwin shinde,” Design &
Comparison with Booth Algorithm (Radix-
simulation of 32-bit floating point ALU
2) ” Research India Publications,2013.
“International Journal of Advances in
Science Engineering and Technology, April
2014.
[3] Sukhmeet Kaur, Suman and Manpreet
Signh Manna, “Implementation of Modified
Booth Algorithm (Radix-4) and its

You might also like