Thread: [myhdl-list] Newbie problem with instances()
Brought to you by:
jandecaluwe
From: Georg A. <ac...@in...> - 2009-03-30 17:04:44
|
Hi, I'm trying to run the Turbo-decoder-project from opencores unter MyHDL 0.6 (on Unbuntu 8.04). But it simply doesn't produce any data, because all the internal instances are not running. Although not very familiar with MyHDL (nor Python) I simplified the code down to this: from myhdl import * def clkGen(clk, duration_1 = 10, duration_2 = 10): print "clkgen start" while 1: yield delay(duration_1) print "j" clk.next = not clk.val yield delay(duration_2) print "k" clk.next = not clk.val def subunit(): clk = Signal(bool(0)) instance_0=clkGen(clk) print "instance0 = ",instance_0 i=instances() print "instances = ",i return i x=subunit(); print "subunit = ",x sim = Simulation(x) sim.run(100) If I understand the docs correctly, instances() should return a list of all generated instances. So in the example I expect [ instance_0 ] to be returned. But: # python main.py instance0 = <generator object at 0xb7cf9a0c> instances = [] subunit = [] <class 'myhdl.StopSimulation'>: No more events When returning instance_0 in subunit, it works as expected and j/k is printed. The empty instances()-list seems to be the root cause for the failure of the turbo decoder... Am I missing something important here? -- Georg Acher, ac...@in... http://www.lrr.in.tum.de/~acher "Oh no, not again !" The bowl of petunias |
From: Jan D. <ja...@ja...> - 2009-03-31 17:18:15
|
Georg Acher wrote: > Hi, > I'm trying to run the Turbo-decoder-project from opencores unter MyHDL 0.6 > (on Unbuntu 8.04). > > If I understand the docs correctly, instances() should return a list of all > generated instances. So in the example I expect [ instance_0 ] to be returned. > > But: > > # python main.py > instance0 = <generator object at 0xb7cf9a0c> > instances = [] > subunit = [] > <class 'myhdl.StopSimulation'>: No more events > > When returning instance_0 in subunit, it works as expected and j/k is > printed. > > The empty instances()-list seems to be the root cause for the failure of the > turbo decoder... > > Am I missing something important here? You have hit a backwards incompatibility: http://www.myhdl.org/doc/0.6/whatsnew/0.6.html#instances-function Only generators produced by MyHDL decorators are now considered by instances(). MyHDL decorators are used as a way to discriminate between "MyHDL generators" and regular ones. In particular, this makes it possible to use regular generators in MyHDL models for different purposes. (Users had reported problems when instances() didn't make this difference.) That having said, I personally don't like instances() that much. I tend to return generators explicitly. Regards, Jan -- Jan Decaluwe - Resources bvba - http://www.jandecaluwe.com Python as an HDL: http://www.myhdl.org VHDL development, the modern way: http://www.sigasi.com Analog design automation: http://www.mephisto-da.com World-class digital design: http://www.easics.com |
From: Georg A. <ac...@in...> - 2009-03-31 19:22:38
|
On Tue, Mar 31, 2009 at 07:18:04PM +0200, Jan Decaluwe wrote: > You have hit a backwards incompatibility: > > http://www.myhdl.org/doc/0.6/whatsnew/0.6.html#instances-function Ouch... That explains everything. I guess I'll have to go over the 20 files and look if it's just a sequential function or intended to be an instance... :-( > Only generators produced by MyHDL decorators are now considered by instances(). > MyHDL decorators are used as a way to discriminate between "MyHDL generators" > and regular ones. In particular, this makes it possible to use regular > generators in MyHDL models for different purposes. (Users had reported > problems when instances() didn't make this difference.) > > That having said, I personally don't like instances() that much. I tend > to return generators explicitly. Removing instances() would IMO make MyHDL quite unusable... It's already tedious to explicitely return the implicitely instantiated modules. If I have to care manually about the correct instantiation of my modules, I can just use raw threads and shared variables ;-) -- Georg Acher, ac...@in... http://www.lrr.in.tum.de/~acher "Oh no, not again !" The bowl of petunias |
From: Jan D. <ja...@ja...> - 2009-03-31 21:45:07
|
Georg Acher wrote: > On Tue, Mar 31, 2009 at 07:18:04PM +0200, Jan Decaluwe wrote: >> You have hit a backwards incompatibility: >> >> http://www.myhdl.org/doc/0.6/whatsnew/0.6.html#instances-function > > Ouch... That explains everything. I guess I'll have to go over the 20 files > and look if it's just a sequential function or intended to be an instance... > :-( It it worked with earlier versions, it means that every generator was intended to be a MyHDL instance. If you want to use instances(), you'll have to adapt all of them to use decorators. That's the bad news. The good news is that there's no need to consider their specific functionality :-) >> Only generators produced by MyHDL decorators are now considered by instances(). >> MyHDL decorators are used as a way to discriminate between "MyHDL generators" >> and regular ones. In particular, this makes it possible to use regular >> generators in MyHDL models for different purposes. (Users had reported >> problems when instances() didn't make this difference.) >> >> That having said, I personally don't like instances() that much. I tend >> to return generators explicitly. > > Removing instances() would IMO make MyHDL quite unusable... It's already > tedious to explicitely return the implicitely instantiated modules. If I > have to care manually about the correct instantiation of my modules, I can > just use raw threads and shared variables ;-) It may be tedious and feel redundant if no conditionals are involved. But in MyHDL, you can use conditionals to control which generators are returned, for example to support recursion or simply different implementations dependent on some condition. In other HDLs this is either not possible (Verilog), or cumbersome (VHDL configurations.) Granted, instances() would still work when you use conditional returns, but it in those cases it probably much clearer to return generators explicitly. Jan -- Jan Decaluwe - Resources bvba - http://www.jandecaluwe.com Python as an HDL: http://www.myhdl.org VHDL development, the modern way: http://www.sigasi.com Analog design automation: http://www.mephisto-da.com World-class digital design: http://www.easics.com |