Re: Verilog: In which case use "Wire" and in which case "Register"
I believe this is a common problem for newcomers to Verilog.
Essentially, the wire datatype is to remind us of real wires in electronic circuits. Likewise, the reg datatype is supposed to remind us of registers in electronic circuits.
To contrast wires and regs:
wire:
Wires must be driven to a value, they do not store data.
Wire behavior is not defined in procedural code
Wire values are updated continuously (every timestep)
Wires provide connectivity between devices, like real wires in electronic circuits. So, the outputs and inputs of an AND gate will be a wire.
Wire values can be accessed at any time. So, if A and B are wires: assign A = B;
reg:
Registers store data. They can not be driven
Register behavior is defined in procedural code
Register values are updated at specific events, like the positive edge of a clock. Like: always @ (posedge CLK) begin ... end
Registers provide data storage, not connectivity.
Register values can be accessed at any time. So, if A is a wire and B is a register: assign A = B;
I'd like to make a small clarification/correction to DFT_designer. "An input is not declared as reg or wire." This could easily be read as "inputs do not have a wire or reg datatype" which is false. But what I think what was intended is, "inputs are wires and the user can not change it" which is true. This goes along with his next statement, which is that outputs can either be wires or regs.
I hope that this is helpful. I'm not very familiar with VHDL, so I can't draw a comparison. Although, the best general advice I can offer for trying to decide when to use this or that in Verilog is to try to design and understand the circuit you are trying to realize before you start to write code. If you have a block diagram scribbled onto a piece of paper in front of you, then it should be very clear from it what is a register and what is a wire.