Re: [myhdl-list] Strange behaviour in traceSignals()
Brought to you by:
jandecaluwe
From: Oscar D. <osc...@gm...> - 2011-12-22 20:17:58
|
2011/12/22 David Kitchen <dav...@in...>: > I am puzzled by traceSignals() generating 'Inconsistent hierarchy' > messages with the following code, but not if badBehaviour is False. > Note that the print at line 32 gives the same structure in both cases, > so its something I don't understand in the introspection. > I wanted to structure a collection of tests using a common library, and > this (bad) behaviour gets in the way of a natural expression of reuse. > > Example: > > #!/usr/bin/python > # example of strange behaviour in traceSignals() > badBehaviour = True > > from myhdl import * > > def ClkDriver(clk, halfperiod=5): > halfPeriod = delay(halfperiod) > @always(halfPeriod) > def driveClk(): > clk.next = 1 & ~clk > return driveClk > > def device_test(clk1, cd1): > clk2 = Signal(0) > cd2 = ClkDriver(clk2, halfperiod=3759) # in picoseconds to give > 7.5ns(133MHz) cycle > if badBehaviour: > return (cd2,) > else: > return cd1, cd2 > > def test(): > # make a clock generator > clk1 = Signal(0) > cd1 = ClkDriver(clk1, halfperiod=3759) # in picoseconds to give > 7.5ns(133MHz) cycle > if badBehaviour: > ret = (cd1,) + device_test(clk1, cd1) For some reason this is the sentence that causes the error. Try this: ret = (cd1, device_test(clk1, cd1)) Or even better, assign to a variable the output of device_test and use instances() to infer the return value. cd1 = ClkDriver(clk1, halfperiod=3759) # in picoseconds to give 7.5ns(133MHz) cycle dt_inst = device_test(clk1, cd1) return instances() Hope this helps you. > else: > ret = device_test(clk1, cd1) > print ret > return ret > > def process(timesteps): > # wrap in a tracer for vcd output > tr_out = traceSignals(test) > # simulate > sim = Simulation(tr_out) > sim.run(timesteps) > > if __name__ == '__main__': > timesteps = 1000 > process(timesteps) > > Dave Kitchen > > > ------------------------------------------------------------------------------ > Write once. Port to many. > Get the SDK and tools to simplify cross-platform app development. Create > new or port existing apps to sell to consumers worldwide. Explore the > Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join > http://p.sf.net/sfu/intel-appdev > _______________________________________________ > myhdl-list mailing list > myh...@li... > https://lists.sourceforge.net/lists/listinfo/myhdl-list Best regards -- Oscar Díaz Key Fingerprint = 904B 306C C3C2 7487 650B BFAC EDA2 B702 90E9 9964 gpg --keyserver subkeys.pgp.net --recv-keys 90E99964 I recommend using OpenDocument Format for daily use and exchange of documents. http://www.fsf.org/campaigns/opendocument |