I've constructed the following, minimal example source file:
# Begin File tb3.py
from pymtl3 import *
class dut(Component):
def construct(s):
@update_once
def next_cycle1():
print("entering update_once block")
my_tb = dut()
my_tb.apply(DefaultPassGroup())
my_tb.sim_reset()
for i in range(4):
print("Iteration:" + str(i))
my_tb.sim_tick()
print("Sim Done")
# End File
I expect the line "entering update_once block" to print once per clock cycle. However, when I run this, I see the following console output:
$ python tb3.py
entering update_once block
entering update_once block
entering update_once block
entering update_once block
Iteration:0
entering update_once block
entering update_once block
Iteration:1
entering update_once block
entering update_once block
Iteration:2
entering update_once block
entering update_once block
Iteration:3
entering update_once block
entering update_once block
Sim Done
This is with python 3.8.2. It appears that this block is scheduled twice per clock cycle Am I misunderstanding how to use the @update_once block?
Thanks