def _tf(lref, rref): if isinstance(lref.typ, low_ir.UIntType) and isinstance( rref.typ, low_ir.UIntType): return [lref, rref], low_ir.UIntType(low_ir.IntWidth(1)) elif isinstance(lref.typ, low_ir.SIntType) and isinstance( rref.typ, low_ir.SIntType): return [lref, rref], low_ir.SIntType(low_ir.IntWidth(1)) else: raise Exception("need uint types or sint types")
def _shrtf(lref, n): if isinstance(lref.typ, low_ir.UIntType): return [lref], low_ir.UIntType( _pickWidth(lref.typ.width, low_ir.IntWidth(n), lambda x, y: x - y)) elif isinstance(lref.typ, low_ir.SIntType): return [lref], low_ir.SIntType( _pickWidth(lref.typ.width, low_ir.IntWidth(n), lambda x, y: x - y)) else: raise Exception("need uint type or sint type")
def _pickWidth(l, r, func): if l.width is None: return r elif r.width is None: return l else: return low_ir.IntWidth(func(l.width, r.width))
def _lowWidth(width: Optional[int] = None): return low_ir.IntWidth(width) if width is not None else None
def getReset(self): return low_ir.Reference("reset", low_ir.UIntType(low_ir.IntWidth(1)))