2
\$\begingroup\$

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?

\$\endgroup\$
1
  • 1
    \$\begingroup\$ 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. \$\endgroup\$
    – Nick T
    Commented Feb 2, 2011 at 17:23

2 Answers 2

5
\$\begingroup\$

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.

\$\endgroup\$
2
  • \$\begingroup\$ 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. \$\endgroup\$ Commented Feb 3, 2011 at 2:30
  • 1
    \$\begingroup\$ obviously FPUs exist, but designing one that can do the kind of operations that the OP wants, is not trivial. \$\endgroup\$
    – sybreon
    Commented Feb 8, 2011 at 12:38
1
\$\begingroup\$

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.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.