I want to know why assignment to a wire datatype variable is not allowed inside always block in verilog?
Wires (nets) were intended as a connection media and they do not keep value. So, you can use them for connecting modules, creating buses, ... There is a special 'assign' statement to assign them. Regs on the other hand were intended to represent registers and keep value. So, you cannot use them for connection, neither you can use wires as registers.
Saying that, all procedural blocks (always) are just small general-purpose programs with some extended semantics. But they use generic type of variables to keep intermediate values. Therefore out of the 2 types above only the 'reg' fits in this category. So, it only allow assignment to regs.
Well this concept creates a lot of headache for verilog programming. Therefore System Verilog came up with the logic datatype, which can replace both of them in most of the cases. You can use it either to connect things or to assign to it in the always blocks.
A wire in Verilog is very distinct concept from a variable. Although both are used to represent values that change over time, the way that obtain their values is very different. As in most other programming languages, you make a procedural assignment of a value to variable, and the variable holds that value until the next procedural assignment.
A wire represents a connection in hardware, or group of connections forming a network. That network is physically implemented as a metal wire on a chip or board. You can think of a wire as the transmission of a value from a driver to a receiver. In Verilog, drivers are represented by constructs that perform continuous assignments as opposed to procedural assignments.
I explain this in further detail in this post.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With