Describe the bug
While not part of the spec, Most of the tools (or at least the 2 that I have checked), treat preprocessor defines that were defined by the command line args (-define or +define+<NAME>=<val>) to be "stronger" than those defined within Verilog files.
To Reproduce
`define N 1
module t;
generate
$info("%d", `N);
endgenerate
endmodule
Call this with:
slang +define+N=2 t.v
And you would get:
Top level design units:
t
t2.v:4:3: note: $info encountered: 1
$info("%d", `N);
^
Build succeeded: 0 errors, 0 warnings
Run the equivalent code on one tool and you would get:
...
Elaborating the design hierarchy:
Top level design units:
t
2
$info("%d", `N);
...
Another tool yields:
# KERNEL: Info: testbench.sv (6): 2
Additional context
You may consider this behavior to be optional (using a new flag), if you think changing this would break past usage of slang, in the same way you do with --single-unit, which as I have just noticed, conforms the IEEE spec to the letter (3.12.1):
The exact mechanism for defining which files constitute a compilation unit is tool-specific. However, compliant tools shall provide use models that allow both of the following cases:a) All files on a given compilation command line make a single compilation unit (in which case the declarations within those files are accessible following normal visibility rules throughout the entire set of files).b) Each file is a separate compilation unit (in which case the declarations in each compilation-unit scope are accessible only within its
corresponding file).
Describe the bug While not part of the spec, Most of the tools (or at least the 2 that I have checked), treat preprocessor defines that were defined by the command line args (-define or
+define+<NAME>=<val>
) to be "stronger" than those defined within Verilog files.To Reproduce
Call this with:
slang +define+N=2 t.v
And you would get:
Run the equivalent code on one tool and you would get:
Another tool yields:
Additional context You may consider this behavior to be optional (using a new flag), if you think changing this would break past usage of slang, in the same way you do with
--single-unit
, which as I have just noticed, conforms the IEEE spec to the letter (3.12.1):The exact mechanism for defining which files constitute a compilation unit is tool-specific. However, compliant tools shall provide use models that allow both of the following cases: a) All files on a given compilation command line make a single compilation unit (in which case the declarations within those files are accessible following normal visibility rules throughout the entire set of files). b) Each file is a separate compilation unit (in which case the declarations in each compilation-unit scope are accessible only within its corresponding file).