In reply to saurabhwass:
No. you can not use an always block inside any procedural code, including a task. An always block implements the following two concepts:
- it creates a process thread by execution of the procedural code within the block.
- Once the procedural block completes, it repeats execution of the procedural block indefinitely. That process continues until the end of the simulation.
An initial block does only implements the first concept. Once the procedural block completes, that process terminates.
In you need an infinite loop, you can use the procedural forever looping statement. That can be used anywhere a procedural statement is allowed, including inside a task.