Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Verilog automatic task

Tags:

verilog

What does it mean if a task is declared with the automatic keyword in Verilog?

task automatic do_things;
  input [31:0] number_of_things;
  reg [31:0] tmp_thing;
  begin
    // ...
  end
endtask;

Note: This question is mostly because I'm curious if there are any hardware programmers on the site. :)

like image 960
cdleary Avatar asked Aug 29 '08 19:08

cdleary


People also ask

What is automatic task in Verilog?

It means that the task is re-entrant - items declared within the task are dynamically allocated rather than shared between different invocations of the task. You see - some of us do Verilog... ( ugh)

What is automatic task?

Task automation refers to the use of software to complete work activities. Task automation improves the accuracy and consistency of workflows, and powers more efficient processes. Most importantly, task automation streamlines manual processes and minimizes the amount of labor required to produce a specific result.

Can task call a function in Verilog?

Functions can use and modify global variables, when no local variables are used. Functions can call other functions, but cannot call tasks.


2 Answers

"automatic" does in fact mean "re-entrant". The term itself is stolen from software languages -- for example, C has the "auto" keyword for declaring variables as being allocated on the stack when the scope it's in is executed, and deallocated afterwards, so that multiple invocations of the same scope do not see persistent values of that variable. The reason you may not have heard of this keyword in C is that it is the default storage class for all types :-) The alternatives are "static", which means "allocate this variable statically (to a single global location in memory), and refer to this same memory location throughout the execution of the program, regardless of how many times the function is invoked", and "volatile", which means "this is a register elsewhere on my SoC or something on another device which I have no control over; compiler, please don't optimize reads to me away, even when you think you know my value from previous reads with no intermediate writes in the code".

"automatic" is intended for recursive functions, but also for running the same function in different threads of execution concurrently. For instance, if you "fork" off N different blocks (using Verilog's fork->join statement), and have them all call the same function at the same time, the same problems arise as a function calling itself recursively.

In many cases, your code will be just fine without declaring the task or function as "automatic", but it's good practice to put it in there unless you specifically need it to be otherwise.

like image 190
Matt J Avatar answered Sep 20 '22 14:09

Matt J


It means that the task is re-entrant - items declared within the task are dynamically allocated rather than shared between different invocations of the task.

You see - some of us do Verilog... (ugh)

like image 39
Will Dean Avatar answered Sep 22 '22 14:09

Will Dean