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) net = pysimulavr.Net() net.Add(xpin)
# hold the connecting net here, it have not be destroyed, if we leave this method self.__net = pysimulavr.Net() self.__net.Add(self) self.__net.Add(dev.GetPin(name)) def SetInState(self, pin): 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()
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() for word in var_list: print "\tvalue '%s' = %s" % (
DEBUG = True baudrate = 9600 etu = 1000000000 / baudrate print "ETU =", etu, "ns" freq = 3579000 period = 1000000000 / freq print "1/Freq =", period, "ns" sim = SimulavrAdapter() sim.dmanSingleDeviceApplication() dev = sim.loadDevice('at90s8515', 'pintaros') dev.SetClockFreq(period) sim.setVCDDump("atr.vcd", ["PORTB.B6-Out", "PORTB.DDR", "PORTB.PIN", "PORTB.PORT"]) io_pin = dev.GetPin("B6") io_val = io_pin.toChar sim.dmanStart() getATR() # readbyte() # readbyte() # readbyte()
DEBUG = True baudrate = 9600 etu = 1000000000/baudrate print "ETU =", etu, "ns" freq = 3579000 period = 1000000000/freq print "1/Freq =", period, "ns" sim = SimulavrAdapter() sim.dmanSingleDeviceApplication() dev = sim.loadDevice('at90s8515','pintaros') dev.SetClockFreq(period) sim.setVCDDump("atr.vcd", ["PORTB.B6-Out","PORTB.DDR","PORTB.PIN","PORTB.PORT"]) io_pin = dev.GetPin("B6") io_val = io_pin.toChar sim.dmanStart() getATR() # readbyte() # readbyte() # readbyte() # readbyte()
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() for word in var_list: print "\tvalue '%s' = %s" % (word, simulator.getWordByName(device, word)) except KeyboardInterrupt: