File: tcl-test.tcl.in

package info (click to toggle)
simulavr 1.0.0%2Bgit20160221.e53413b-1
  • links: PTS
  • area: main
  • in suites: buster
  • size: 5,748 kB
  • sloc: cpp: 35,491; python: 6,991; ansic: 3,567; makefile: 1,072; sh: 653; asm: 414; tcl: 320
file content (55 lines) | stat: -rw-r--r-- 1,399 bytes parent folder | download | duplicates (2)
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
51
52
53
54
55
#! @TCL_SHELL@
#
#  $Id$
#

#load the avr-simulator package
proc locateInDirs {name dirs} {

  foreach dir ${dirs}  {
     set toTest ${dir}/${name}
     if { [file exists ${toTest}] } {
       return ${toTest}
     }
  }
  error "unable to locate ${name}"
}

if { $tcl_platform(platform) == "windows" } {
  set pathSeparator ";"
} else {
  set pathSeparator ":"
}
set libraryFile [locateInDirs libsimulavr@AVR_TCL_MODULE_SUFFIX@ [list [file normalize ../../src/.libs] /lib /usr/lib]]
set libraryPath [file dirname ${libraryFile}]
set env(PATH) "${env(PATH)}${pathSeparator}${libraryPath}"
load ${libraryFile}

#create new device
set dev1 [AvrFactory_makeDevice [AvrFactory_instance] "atmega16"]

#set the clock cycle time [ns] to 124 = 4MHz clock
AvrDevice_SetClockFreq ${dev1} 125

# Exit magic register
set exitInstance [new_RWExit ${dev1}]
AvrDevice_ReplaceIoRegister ${dev1} 0x4f $exitInstance

# Write magic register (only stdout supported)
set writeToPipeInstance [new_RWWriteToFile ${dev1} "FWRITE" "-"]
AvrDevice_ReplaceIoRegister ${dev1} 0x52 ${writeToPipeInstance}

#load elf file to the device
AvrDevice_Load ${dev1} "main.elf"

#last exit instance
AvrDevice_RegisterTerminationSymbol ${dev1} "exit"

#systemclock must know that this device will be stepped from application
set sc [GetSystemClock]
$sc Add ${dev1}

#lets the simulation run until it terminates itself
$sc Endless

exit 0