Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using wire or reg with input or output in Verilog

Tags:

verilog

When you declare something as input or output, how do you know if you have to also declare it as a reg or a wire?

like image 605
node ninja Avatar asked Mar 19 '11 06:03

node ninja


People also ask

Can Reg be used as input Verilog?

So, outputs can be either reg or wire, but an input cannot be a reg. So, in your example you could declare an internal - temporary variable as reg and an input signal as wire.

Why do we use wire and reg in Verilog?

wire elements must be continuously driven by something, and cannot store a value. Henceforth, they are assigned values using continuous assignment statements. reg can be used to create registers in procedural blocks. Thus, it can store some value.

Can you assign wire to register Verilog?

As you can see from the example above, a wire can be assigned a value by an assign statement. Default data type is wire: this means that if you declare a variable without specifying reg or wire, it will be a 1-bit wide wire. Now, coming to reg data type, reg can store value and drive strength.

What is the difference between reg wire and logic in SystemVerilog?

There is no difference between reg and logic other than their spelling. The keyword reg remains because SystemVerilog is %100 percent backward compatible with Verilog.


1 Answers

reg and wire specify how the object will be assigned and are therefore only meaningful for outputs.

If you plan to assign your output in sequential code,such as within an always block, declare it as a reg (which really is a misnomer for "variable" in Verilog). Otherwise, it should be a wire, which is also the default.

like image 99
Jan Decaluwe Avatar answered Oct 02 '22 17:10

Jan Decaluwe