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
?
相关问题
- Using single ended port in logic expecting diff-pa
- Warning: (vsim-7) Failed to open readmem file “mem
- Evaluation Event Scheduling - Verilog Stratified E
- Which way is better writing a register path in Ver
- How to write a module with variable number of port
相关文章
- ' << ' operator in verilog
- Why is Verilog not considered a programming langua
- Best way to access the uvm_config_db from the test
- Finding the next in round-robin scheduling by bit
- Verilog D-Flip-Flop not re-latching after asynchro
- What does |variable mean in verilog?
- Use of wire inside an always block?
- The states in this FSM machine are changing too qu
An
output reg foo
is just shorthand foroutput foo_wire; reg foo; assign foo_wire = foo
. It's handy when you plan to register that output anyway. I don't thinkinput reg
is meaningful formodule
(perhapstask
).input wire
andoutput wire
are the same asinput
andoutput
: it's just more explicit.basically reg is used to store values.For example if you want a counter(which will count and thus will have some value for each count),we will use a reg. On the other hand,if we just have a plain signal with 2 values 0 and 1,we will declare it as wire.Wire can't hold values.So assigning values to wire leads to problems....
reg
andwire
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 areg
(which really is a misnomer for "variable" in Verilog). Otherwise, it should be awire
, which is also the default.seeing it in digital circuit domain
so it completely depends on your use whether you need to create a register and tick it according to sensitivity list or you want to create a port/pin assignment
The Verilog code compiler you use will dictate what you have to do. If you use illegal syntax, you will get a compile error.
An
output
must also be declared as areg
only if it is assigned using a "procedural assignment". For example:There is no need to declare an
output
as awire
.There is no need to declare an
input
as awire
orreg
.