Skip to content

Commit ed6c355

Browse files
committed
Add invert to Register
1 parent 41c9dce commit ed6c355

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

riscvmodel/types.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,11 @@ def __rshift__(self, other):
236236
raise TypeError("unsupported operand type for Register >>: {}".format(other.__class__))
237237
return new
238238

239+
def __invert__(self):
240+
new = Register(self.bits)
241+
new.set(self.value ^ self.mask)
242+
return new
243+
239244

240245
class RegisterFile(object):
241246
def __init__(self, num: int, bits: int, immutable: list = {}):

0 commit comments

Comments
 (0)