Re: [myhdl-list] Small buglet
Brought to you by:
jandecaluwe
|
From: Jan D. <ja...@ja...> - 2007-05-21 20:14:42
|
Thomas Heller wrote: > While working with Python generators in a testbench to supply test data to my instances, > I found that the myhdl.instances() function not only returns MyHDL instances but also > these generators. Right. Sometimes I think that myhdl.instances() is a result of me trying to be too clever, and therefore not really a good idea. Suppose it would be required to always return instances explicitly, would anyone have missed it? Anyway. I think that you expect that the function only finds instances created by the MyHDL decorators @instance, @always and @always_comb (and also the "hierarchical" instances of course.) Those decorators could return special objects that can be easily be looked up by type. That's indeed what currently happens with @always and @always_comb - but not with @instance, which creates a generator directly. Before 0.5, MyHDL had no decorators and the only option was to use generators directly. Therefore, it was not possible to differentiate between "MyHDL" generators and other ones. At this point, myhdl.instances() is still compatible with that behavior. In the future, I believe the function should be modified so that it works like you expect. It's a good idea to require using MyHDL decorators for instances. The code becomes clearer, and as you say, plain generators have other uses, also in MyHDL code. In the mean time, returning instances explicitly is a good workaround. Perhaps better than the "feature" :-) Feedback welcome. Jan -- Jan Decaluwe - Resources bvba - http://www.jandecaluwe.com Losbergenlaan 16, B-3010 Leuven, Belgium From Python to silicon: http://myhdl.jandecaluwe.com |