[myhdl-list] Restrictions for conversion
Brought to you by:
jandecaluwe
From: Oscar D. <osc...@gm...> - 2011-12-23 12:37:13
|
Hi I was doing some experiments with the conversion function, and I found a problem I'd like to discuss regarding access to members of data structures inside generators. Suppose you have a dict with some constants you need for the calculations: constants_list = {"myconst": 10} def trans_block(clk, din, dout, const_list): @always(clk.posedge) def proc(): dout.next = din + const_list["addconst"] return instances() conversion fails with: myhdl.ConversionError: in file simpletest.py, line 22: Object type is not supported in this context: const_list, <type 'dict'> Same occur if you have a list: myhdl.ConversionError: in file simpletest.py, line 22: Object type is not supported in this context: const_list, <type 'list'> Or, even if you use an object with members accessed as attributes, like this: dout.next = din + const_list.addconst conversion fails with: myhdl.ConversionError: in file simpletest.py, line 29: Unsupported attribute: addconst A workaround is to access data outside the generator, with another variable name: constants_list = {"myconst": 10} def trans_block(clk, din, dout, const_list): addconst = const_list["addconst"] @always(clk.posedge) def proc(): dout.next = din + addconst return instances() However, it's kind of annoying to do that when you have a lot of variables to access. Something similar occurs when you access signals. What are your thoughts? Is it good to allow access data members whatever way you want or is better to have a fixed coding style? By the way, I think these kind of details should be explained in the conversion documentation. Best regards -- Oscar Díaz Key Fingerprint = 904B 306C C3C2 7487 650B BFAC EDA2 B702 90E9 9964 gpg --keyserver subkeys.pgp.net --recv-keys 90E99964 I recommend using OpenDocument Format for daily use and exchange of documents. http://www.fsf.org/campaigns/opendocument |