Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(preprocessor) define propagates across files #306

Closed
veripoolbot opened this issue Dec 2, 2010 · 2 comments
Closed

(preprocessor) define propagates across files #306

veripoolbot opened this issue Dec 2, 2010 · 2 comments
Assignees
Labels
area: parser Issue involves SystemVerilog parsing resolution: fixed Closed; fixed

Comments

@veripoolbot
Copy link
Contributor


Author Name: Pawel Jewstafjew
Original Redmine Issue: 306 from https://www.veripool.org
Original Date: 2010-12-02
Original Assignee: Wilson Snyder (@wsnyder)


Verilator version: 3.805 (and, at least 3.803)

preprocessor 'define should be cleared at the scope
instead it is still active is all the files loaded afterwards

For example, two modules are instantiated for top.v
mod_a i_a ();
mod_b i_b ();

in mod_a.v:
define MOD_A_DEF define MY_DEF A

in mod_b.v:
define MOD_B_DEF define MY_DEF B

ifdef MOD_A_DEF this should not be defined here !!! endif

Verilator output:
%Warning-REDEFMACRO: mod_b.v:6: Redefining existing define: MY_DEF, with different value: B
%Warning-REDEFMACRO: Use "/* verilator lint_off REDEFMACRO */" and lint_on around source to disable this message.
%Warning-REDEFMACRO: mod_a.v:13: Previous definition is here, with value: A
%Error: mod_b.v:8: Unsupported: SystemVerilog 2005 reserved word not implemented:
this
%Error: mod_b.v:8: syntax error, unexpected "not", expecting "IDENTIFIER"

<-- preprocessor definitions from mod_a.v are visible in mod_b.v

verilator invocation:
verilator -cc top.v

example files are attached

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2010-12-02T19:07:36Z


Are you comparing this against another simulator?

This is unfortunately the way it must work, it wouldn't have been my choice :) `defines have effect across the entire compilation unit, per spec, and many designs require that.

If you don't want this, use `undefineall at the end of your modules. I might be convinced to make each file on the command line a separate compilation unit, but you need to be sure this is what you really want, as few other tools support that so it might not make for a portable environment.

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Pawel Jewstafjew
Original Date: 2010-12-02T20:08:04Z


Thanks a lot for the explanation!

(the chip is simulated with ModelSim with VHDL on top level
and, most likely, defines are not propagated across language barrier)

Thanks,
Pawel

@veripoolbot veripoolbot added area: parser Issue involves SystemVerilog parsing resolution: fixed Closed; fixed labels Dec 22, 2019
kbieganski added a commit to antmicro/verilator that referenced this issue Dec 13, 2021
* Retrieve constant sizes from UHDM; create AstConsts instead of V3Numbers

* Enable ConstSizes test

* Fix unsized constants exceeding 64 bits

* Bump Surelog; handle Surelog's default constant size of 64 bits
tgorochowik pushed a commit to antmicro/verilator that referenced this issue Feb 29, 2024
* Retrieve constant sizes from UHDM; create AstConsts instead of V3Numbers

* Enable ConstSizes test

* Fix unsized constants exceeding 64 bits

* Bump Surelog; handle Surelog's default constant size of 64 bits
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: parser Issue involves SystemVerilog parsing resolution: fixed Closed; fixed
Projects
None yet
Development

No branches or pull requests

2 participants