<s> from copy import deepcopy <EOL> from collections import deque <EOL> from pymtl import * <EOL> from pclib . cl import OutValRdyQueueAdapter <EOL> from pipelines import Pipeline <EOL> class OutValRdyInelasticPipeAdapter ( object ) : <EOL> def __init__ ( s , out , nstages = <NUM_LIT:1> ) : <EOL> s . nstages = nstages <EOL> s . out_q = OutValRdyQueueAdapter ( out ) <EOL> if s . nstages > <NUM_LIT:0> : <EOL> s . pipe = Pipeline ( s . nstages ) <EOL> def full ( s ) : <EOL> if s . nstages == <NUM_LIT:0> : <EOL> return s . out_q . full ( ) <EOL> else : <EOL> return not s . pipe . data [ <NUM_LIT:0> ] == None <EOL> def enq ( s , item ) : <EOL> assert not s . full ( ) <EOL> if s . nstages == <NUM_LIT:0> : <EOL> s . out_q . enq ( item ) <EOL> else : <EOL> s . pipe . insert ( item ) <EOL> def xtick ( s ) : <EOL> s . out_q . xtick ( ) <EOL> if s . nstages != <NUM_LIT:0> : <EOL> if not s . out_q . full ( ) : <EOL> if s . pipe . ready ( ) : <EOL> s . out_q . enq ( s . pipe . remove ( ) ) <EOL> s . pipe . advance ( ) <EOL> def __str__ ( s ) : <EOL> if s . nstages > <NUM_LIT:0> : <EOL> return '<STR_LIT>' . join ( [ ( "<STR_LIT:*>" if x != None else '<STR_LIT:U+0020>' ) for x in s . pipe . data ] ) <EOL> else : <EOL> return "<STR_LIT>" </s>
