You should have gotten a nested set of filenames in you error message. What is the name of the file that has the `include “packageA.sv”;, and is that the first line of the file?
Somethat that come before that could be the problem.
Syntax error messages can be very cryptic. Sometimes there is nothing wrong with the line it is pointing to, but there is a problem with the source text that comes just before it. The pre-processor is just going to inline all the `include files, so think only of the single stream of text that is being compiled.
So I’ll ask again, what source text comes before the `include statement in the stim.sv file?
the stim.sv is compiled separately. As in, in a package , there are a list of files included, one of them is stim.sv: like:
package bus_agent;
include "file1.sv" include “stim.sv”
endpackage
Another thing I tried was : in the above stim.sv file, I removed the import packageA and used only include , like as follows:
`include “packageA.sv”;
class stim;
abc obj1;
packageA::obj1 = new();
…
endclass
Now, the error is: packageA.sv(1) near “package”: syntax error, unexpected package, expecting class.
Can a package have a class within it as I’ve shown above and what would be a correct way to include/import packageA in stim.sv. Note: packageA comes from a different directory structure (from another team. This is suposed to be shared). So, I can only include/import packageA and use it.
package bus_agent;
`include "file1.sv"
`include "stim.sv"
// stim.sv does an include of pkgA.sv
// So a pre-processor ends up with:
package A; // Syntax error