Local variables in a sequence
The local variables in a sequence or properties are similar to local variables in the function or task.
- Local variables are dynamically created inside sequence instance and removed at the end of the sequence
- Each sequence instance has its copy. Hence, the sequence can not access the local variable declared in another instance.
Local variable in a sequence example-1
Consider a computing unit that reads data from a flip flop in 1 clock cycle, increments read data by 10, and writes it to the SRAM memory after 5 clock cycles.
sequence seq; int tmp_data; (##1 ff_rdata, tmp_data = ff_rdata) ##5 (sram_wdata == (tmp_data+1)); endsequence
Local variable in a sequence example-2
The local variable declared in the sequence is not accessible from another sequence where it is instantiated.
sequence seqA; int tmp_data; (##1 ff_rdata, tmp_data = ff_rdata) ##5 (sram_wdata == (tmp_data+1)); endsequence sequence seqB; seqA ##2 (d_data == tmp_data); // tmp_data is not accessible even if seqA is instantiated in the seqB. endsequence