<s> from copy import deepcopy <EOL> from pymtl import * <EOL> from pclib . ifcs import InValRdyBundle , OutValRdyBundle <EOL> class TestSimpleNetSink ( Model ) : <EOL> def __init__ ( s , dtype , msgs ) : <EOL> s . in_ = InValRdyBundle ( dtype ) <EOL> s . done = OutPort ( <NUM_LIT:1> ) <EOL> s . msgs = deepcopy ( msgs ) <EOL> s . recv = [ ] <EOL> s . idx = <NUM_LIT:0> <EOL> s . msgs_len = len ( msgs ) <EOL> @ s . tick <EOL> def tick ( ) : <EOL> if s . reset : <EOL> s . in_ . rdy . next = False <EOL> s . done . next = False <EOL> return <EOL> in_go = s . in_ . val and s . in_ . rdy <EOL> if in_go : <EOL> if s . in_ . msg not in s . msgs : <EOL> if s . in_ . msg in s . recv : <EOL> raise AssertionError ( "<STR_LIT>" <EOL> . format ( s . in_ . msg ) ) <EOL> else : <EOL> raise AssertionError ( "<STR_LIT>" <EOL> . format ( s . in_ . msg ) ) <EOL> s . msgs . remove ( s . in_ . msg ) <EOL> s . recv . append ( s . in_ . msg ) <EOL> s . idx = s . idx + <NUM_LIT:1> <EOL> if ( s . idx < s . msgs_len ) : <EOL> s . in_ . rdy . next = True <EOL> s . done . next = False <EOL> else : <EOL> s . in_ . rdy . next = False <EOL> s . done . next = True <EOL> def line_trace ( s ) : <EOL> return "<STR_LIT>" . format ( s . in_ , s . idx ) </s>
