OVM Macros

Hi All,

I am a newbie in OVM, can any one help me to solve this problem.

  • I want to use macros in my test, which is not under “src” directory.

  • So i have to import only"ovm_pkg"(import ovm_pkg::)* in my test (As ovm_pkg includes “ovm.svh” and “ovm.svh” includes “ovm_macros.svh”). No needs to include “ovm_macros.svh” in the test.

  • But I am getting following erros, If i didn’t include ovm_macros.svh.

================================================== =========================================
QuestaSim vlog 6.4 Compiler 2008.06 Jun 18 2008
– Compiling package ovm_pkg
– Compiling module test
– Importing package ovm_pkg
** Error: hierarchy.sv(58): (vlog-2163) Macro ovm_object_utils_begin is undefined. ** Error: hierarchy.sv(58): near "(": syntax error, unexpected '(', expecting "function" or "task" ** Error: hierarchy.sv(59): (vlog-2163) Macro ovm_field_int is undefined.
** Error: hierarchy.sv(60): (vlog-2163) Macro ovm_field_int is undefined. ** Error: hierarchy.sv(61): (vlog-2163) Macro ovm_object_utils_end is undefined.
** Error: hierarchy.sv(89): near “$display”: syntax error, unexpected “SYSTEM_IDENTIFIER”
================================================== =========================================

Here is the program code :
================================================== =========================
49 module test;
50 import ovm_pkg::*;
**51 // include "ovm_macros.svh";** 52 53 class transaction extends ovm_transaction; 54 55 rand int data; 56 rand int addr; 57 58 ovm_object_utils_begin(transaction)
59 ovm_field_int(addr, OVM_ALL_ON) 60 ovm_field_int(data, OVM_ALL_ON)
61 `ovm_object_utils_end
62
63 constraint c { addr >= 0 && addr < 'd100; }
64 constraint c1 { data >= 'd10 && data < 'd20; }


endclass


endmodule
================================================== =========================

Note : This test is working fine if i include “ovm_macros.svh” in the test (line#51).

So can anyone tell me,

  1. Whether we have to include ovm_macros.svh,enven though we are importingovm_pkg. ?
  2. If yes, then please explain why ?

Thanks in advance,
HS.

HS,

Compiler directives, including text macros, exist only for the compilation unit they appear in and do not get saved in packages. Text macros must be `defined in each compilation unit they are referenced. This is defined in the SV LRM.

BTW, you need Questa 6.4a to run OVM 2.0.1, 6.4b is the current release. Those versions come with a precompiled version of the OVM that you’ll want to use so all you have to do is import the ovm_pkg and `include “ovm_macros.svh”

Dave Rich