pysimulavr.Pin.__init__(self) self.name = name def SetInState(self, pin): pysimulavr.Pin.SetInState(self, pin) print "%s set to '%s' (t=%dns)" % (self.name, pin.toChar(), sim.getCurrentTime()) if __name__ == "__main__": doVCD = False proc, elffile = argv[1].split(":") sim = SimulavrAdapter() sim.dmanSingleDeviceApplication() dev = sim.loadDevice(proc, elffile) #dev.SetClockFreq(100) if doVCD: print "all registrered trace values:\n ", print "\n ".join(sim.getAllRegisteredTraceValues()) sigs = ("IRQ.VECTOR9", "PORTA.PORT") sim.setVCDDump(splitext(basename(argv[0]))[0] + ".vcd", sigs) print "-" * 20 xpin = XPin("port A.0") # watch out, that this Net instance will not be deleted until simulation is # done (for example, if you create this in a subfunction and do not save # this instance too, before you leave this subfunction)
import pysimulavr from ex_utils import SimulavrAdapter if __name__ == "__main__": proc, elffile = sys.argv[1].split(":") # creates a list of observed variables (parsed from arguments) try: var_list = sys.argv[2].split(',') except IndexError: print 'indicate a list of comma-separated variables: var1,var2,var3' sys.exit(1) print 'monitored variables: %s' % var_list simulator = SimulavrAdapter() simulator.dmanSingleDeviceApplication() device = simulator.loadDevice(proc, elffile) # ~16MHz device.SetClockFreq(62) simulator.dmanStart() print "simulation start: (t=%dns)" % simulator.getCurrentTime() for word in var_list: print "\tvalue '%s' = %d" % (word, simulator.getWordByName( device, word)) try: while True: simulator.doRun(simulator.getCurrentTime() + 1000000) print "device time: %d ns" % simulator.getCurrentTime()