Re: Setting of enum values

Marcel Hellwig <[email protected]> Fri, 22 Jan 2016 19:39:29 +0100
Newsgroups gmane.comp.python.myhdl
Message-ID <[email protected]>
On 20.01.2016 23:11, Marcel Hellwig wrote:
> 
> Now, myhdl tells me:
> 
>> > myhdl.ConversionError: in file xxx.py, line 63:
>> >     Unsupported attribute: User
> line 63:
>> > if mode == CpuMode.User:


I finally found out, why this happens.
Because I don't like to write the same code twice, I outsourced the
if/elif section into a seperate function.

> def getRegisterbank(mode):
>     if mode == ProcMode.User or mode == ProcMode.System:
>         return 0
>     elif mode == ProcMode.Supervisor:
>         return 1
>     elif mode == ProcMode.Abort:
>         return 2
>     elif mode == ProcMode.IRQ:
>         return 4
>     elif mode == ProcMode.FIQ:
>         return 5
>     else:
>         return 3
> 
> @always_seq(clk.posedge, reset=reset)
> def write():
>     if we:
>         mul = 0
>         if mode == ProcMode.User or mode == ProcMode.System:
>             mul = 0
>         # ...
>         else:
>             mul = 3
>         # mul = getRegisterbank(mode)
>         re = regbank[mul*18 + rd]
>         regs[re].next = din
> 
> @always_comb
> def read():
>     # mul = getRegisterbank(mode)
>     mul = 0
>     re = regbank[mul*18 + rs]
>     sout.next = regs[re]
> 
> return write, read


And here is the problem. When I write it directly in the write/read
methods, everything works fine, but as soon as I call the
getRegisterbank function, it will complain about unsupported Attribute.
Is there a way around this? :/

------------------------------------------------------------------------------
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

iQIcBAEBCgAGBQJWondhAAoJEIROXYQnkAHpKCUQALYhSOnUCdBvywU3CKbccMiL
Ygv4LTFOW9m/Zx8Zg+ZDOb4ij9khjErHRdgNmOUH6BepajtzcrWdOzg6G1GpYp7Z
lF2KqDlPPPblJYTTT36fOW4r59UGZF2eY7ri56qXqD+cwbsuos5Hn/xVvZBXwg4Z
VA96MJBYYUUWzw9lspM++UYvHt8E7ysK5eKKU6RXPnBYs2ZiU9S8nPKCkiVqrad4
lf8/a2uZGvOlz1E77D4SbcYJ/IKkcuKWZFQMWaMHVuNZsg6VpHaRTFPEmpohLEhs
Q6tu2rl+kWN5orvJ7LgsmM8n3cjG2XIjVPacfWOTru94JVslabJtgMnqTjf78c22
c2jXkIoJ3/AM9E++1UAlRDrP01peXP/jv6VfjypF/V4aSzSwECExXD9HpFSpk9Hv
/8HzjntoYkjo9npproYmuLCPcuG2y8S4w86ekDx7Bb/5fVc2vEViTnsrIz+obrkD
ke/vQrmqvQaa0iqm2IP2LFEynKGG1G3uQI8DmAPDzUOZvs19lLF3RPe03X/j9A5z
03Vm1so+kxpEeqOdaP50JVM6W6IvetxoXoYiVmMgh0c8mkOxHKwFpWZIvg9LlP4H
g5AWER0Qcm/DYzg529sCCkeA64Mi2ADYC8OhsbsOfT8gY/MvtdhxudOr0Qhmf2ub
bWZWEqm6GDgf1koIBoBe
=wgIv
-----END PGP SIGNATURE-----