Refer to the CSDN blog below
Tcl Commands#
proc write_sim_data {env name radix cycle file} {
set fid [open $file w]
for {set i 0} {$i <= $::now} {incr i [expr $cycle * 1000]} {
set str [exa -env $env -radix $radix -time ${i}ps {*}$name]
puts $fid $str
}
close $fid
}
-
Line1: Defines a procedure named write_sim_data with the parameter list: {env name radix cycle file}
env: Specifies the path to the object name. For example, top_tb/top_u
name: The list of variables to be exported. For example, {I_reset_n R_data_cnt}
radix: Number base. Options: ascii, binary, decimal, hexadecimal, unsigned, etc.
cycle: Clock cycle, in ns
file: Output file. For example, ./1.txt -
Line2: Opens a document and returns the file descriptor
-
Line3: Samples and outputs data at clock cycle intervals from 0 to the end of simulation time
-
Line4: Obtains specific data
-
Line5: Writes data to the file
-
Line7: Closes the file
Example:
write_sim_data sim:/top_tb/u_top_wrapper/top_i/RS_Enc_0 {RS_Out Trigger} unsigned 1000 data.txt