Re: [myhdl-list] Small buglet
Brought to you by:
jandecaluwe
|
From: Thomas H. <th...@ct...> - 2007-05-23 17:25:47
|
Jan Decaluwe schrieb: > 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? Well, I like instances() a lot. It allows me to split one 'instance' into two or more which is sometimes a little more elegant, and avoids the error that I forget to include the new instance into the return statement. (toVerilog usually complains about some signals not been driven in that case, but the simulation does not, IIRC.) When I was first playing with myhdl, I missed 'instances' so much (since it wasn't mentioned in the first chapters of the manual) that I decided to implement it myself. Luckily I found it before the implementation did really work. > 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. Thanks, Thomas |