Re: [myhdl-list] intbv with max != 2**n. Error or annoyance?
Brought to you by:
jandecaluwe
From: Christopher F. <chr...@gm...> - 2013-02-25 15:49:07
|
On 2/25/2013 9:22 AM, Jan Decaluwe wrote: > On 01/28/2013 04:06 PM, Christopher Felton wrote: >> On 1/28/2013 5:54 AM, Per Karlsson wrote: >>> Hi! >>> Over the weekend I have come to the conclusion that it is an error. > > I don't get this. Here, MyHDL tries to check dubious code a soon as > possible (like VHDL). This prevents you from writing convoluted code > that require you to play delta cycle games to see whether or not > a value is in the range it is supposed to be. > > That is a good thing, and the intention. > When we were discussing this, the point that got my attention was: "where would you insert the assertion" if it was not build into the /intbv/. The example provided was someone implementing a gating operation. The gate signal occurs at the same time as the out of bound value. Yes, the out of bounds (OOB) is detected ASAP but the designers intent was to have the OOB gated (blocked). @always_comb def hdl(): if block_oob: downstream.next = oob_truncation else: downstream.next = upstream In this example the designers intent is to prevent the OOB on the downstream, assuming the upstream has greater range, the /block_oob/ was generate by some other logic (OP's example was third party IP). Are we saying, that generating a combinatorial selection like this should be avoided because it is a race-condition and you can't prevent /downstream/ from talking on the OOB value, simulation or physical? Obviously changing the above to: @always_seq(clock.posedge, reset=reset) def hdl(): if block_oob: downstream.next = oob_truncation else: downstream.next = upstream will fix the issue. Regards, Chris |