summaryrefslogtreecommitdiffstats
path: root/test/vhdltest/automation.tcl
blob: cf2f05ba7fdfbebb3a64fecd51be3e5a46cd4de8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# simulation time in ms
echo "step size"
set step 20
# time until simulation will be canceled
echo "timeout after"
set timeout 15000000

proc runSim {} {
   # import the global variable step
   global step
   global timeout
   upvar 0 errorMsg_ errorMsg
   set runtime 0

   # reset simulator
   restart -force -nowave
   add wave *
      set errorMsg "ERROR"

   echo "start simulation"

   # run until state machine is finished
   set err 0
   set completed 0
   while { $err != 1 & $completed != 1 & $runtime < $timeout } {
      run $step ns
      set err [examine -time $runtime -binary /testbench/error_o]
      set completed [examine -time $runtime -binary /testbench/completed_o]
      set runtime [ expr $runtime + $step]
   }

   # if running in gui mode, view results
   view wave

   # export results to cmd line
   if { $runtime == $timeout } {
      echo "TIMEOUT"
   } elseif { $err == 1 } {
      echo "ERROR"
   } else {
      echo "OK"
   }

}

# start simulation
runSim

# exit simulator
exit -force