Re: [myhdl-list] yield before the end of a simulation
Brought to you by:
jandecaluwe
From: Christopher F. <chr...@gm...> - 2011-12-20 13:17:28
|
On 12/20/2011 5:35 AM, Oscar Diaz wrote: > Hi > > I have a testbench that needs to do some asserts at the end of a > simulation. However, I couldn't find an elegant way to do it. Right > now I'm passing to the testbench generator the same duration as in > "Simulation.run(duration)" , so I can do a "yield delay(duration-1)" > and do the final asserts (by the way, in my case all my simulations > have a defined duration). I tried to catch the StopSimulation > exception, but it doesn't work inside a generator. Any ideas? Thanks! > > Best regards > I believe you can catch exceptions in generators. At least the generator PEP says so and the following works. ~~~ [Code Snip] ~~~ from myhdl import * def test(): @instance def ex_in_g(): try: for ii in xrange(10): yield delay(7) raise StopSimulation except Exception, e: print("Caught exception %s" % (str(e))) raise StopSimulation return ex_in_g if __name__ == '__main__': Simulation(test()).run() ~~~~~~~~~~~~~~~~~~~~~~~ Regards, Chris |