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

Add ability to not process some `ifdefs #426

Closed
veripoolbot opened this issue Dec 23, 2011 · 2 comments
Closed

Add ability to not process some `ifdefs #426

veripoolbot opened this issue Dec 23, 2011 · 2 comments
Labels
wontfix This will not be worked on

Comments

@veripoolbot
Copy link
Collaborator


Author Name: Chris Randall
Original Redmine Issue: 426 from https://www.veripool.org
Original Date: 2011-12-23


Hi:
I'm trying to write a tool that will pre-process a verilog file, but leave a particular set of ifdefs in the file, eg:.

module blah()

ifdef LEAVE_ME ... endif

ifdef PRE_PROCESS_ME .. endif

endmodule

I'd want the output to include the `ifdef LEAVE_ME line, but either include (or not) the PRE_PROCESS_ME -- I couldn't find a hook that would allow me to do in your modules -- could you point me in the correct direction, please?

I also want all includes and all defines expand -- but I suspect for maximum genericty we should consider the ability of not doing it for all of them.

Cheers.

@veripoolbot
Copy link
Collaborator Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2011-12-23T14:48:41Z


I moved this to under Verilog-Perl, as I presume your intent is to extend vppreproc. The same thing could be done with "verilator -E" but vppreproc seems the more extendable solution.

If I understand properly there would be a new "vppreproc --keep-ifdef FOO" where all references to "ifdef/ifndef/`elsif FOO" etc would remain in the output.

To implement this, working from the top down

  • make a test case in the t/ directory - this will obviously fail until implemented :) Be sure the test includes the elsif cases noted below.
  • add the option including documentation to vppreproc; the option would set opt_pp_flags->{keep_ifdef}{$NAME} = 1 for each passed option.
  • In Preproc.pm document the keep_ifdef, add a new function def_keep that tests that hash and returns true.
  • Plumb def_keep into the .h, .cpp, .xs similar to how def_value is done though
    def_keep can return a bool. (See also defExists)
  • In V3Preproc under 'case ps_DEFNAME_IFDEF:' you'd call defKeep() and if set
    buf= a string with "`ifdef "+ the define name to yyourtext, then return VP_TEXT; (i.e. return the text to print rather than do the ifdef)
  • ENDIF/ELSIF needs to know defKeep() was set for that level; remember defKeep in the VPreIfEntry structure. ELSIF is a bit complicated as you may need to convert it to a ifndef/ifdef (All the permutations of if REMOVING elsif REMOVING, if NOT_REMOVING elsif REMOVING, etc.)

Seems like a lot but shouldn't take too long as it's almost all plumbing.

Start with the git version, as I did a small refactoring to make this easier.

@veripoolbot
Copy link
Collaborator Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2013-05-30T00:35:59Z


Closing due to age - if you want to do this yourself we'll still take it.

@veripoolbot veripoolbot added the wontfix This will not be worked on label Mar 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

1 participant