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

Verilog preprocessor does not expand macros in argument #283

Closed
veripoolbot opened this issue Sep 16, 2010 · 5 comments
Closed

Verilog preprocessor does not expand macros in argument #283

veripoolbot opened this issue Sep 16, 2010 · 5 comments
Assignees

Comments

@veripoolbot
Copy link
Collaborator


Author Name: Usha Priyadharshini
Original Redmine Issue: 283 from https://www.veripool.org
Original Date: 2010-09-16
Original Assignee: Wilson Snyder (@wsnyder)


Hi,
I am trying to expand the following macro definition:

define FRAME_TYPE sonet define JOIN(__arg1, __arg2) __arg1``__arg2
define XACTION JOIN(`FRAME_TYPE, _frame)

`XACTION

I would expect the last XACTION call expanding to sonet_frame. However output of preprocessor shows FRAME_TYPE_frame. Parsing this in VCS produces the expected output: sonet_frame

As the macro is expanded, the arguments are fully expanded before the next expansion, I would expect the following steps:

XACTION JOIN(FRAME_TYPE, _frame) JOIN(cxtf, _frame)
cxtf``_frame
cxtf_frame

@veripoolbot
Copy link
Collaborator Author


Original Redmine Comment
Author Name: Usha Priyadharshini
Original Date: 2010-09-16T17:25:50Z


Updating since the code segment does not show up as expected:

Trying to expand the following macro definition:

`define FRAME_TYPE sonet 
`define JOIN(__arg1, __arg2) __arg1``__arg2 
`define XACTION `JOIN(`FRAME_TYPE, _frame)

`XACTION

I would expect the last XACTION call expanding to sonet_frame. However output of preprocessor shows FRAME_TYPE_frame. Parsing this in VCS produces the expected output: sonet_frame.

As the macro is expanded, the arguments are fully expanded before the next expansion, I would expect the following steps:

`XACTION 
`JOIN(`FRAME_TYPE, _frame)
`JOIN(sonet, _frame) 
sonet``_frame 
sonet_frame

@veripoolbot
Copy link
Collaborator Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2010-09-16T17:37:32Z


Unfortunately the specification doesn't clearly specify the order of expansion, so the results depends on the simulator.
I think you're interpretation makes more sense, but let me try more simulators to see what the majority believe.

@veripoolbot
Copy link
Collaborator Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2010-09-16T17:39:44Z


Misspoke above, the order of expansion is specified, just not when `` is done during expansion.

@veripoolbot
Copy link
Collaborator Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2010-09-20T19:20:34Z


First, I did some research, and only 3 of four simulators surveyed support this ordering. If you want to be maximally compliant, you may not want to do that.

However, majority rules. I further discovered that the majority believes:

`define QA_b qindirect
`define Q1 `QA``_b
//-> qindirect

`define QA a
//-> a_b

which is amazing, as I just wrote a paper that discovered a ton of odd stuff, but missed this!

Anyhow, fixed in git, for 3.303.

@veripoolbot
Copy link
Collaborator Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2010-09-20T19:32:18Z


In 3.303

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants