<s> from __future__ import absolute_import <EOL> from __future__ import print_function <EOL> import sys <EOL> import os <EOL> from pyverilog . dataflow . dataflow import * <EOL> def replaceUndefined ( tree , termname ) : <EOL> if tree is None : return DFTerminal ( termname ) <EOL> if isinstance ( tree , DFUndefined ) : return DFTerminal ( termname ) <EOL> if isinstance ( tree , DFConstant ) : return tree <EOL> if isinstance ( tree , DFEvalValue ) : return tree <EOL> if isinstance ( tree , DFTerminal ) : return tree <EOL> if isinstance ( tree , DFBranch ) : <EOL> condnode = replaceUndefined ( tree . condnode , termname ) <EOL> truenode = replaceUndefined ( tree . truenode , termname ) <EOL> falsenode = replaceUndefined ( tree . falsenode , termname ) <EOL> return DFBranch ( condnode , truenode , falsenode ) <EOL> if isinstance ( tree , DFOperator ) : <EOL> nextnodes = [ ] <EOL> for n in tree . nextnodes : <EOL> nextnodes . append ( replaceUndefined ( n , termname ) ) <EOL> return DFOperator ( tuple ( nextnodes ) , tree . operator ) <EOL> if isinstance ( tree , DFPartselect ) : <EOL> msb = replaceUndefined ( tree . msb , termname ) <EOL> lsb = replaceUndefined ( tree . lsb , termname ) <EOL> var = replaceUndefined ( tree . var , termname ) <EOL> return DFPartselect ( var , msb , lsb ) <EOL> if isinstance ( tree , DFPointer ) : <EOL> ptr = replaceUndefined ( tree . ptr , termname ) <EOL> var = replaceUndefined ( tree . var , termname ) <EOL> return DFPointer ( var , ptr ) <EOL> if isinstance ( tree , DFConcat ) : <EOL> nextnodes = [ ] <EOL> for n in tree . nextnodes : <EOL> nextnodes . append ( replaceUndefined ( n , termname ) ) <EOL> return DFConcat ( tuple ( nextnodes ) ) <EOL> raise DefinitionError ( '<STR_LIT>' % ( str ( type ( tree ) ) , str ( tree ) ) ) </s>
