Skip to content

Package assert_rpt_pkg is redefined in each translation unit that includes assertions.svh when using UVM #250

@michael-platzer

Description

@michael-platzer

The assertions.svh header file includes the following code snippet, which defines a package on-the-fly when the macro UVM is defined:

`ifdef UVM
// report assertion error with UVM if compiled
package assert_rpt_pkg;
import uvm_pkg::*;
`include "uvm_macros.svh"
function void assert_rpt(string msg);
`uvm_error("ASSERT FAILED", msg)
endfunction
endpackage
`endif

This works fine as long as this header is only included in one translation unit (repeated includes are avoided by the guard macros), but as soon as a second translation unit uses it as well, it leads to elaboration issues:

# ** Error (suppressible): ** while parsing file included at .bender/git/checkouts/common_cells-6e5a0419831bc5c6/src/exp_backoff.sv(23)
# ** at .bender/git/checkouts/common_cells-6e5a0419831bc5c6/include/common_cells/assertions.svh(14): (vlog-13389) Existing package 'assert_rpt_pkg' would be overwritten.

The most straight-forward resolution that I can think of, is to move these lines into a dedicated source file, call it assert_rpt_pkg.sv and add it to the design sources.

However, before proceeding with a PR, I would like to understand whether there is a particular rational behind the current solution that I am not aware of?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingquestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions