<s> from pymtl import * <EOL> class Reg ( Model ) : <EOL> '''<STR_LIT>''' <EOL> def __init__ ( s , dtype = <NUM_LIT:1> ) : <EOL> s . in_ = InPort ( dtype ) <EOL> s . out = OutPort ( dtype ) <EOL> @ s . posedge_clk <EOL> def seq_logic ( ) : <EOL> s . out . next = s . in_ <EOL> def line_trace ( s ) : <EOL> return "<STR_LIT>" . format ( s . in_ , s . out , s . out ) <EOL> class RegEn ( Model ) : <EOL> '''<STR_LIT>''' <EOL> def __init__ ( s , dtype = <NUM_LIT:1> ) : <EOL> s . in_ = InPort ( dtype ) <EOL> s . en = InPort ( <NUM_LIT:1> ) <EOL> s . out = OutPort ( dtype ) <EOL> @ s . posedge_clk <EOL> def seq_logic ( ) : <EOL> if s . en : <EOL> s . out . next = s . in_ <EOL> def line_trace ( s ) : <EOL> return "<STR_LIT>" . format ( s . in_ , s . out , s . out ) <EOL> class RegRst ( Model ) : <EOL> '''<STR_LIT>''' <EOL> def __init__ ( s , dtype = <NUM_LIT:1> , reset_value = <NUM_LIT:0> ) : <EOL> s . in_ = InPort ( dtype ) <EOL> s . out = OutPort ( dtype ) <EOL> @ s . posedge_clk <EOL> def seq_logic ( ) : <EOL> if s . reset : <EOL> s . out . next = reset_value <EOL> else : <EOL> s . out . next = s . in_ <EOL> def line_trace ( s ) : <EOL> return "<STR_LIT>" . format ( s . in_ , s . out , s . out ) <EOL> class RegEnRst ( Model ) : <EOL> '''<STR_LIT>''' <EOL> def __init__ ( s , dtype = <NUM_LIT:1> , reset_value = <NUM_LIT:0> ) : <EOL> s . en = InPort ( <NUM_LIT:1> ) <EOL> s . in_ = InPort ( dtype ) <EOL> s . out = OutPort ( dtype ) <EOL> @ s . posedge_clk <EOL> def seq_logic ( ) : <EOL> if s . reset : <EOL> s . out . next = reset_value <EOL> elif s . en : <EOL> s . out . next = s . in_ <EOL> def line_trace ( s ) : <EOL> return "<STR_LIT>" . format ( s . in_ , s . out , s . out ) </s>
