Support for constants in the system definition XML.
wzab opened this issue · 2 comments
It is desired, that the system definition XML should contain also the constants (e.g. the number of subblocks or size of register vectors). Those constants should be used in generated code and included in HDL and SW packages.
Now, when we have support for included XMLs, it is possible to define those constants even in a separate file.
So now we should only add a possibility to use those constants during parsing of XML.
It would require evauation of simple expressions. The question is also where we would like to allow using the expressions based on those constants. I can see the following reasonable use cases:
- Number of repetitions of the block or register
- Width of the bitfield
Now it seems, that we may simply use Python "eval" with our own "globals" and 'locals" dictionaries to calculate the value of the expression. It is not very safe, but we assume that the system definition is a "trusted" resource.
We may avoid using unsafe "eval" in Python by e.g. using "ast" module, as described here: https://stackoverflow.com/a/30516254/1735409
Constants in system definitions are supported after commit wzab/addr_gen_wb@e7dac6f