Implementation of 32 Bit Floating Point MAC Unit To Feed Weighted Inputs To Neural Networks
Implementation of 32 Bit Floating Point MAC Unit To Feed Weighted Inputs To Neural Networks
Implementation of 32 Bit Floating Point MAC Unit To Feed Weighted Inputs To Neural Networks
Abstract- This paper describes an FPGA implementation of sequence of mantissa operations swap, shift, add, normalize,
IEE-754 format single precision floating point MAC unit that and round. A floating point adder first compares the
is used in artificial neural networks to feed the weighted inputs exponents of the two input operands, swaps and shifts the
to the neurons. Use of floating point numbers improves the mantissa of the smaller number to get them aligned. The
range of the representation of data from very small number to
number has to be adjusted if the incoming number is
a very large number which is mostly recommended for
Artificial Neuron Networks. negative. Finally, the sum is renormalized, Exponents are
adjusted accordingly, and resulting mantissas are truncated
Keywords- FPGA, IEEE-754, floating point MAC, weighted by an appropriate rounding scheme. If extra speed is
inputs, Artificial Neural Networks. required then FP adders use leading-zero anticipatory (LZA)
logic to carryout pre-decoding for normalization shifts in
I. INTRODUCTION parallel with the mantissa addition. Floating point
multiplication basically involves xoring of the signs,
multiplication of significands and adding exponents of both
T he main goal of this paper is designing of floating point
MAC unit. Representing real numbers in binary format
requires floating point numbers .In this paper floating point
the numbers. After addition the exponent is called tentative
result exponent. Then we have to subtract bias from added
numbers are represented according to IEEE 754 standard exponents. Result can be a normalized number if the MSB
format. In single precision, a Floating Point number consists is 1. In this paper floating point multiplier and floating point
of a 32-bit word divided in 1 bit for sign, 8 bits for exponent adder/subtractor are designed and an accumulator is
that constitutes a 127 bias, and 23 bits for the significand. designed. Then floating point MAC unit is designed.MAC
This standard supports two types of formats binary basically consists of adder, multiplier and an accumulator
interchanges format and decimal interchange format. In certain values are used for special number representation, as
many applications computation is done using floating point follows. If the exponent is 0 and mantissa is 0 then the
arithmetic. Earlier floating point operations were mainly number is a zero number. If the exponent is 0 and mantissa
implemented as software while for main stream general is greater than 0 then the number is a subnormal number. If
purpose processor hardware implementation was an option the exponent lies in between 0 and 255 and mantissa is
because cost of the hardware was not reasonable. Today greater than 0 then the number is a normal number. If the
every microprocessor is hardware specific for handling exponent is 255 and mantissa is 0 then the number is an
various floating point operations. In artificial neural infinite number. If the exponent is 255 and the mantissa is
network applications floating point MAC unit is required in greater than 0 then the number is not a number.
order to achieve desired performance. But because of the
Table 1. Special Numbers
advancements in reconfigurable logic now these Mac units
can be implemented on FPGA. The goal of this project is S.No Exponent Mantissa Output
FPGA implementation of floating point MAC unit for ANN 1 =0 =0 Zero
applications. Floating point number can be given by
2 =0 >0 Subnormal
equation (1):
3 0<E<255 >0 Normal
5 =255 =0 NAN
Equation 1 represents IEEE 32 bit single precision floating
point format. One very important requirement of the IEEE-
754 representation is that the number should be represented The concept of ANN is basically introduced from the
with it closest equivalent for the precision chosen, which subject of biology where neural network plays a important
means that it is assumed that any operation is performed and key role in human body. In human body work is done
with infinite precision Any floating point number is first of with the help of neural network. Neural Network is just a
all converted into this format (1) and further operations are web of inter connected neurons which are millions and
performed. Floating-point (FP) addition is based on millions in number. With the help of these interconnected
www.rsisinternational.org/IJRSI.html Page 40
Volume II, Issue IV, April 2015 IJRSI ISSN 2321 - 2705
neurons all the parallel processing is done in human body Point Unit (FPU) consisting of a multiplier and
and the human body is the best example of Parallel adder/Subtractor units is proposed. A novel multiplication
Processing. An Artificial Neuron is basically an engineering algorithm is proposed and used in the multiplier implementation.
approach of biological neuron. It has device with many
inputs and one output. ANN consists of large number of III. ORGANIZATION OF WORK
simple processing elements that are interconnected with
each other and also layered. Similar to biological Neuron In this section IEEE 754 single precision format, floating
Artificial Neural Network also have neurons which are point adder, Floating point multiplier and floating point
artificial and they also receive inputs from the other MAC unit are explained. MAC consists of a multiplier and
elements or other artificial neurons and then after the inputs an accumulator unit. Multiplier will multiply two numbers
are weighted and added, the result is then transformed by a and result will be added to the number already stored in the
transfer function into the output. The transfer function may accumulator.
be anything like Sigmoid, hyperbolic tangent functions or a
step. 3.1. STANDARD IEEE 754 FORMAT
www.rsisinternational.org/IJRSI.html Page 41
Volume II, Issue IV, April 2015 IJRSI ISSN 2321 - 2705
expl&fracl and exp2&f rac2. It implies that the exponents are subtracted from it. Subtraction is easily achieved by adding
compared first, and if they are the same, the significands are carry in to the sum and then subtracting 128 from it by
compared. complementing most significant bit. For multiplying
significands 48 bit multiplier is used. The 28 bits are
considered as the most significand bits out of which 24 bits
are the mantissa bits, 3 bits are for proper rounding, 1 bit is
for range overflow. The result is then normalized for proper
approximation to closest value. The approximation consists
of a possible single bit right shift and corresponding
exponent is incremented depending on b1 bit. The resultant
sign, exponent and mantissas are obtained. The resultant
sign, exponent and mantissas are then obtained. The figure
shown below is simple floating point multiplier. In this
paper three floating point multipliers have been designed
using carry save, carry look ahead, ripple carry adder. Same
flow is used for all of them .only for addition of exponents
different adders are used.
www.rsisinternational.org/IJRSI.html Page 42
Volume II, Issue IV, April 2015 IJRSI ISSN 2321 - 2705
the multiplier. Multiplier will multiply the inputs and it will Then a complete MAC unit is designed using floating point
give the results back to the adder and then the results of the adder and multiplier and its FPGA implementation is done.
multiplier are added to the previously accumulated results. This MAC Unit is used to feed the inputs to a neuron in
Computation of most important formula i.e. b (n) x (n-k) is Artificial Neural Networks.
easily solved by this operation.
REFERENCES
[1]. Mohamed Al-Ashrafy, Ashraf Salem and Wagdi Anis, “An Efficient
Implementation of Floating Point Multiplier, “proceeding of 2011
IEEE.
[2]. Guillermo Marcus, Patricia Hinojosa, Alfonso Avila and Juan
Nolazco-Flores, “A Fully Synthesizable Single-Precision, Floating-
Point Adder/Subtractor and Multiplier in VHDL for General and
Educational Use”, Proceedings of the Fifth IEEE International
Caracas Conference on Devices, Circuits and Systems, Dominican
Republic.
[3]. Xilinx Inc, ISE, at http://www.xilinx.com.
[4]. Behrooz Parhami, Computer Arithmetic: Algorithms and Hardware
Designs, 1st ed. Oxford: Oxford University Press, 2000
[5]. John G. Proakis and Dimitris G. Manolakis (1996), “Digital Signal
Figure 6 Block Diagram for floating point MAC
Processing: Principles. Algorithms and Applications”, Third Edition.
[6]. Patterson, D. & Hennessy, J. (2005), Computer Organization and
Design: The Hardware/software Interface, Morgan Kaufmann.
IV. RESULTS [7]. Mentor Graphics Inc, FPGA Advantage, at
http://www.mentor.com/fpgaadvantage.
The proposed Mac unit is implemented on Xilinx ISE design suite [8]. IEEE Standards Board, IEEE-754, IEEE Standard for Binary
Floating-Point Arithmetic, New York: IEEE, 1985.
9.2 in Vertex 2P family. The device utilization factor for the
[9]. Lamiaa S.A.Hamid, Khaled A.Sheata, Hassan El-Ghitani, Mohamed
floating point MAC unit is given below. Elsaid (2010),“ Design of Generic Floating Point Multiplier and
Adder/Subtractor Units”, in proceedings of the 12th IEEE
Table 2. Device Utilization Summary of FPMAC international Conference on computer modeling and Simulation.
[10]. YAJUAN CH. and Q. WU. Design and implementation of PID
Logic Used Available Utilization controller based on FPGA and genetic algorithm. In: Proceedings of
utilization 2011 International Conference on Electronics and Optoelectronics.
Dalian: IEEE, 2011, pp. 308–311. ISBN 978-1-61284-275-2.DOI:
10.1109/ICEOE.2011.6013491
Number of slices 610 1408 43% [11]. ZHENBIN G., X. ZENG, J. WANG and J. LIU. FPGA
implementation of adaptive IIR filters with particle swarm
optimization algorithm. In: 11th IEEE Singapore International
Number of 4 input 1123 2816 39%
LUTs
Conference on Communication Systems. Guangzhou: IEEE, 2008,
pp. 1364–1367. ISBN 978-1-4244-2424-5. DOI:
Number of bonded 99 140 70% 10.1109/ICCS.2008.4737406.
IOBs
[12]. OTSUKA, T., T. AOKI, E. HOSOYA and A. ONOZAWA. An
Number of MULT 4 12 33% Image Recognition System for Multiple Video Inputs over a Multi-
18x18s FPGA System. In: IEEE 6th International Symposium on Embedded
Multicore SoCs. Aizu-Wakamatsu: IEEE, 2012, pp. 1–7. ISBN 978-
0-7695-4800-5. DOI: 10.1109/MCSoC.2012.33.
[13]. RAMAKRISHNAN, A. a J. M. CONRAD. Analysis of floating point
operations in microcontrollers. In: Proceedings of IEEE
Southeastcon. Nashville: IEEE, 2011, pp. 97–100. ISBN: 978-1-
61284-739-9. DOI: 10.1109/SECON.2011.5752913.
[14]. UNDERWOOD, K. FPGAs vs. CPUs. In: Proceeding of the 2004
ACM/SIGDA 12th international symposium on Field programmable
gate arrays. New York: ACM Press, 2004, pp. 171–180. ISBN 1-
58113-829-6.DOI: 10.1145/968280.968305.
V. CONCLUSION
www.rsisinternational.org/IJRSI.html Page 43