Modules communicate with external world using ports. They provide interface to the modules. A module definition contains list of ports. All ports in the list of ports must be declared in the module, ports can be one the following types:

  • Input port, declared using keyword input.
  • Output port, declared using keyword output.
  • Bidirectional port, declared using keyword inout.
All the ports declared are considered to be as wire by default. If a port is intended to be a wire, it is sufficient to declare it as output, input, or inout. If output port holds its value it should be declared as reg type. Ports of type input and inout cannot be declared as reg because reg variables hold values and input ports should not hold values but simply reflect the changes in the external signals they are connected to.

Port Connection Rules
  • Inputs: Always of type net(wire). Externally, they can be connected to reg or net type variable.
  • Outputs: Can be of reg or net type. Externally, they must be connected to a net type variable.
  • Bidirectional ports (inout): Always of type net. Externally, they must be connected to a net type variable.
  • It is possible to connect internal and external ports of different size. In general you will receive a warning message for width mismatch.
  • There can be unconnected ports in module instances.
Ports can declared in a module in C-language style:

module module_1( input a, input b, output c);
// Internals

If there is an instance of above module, in some other module. Port connections can be made in two types.

Connection by Ordered List:
module_1 instance_name_1 ( A, B, C);
Connecting ports by name:
module_1 instance_name_2 (.a(A), .c(C), .b(B));

In connecting port by name, order is ignored.

<< Previous Home  Next >>   



 Save and Share: Digg del.icio.us Reddit Facebook Mixx Google YahooMyWeb blogmarks Blue Dot StumbleUpon Bumpzee Furl Sphinn Ma.gnolia MisterWong Propeller Simpy TwitThis Wikio BlinkList NewsVine