From: Martin W. <mai...@ma...> - 2011-04-16 17:25:47
|
On 16/04/11 17:52, Cary R. wrote: > I believe #0 in a continuous assignment is thrown out by the > compiler so like Martin said it serves no purpose. > > What's confusing me and I'll admit I'm not fully awake is why > is each always block executed twice. It's related to the > equality check since @(x) if (x == 4'b1010) ... works > differently (may work as Michael expects). I would expect @(x) > and @(x == 4'b1010) to have the same sensitivity list, but > that appears to not be the case. If there is a bug in Icarus > that is where it is. FYI GPL cver and veriwell have the same > output as Icarus. > This confused me to begin with too... The answer is that @(x == 4'b1010) triggers each time "x == 4'b1010" evaluates to a different value. At time 0, x has the value 4'bxxxx, so the expression evaluates to 1'bx. At time 1, x is assigned the value 4'b0000, so the expression evaluates to 1'b0, triggering the event, and causing the always block to get executed at this time. At time 2, x is assigned the value 4'b1010, so the expression evaluates to 1'b1, triggering the event once, and is then assigned the value 4'b1111, so the expression evaluates to 1'b0, triggering the event a second time. But because there is no delay between these two assignments, the always block only gets executed once at this time, despite being triggered twice. Where there does seem to be a bug in Icarus is if you change the expression to "x === 4'b1010". Then the always block gets executed at time 0, which I don't think is correct. Martin |