You are on page 1of 2

Help with executing testbench.

in example | Verification Academy

Search form

Verification Academy (/)

Log In (/user/login?destination=forums/systemverilog/help-executing-testbenchin-example)




Ask a Question (/user/login?destination=ask-a-question)


Register >



Home (/) / Forums (/forums) / SystemVerilog (/forums/systemverilog) / Help with executing example

Help with executing example


1099 (/forums/systemverilog)
Hi mates,

Forum Access
1 post

I study computer science and therefore I want to look at SystemVerilog with QuestaSim cause I know
VHDL/Verilog/SystemC very well.
My problem is I found a SV example on (

March 04, 2014 at 2:02 am

/TS_23_ONES_COUNTER_EXAMPLE.html)) with all *.sv-files but they don't compile without errors in
The toplevels 'monitor', 'driver' and 'environment' don't have access to the lower classes 'scoreboard' and
Error message: Invalid type 'xx'. Please check the type of the variable 'xx'.
Maybe you guys could help me, I would be very grateful :)


Order by:

1915 posts

may be problems with the way you are compiling the code because the example does not use packages.


1 of 2

Log In to Answer or Comment (/user/login?destination=node/40080)

There are a number of problems with this example. There are a few illegal constructs in the code, and there

March 04, 2014 at 10:05 am


Newest Last

The interface declaration declares clk twice. Once as a port, and a second time internal to the interface.
Verilog has two styles of port declarations: 1) an older style where you just list the names of ports in a list,
and then you declare the port direction inside the module/interface, and a third time inside to declare its type.
2) A newer stle (called ANSI) where you declare the port direction, type, and name inside the port list. You
cannot mix the two styles.
Another problem is that the the driver class is trying to make procedural assignments to the wires in the
interface. That is illegal, you can only make procedural assignments to variables. See
/wire-vs-reg ( So the interface should look like

interface intf_cnt(input clk);

logic reset;
logic data;
logic [0:3] count;

17-06-2015 PM 06:48

Help with executing example | Verification Academy

There is also a problem with the way the environment class is constructed in the test. The constructor
contains a fork/join_none block that spawns a thread and the constructor is called as part of a static
initialization declaration. That is illegal because you can only spawn threads from threads created by initial or
always blocks. So you need to remove the static initialization (a good rule to follow in any case because of
potential races between static initializations) and call the constructor inside the initial block.

program testcase(intf_cnt intf);

environment env; // = new(intf);
env =new(intf);

Finally, SystemVerilog has the concept of compilation units ( When you
compile a class in a separately from another class, is no data type visibility between the two compilations
unless you use a package. So you must compile this example as one concatenated file, or one file that
`includes all the other files. Some simulators treat all files on a single command line as if they were written as
a single file, but Questa does not do that by default.
- Dave Rich (

Mentor Graphics, All Rights


2 of 2

Forum Terms of Use ( Sitemap (/sitemap)

Privacy Policy (
Terms & Conditions (
Verification Horizons Blog (
LinkedIn Group (

17-06-2015 PM 06:48