There are differences between continuous assignments, procedural assignments, and procedural continuous assignments. They are all described in Chapter 10 of the LRM.
Your code is demonstrating procedural continuous assignments, and not continuous assignments. It will work, but only you can determine if what you are doing meets your requirements.
Thank you.
In that case, if I bring the assign statement outside of the initial block, the assignment becomes continuous assignment. Is this true?
The assignment in the below code also passes compilation. I expected to see that continuous assignment of “reg” is invalid. Why is this the case?
Why would you expect that the continuous assignment to “reg” is invalid?
From section 10.3 of the LRM:
Continuous assignments shall drive values onto nets or variables, both vector (packed) and scalar. This
assignment shall occur whenever the value of the right-hand side changes.