4

I want to know why assignment to a wire datatype variable is not allowed inside always block in verilog?

3 Answers 3

3

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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.

Comments

0

Its just because in case of always block target has to store the value unless and until new inputs arrived or there is a change in sensitivity list,which on the other hand wires are unable to do.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.