The typical user defined pragma in verilog is done in a comment
\\ pragma
I suppose we could define an empty macro:
`define inpackage(x)
And then use that like:
`inpackage(FooPkg)
The only thing I don't like about that, is you have to do that `define somewhere. Doing it in the file is less than ideal, and doing it outside the file creates compile dependencies.
I also tested a user defined attribute, and got this to work:
class A;
int x;
endclass // A
(* inpackage="FooPkg" *) class B extends A;
int y;
endclass // B
// this class is not in FooPkg
class C extends A;
int z;
endclass // C
module m;
initial begin
A a;
B b = new;
C c;
a = b;
$cast(c,a);
$display("\n\n\n ------ got here? -------\n\n\n");
end
endmodule // m
There are some rules to attributes though. The attribute name can't be a keyword, so I used 'inpackage' instead of 'package'. The attribute value must be a valid verilog data type, so I had to use a quoted string.
The LRM also state's that the attribute only applies to entity immediately following it. So in this example, class B has the inpackage=FooPkg attribute, but the other classes do not.
-Ryan