[myhdl-list] Re: MyHDL question
Brought to you by:
jandecaluwe
From: Jan D. <ja...@ja...> - 2004-02-11 22:38:46
|
Frank Palazzolo wrote: > Hello Jan, > > I've just discovered MyHDL and I am quite impressed! I have been > fooling around with generators in Python with an eye toward > simulation. I first discovered SimPy, and then those guys introduced > me to MyHDL when I mentioned I wanted to do gate-level simulation. Nice from them. > I am trying to do some logic simulations of old TTL designs. So far > I've run into one small issue.... > > If I want to edge-trigger on either of two edge events, as in > yield posedge(A), posedge(B) > > How can I tell which one has occurred after the yield, or if both > have occurred? Should this be broken into two processes somehow? > > I realize I can check the current value of A and B - but I don't seem > to have any information on the previous values of A and B when the > yield was called. Some of your examples have a similar situation > (clock and reset) but in those cases you don't care about the actual > "edge" of reset, only the resulting level. Ok. In VHDL, you could do this with the 'event attribute, but I don't think it is possible in Verilog. In any case I would like to know how this feature is useful in your modeling. Note that it is perfectly possible that the two events happen "simultaneously". I've been thinking on how to accomplish this in MyHDL. You'll need some help from the "internals" at this point (_Signal.py). Each signal maintains 3 "waiter" lists, for plain events, posedge events and negedge events. Those are just lists that can be tested. When you have: yield posedge(A), posedge(B) it is certain that both A and B had a non-empty posedge waiter list right before the generator resumes. With the following function: def posedgeEvent(sig): return not sig._posedgeWaiters you can test whether that event list has become empty, and therefore, whether that event has triggered the generator. Again, it is possible that both have become empty in the same delta cycle. I used the name posedgeEvent to illustrate the point - but it is probably misleading. It just tests whether the waiter list is empty, not whether an event has just occured. When you use the function right after a corresponding event in a yield, the effect is the same though. Testing for not hasPosedgeWaiters(sig) or not hasWaiters(posedge(sig)) would be correct names, but less clear I guess. Hope this helps for now, Regards, Jan -- Jan Decaluwe - Resources bvba - http://jandecaluwe.com Losbergenlaan 16, B-3010 Leuven, Belgium Python is fun, and now you can design hardware with it: http://jandecaluwe.com/Tools/MyHDL/Overview.html |