Electronic – Why Verilog doesn’t introduce a FF for reg type variable in always@* block and why reg is allowed in combinational circuits

verilog

as far as I know, register (e.g., reg reg1) and register file (e.g., reg [3:0] reg2)

can be used in the always block whether it is a sequential (i.e., always @(posedge clk)) or combinational (i.e., always @*).

However, only when they are used in sequential always block, Flip-flops are inferred.

I think it's because register and register file in combinational always block are assigned continuously, so memory may not necessary.

However, I don't know why Verilog allows using register and register-files inside the always @* block which is a combinational circuit.

Is it because to enable RT level description such as if statement, case statement, etc in combinational logic?

The name 'reg' confuses me because its name implies the storage (FF), but it acts like a just wire inside the always @* block.

It seems that the 'reg' works as expected as a storage only inside the sequential always block.

Even though assign keyword allows a value to be assigned to a wire variable,
is there any other reason that the Verilog allows register and register files to be used inside always @* block as a wire?

To me, a register and register file are just declared as a reg type in combinational always block to be used at LHS of assignment, but act as a wire type variable.

I appreciate any help.

Best Answer

However, I don't know why Verilog allows using register and register-files inside the always @* block which is a combinational circuit.

Because designating a signal as reg or wire has nothing to do with whether it is implemented as the output of a register or a combinatorial circuit. It only relates to whether the signal can be assigned to by a procedural assignment (assignment in an initial or always block) or by a continuous assignment (assignment by an assign or instance output).

Reg signals can be assigned to in procedural blocks. Wire signals can be assigned by continuous assignment. That is absolutely all the different signal types mean, and this is simply something you have to get used to when working in Verilog.

The names seem to imply a different meaning because Verilog was originally intended to be a tool for modeling hardware that was designed by other tools rather than a tool to synthesize new designs, and so using it for synthesis has a few warts that reflect the inherent kluginess of doing that.