On Tue, Nov 09, 2010 at 10:04:39PM -0800, Kirk Wallace wrote:
> if(new_in && new_in != last_in) { // If new_in is non-zero and
> different than last_in, edge is detected?
By itself, this line is able to detect a rising edge. (The in_edge
parameter appears to shift detection to the falling edge, if desired.)
The only significant 'C' language consideration is that the line is
effectively:
if(new_in && (new_in != last_in)) {
i.e. True if new_in is non-zero (i.e. true), and previously wasn't.
<red herring>
Lazy evaluation is only possible when new_in is false.
When it is true, the rest of the expression must be evaluated before a
result can be determined. No lazy evaluation is possible in this case. [1]
So the 'C' semantics mimic our interest in the input state. (Hopefully
by design, not just coincidence.) Only at the edge of interest is it
worthwhile to differentiate between the edge, and steady a state true.
(The top of the input pulse.)
</red herring>
(It's 1:30 a.m. here, but I think I've typed what I meant.)
Erik
[1] That's not just 'C', but plain Boolean algebra:
0 && A = 0 # So why check A?
1 && A = A # So must check A.
------------------------------------------------------------------------------
The Next 800 Companies to Lead America's Growth: New Video Whitepaper
David G. Thomson, author of the best-selling book "Blueprint to a
Billion" shares his insights and actions to help propel your
business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev
_______________________________________________
Emc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-users