Howto Lookup-Table

Marcel Hellwig <[email protected]> Thu, 21 Jan 2016 12:07:41 +0100
Newsgroups gmane.comp.python.myhdl
Message-ID <[email protected]>
Hello everyone,

for my current project I need some kind of lookup-table.
Setting:
    I have different CPU Modes and depending on the mode, I need to
access certain registerbanks (yeah, it's an arm-ripof)

My intentional idea was to create a dictionary where the keys are the
modes and the values are the register numbers, e.g.

>
> regbank = {
>     cpumode_User : (R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11,
> R12, R13, R14, PC, CPSR),
>     ..... }
>
> registers = [Signal(intbv(0)[32:]) for _ in range(37)]


and then access them via registers[regbank[mode][rd]] whereas mode is
the mode (just an Signal(int)) and rd is the destionation register. R0,
R1, ... etc are ints as well

This leads to:
> Object type is not supported in this context: regbank, <type 'dict'>

Okay, I thought, then I will just outsource the tuples to variables and
make a "big" if/elif switch-case. But that don't work either :/

> AssertionError: var MYHDL2_getRegisterbank has unexpected type <class
> 'myhdl.conversion._analyze._Rom'>
or
> Object type is not supported in this context: USER, <type 'tuple'>


This is frustrating and I don't know why, because ROM works with tuples
too. So, what kind of mistake I am doing here?

My idea would also to add a section in the examples for a LUT, because I
think that is something you use from time to time.

Thanks in advance,
Marcel


Ps. here is a gist for a better overview
https://gist.github.com/punkkeks/d09e26f67d15cd2caf6a

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

iQIcBAEBCgAGBQJWoLv9AAoJEIROXYQnkAHp1M0P/jb2Tj5uxe7u8ziXjoxjAQlQ
tAsF+RAgxRdxRdBZVqN0WrT1T6rC2LG2p+0/qp65F+mv4NgA3GH/jzygOH/O3q4w
oE4Svy+QR2QrDGjRYI8Kbd6AiyliBMBT/eO47+1akaIPpKbRJOMB8lXFfkJzjZ97
ZP3oTVGp+gCFsqYPc9W2h168TC8kg0Fvx61n0XzOI4guIPR5Cr4YGVdbXtGYWQbq
Ws3AjBWrkldBiwThfxj+y4PPDkkpS1kdor23Jcux9HbJ2/Mb0W/F8ehvbQjhjjJf
Owc3u7SC90fqyAEHq+DBPLsKLsCuCKBbU9ru2ADY61WdfTJ37JIf7vqj4szvSf25
UIkb3WOciA1UMu6y6A1G/y2cdLhp0++JlJ08FEA1X4I5+O2ZyVwicXFTVtWevD4N
sS+OuCMlc/Nau1s3JAOftqHM0oDQorF4f4yxa0C47JvBK3YihUURqHrpUwjxnd1v
fvA3ETCbiqdrrOK077R50Yzr3vLXK83Vu97PolXt2r1xg3PYYVPq2Ovpp2pRBGSz
STOphIvYc08XqknYlbChP71OhZ+JduNM8RwVZ8sP2l2w0xUAfbbJriLdi9nM6kA1
aa0N6CEtl3s7zxyk0FHiTY9ut+7UnYzY7FweUmiAFxN5xaYP1NZp+aR/Bo5uPzkc
/RxAOSXG0cR8CuWRRlew
=GwYY
-----END PGP SIGNATURE-----