def _(left, right): check_connect_dir(left, right) # TODO: Accurate Error Message assert left.hcl_type.size == right.hcl_type.size for i in range(left.hcl_type.size): op_apply('<<=')(left[i], right[i]) return left
def _(left, right): msg = 'connect(): connecting SInt to UInt, an auto-conversion will occur' logging.warning(msg) if left.hcl_type.width < right.hcl_type.width: logging.warning( 'connect(): connecting {} to {} will truncate the bits'.format( right.hcl_type, left.hcl_type)) return op_apply('<<=')(left, right[left.hcl_type.width - 1:0]) return op_apply('<<=')(left, right.to_uint())
def _(self, item): start = item.start if item.start is not None else 0 if item.step is None: if item.stop is not None: return op_apply('[i:j]')(self, start, item.stop) if item.stop is None: return op_apply('[i:]')(self, start) if item.stop is not None: return op_apply('[i:j:k]')(self, start, item.stop, item.step) if item.stop is None: return op_apply('[i::k]')(self, start, item.step)
def _(left, right): check_connect_dir(left, right) if left.hcl_type.width < right.hcl_type.width: logging.warning( 'connect(): connecting {} to {} will truncate the bits'.format( right.hcl_type, left.hcl_type)) right = right[left.hcl_type.width - 1:0].to_sint() if left.hcl_type.width > right.hcl_type.width: right = op_apply('extend')(right, left.hcl_type.width) assert left.hcl_type.width == right.hcl_type.width StatementTrapper.track(Connect(left, right)) return left
def _(left, right): check_connect_dir(left, right) # TODO: Accurate Error Message dir_and_types = right.hcl_type.fields keys = dir_and_types.keys() assert keys == left.hcl_type.fields.keys() for k in keys: lf = op_apply('.')(left, k) rt = op_apply('.')(right, k) if dir_and_types[k]['dir'] == Dir.SRC: op_apply('<<=')(lf, rt) else: op_apply('<<=')(rt, lf) return left
def to_bool(self): return op_apply('to_bool')(self)
def to_sint(self): return op_apply('to_sint')(self)
def _(self, item): return op_apply('[i]')(self, item)
def __getattr__(self, item): return op_apply('.')(self, item)
def __xor__(self, other): return op_apply('^')(self, other)
def __or__(self, other): return op_apply('|')(self, other)
def __and__(self, other): return op_apply('&')(self, other)
def __add__(self, other): return op_apply('+')(self, other)
def __ilshift__(self, other): return op_apply('<<=')(self, other)