Re: Setting of enum values

Marcel Hellwig <[email protected]> Thu, 21 Jan 2016 18:19:35 +0100
Newsgroups gmane.comp.python.myhdl
Message-ID <[email protected]>
On 21.01.2016 17:34, Christopher Felton wrote:
> 
>      from myhdl import *
> 
>      class MyConstants(object):
>          def __init__(self):
>              self.const1 = int(intbv("1111_0001"))
>              self.const2 = int(intbv("1010_0101"))

why the intbv -> int conversion here? Just for using bitwise representation?

> 
>      def const_select(sel, x):
>          const = MyConstants()
> 
>          @always_comb
>          def beh_select():
>              if sel == 1:
>                  x.next = const.const1
>              elif sel == 2:
>                  x.next = const.const2
>              else:
>                  x.next = 0
> 
>          return beh_select
> 


Although I can reproduce your example in some test-cases, I can't use it
in my project...

I use two approaches here. First is to create a instance of the class in
the __init__.py. Then I will get a

> Local variable may be referenced before assignment: ProcMode

When I create the instance directly in my myhdl-method, I will get

> Free variable should be a Signal or an int: ProcMode


The advantage of having the enum over, that you can use it directly in a
Signal, e.g.

> mode = Signal(ProcMode.User)

currently, it will complain about not havin the bitsize (I have set it
manually, which will work fine)

I'm not happy about the solutions yet, altough I really appreciate the
help I'm getting here (thanks!), but in my eyes, I just want to solve a
simple problem. Has never anyone encountered this and made some
thoughts? :/

------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140

_______________________________________________
myhdl-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/myhdl-list
signature.asc (application/pgp-signature, 819 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQIcBAEBCgAGBQJWoRMnAAoJEIROXYQnkAHpql4P/iokWOFji+L/7HhEpPTDlCT+
f6VJ7QET3z189IuUBtu/GFm0Jw/17m7LLBy8+P62Qr5ZZ8lKN3R/0xqKhQq5Tzuj
O/EkknzpKBnGX8l9Db0PbQcI/3TMR9ryJ9uYMAXzsFGYJltAjFVROBg+VIJSPalj
yYRbGiYJv9npcDrXrlCfQiIe/1lxdmJp37q+DYPH6AtyJiav5baX7W8dW8IhSO1+
eyWFe+ly7gIVZcbdaJa8UDxgSB0X1NUg0uaExoxTun5+mRtJzVY4KftbDbbMB3rw
nYH6ULezqkeHpK7jx+Af+3XgU0qTy6vH+PX3EfulpsBEapv4d95CIoR2wvM4cxFO
KLyXQJYh2XQ1zSzFr3A49GflE3z1XB/onxzyEeAKkPY6Ie/4i+B6byS5x+xJ216P
g1U1/Jzgxg5e7Cbr7RlT5IuEQlR4mLOqGwPI+g+pCSLNsoLgiBmQlXnhzWV5kFNU
nqKJuEsuodnuxF4Q+R9pbDNVfKlHKW/zvXEa1mXG/vJ5xTihsB3QeIRrnRms+wXV
Ri1bDjZFhzB2AI9Lly3/InSMRoIOGsapyGN/GhmyzpZx3bT9xUjW03BDvhO5Ph7u
MHPKSxVnYVxcUaMAhMgmr1mfEAY+0JmpAdH0OFIa/R23A5DzpwPHizJy9pd0DBpd
E0G1UIQXO6RM/iaxfOC3
=67Go
-----END PGP SIGNATURE-----