Uvm scoreboard error

hi,
i am getting a error in scoreboard, i have shared my edaplayground code link and error message.

error message:
Error-[SE] Syntax error
Following verilog source has syntax error :
token ‘seq_item’ should be a valid type. Please declare it virtual
if it is an Interface.
“scoreboard.sv”, 3: token is ‘;’
seq_item qseq[$];

In reply to dkumar264:

All you need is a forward type declaration. Here, the scoreboard file is getting compiled first and then the sequence item filed is compiled. So, when the scoreboard file is compiled, the compiler doesn’t know anything about sequence item class. Hence it throws an error.

Add a typedef before the scoreboard class:

typedef class seq_item; 
class sboard extends uvm_scoreboard;

Moreover, it is advisable to use `include’s in a single file and not in multiple places. This will help you visualize the problem more easily.

Refer to typedef class and this forum question for more details.

In reply to sharvil111:

Don’t use a typedef as it is a poor coding practice and can lead to other errors which won’t be detected during compilation.

You should use packages properly and import them prior to making reference to any classes contained within them.

In reply to cgales:

Don’t use a typedef as it is a poor coding practice and can lead to other errors which won’t be detected during compilation.

Agree. Usage of packages can be another alternative, yet can you please enlighten about other type of coding errors that can pop out by using typedef. Mostly we use import/typedef to resolve cross dependencies.

In reply to sharvil111:

For me, the problem is more a code maintenance issue. As you said before, compiling code in the correct order helps you mentally visualize your code dependencies. If you start using too many forward typedefs, you wind up including files more than necessary, and it becomes much more difficult to separate your code into managable packages for re-use.