Forum Discussion

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

Quartus eliminates intermediate signal causing an overflow.

I have the following code:

input signed  b;
input signed  c;
input signed  d;
output signed  e;
wire signed  f;
assign f = b*c/d;
assign e = f
I believe that Quartus is eliminating f and replacing my two assignments with:

assign e = b*c/d;
which causes b*c to overflow and the operation is effectively e = ((b*c)%2^14)/d. The purpose of f is to expand b and c so that no overflow occurs. After dividing by d the result cannot be larger than 2^14.

If I make f an output rather than just a wire, Quartus does not eliminate it and the operation is performed correctly. Is there some way to get Quartus to not eliminate f without making f an output?

12 Replies

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

    You didn't need to use the keep keyword for this to work right? (I wouldn't expect you to really need it if you break the calcuation down into two assign statements with the appropriate widths).

    I recommend not getting into a habit of using the keep keyword since it prevents having Quartus II optimizing that net when it or portions of it are not used in your design. I normally only use it for debug purposes.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    No, I didn't need to use the keep keyword. I just thought I might use it in the future to make certain signals available for observation in a simulation.