| /* | |
| * Copyright 2018 Google LLC | |
| * | |
| * Licensed under the Apache License, Version 2.0 (the "License"); | |
| * you may not use this file except in compliance with the License. | |
| * You may obtain a copy of the License at | |
| * | |
| * http://www.apache.org/licenses/LICENSE-2.0 | |
| * | |
| * Unless required by applicable law or agreed to in writing, software | |
| * distributed under the License is distributed on an "AS IS" BASIS, | |
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| * See the License for the specific language governing permissions and | |
| * limitations under the License. | |
| */ | |
| `ifndef uvm_object_new | |
| `define uvm_object_new \ | |
| function new (string name=""); \ | |
| super.new(name); \ | |
| endfunction : new | |
| `endif | |
| `ifndef uvm_component_new | |
| `define uvm_component_new \ | |
| function new (string name="", uvm_component parent=null); \ | |
| super.new(name, parent); \ | |
| endfunction : new | |
| `endif | |
| `ifndef gfn | |
| `define gfn get_full_name() | |
| `endif | |
| `ifndef DV_CHECK | |
| `define DV_CHECK(T_, MSG_="", SEV_=error, ID_=`gfn, WITH_C_=) \ | |
| if (!(T_ WITH_C_)) begin \ | |
| `uvm_``SEV_(ID_, $sformatf("Check failed (%s) %s ", `"T_`", MSG_)); \ | |
| end | |
| `endif | |
| `ifndef DV_CHECK_FATAL | |
| `define DV_CHECK_FATAL(T_, MSG_="", ID_=`gfn, WITH_C_=) \ | |
| `DV_CHECK(T_, MSG_, fatal, ID_, WITH_C_) | |
| `endif | |
| // Shorthand for common foo.randomize() + fatal check | |
| `ifndef DV_CHECK_RANDOMIZE_FATAL | |
| `define DV_CHECK_RANDOMIZE_FATAL(VAR_, MSG_="Randomization failed!", ID_=`gfn) \ | |
| `DV_CHECK_FATAL(VAR_.randomize(), MSG_, ID_) | |
| `endif | |
| // Shorthand for common std::randomize(foo) + fatal check | |
| `ifndef DV_CHECK_STD_RANDOMIZE_FATAL | |
| `define DV_CHECK_STD_RANDOMIZE_FATAL(VAR_, MSG_="Randomization failed!", ID_=`gfn) \ | |
| `DV_CHECK_FATAL(std::randomize(VAR_), MSG_, ID_) | |
| `endif | |
| // Shorthand for common foo.randomize() with { } + fatal check | |
| `ifndef DV_CHECK_RANDOMIZE_WITH_FATAL | |
| `define DV_CHECK_RANDOMIZE_WITH_FATAL(VAR_, WITH_C_, MSG_="Randomization failed!", ID_=`gfn) \ | |
| `DV_CHECK_FATAL(VAR_.randomize(), MSG_, ID_, with { WITH_C_ }) | |
| `endif | |
| // Shorthand for common std::randomize(foo) with { } + fatal check | |
| `ifndef DV_CHECK_STD_RANDOMIZE_WITH_FATAL | |
| `define DV_CHECK_STD_RANDOMIZE_WITH_FATAL(VAR_, WITH_C_,MSG_="Randomization failed!",ID_=`gfn) \ | |
| `DV_CHECK_FATAL(std::randomize(VAR_), MSG_, ID_, with { WITH_C_ }) | |
| `endif |