Open CaseyZhu opened 1 month ago
Hi,
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:
@update_once
def up_counter_ff():
if s.reset:
s.counter @= 0
elif s.send.rdy():
s.send(s.counter)
s.counter @= s.counter + b32(1)
''' from pymtl3 import * from pymtl3.stdlib.queues import PipeQueueCL
定义一个简单的被调用组件
class SimpleCallee(Component): def construct(s):
s.set = CalleePort(Type=Bits32)
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()
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 '''