A typedef
defines a datatype that can be applied to a net or variable object kinds. Things are confusing to maintain backward compatibility with Verilog because of implicit definitions.
When you see
logic [4:0] v;
This is implicitly a variable declaration a
with an explicit 5-bit 4-state packed array datatype.
var logic [4:0] v;
When you see
wire [4:0] w;
This is explicitly a net declaration a
with a 5-bit implicit 4-state packed array datatype.
wire logic [4:0] w;
You can use a typedef
for both:
typedef logic [4:0] uint5;
var uint5 v; // var can be implicit
wire uint5 w;
Note that module input
and inout
ports have wire
as the implicit object kind. Also reg
and logic
are synonyms for 4-state types with logic
being the preferred keyword. A reg
is not always associated with a register.