[myhdl-list] Setting "sig.next" before starting the simulation
Brought to you by:
jandecaluwe
|
From: Nick P. <np...@in...> - 2003-10-05 14:40:09
|
On Mon, Sep 29, 2003 at 09:23:42PM +0200, Jan Decaluwe wrote:
[[[ refers to an off-list discussion ]]]
>
> Very nice work! I would gladly add it as an example to future
> MyHDL distributions.
>
> Some upfront comments:
>
Sorry for taking so long to answer, but I was engaged in other
activities that kept me away for several days. As I was trying to
address your comments, and write a test-framework for mu0 (which is
turning out very nicely), I came upon this strange behavior:
from myhdl import *
def gen_tst (db):
while 1:
yield delay(10)
if db.val: print "now = %d" % (now())
def mktst():
db=Signal(bool(0))
g = gen_tst(db)
return g, db
g, db = mktst()
db.next = 1
sim = Simulation(g)
print "db.val=%d, db.next=%d" % (db.val, db.next)
sim.run(50)
When I run this, I get:
$ python2.3 tst.py
db.val=0, db.next=1
now = 10
now = 20
now = 30
now = 40
now = 50
SuspendSimulation: Simulated for duration 50
Which is fine. Now, if I comment-out the "print" line like this:
from myhdl import *
def gen_tst (db):
while 1:
yield delay(10)
if db.val: print "now = %d" % (now())
def mktst():
db=Signal(bool(0))
g = gen_tst(db)
return g, db
g, db = mktst()
db.next = 1
sim = Simulation(g)
# print "db.val=%d, db.next=%d" % (db.val, db.next)
sim.run(50)
Then I strangely get:
$ python2.3 tst.py
SuspendSimulation: Simulated for duration 50
Is this supposed to happen?
/npat
--
But the delight and pride of Aule is in the deed of making, and in the
thing made, and neither in possession nor in his own mastery;
wherefore he gives and hoards not, and is free from care, passing ever
on to some new work."
-- J.R.R. Tolkien, Ainulindale (Silmarillion)
|