From b6171a500028d618341ec1767d2e80fca5b9419b Mon Sep 17 00:00:00 2001 From: Michael Platzer Date: Tue, 8 Oct 2024 12:12:35 +0000 Subject: [PATCH 1/2] assertions: Undefine lowRISC macros if their presence is detected --- include/common_cells/assertions.svh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/include/common_cells/assertions.svh b/include/common_cells/assertions.svh index 8d6b2107..975e4fec 100644 --- a/include/common_cells/assertions.svh +++ b/include/common_cells/assertions.svh @@ -39,6 +39,34 @@ `endif `endif +// detect and resolve potential collision with lowRISC's prim_assert macros by undefining all of +// their macros (the variants in here should be backwards compatible with lowRISC's macros) +`ifdef PRIM_ASSERT_SV + `ifdef INC_ASSERT + `undef ASSERT_I + `undef ASSERT_INIT + `undef ASSERT_FINAL + `undef ASSERT + `undef ASSERT_NEVER + `undef ASSERT_KNOWN + `undef COVER + `undef ASSERT_PULSE + `undef ASSERT_IF + `ifndef FPV_ON + `undef ASSERT_KNOWN_IF + `endif + `undef ASSUME + `undef ASSUME_I + `endif + `ifdef FPV_ON + `undef ASSUME_FPV + `undef ASSUME_I_FPV + `undef COVER_FPV + `endif +`endif +// define PRIM_ASSERT_SV to anticipate a later inclusion of lowRISC's prim_assert macros +`define PRIM_ASSERT_SV + // Converts an arbitrary block of code into a Verilog string `define ASSERT_STRINGIFY(__x) `"__x`" From 52181279b0de3d4ac6c32859dc20e06ceac708e9 Mon Sep 17 00:00:00 2001 From: Philippe Sauter Date: Wed, 1 Jul 2026 23:47:19 +0200 Subject: [PATCH 2/2] assertions: Move UVM report package to source file --- Bender.yml | 1 + include/common_cells/assertions.svh | 11 ----------- src/assert_rpt_pkg.sv | 17 +++++++++++++++++ 3 files changed, 18 insertions(+), 11 deletions(-) create mode 100644 src/assert_rpt_pkg.sv diff --git a/Bender.yml b/Bender.yml index 855dc51c..7ee29bbd 100644 --- a/Bender.yml +++ b/Bender.yml @@ -23,6 +23,7 @@ sources: # etc. Files within a level are ordered alphabetically. # Level 0 + - src/assert_rpt_pkg.sv - src/cc_binary_to_gray.sv - target: not(all(xilinx,vivado_ipx)) diff --git a/include/common_cells/assertions.svh b/include/common_cells/assertions.svh index 975e4fec..892d9435 100644 --- a/include/common_cells/assertions.svh +++ b/include/common_cells/assertions.svh @@ -9,17 +9,6 @@ `ifndef COMMON_CELLS_ASSERTIONS_SVH `define COMMON_CELLS_ASSERTIONS_SVH -`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 - /////////////////// // Helper macros // /////////////////// diff --git a/src/assert_rpt_pkg.sv b/src/assert_rpt_pkg.sv new file mode 100644 index 00000000..da53c8f5 --- /dev/null +++ b/src/assert_rpt_pkg.sv @@ -0,0 +1,17 @@ +// Copyright lowRISC contributors. +// Licensed under the Apache License, Version 2.0, see LICENSE for details. +// SPDX-License-Identifier: Apache-2.0 + +`ifdef UVM +package assert_rpt_pkg; + + import uvm_pkg::*; + + `include "uvm_macros.svh" + + function automatic void assert_rpt(string msg); + `uvm_error("ASSERT FAILED", msg) + endfunction + +endpackage +`endif