You are on page 1of 2

Help with executing testbench.

in example | Verification Academy

https://verificationacademy.com/forums/systemverilog/help-executing-te...

Search form

Verification Academy (/)

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

Courses

Forums

Cookbooks

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

Events

Register >

More

SystemVerilog
(/forums/all-topics)

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

Help with executing testbench.in example


SystemVerilog

1099 (/forums/systemverilog)
Hi mates,

MichiDresden
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 testbench.in (http://www.testbench.in

March 04, 2014 at 2:02 am

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

Answers

Order by:

dave_59
Forum
Moderator
1915 posts

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

(https://verificationacademy.com
/forums/systemverilog/helpexample#answer-40087)

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

executing-testbenchin-

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 http://go.mentor.com
/wire-vs-reg (http://go.mentor.com/wire-vs-reg) So the interface should look like

interface intf_cnt(input clk);


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

17-06-2015 PM 06:48

Help with executing testbench.in example | Verification Academy

https://verificationacademy.com/forums/systemverilog/help-executing-te...

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);
initial
begin
env =new(intf);

Finally, SystemVerilog has the concept of compilation units (http://go.mentor.com/unit-vs-root). 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 (http://go.mentor.com/drich)

Mentor Graphics, All Rights


Reserved

2 of 2

Forum Terms of Use (https://communities.mentor.com/docs/DOC-4739) Sitemap (/sitemap)


Privacy Policy (http://www.mentor.com/terms_conditions/privacy)
Terms & Conditions (http://www.mentor.com/terms_conditions/)
Verification Horizons Blog (http://www.verificationhorizonsblog.com)
LinkedIn Group (http://www.linkedin.com/groups/Verification-Academy-4668056)

17-06-2015 PM 06:48

You might also like