Skip to content

[BUG] Verilog preprocessor, ifdef around include statement #223

Closed
@Risto97

Description

@Risto97

Describe the bug

In the following code:

`ifdef SOME_MACRO
`include "inc.rdl"
`endif

addrmap test {
  reg {
    field {
    hw = rw; sw =rw;
    }f1 [`RANDOM] = 0;
  } reg1;
};

I want to include inc.rdl only if SOME_MACRO is defined.
However this doesn't work, as the PerlPreprocessor runs before VerilogPreprocess and expands include directives without considering ifdef, if, else, ... directives.

# Run file through Perl preprocessor
ppp = PerlPreprocessor(env, path, search_paths)
preprocessed_text, seg_map = ppp.preprocess()
included_files = ppp.included_files
# ... then through the Verilog preprocessor
vpp = VerilogPreprocessor(env, preprocessed_text, seg_map, defines=defines)
preprocessed_text, seg_map = vpp.preprocess()

Expected behavior
I expect PerlPreprocessor to ignore include directives if they are surrounded by ifdef which should disable it.

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions