0
\$\begingroup\$

I have not been able to find a book or information in internet, about the correct way to describe a Math Equation in Verilog.

With the correct way I mean for example, how to analyze the equation and to express it, Behavioral? Sequential? How to take advantage of the Non-blocking assignments, or if to avoid the blocking assignments. Create the basics operations in a different module and instantiate, as a task? or to create everything in one module?

I have not been able even to find an example in internet, arithmetic books limit themselves to the basic operations and fixed-floating point representations.

Let's say an equation like this: A = (B + 1) / C^(B-10.05)

MOREOVER, I sense like Verilog/VHDL was not designed to do this (this would explain the lack of information?), most of the books teach how to do registers, memories, latches, flip-flop, then state machines, THEN a full Microprocessor with instruction set and ALU.

Might I be wrongly focusing my vision of Arithmetic (equation implementation) in verilog? Is designing a Microprocessor a better aproach for this kind of equations?

Maybe you can adress me to a proper information to read?

\$\endgroup\$
3
  • \$\begingroup\$ vhdl/verilog can do this. Calculators can ergo logic can. How small & how fast is the real question. TIP. Don't think in algebra... in vhdl is it quicker and cheaper todo a shift and add/subtract rather than multiply. \$\endgroup\$
    – user16222
    Feb 4, 2016 at 13:24
  • \$\begingroup\$ Could you shortly describe how to describe some simple equation like A = (B + 1) / (B * 5)? I didn't say that verilog can't BUT how, is the question, afaics the language is highly limited unless you actually design the components of a Calculator then make the calculations. \$\endgroup\$
    – sujeto1
    Feb 4, 2016 at 13:31
  • \$\begingroup\$ The language is highly logical & that is the point of it. \$\endgroup\$
    – user16222
    Feb 4, 2016 at 13:32

1 Answer 1

1
\$\begingroup\$

There are often standard ip cores that can do floating point logic furnished by the manufacturer. For example, Altera have megafunctions that can do floating point operations, and pipelinable. See this document:

https://www.altera.com/content/dam/altera-www/global/en_US/pdfs/literature/ug/ug_altfp_mfug.pdf

\$\endgroup\$
6
  • \$\begingroup\$ My question is a bit in top level than this. I mean how to describe the equation itself, not the IP core for the basic function. \$\endgroup\$
    – sujeto1
    Feb 4, 2016 at 13:45
  • \$\begingroup\$ Let's say you want to describe a*b + c, you would use one altfp_mult block then one altfp_add block. Of course you will need to use VHDL or Verilog to do this. \$\endgroup\$
    – lucas92
    Feb 4, 2016 at 13:48
  • \$\begingroup\$ Should I describe parallel state machines? or one always@ procedural? How are the IPs called inside the code, as instations? Supose X = a*b+c , then later I need X + a = a, so I have a new a. and 1 more questions, this IP cores, are they linked to specific Hardware, or can I use them in any other hardware (from Altera to Xilinx for example). \$\endgroup\$
    – sujeto1
    Feb 4, 2016 at 14:04
  • \$\begingroup\$ Well, it depends on the speed you need to achieve. For Altera FPGAs, they are pretty easy to instantiate, you use the megafunction GUI to set its parameters then you use the megafunction as a component in your VHDL code. \$\endgroup\$
    – lucas92
    Feb 4, 2016 at 14:13
  • \$\begingroup\$ When you want x = a * b, then you would invoke the task like floating_multiply(x, a, b) with x being output, a and b being input. This is a generic answer, an actual IP core would have many more I/Os. Every time such a task is invoked, it creates a (big) block of logic. To reuse this big block of logic, you need to design datapath around it. I don't know for a fact, but it may be a safe bet that no synthesizer would synthesize operations with floating point type in equation form. \$\endgroup\$
    – rioraxe
    Feb 4, 2016 at 22:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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