Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
14 years ago

What is the difference between direct arithmetic computation and using MegaWizard blo

When I try to do addition, reduction, multiplication, previously I will use

plug ins in Quartus II like LPM_ADD_SUB. Then I will program use this addtion block to do addtion.The program will be:

module Test1121(out1,out2,a,b);

input [7:0] a,b;

output [8:0] out1;

output [15:0] out2;

add1(a,b,out1);

mul1(a,b,out2);

endmodule

However, It seems I can directly programing like this:

module Test1121(out1,out2,a,b);

input [7:0] a,b;

output [8:0] out1;

output [15:0] out2;

always@(a or b)

begin

out1=a+b;

out2=a*b;

end

endmodule

So I wonder what is the difference between them? Which one is better to be used?

Thanks

13 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Pipelinening (with more than an input and output register) can be easier specified with MegaFunctions. Unregistered arithmetic, as shown in this post should give identical results, because arithmetic inferred from HDL uses the same lpm_add and lpm_mul blocks, as you can see from the RTL netlist. Of course there may be cases, where the implementation looks slightly different.

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    in theory you should be able to get HDL to be pipelined just like the LPM but it will probably not be as simple as:

    out2=a*b;
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    writing HDL is obviously more portable between FPGA vendors, ASICs, and doesn't require Altera specific simulation libraries

    i have seen better fmax numbers using LPM functions rather than HDL - i think the LPMs are implemented at an atom level rather than being synthesized, so they are or can be pretty well optimized