question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Div and Rem act as sources of X

See original GitHub issue

I ran into this problem when trying to run LEC to test examples for #1365.

From IEEE 1364-2005 (same for older standards):

For the division or modulus operators, if the second operand is a zero, then the entire result value shall be x.

I know these don’t pop up too much in practice, but it might be reasonable to control via randoms.

z <= a / b;                        // source of X
z <= a % b;                        // source of X
z <= (b == 0) ? _RAND_0 : a % b;   // no X
z <= (b == 0) ? _RAND_0 : a / b;   // no X

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
albert-magyarcommented, Feb 13, 2020

Is this meant to be the in a synthesizeable code block produced by FIRRTL? This would generate additional hardware. Having them return 0 is probably less hardware, but still more than nothing (which leaves the synthesis tool to do as it pleases).

Sorry I didn’t specify; this would be simulation only – the _RAND_ signals are generally only used in simulation. This would fit in our existing set of conditional compilation modes that cover things like register initialization.

1reaction
aswatermancommented, Feb 13, 2020

Can use an ifdef-guard in the same manner as out-of-bounds array indices, so that the new Verilog only affects simulation, letting the synthesis tool do as it pleases.

On Thu, Feb 13, 2020 at 10:18 AM John Wright notifications@github.com wrote:

Is this meant to be the in a synthesizeable code block produced by FIRRTL? This would generate additional hardware. Having them return 0 is probably less hardware, but still more than nothing (which leaves the synthesis tool to do as it pleases).

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/freechipsproject/firrtl/issues/1393?email_source=notifications&email_token=AAH3XQQ7GOC5MKVUGIF6RLLRCWFG7A5CNFSM4KUXJE32YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOELWBW6A#issuecomment-585898872, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAH3XQXDBSZMYMSALUQJBCDRCWFG7ANCNFSM4KUXJE3Q .

Read more comments on GitHub >

github_iconTop Results From Across the Web

<div>: The Content Division element - HTML - MDN Web Docs
The <div> HTML element is the generic container for flow content. It has no effect on the content or layout until styled in...
Read more >
How to perform an integer division, and separately get the ...
Either use trunc instead of floor (thereby permitting negative remainders) or use subtraction to get the remainder ( rem = y - div...
Read more >
Introduction to Ionizing Radiation
Ionizing Radiation: Any electromagnetic or particulate radiation capable of producing ion pairs by interaction with matter. Scope limited to X and gamma rays, ......
Read more >
Euclidean division: div , rem and friends #9283
For any two real numbers x and y, Euclidean division is the problem of finding an integer q (the quotient) and number r...
Read more >
Function Reference: rem - Octave Forge - SourceForge
Return the remainder of the division x / y . The remainder is computed using the expression. x - y .* fix (x...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found