A VCD file is an ASCII file that includes header information, definitions of variables, and the value changes for all variables specified in the task calls. Various system tasks can be incorporated into the source description to create and manage the VCD file.
Read more on Value Change Dump (VCD) !
Simulation variables can be dumped into a VCD file using the following tasks:
$dumpfile
The $dumpfile
task is used to specify the name of the VCD file.
$dumpfile(<filename>);
The filename is optional and defaults to the string "dump.vcd" if it is not provided.
module tb;
initial begin
$dumpfile(); // default "dump.vcd"
$dumpfile("wave1.vcd"); // dumps into "wave1.vcd"
end
endmodule
$dumpvars
The $dumpvars
task is used to specify which variables should be recorded in the file indicated by $dumpfile
. This task can be called multiple times throughout the model (for instance, within different blocks), but all instances of $dumpvars
will execute at the same simulation time.
$dumpvars(levels, [list_of_modules_or_variables]);
$dumpvars
will dump all variables to the VCD file if no arguments are given, else the first argument specifies the number of hierarchy levels below each designated module instance to include in the VCD file. The following arguments indicate which scopes of the model should be recorded in the VCD file.
module tb;
initial begin
$dumpvars (0); // Dumps all variables from all module instances
$dumpvars (0, tb); // Dumps all variables within module 'tb' and in all sub-modules
$dumpvars (1, tb); // Dumps all variables within module 'tb', not in any sub-modules
$dumpvars (0, tb.ram_ctrl, tb.alu2.a); // Dumps all variables in 'tb.ram_ctrl' and in all its sub-modules, and the variable 'tb.alu2.a' in module 'alu2'
end
endmodule
Note that the argument 0 applies only to subsequent arguments that specify module instances, and not to individual variables. For instance, 0 is applied only to 'tb.ram_ctrl' and not to the individual net 'tb.alu2.a' in the example shown above.
$dumpon, $dumpoff
Executing the $dumpvars
task initiates value change dumping at the end of the current simulation time unit. To pause the dumping process, the $dumpoff
task can be called. To resume dumping, the $dumpon
task can be invoked.
module tb;
initial begin
$dumpvars;
#100ns $dumpoff; // Stop dump of all vars at 100ns
#2000ns $dumpon; // Resume dump of all vars at 2000ns
end
endmodule
When $dumpoff
is executed by the simulator, all selected variables will be dumped with the value X
and the actual value of the variable when $dumpon
is called later to resume. The idea is to pause dumping of signal change values in between.
Dumping of signal values for large designs causes simulation to take a longer wall-clock time to finish, and these tasks help to selectively dump variables within regions of interest.
$dumpall
The $dumpall
creates a checkpoint in the VCD file and shows current values of all the selected variables.
$dumpall;
$dumplimit
This task is used to control the size of the VCD file, specified in bytes. VCD dumping will stop when size of the file reaches this limit, and a comment will be inserted to indicate that dump limit has been reached.
module tb;
initial begin
$dumplimit(1048576); // Dump 1MB limit
end
endmodule