Issue #532
Support +systemverilogext+
| Status: | Closed | Start date: | 07/19/2012 | |
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assignee: | Jeremy Bennett | % Done: | 0% |
|
| Category: | Unsupported | |||
| Target version: | - |
Description
VCS provides an option, +systemverilogext+, to specify that a particular file extension is associated with SystemVerilog source code. This is particularly useful when mixing new SystemVerilog code with legacy Verilog code, which uses variables that are keywords in SystemVerilog.
This should be relatively straightforward to implement, since Verilator already enforces language type by inserting begin_keywords into the lexer's token stream. This just has to be made dependent on any extensions specified.
+verilogext++1364-1995ext++1364-2001ext++1364-2001ext++1364-2005ext++1800-2005ext++VAMS-2.3ext++1800+VAMSext+
I'm happy to implement this, as soon as I have finished my current work on COMBDLY.
History
Updated by Wilson Snyder 10 months ago
- Status changed from New to Assigned
Makes sense. FYI VCS supports
systemverilogext<ext> verilog1995ext<ext> verilog2001ext<ext>
So I'd suggest that set.
Updated by Jeremy Bennett 7 months ago
I have created a patch for this. It adds the following:
- 1364-1995ext<ext>
- 1364-2001ext<ext>
- 1364-2001ext<ext>
- 1364-2005ext<ext>
- 1800-2005ext<ext>
- systemverilogext<ext>
- verilog1995ext<ext>
- verilog2001ext<ext>
Please pull the patch from branch langext at https://github.com/jeremybennett/verilator.
I have added a new option --default-language as a synonym for --language, which I suggest should now be deprecated. I have corrected the list of permitted languages that may be passed to --language as an option.
Updated by Wilson Snyder 7 months ago
Does another simulator support -default-language, or is the rename just for making it more obvious? I use --language in a bunch of other tools, so while perhaps not the best name want it to remain. We could retain both I suppose (not mark --language deprecated.)
Also are you using the language() in the FileLine? It might be the right spot (you found my comment to that :) but it is an expensive place to store it if it will not be used since there's one structure for each line of source (potentially millions.) If it is going to now be there, then you need to update the constructor, copy and compare methods etc to also look at that new member.
Updated by Jeremy Bennett 6 months ago
I only changed to --default-language, because I thought it was less confusing. I've reworded, so it is just an alternative to --language.
Good point about the space implications. Since language is associated with a filename, I've added it as a new table in FileLineSingleton. The constructor sets an appropriate default. This avoids the space issue. There are no regression failures.
Please pull the patch from branch langext at https://github.com/jeremybennett/verilator.
Updated by Jeremy Bennett 6 months ago
Hold fire on this patch. I realize it doesn't quite work properly. In parseFile() am associating the language with the initial fileline (where the file is being opened from), not the modfilename that is being opened.
New patch shortly...
Updated by Wilson Snyder 6 months ago
Note also at present it's legal to change the language between modules within one filename.
Updated by Jeremy Bennett 6 months ago
Fault corrected. All regression tests pass.
The language from which tokens are recognized can be changed within a filename, by using `begin_keywords. This still works, since it uses the scanner (verilog.l) in the same way as before. However the semantics of the language being recognized are not changed by `begin_keywords (IEEE 1800-2009 section 22.14 "...The directives do not affect the semantics, tokens, and other aspects of the SystemVerilog language...".
The --language/--default-language and the various <language>ext options define the language semantics being followed, and this is stored on a per-filename basis. I believe this is the same for other simulators. If a source file is used twice, with an intervening <language>ext option, the semantics used would change, and potentially cause a problem. The only way to avoid this is to put the language in the FileLine, rather than FileLineSingleton, with the consequent increase in AST size. However I believe this mode of operation is so unlikely as to be not worth worrying about.
Strictly speaking `begin_keywords is a SystemVerilog construct, but it is helpful to allow it in Verilog source code as well.
Please pull the corrected patch from branch langext at https://github.com/jeremybennett/verilator.
Updated by Wilson Snyder 6 months ago
- Status changed from Assigned to Resolved
Pushed to git towards 3.843.
Only minor changes; most notably put the code in V3LangCode.cpp back into V3Options.cpp because each additional object adds to the overall compile time noticeably, and it was too small of a C file to be worth that overhead. (Compiling all of the headers takes most the time.)
Nice testing by the way.
Also available in: Atom
![[logo]](/img/veripool_small.png)