Ovm_test syntax error

I am compiling the given code on Questasim 10.0b.

include "ovl.vlib" // At the top of each file include “ovm_macros.svh”
// Within any modules or packages

interface dut_if();

bit x,y,s,c;
modport test(output x,y,s,c);
modport dut(input x,y,s,c);


module dut(dut_if.dut i_f);

always @ (i_f.x or i_f.y)


package my_pkg;
import ovm_pkg::*;
class my_driver extends ovm_driver;
virtual dut_if m_dut_if;
class my_env extends ovm_env;
my_driver m_driver;


module top;

import my_pkg::*;

dut_if dut_if1 ();
dut dut1 ( .i_f(dut_if1) );

class my_test extends ovm_test;
my_env m_env;
virtual function void connect;
m_env.m_driver.m_dut_if = dut_if1;


After compilation, i get this error.
** Error: C:/Modeltech_6.1f/examples/half-adder.sv(45): near “ovm_test”: syntax error, unexpected IDENTIFIER
** Error: C:/Modeltech_6.1f/examples/half-adder.sv(45): Error in class extension specification.

Please suggest a solution. Thank you in advance.

In reply to yasirqadri:


Class definition inside module is not allowed.

put class my_test definition outsite module scope and try compiling again

In reply to yasirqadri:

You need to import ovm_pkg in top module as well.

module top;

  import ovm_pkg::*;
  import my_pkg::*;

  //Everything else


I have studied that it is possible to declare a class inside a module. The given link explains it.

The module top has a definition of class ovm_test. Is that right?

That also doesn’t work.

In reply to yasirqadri:

Several comments:

  1. You mention that you are using Questasim 10.0b, but your logs show Modelsim 6.1f. You should check your environment to ensure you are using what you think you are.
  2. When you are defining my_test, you need to ensure that the ovm_pkg is imported in the same scope. You import ovm_pkg as part of my_pkg, but when you import my_pkg in the top module, this does not in turn import ovm_pkg. You need to import the ovm_pkg at the same time you import my_pkg.
  3. You don’t declare a new() function in my_test, and you will get another error when you fix the import issue.
  4. If you are starting a new project, you should be using UVM instead of OVM. OVM is no longer supported and UVM is becoming the IEEE standard.