Files
iverilog/ivtest/ivltests/mod_inst_pkg.v
T
Stephen Williams cea237b407 Add ivtest to the iverilog source tree
By adding ivtest to the iverilog source tree, it is easier to keep
the regression test synchronized with the source that is being tested.
This should be especially helpful for PRs that add a new feature, and
have a matching ivtest PR with the regression test for that feature.
2022-01-15 10:18:50 -08:00

68 lines
1.5 KiB
Verilog

package fooPkg;
localparam FOO = 5;
endpackage
package barPkg;
function int get_size (
input int x
);
return x + 3;
endfunction
endpackage
package bazPkg;
typedef int baz;
endpackage
/*
IEEE 1800-2012 A.1.2 says:
module_nonansi_header ::=
{ attribute_instance } module_keyword [ lifetime ] module_identifier
{ package_import_declaration } [ parameter_port_list ] list_of_ports ;
module_ansi_header ::=
{ attribute_instance } module_keyword [ lifetime ] module_identifier
{ package_import_declaration } [ parameter_port_list ] [ list_of_port_declarations ] ;
This allows for the importing of packages during module definition which can be used in the
parameter and port lists.
*/
module foo
// Testing comman separated imports
import
fooPkg::*,
barPkg::*;
// Testing multiple import statements
import bazPkg::*;
#(
parameter FOO_PARAM = FOO
)
(
input [get_size(7)-1:0] inport
);
baz value = 11;
initial begin
if ($bits(inport) != 10) begin
$display("FAILED -- function import in module declaration failed (%d)", $bits(inport));
$finish;
end
if (value != 11) begin
$display("FAILED -- Something is wrong with typedef import (%d)", value);
$finish;
end
if (FOO_PARAM != 5) begin
$display("FAILED -- Something is wrong with paramater imports (%d)", FOO_PARAM);
$finish;
end
$display("PASSED");
$finish;
end
endmodule