# Looking for a open-source ALU

I am looking for a open ALU to compute several equations like these:

y1 = e^((constant1 - x)^2/(2*x))
y2 = constant2/y1
y3 = y2*constant3 + x*constant4


Where x is the input of my system and y3 is the output.

I would prefer that the ALU supported floating-point operations. Where can I find an open or free floating-point ALU?

• Are you planning on running these at very high speed in an FPGA or the like? Barring some extreme performance requirement or if you are already using an FPGA (or have very high volume), using an appropriate MCU and doing it in software would likely be cheaper in both component and development cost. – Nick T Feb 2 '11 at 17:23

As a processor guy and designer of an open-source microprocessor, I can tell you that it will be difficult to find what you are looking for.

Multiplication, subtraction and addition are very doable in hardware but irrational numbers, arbitrary powers and division are difficult if not infeasible to do in digital hardware. It may be easier to do it in analogue electronics if your equations have a tolerance for errors. Otherwise, you will need to come up with some tricks to get what you need.

If performance is not critical, you would be better served by doing it in software.

From this and some of your other questions, I think that you may need to re-define your problem or come up with a better alternative that does not rely so much on complicated math.

It may not be possible to do what you need, in hardware and you may need to resort to software emulation instead.

• It is possible, because floating point ALUs exist in many processors. Whether it's been made open source and is achievable on an FPGA of reasonable size is up for debate. – Kevin Vermeer Feb 3 '11 at 2:30
• obviously FPUs exist, but designing one that can do the kind of operations that the OP wants, is not trivial. – sybreon Feb 8 '11 at 12:38

There are several open-source ALUs available. In particular, there is at least one open-source ALU somewhere in every open-source CPU.

The Open Cores website, under the "Arithmetic core" tab, has a bunch of projects -- some of them involve floating point. It also has a bunch of CPUs under the "Processor" tab, some of which apparently include FPUs -- OpenFire, S1 Core (OpenSPARC), Zet (x86), and probably a few others.

This table of embedded CPU soft cores has a column that indicates which ones have a FPU and another column that indicates which are open source; several of them are both.

Pretty much any ALU can perform any floating-point operations. There are several approaches, including:

• use a CPU with only an integer ALU; emulate all floating-point operations in software. Perhaps you can compile your code with the -msoft-float option or --without-fp option. Or perhaps you will want to manually port a floating-point library such as fp-bit.c, ieeelib, or soft-fp or other floating point emulation library.
• use a CPU with a simple floating-point ALU (aka FPU) that only does add, subtract, multiply, and a few utility operations; emulate more complicated operations such as divide in software.
• use a CPU with a more complicated floating-point ALU (aka FPU); only emulate really complicated operations such as cosh(), asin(), etc.

As other posters have already pointed out, doing floating-point calculations in a FPGA may not be the be the easiest or lowest-cost way to achieve your goals. Many people using FPGAs prefer to use fixed-point calculations if at all possible. Often an off-the-shelf microprocessor is a better fit than a FPGA.