Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
7 years ago

task vs always

Hello, i know that always executes always when some parameter in the sensitivity list changes.

in what cases task executes?

if i have a task block and always block one after the other' which one executes first?

Thanks

4 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    A task has to be called. Hence it needs to be called from inside an always or initial block.

    A task block on it's own will be called as an implicit always.

    You cannot guarantee which will be called first, as it is down to what order the compiler decides to order them. So you shouldnt be assigning the same variable in both.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    A task has to be called. Hence it needs to be called from inside an always or initial block.

    A task block on it's own will be called as an implicit always.

    --- Quote End ---

    What do you mean by this? A task is a procedure that must be called by from a running process.

    An always block is a continuously running process.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    What do you mean by this? A task is a procedure that must be called by from a running process.

    An always block is a continuously running process.

    --- Quote End ---

    Maybe Im getting myself confused. In VHDL a procedure can be called outside of a process and in doing so you have an implicit process. I thought the same could be done in verilog - mistaken.