|
LCS-2016-61 |
|
7 |
|
v3 26-Jan-17, v4 18-Feb-17, v5 2-Mar-17, v6 9-Mar-17,v7 13-Apr-17 |
|
|
|
Peter Flake |
|
|
|
Conditional Compilation VHDL Preprocessor |
|
Provide conditional compilation mechanism |
conditional_analysis_block
) - ver 7
conditional_analysis_directive ::=
`if conditional_analysis_expression then
| `elsif conditional_analysis_expression then
| `else
| `end [ if ]
| `warning string_literal
| `error string_literal
conditional_analysis_block ::=
source_text { conditional_analysis_block }
| `warning string_literal { conditional_analysis_block }
| `error string_literal { conditional_analysis_block }
| `if conditional_analysis_expression then { conditional_analysis_block }
{`elsif conditional_analysis_expression then { conditional_analysis_block } }
[`else { conditional_analysis_block } ]
`end [ if ] { conditional_analysis_block }
conditional_analysis_expression ::=
conditional_analysis_relation
| conditional_analysis_relation { and conditional_analysis_relation }
| conditional_analysis_relation { or conditional_analysis_relation }
| conditional_analysis_relation { xor conditional_analysis_relation }
| conditioanl_analysis_relation { xnor conditional_analysis_relation }
conditional_analysis_relation ::=
( conditional_analysis_expression )
| not ( conditional_analysis_expression )
| conditional_analysis_identifier = string_literal
| conditional_analysis_identifier /= string_literal
| conditional_analysis_identifier < string_literal
| conditional_analysis_identifier <= string_literal
| conditional_analysis_identifier > string_literal
| conditional_analysis_identifier >= string_literal
VHDL_VERSION
TOOL_TYPE
TOOL_VENDOR
TOOL_NAME
TOOL_EDITION
TOOL_VERSION
"1987", "1993", "2000", "2002", "2008", etc.
"SIMULATION", "SYNTHESIS", "FORMAL"
'if VHDL_VERSION = "1987" constant VHDL_VERSION : string := "1987"; 'elsif VHDL_VERSION = "1993" constant VHDL_VERSION : string := "1993"; 'elsif ... 'end ifThe fixed set of compilation identifiers also precludes the most useful specification of user-defined identifiers. --
compilation_directive
misses the reference to conditional_compilation_block
.
2. The definition of compilation_directive
misses a then
to be consistent with the existing syntax. This would also allow comments after a compilation expression for documentation and also easier reading if a complex compilation expression is scattered across multiple lines.
3. The root of this preprocessor tree (which is of course compilation_directive
) should be explicitly named.
4. A definition of null
and source_text
is missing.
5. At the moment an `if
is considered everywhere, also in comments or in the middle of a VHDL statement. I prefer the C way. Preprocessor directives might be only preceded by spaces within a line.
6. For the tool version, I would detail the "chronological order" to something like: Given an older tool version OLD_VERSION and a newer tool version NEW_VERSION, the expression NEW_VERSION > OLD_VERSION should return TRUE.
-- compilation_directive
misses the reference to conditional_compilation_block
. And even more, the current BNF would allow to start with a `elsif
, or `else
or `end
instead of just `if
. Furthermore the if
after `endif
could not be optional, it my be part of the intended source text.
My view is, design units are analyzed as usual until the tool directive compilation_directive
is encountered. Then according to the conditions, one of the conditional_compilation_block=s may be included. This =conditional_compilation_block
may again include another tool directive. Thus, the BNFs should be:
conditional_analysis_directive ::=
`if conditional_analysis_expression conditional_analysis_block
{`elsif conditional_analysis_expression conditional_analysis_block}
[`else conditional_analysis_block]
`end
conditional_analysis_block ::=
null
| source_text
| conditional_analysis_directive
`elsif
, or `else
and `end
if conditional analysis directives are nested.
NOTE: The analyzer must parse the text of the design file until he founds the `end
of the outermost conditional analysis directives, before he can continue with the analysis of the design file. I suspect that the goal of this LCS can be only achieved by a separate pre-processing pass before analysis.
-- conditional_analysis_directive
really needed? It just duplicates snippets from the EBNF for conditional_analysis_block
. Additionally within the text after this latter EBNF, you will find "expression is TRUE" but "identifier is FALSE".
-- 'warning
to coexist with regular code within the same block.
--