Forum Discussion

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

Multiplication by constant

Hi all. Just found out that Quartus does not instantiate hard block multiplier if multiplication is done by a constant. Even if i define multstyle = "dsp", why?

4 Replies

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

    --- Quote Start ---

    Hi all. Just found out that Quartus does not instantiate hard block multiplier if multiplication is done by a constant. Even if i define multstyle = "dsp", why?

    --- Quote End ---

    what value is your constant?
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    With a constant there are some sizable reductions that can be done during synthesis to make it more palatable in logic. That being said, if you have a DSP block available, why not use it. Perhaps try keeping the constant, e.g.

    (* keep *) wire mult_const;

    assign mult_const = 16'ha9a9;

    I'm guessing something like that will get it to synthesize a DSP.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    If the constant value is 2^n, then the result is simply a bitshift.

    Similarly, if it has just a couple of bits set, it may be easier just to create an adder.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Thanx for fast reply, however it was a simple typo, so now synthesis multstyle works fine :). So not to create one more thread, ill ask here, for example i need to partially connect some modules output (let it be 8 most significant bits of 16). The straightforward solution is:

    mult mult_inst(
      .a(a_8bit),
      .b(b_8bit),
      .res(c_16bit)
    );
    assign c_8bit = c_16bit

    May there be more elegant approach (without this intermediate wire) ?