예제 #1
0
 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")
예제 #2
0
 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")
예제 #3
0
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))
예제 #4
0
 def _lowWidth(width: Optional[int] = None):
     return low_ir.IntWidth(width) if width is not None else None
예제 #5
0
 def getReset(self):
     return low_ir.Reference("reset", low_ir.UIntType(low_ir.IntWidth(1)))