It seems that the SystemVerilog language specification allows the interface
construct to have a defined lifetime (LRM 1800-2017, section 25.3). However, I haven’t been able to find much more information about it. This leads to three questions:
- What is the default lifetime of an interface when it’s not explicitly specified?
- Can an interface have an
automatic
lifetime?
- If so, what are the implications of using the
automatic
lifetime for variables, tasks/functions, and variables declared within those tasks/functions?
Automatic lifetime applies only to variables declared within procedural code. When you declare a module or interface with an automatic lifetime default, you are not modifying the module’s or interface’s lifetime; instead, you are setting the default lifetime for variables declared within procedural code inside those design units.
The default lifetime for variables declare within procedural code in SystemVerilog is static, which sets it apart from most other programming languages. This is because of historical reasons to maintain backward compatibility with the original Verilog-1995 standard. In Verilog-1995, all lifetimes were static, and the concept of automatic lifetimes was not present.
Note that procedural class methods always have an automatic lifetime.