If I create a function in the top module, and I want to call this from test (or any other place), how can I achieve it ?
In reply to zz8318:
It depends where you are making the call from.
You can always call a task or function directly if it defined in a module instance above where you are calling it from.
module top;
mid m();
function void hello;
$display("hello");
endfunction
endmodule
module mid;
bot b();
endmodule
module bot;
initial hello();
endmodule
To avoid collisions with other routines having the same name in different modules, you can use an upwards reference by naming the module
module bigtop;
top t();
function void hello;
$display("hi");
endfunction
endmodule
module top;
mid m();
function void hello;
$display("hello");
endfunction
endmodule
module mid;
bot b();
endmodule
module bot;
initial top.hello();
endmodule
You can also use $root.bigtop.t.hello as an absolute reference instead of an upwards reference.
If you are inside a package, you cannot refer to anything outside the package except another package that has been imported.