Friday, June 22, 2012

Modelsim TCL

Long simulation runs in the data path engines (filters, FFT, IFFT etc) verifications are  mostly due to
  • memory filling before the HW processing engine starts
  • on the fly preparing the new memory contents and writing to the memories
  • on the fly checking the memory contents for the expected HW behavior
Once the memory read/write behavior is fully verified, short-cutting the above tasks will reduce the simulation run time significantly. One way is to use back door initialization via the text file, saving of the memory contents to the text file for offline processing. Modelsim/NCSIM TCL is can be used as quick and efficient way.

E.g. TCL script

# use the  native "mem load" command to fill the contents of the memory from a file
proc mem_load_proc { file mem} {
     if { [file exists $file] } {  
         mem load -i $file $mem
   }    
}
# use the native "mem display" command to save the contents from the memory to a file
proc mem_save_proc { file mem} {
     set f [open $file w+]
     puts $f [mem display -format mti -dataradix hexadecimal -addressradix hexadecimal -wordsperline 8 $mem]
     flush $f
     close $f
}
# concurrent When statement triggered based on the signal value conditional check
when "/tb_top/hier1/sig_a = '1'" {
    # save the current memory contents 
    mem_save_proc $save_file $mem
   # generate new data, in this case using DataGen.pl
    exec DataGen.pl
   # load the new memory contents
   mem_load_proc $load_file $mem
}


No comments: