Ports are by default considered as nets of type wire.

Port Types

Port

Description

input

  • the design module can only receive values from outside using its input ports

output

  • the design module can only send values to the outside using its output ports

inout

  • the design module can either send or receive values using its inout ports

Ports of type input and inout cannot be declared as reg because they are being driven from outside continuously and should not store values, but rather reflect the changes in the external signals as soon as possible.

It is perfectly legal to connect two ports with varying vector sizes, but the one with a lower vector size will prevail and the remaining bits of the other port with a higher width will be ignored.

Syntax

input	[net_type] [range] list_of_names;	// input port
inout	[net_type] [range] list_of_names;	// input and output port

output	[net_type] [range] list_of_names;	// output port driven by wire
output	[var_type] [range] list_of_names;	// output port driven by variable

Example

module my_design(input wire 	clk,
				 input			en,
				 input			rw,
				 inout[15:0]	data,
				 output			int);
	// ...
endmodule

Syntax Variations

Signed Ports

The signed attribute can be attached to a port declaration or a net/reg declaration or both. Implicit nets are by default unsigned

module my_design(input	a, b,
				 output	c);
	// ports a, b, and c are by default unsigned
endmodule

If either the net/reg declaration has a signed attribute, then the other shall also be considered signed

module my_design(input signed a, b,
				 output c);
	wire a, b;		// a, b are signed from port declaration
	reg signed c;	// c is signed from reg declaration
endmodule