Reputation: 153
Can a SystemVerilog function return a value of a type defined in a package? How do I import the package before I declare the type of the function?
Upvotes: 1
Views: 1077
Reputation: 1992
I think you want to return a datatype value, which was defined in a package.
Here is a sample code for it.
package tmp;
typedef bit[1:0] x;
endpackage
import tmp::*;
module tp();
x a;
initial
begin
a = return_x();
$display("a - %p", a);
end
endmodule
function x return_x();
return_x = 3;
endfunction
// Output
// a = 3
Upvotes: 1