If you have ever moved a verification environment to another simulator, you have probably run into this: code that worked fine in Synopsys VCS does not even compile in Cadence Xcelium.
Usually neither tool is simply wrong. It happens because VCS accepts a little more than the standard (LRM) allows, while Xcelium checks more strictly. This post covers three cases I actually ran into, what the standard says about each, and how to catch these problems early.
Test environment: VCS U-2023.03-SP2, Xcelium 23.03
1. Using a keyword as an argument name: context
Say you wrote a task for printing logs like this.
task automatic dpi_print_log(input string context);
`uvm_info("LOG_API", $sformatf("%s", context), UVM_LOW)
endtask
VCS accepts it without a single warning. Xcelium, however, gives this error.
xmvlog: *E,FNDKWD (.../my_dpi_pkg.sv,269|52): A SystemVerilog keyword was found where an identifier was expected.
That is because context is a SystemVerilog keyword, the same one used in DPI as in import "DPI-C" context function .... VCS treats it as an identifier from the context and lets it go, but by the standard it cannot be used as an identifier.
Fix
Just rename it.
task automatic dpi_print_log(input string ctx);
`uvm_info("LOG_API", $sformatf("%s", ctx), UVM_LOW)
endtask
Keywords that are easy to use as names
These keywords look like ordinary English words, so it is easy to use them as variable names without thinking. The full list is in Annex B of IEEE 1800.
| Keyword | Original use |
|---|---|
context |
DPI import property |
type |
Type operator, type parameters |
config |
Configuration blocks |
sequence, property |
SVA |
clocking |
Clocking blocks |
bins, cover, cross |
Coverage |
local, protected, static |
Class qualifiers |
unique, priority |
case/if qualifiers |
2. Using `" outside a macro definition
`" is the syntax that turns a macro argument into a string (stringify) inside a macro. What happens if you use it directly outside a macro definition?
parameter string IMAGENAME = `"`BIN_PATH`";
`uvm_info("rx_check",
$sformatf("Check %s = %0h", `"`VIP_BFM_PATH.event_rx_rejected`", is_rejected),
UVM_LOW)
VCS accepts it, but Xcelium rejects it like this.
xmvlog: *E,UMINQT (...): Usage of `" outside of a macro definition is not LRM compliant.
Just as the error says, the standard allows `" only inside a macro definition.

`" stringification only has meaning when the preprocessor expands a macro body. In ordinary code, VCS accepts it but Xcelium rejects it, as the standard says.Special macro syntax defined by the standard (LRM)
Section 22.5.1 `define of IEEE 1800-2017 defines three special forms that can be used only inside a macro body.
| Syntax | Meaning | Example |
|---|---|---|
`" |
Start and end of a string literal; macro arguments inside are substituted | `define STR(x) `"x`" → `STR(abc) = "abc" |
`\`" |
Puts an escaped quote \" into the expansion |
When you need a quote inside a string |
`` |
Joins the tokens before and after with no space | `define CAT(a,b) a``b → `CAT(clk,_en) = clk_en |
All three are defined only inside a macro body. Using them in ordinary code violates the standard.
Fix
Wrap the stringifying part in its own `define and use that macro.
`define IMAGENAME_DEF `"`BIN_PATH`"
parameter string IMAGENAME = `IMAGENAME_DEF;
`define VIP_RX_REJECTED_EVENT `"`VIP_BFM_PATH.event_rx_rejected`"
`uvm_info("rx_check",
$sformatf("Check %s = %0h", `VIP_RX_REJECTED_EVENT, is_rejected),
UVM_LOW)
This form works without problems in both VCS and Xcelium.
3. Stringifying nested macros: the two simulators behave differently
This is the trickiest case. If you nest macros that take arguments and then stringify the result, the two simulators give completely different results.
`define FIRST Bits
`define SECOND Bites
`define JOIN_ME(__a,__b) __a``__b
`define JOINED `JOIN_ME(`FIRST, `SECOND)
`define JOINED_STR1 `"`JOINED`"
`define JOINED_STR2 `JOINED
`define SUB_INST i_sub_a
`define SUB_INST_TRIG `"`SUB_INST.a_trig`"
module sub_a ();
event a_trig;
initial begin
#5;
-> a_trig;
end
endmodule
module macro_test ();
sub_a i_sub_a ();
initial begin
#1;
$display("JOINED_STR1 : %s", `JOINED_STR1);
$display("Trigger Name : %s", `SUB_INST_TRIG);
fork
begin
@(`SUB_INST.a_trig)
$display($time, "\t Event Triggered!!");
end
join
end
endmodule
Here are the results of writing the same expression in several ways and running each in both simulators.
| Expression | VCS | Xcelium |
|---|---|---|
`"`JOINED`" used directly in code |
✅ BitsBites |
❌ error (UMINQT) |
`JOINED_STR1 (stringified inside a macro) |
⚠️ compiles, but prints `JOIN_ME(Bits, Bites) literally |
✅ BitsBites |
`JOINED_STR2 used where a string is expected |
❌ error | ❌ error |
`"`JOINED_STR2`" |
✅ BitsBites |
❌ error |
`"`SUB_INST.a_trig`" |
✅ i_sub_a.a_trig |
❌ error |
`SUB_INST_TRIG |
✅ i_sub_a.a_trig |
✅ i_sub_a.a_trig |
@(`SUB_INST.a_trig) |
✅ event detected | ✅ event detected |
@(`SUB_INST_TRIG) |
⚠️ compiles but never detects the event | ⚠️ same |
A few things stand out.
- **Stringifying a macro without arguments inside a
`define** (`SUB_INST_TRIG) gives the same result in both tools. - Nesting macros with arguments and then stringifying gives different results per tool, and in VCS in particular it produces a bug where the wrong string goes in without any error. That is more dangerous than a compile error.
- A stringified name is only ever a string. If you put it where an event belongs, as in
@(`SUB_INST_TRIG), it may compile but it does not wait for the real event. To refer to an event or signal, use the hierarchical path without stringifying it (`SUB_INST.a_trig).
Why do the tools differ?
The standard's description does not clearly settle the order in which nested macros are expanded in every case. Implementations differ on details such as whether `JOINED inside `" is expanded first and then stringified, or stringified first and expanded later. The community has discussed this exact issue as "which simulator interprets it correctly", and the macro expansion algorithm has come up several times on the standards committee (sv-bc) mailing list. (Verification Academy forum)
In the end, steering clear of areas where the standard is vague is the safest choice.
A safe alternative
If you need to turn something built from macros with arguments into a string, assemble the string at run time instead of in the preprocessor.
parameter string FIRST = "Bits";
parameter string SECOND = "Bites";
string joined = {FIRST, SECOND}; // string concatenation operator
// or
string joined2 = $sformatf("%s%s", FIRST, SECOND);
The result is the same in both simulators, and the value is visible as-is when debugging, which is much more convenient.
4. How do you catch these problems early?
If you hit all of these at once when you actually switch simulators, there is a lot to fix. Doing two things routinely helps.
Check once more with a parser that follows the standard strictly
Some open-source tools include parsers that follow the LRM strictly. You can use them as a quick pass before running a commercial simulator.
# slang: SystemVerilog compiler/language services. Reports parsing and elaboration errors
slang top.sv my_pkg.sv
# Verilator: lint only
verilator --lint-only -Wall top.sv
Neither tool supports exactly the same feature set as the commercial simulators. Large verification libraries such as UVM in particular may be hard to get through, so it is best to start with the RTL and shared packages.
Add a CI stage that compiles with both simulators

You do not need to run the simulation twice. Checking that compilation and elaboration pass in both tools filters out most portability problems.
Summary: staying safe in both simulators
- Do not use keywords as identifiers. Even if VCS accepts it, other tools will report an error.
- Use
`",`\`"and``only inside a`definebody. If you need a string, create one more dedicated macro. - Avoid nesting macros with arguments and then stringifying them. If you really must, assemble the string at run time with
{}concatenation or$sformatf. - Do not use stringified paths to refer to events or signals.
- Put a strict LRM parser + compilation in both simulators into CI.
Code a tool lets slide is convenient for now, but the cost comes back when you port. Writing code against the standard (LRM) is the best prevention.
Further reading
- 22 SystemVerilog coding guidelines for synthesis, and why
- Learning RTL coding by rewriting Verilog in SystemVerilog
- IEEE Std 1800-2017, Section 22.5.1
`define, Annex B list of keywords - Verification Academy – Which simulator is correctly interpreting these nested macros?
- slang – SystemVerilog compiler and language services
Verification (8 posts)
- Verilog Testbenches: From Writing One to Waveform Debugging
- Getting Started with UVM: Structure, Phases, a Minimal Example and Verdi Debugging
- Functional Coverage in Practice: How to Write a covergroup
- Random Numbers for Verification Engineers: PRNGs and Random Stability
- Designing Verification Logs and Error Messages: Levels, Severity and Message IDs
- 3 SystemVerilog Portability Traps: VCS vs Xcelium Reading now
- Measuring AXI Bus Throughput Automatically from FSDB Waveforms
- Seeing Gate Shapes in Verdi Netlist Schematics
Leave a Reply