From 16648471303428c62f996d463ec3f94e911f7a5d Mon Sep 17 00:00:00 2001 From: Keerthan Jaic Date: Tue, 21 Jul 2015 17:51:36 -0400 Subject: [PATCH] add __int__ magic method to EnumType --- myhdl/_enum.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/myhdl/_enum.py b/myhdl/_enum.py index 81293f5b..b8f580e0 100644 --- a/myhdl/_enum.py +++ b/myhdl/_enum.py @@ -85,6 +85,9 @@ def enum(*names, **kwargs): __str__ = __repr__ + def __int__(self): + return int(self._val, 2) + def __hex__(self): return hex(int(self._val, 2))