示例#1
0
 def _tf(ref):
     if isinstance(ref.typ, low_ir.UIntType):
         return [ref], ref.typ
     elif isinstance(ref.typ, low_ir.SIntType):
         return [ref], low_ir.UIntType(ref.typ.width)
     else:
         Exception("need sint type")
示例#2
0
 def _mapToIR(_, __=None):
     # If caller is UInt Type, it would call `mapToIR(ctx)`
     # Or caller is UInt Literal, it would call `mapToIR(literal, ctx)`
     if __ is not None:
         return low_ir.UIntLiteral(_.v, U._lowWidth(width))
     else:
         return low_ir.UIntType(U._lowWidth(width))
示例#3
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(
             _pickWidth(lref.typ.width, rref.typ.width, uintWidthFunc))
     else:
         raise Exception("need uint types")
示例#4
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")
示例#5
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")
示例#6
0
 def _dshltf(lref, rref):
     if isinstance(lref.typ, low_ir.UIntType) and isinstance(
             rref.typ, low_ir.UIntType):
         return [lref, rref], low_ir.UIntType(
             _pickWidth(lref.typ.width, rref.typ.width, lambda x, y: x +
                        (1 << y) - 1))
     elif isinstance(lref.typ, low_ir.SIntType) and isinstance(
             rref.typ, low_ir.UIntType):
         return [lref, rref], low_ir.SIntType(
             _pickWidth(lref.typ.width, rref.typ.width, lambda x, y: x +
                        (1 << y) - 1))
     else:
         raise Exception(
             "lhs needs uint type or sint type, rhs needs uint type")
示例#7
0
 def getReset(self):
     return low_ir.Reference("reset", low_ir.UIntType(low_ir.IntWidth(1)))