# System Verilog - default type of a declared variable

Status
Not open for further replies.

#### shaiko

##### Advanced Member level 5
Hello,

As far as I know (correct me if I'm wrong), if we declare a variable in Verilog without explicitly giving it a type - it defaults to a "wire".
Is this rule the same with System Verilog ? Or the default is something else ( "logic" for example ) ?

#### ThisIsNotSam

##### Advanced Member level 5
Hello,

As far as I know (correct me if I'm wrong), if we declare a variable in Verilog without explicitly giving it a type - it defaults to a "wire".
Is this rule the same with System Verilog ? Or the default is something else ( "logic" for example ) ?
inputs/outputs in verilog default to wire. variables are the type you declared them to be.

shaiko

### shaiko

points: 2

#### shaiko

##### Advanced Member level 5
With SV, is there a good reason why not declare all variables and ports as type "logic" ?

#### vGoodtimes

##### Advanced Member level 4
Verilog has default_nettype option. this can be added to the top of any files you write. Verilog's default net type is wire and any undeclared variables will be of that type. This made a lot more sense when structural designs were popular. I've only seen default_nettype none used, so I don't know if you can set default_nettype logic. Doing so should convert any typos into 1 bit logic.

#### shaiko

##### Advanced Member level 5
But isn't writingdefault_nettype none equivalent to not writing anything at all ?

#### vGoodtimes

##### Advanced Member level 4
Verilog has an anti-feature that an undeclared name is treated as a wire. Before Verilog2001, this would always be 1 bit. After 2001, the width could be inferred. The intent seems to have been making it easier to connect module instances in a highly structural design.

Because typos get treated as wires, some developers declare `default_nettype none. A side effect of this is that ports now need "input wire" vs just "input".

shaiko

### shaiko

points: 2

#### shaiko

##### Advanced Member level 5
What do you do in your designs?
Suppose, a signal is indeed logically a wire - do you explicitly declare it as a such?

#### dave_59

##### Advanced Member level 3
Status
Not open for further replies.