Skip to content

Commit

Permalink
Merge pull request #154 from leonardt/no-mixin
Browse files Browse the repository at this point in the history
Remove use of mixin bv methods
  • Loading branch information
cdonovick authored Aug 30, 2023
2 parents 3afb9f0 + 15d97e5 commit c01fc3a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
25 changes: 20 additions & 5 deletions hwtypes/bit_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,22 @@ def bvcomp(self, other):
def bveq(self, other):
return self.get_family().Bit(self.as_uint() == other.as_uint())

@bv_cast
def bvne(self, other):
return self.get_family().Bit(self.as_uint() != other.as_uint())

@bv_cast
def bvuge(self, other):
return self.get_family().Bit(self.as_uint() >= other.as_uint())

@bv_cast
def bvugt(self, other):
return self.get_family().Bit(self.as_uint() > other.as_uint())

@bv_cast
def bvule(self, other):
return self.get_family().Bit(self.as_uint() <= other.as_uint())

@bv_cast
def bvult(self, other):
return self.get_family().Bit(self.as_uint() < other.as_uint())
Expand All @@ -322,7 +338,6 @@ def bvslt(self, other):
def bvneg(self):
return type(self)(~self.as_uint() + 1)


def adc(self, other : 'BitVector', carry : Bit) -> tp.Tuple['BitVector', Bit]:
"""
add with carry
Expand Down Expand Up @@ -419,10 +434,10 @@ def __neg__(self): return self.bvneg()
__rmod__ = dispatch_roper(__mod__)

__eq__ = dispatch_oper(bveq)
__ne__ = dispatch_oper(AbstractBitVector.bvne)
__ge__ = dispatch_oper(AbstractBitVector.bvuge)
__gt__ = dispatch_oper(AbstractBitVector.bvugt)
__le__ = dispatch_oper(AbstractBitVector.bvule)
__ne__ = dispatch_oper(bvne)
__ge__ = dispatch_oper(bvuge)
__gt__ = dispatch_oper(bvugt)
__le__ = dispatch_oper(bvule)
__lt__ = dispatch_oper(bvult)

def as_uint(self):
Expand Down
8 changes: 4 additions & 4 deletions hwtypes/smt_bit_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,10 +552,10 @@ def __neg__(self): return self.bvneg()
__rmod__ = dispatch_roper(__mod__)

__eq__ = dispatch_oper(bveq)
__ne__ = dispatch_oper(AbstractBitVector.bvne)
__ge__ = dispatch_oper(AbstractBitVector.bvuge)
__gt__ = dispatch_oper(AbstractBitVector.bvugt)
__le__ = dispatch_oper(AbstractBitVector.bvule)
__ne__ = dispatch_oper(bvne)
__ge__ = dispatch_oper(bvuge)
__gt__ = dispatch_oper(bvugt)
__le__ = dispatch_oper(bvule)
__lt__ = dispatch_oper(bvult)

@int_cast
Expand Down

0 comments on commit c01fc3a

Please sign in to comment.