Skip to content

Instantly share code, notes, and snippets.

@zhuzhzh
Created August 5, 2017 05:28
Show Gist options
  • Save zhuzhzh/39b9b441c23544649bbfb9ee1694a25a to your computer and use it in GitHub Desktop.
Save zhuzhzh/39b9b441c23544649bbfb9ee1694a25a to your computer and use it in GitHub Desktop.
tcl_sdl_img_regression.md
  1. 把所有的图像文件名称放到一个文件里, 一行一个
  2. 把图像文件名读到一个tcl的列表里 注意tcNames需要是全局变量
set FSIZE_B 100
set gcnt 0
array set tcNames { }
# read out the testcase name fromt he file
proc getTCNames {path} {
    global tcNames
    set fileHandle [open $path {RDONLY}]
    set tcNames [split [read $fileHandle nonewline] "\n"]
    close $fileHandle
}
  1. 定义load 文件函数
proc loadNewFile {{mempath "dut.m1.sram.mem"}} {
  global gcnt
  global tcNames
  set filename [lindex $tcNames $gcnt]
  puts $filename

  #if the file size is less than FSIZE_B, then wait
  while { [file size $filename] < $FSIZE_B } {
  	sleep 1s
  }

  memory -load $mempath -file $filename
  incr gcnt;
}
  1. 定义sdl
# if the current image id processed, load the new image
INSTANCE loadNext;
state s0 {
    if (dut.BFM.nextImg == 'bP)
    {
        DISPLAY("the current image is done at %t");
        exec "loadNewFile";
    }
}
# if the all testcase is done
INSTANCE monDone;
state s0 {
    if ( dut.BFM.done == 1 ) {
        trigger;
        DISPLAY("the emulation is done at %t");
    }
}
  1. run script
emu_init
getTCNames ../tc_list
loadNewFile
sdl -load ld.tdf
sdl -enable
emu_run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment