自动存储 (绿皮书3.6)
Function或task的生命期仅见于Verilog语言。Verilog早期仅有静态生命期(static lifetime),无论是function还是task,用来描述硬件,无论调用多少次,同一个Task或者function都是分配一个地址。
这意味着,过程的参数和局部变量,都没有调用堆栈。这是和其它大多数语言完全不同的,需要特别注意。
这也就意味着,你不能有递归和重入的过程。
example1:
// automatic.sv
`timescale 1ns/1ps
program test();
// define the function
function integer factorial (input [31:0] operand);
if (operand >= 2)
factorial =factorial (operand - 1) * operand;
else
factorial = 1;
endfunction: factorial
//