You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thank you for using PyMTL3. The issue is that when you call the sim_reset() method, the clock will be advanced, and the first few messages will be transmitted. If you are doing pure CL simulation, sim_reset() is not needed since all it does is just toggling the reset signal and ticking the clock for a few cycles.
If you do want to use the reset signal for some reason, you can either write your own reset function to do what you want or modify your update block to not do anything during reset, for example:
'''
from pymtl3 import *
from pymtl3.stdlib.queues import PipeQueueCL
定义一个简单的被调用组件
class SimpleCallee(Component):
def construct(s):
#s.set = CalleePort(Type=Bits32)
s.send = CallerIfcCL(Type=Bits32)
s.counter = b32(0)
print(s.counter)
#s.set //= s.my_set
class SimpleCaller(Component):
def construct(s):
s.receive = CalleeIfcCL(Type=Bits32)
s.received_data = Wire(32)
s.receive //= s.f_receive
'''
s.in_q = PipeQueueCL(num_entries=2)
class TopLevel(Component):
def construct(s):
s.callee = SimpleCallee()
s.caller = SimpleCaller()
connect(s.callee.send, s.caller.receive)
def test_caller_callee():
top = TopLevel()
#top.elaborate()
top.apply(DefaultPassGroup())
#top.sim_reset() 这个会占用仿真时间!!(会触发update_once)
print(top.callee.counter)
print("Starting simulation...")
for i in range(10): # 运行10个周期
top.sim_tick()
print(f"Cycle {i}: {top.line_trace()}")
if name == "main":
test_caller_callee()
'''
the code above will print
if add sim_reset() the results is wrong
'''
00000000
00000004
Starting simulation...
Cycle 0: Callee: counter=00000005 -> Caller: received=00000004
Cycle 1: Callee: counter=00000006 -> Caller: received=00000005
Cycle 2: Callee: counter=00000007 -> Caller: received=00000006
Cycle 3: Callee: counter=00000008 -> Caller: received=00000007
Cycle 4: Callee: counter=00000009 -> Caller: received=00000008
Cycle 5: Callee: counter=0000000a -> Caller: received=00000009
Cycle 6: Callee: counter=0000000b -> Caller: received=0000000a
Cycle 7: Callee: counter=0000000c -> Caller: received=0000000b
Cycle 8: Callee: counter=0000000d -> Caller: received=0000000c
Cycle 9: Callee: counter=0000000e -> Caller: received=0000000d
'''
The text was updated successfully, but these errors were encountered: