Embedded Perl in `include is not expanded
peter-smith-wdc opened this issue · 1 comments
A statement like:
`include "<%=$ENV{SRC_INCLUDE}%>HEADER.rdl.h"
fails because the Perl code is not run before searching for HEADER.rdl.h
This example is derived from RDL that is processed successfully by a commercial tool (Agnisys) which suggests that that tool considers Interpretation 2 in the notes https://systemrdl-compiler.readthedocs.io/en/stable/dev_notes/preprocessors.html to be correct
My decision to go with "Interpretation 3" was based directly on a conversation I had with one of the SystemRDL standards committee members. Apparently this was somewhat a contentious issue in the committee discussions. Ultimately their recommendation was based on the behavior of the original Denali Blueprint tool (now owned by Cadence).
Interesting that Agnisys chose "Interpretation 2" since that would actually cause compile failures if they ran against some of the examples from Accellera. Then again, I've seen more than one example from Agnisys that breaks compatibility with the official spec.
I'll see what I can do to extend the preprocessor to handle this specific situation. I'm not a huge fan of augmenting includes like this, but I can see why it could be useful, especially if other commercial tools have conflicting limitations.
Regarding my comment about using the Perl preprocessor in include, there are generally better ways of accomplishing this that are less clunky:
- Simply use a relative path to the header file. The compiler will search relative to the enclosing source file.
- If a relative path is not desirable (your includes folder is far away in a common location), you should be able to specify an include search path to the compiler. I would expect that Agnisys would let you do something similar. This is how it could be done for this compiler by querying the same environment variable:
rdlc.compile_file("path/to/my_source.rdl", incl_search_paths=[os.getenv(SRC_INCLUDE)])
- Lastly, this compiler supports calling
compile_file()
multiple times which allows you to specify numerous RDL files. In my opinion, this is better since it does a better job of compartmentalizing compilation units. Not sure if Agnisys allows that.