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) net = pysimulavr.Net() net.Add(xpin) net.Add(dev.GetPin("A0")) sim.dmanStart() print "simulation start: (t=%dns)" % sim.getCurrentTime() sim.doRun(15000000) print "simulation end: (t=%dns)" % sim.getCurrentTime() print "value 'timer2_ticks'=%d" % sim.getWordByName(dev, "timer2_ticks") sim.dmanStop() del dev # EOF
# 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() for word in var_list: print "\tvalue '%s' = %s" % ( word, simulator.getWordByName(device, word)) except KeyboardInterrupt: pass finally:
pysimulavr.Pin.SetInState(self, pin) print "%s='%s' (t=%dns)" % (self.name, pin.toChar(), sim.getCurrentTime()) if __name__ == "__main__": proc, elffile = argv[1].split(":") sim = SimulavrAdapter() sim.dmanSingleDeviceApplication() dev = sim.loadDevice(proc, elffile) a0 = XPin(dev, "A0") a1 = XPin(dev, "A1", "H") a7 = XPin(dev, "A7", "H") sim.dmanStart() print "simulation start: (t=%dns)" % sim.getCurrentTime() sim.doRun(sim.getCurrentTime() + 7000000) a1.SetPin("L") sim.doRun(sim.getCurrentTime() + 5000000) a7.SetPin("L") sim.doRun(sim.getCurrentTime() + 2000000) a1.SetPin("H") sim.doRun(sim.getCurrentTime() + 1000000) print "simulation end: (t=%dns)" % sim.getCurrentTime() print "value 'timer2_ticks'=%d" % sim.getWordByName(dev, "timer2_ticks") print "value 'port_val'=0x%x" % sim.getWordByName(dev, "port_val") print "value 'port_cnt'=%d" % sim.getWordByName(dev, "port_cnt") sim.dmanStop()
# 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() for word in var_list: print "\tvalue '%s' = %s" % (word, simulator.getWordByName(device, word)) except KeyboardInterrupt: pass finally: print "simulation end: (t=%dns)" % simulator.getCurrentTime() for word in var_list: