예제 #1
0
    proc, elffile = argv[1].split(":")

    verbose = False
    changeMap = dict()

    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=%0.0fµs)" % ns2us(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=%0.0fµs)" % ns2us(sim.getCurrentTime()))

    l = list(changeMap)
    l.sort()
    for k in l:
        print("pin %s" % k)
        ot = 0
        for c, t in changeMap[k]:
            print("  change to '%s' at %0.0fµs (dt=%0.0fµs)" %
예제 #2
0
    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
    xpin = XPin("port D.3", dev.GetPin("D3"))

    f_vol_pin = XPin("port D.2", dev.GetPin("D2"))
    f_pitch_pin = XPin("port B.0", dev.GetPin("B0"))

    hw_button_pin = XPin("port D.6", dev.GetPin("D6"))

    sim.dmanStart()

    print("simulation start: (t=%dns)" % sim.getCurrentTime())
    #sim.doRun(15000000)

    f_vol_pin.SetPin("H")
    f_pitch_pin.SetPin("H")
    hw_button_pin.SetPin("L")

    #for i in range(10000):
    while sim.getCurrentTime() < (1.5 / 1e-9):
        xpin.SetPin("L")
        sim.doRun(sim.getCurrentTime() + int1Period)
        xpin.SetPin("H")
        sim.doRun(sim.getCurrentTime() + int1Period)
    print("simulation end: (t=%dns)" % sim.getCurrentTime())

    #print("value 'timer2_ticks'=%d" % sim.getWordByName(dev, "timer2_ticks"))

    sim.dmanStop()
    del dev

# EOF
예제 #4
0
 
 a0 = XPin(dev, "A0", 'a')
 aref = XPin(dev, "AREF", 'a')
 
 INT_MAX = 2**31 - 1
 aref.SetAnalog(INT_MAX)
 # hwad.cpp: adSample= (int)((float)adSample/(float)adref*INT_MAX);
 
 sim.dmanStart()
 print "simulation start: (t=%dns)" % sim.getCurrentTime()
 a0.SetAnalog(123)
 
 print "run till main function ..."
 bpaddr = dev.Flash.GetAddressAtSymbol("main")
 dev.BP.AddBreakpoint(bpaddr)
 sim.doRun(30000)
 if not dev.PC == bpaddr:
     print "error: main function not arrived!"
 dev.BP.RemoveBreakpoint(bpaddr)
 print "simulation main entrance: (t=%dns)" % sim.getCurrentTime()
 print "  value 'adc_value'=%d (after init)" % sim.getWordByName(dev, "adc_value")
 
 sim.doRun(sim.getCurrentTime() + 120000)
 print "simulation break: (t=%dns)" % sim.getCurrentTime()  
 print "  value 'conversions'=%d" % sim.getWordByName(dev, "conversions")
 print "  value 'adc_value'=%d (simulation break)" % sim.getWordByName(dev, "adc_value")
 
 sim.doRun(sim.getCurrentTime() + 330000)
 print "simulation end: (t=%dns)" % sim.getCurrentTime()  
 print "  value 'conversions'=%d" % sim.getWordByName(dev, "conversions")
 print "  value 'adc_value'=%d (simulation end)" % sim.getWordByName(dev, "adc_value")
예제 #5
0
  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
예제 #6
0
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()
  del dev
  
    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:
            print "\tvalue '%s' = %d" % (word,
                                         simulator.getWordByName(device, word))

        simulator.dmanStop()
        del device
 
 a0 = XPin(dev, "A0", 'a')
 aref = XPin(dev, "AREF", 'a')
 
 INT_MAX = 2**31 - 1
 aref.SetAnalog(INT_MAX)
 # hwad.cpp: adSample= (int)((float)adSample/(float)adref*INT_MAX);
 
 sim.dmanStart()
 print "simulation start: (t=%dns)" % sim.getCurrentTime()
 #a0.SetAnalog(123)
 
 print "run till main function ..."
 bpaddr = dev.Flash.GetAddressAtSymbol("main")
 dev.BP.AddBreakpoint(bpaddr)
 sim.doRun(30000)
 if not dev.PC == bpaddr:
     print "error: main function not arrived!"
 dev.BP.RemoveBreakpoint(bpaddr)
 print "simulation main entrance: (t=%dns)" % sim.getCurrentTime()
 print "  value 'adc_value'=%d (after init)" % sim.getWordByName(dev, "adc_value")
 
 sim.doRun(sim.getCurrentTime() + 120000)
 print "simulation break: (t=%dns)" % sim.getCurrentTime()  
 print "  value 'conversions'=%d" % sim.getWordByName(dev, "conversions")
 print "  value 'adc_value'=%d (simulation break)" % sim.getWordByName(dev, "adc_value")
 
 sim.doRun(sim.getCurrentTime() + 330000)
 print "simulation end: (t=%dns)" % sim.getCurrentTime()  
 print "  value 'conversions'=%d" % sim.getWordByName(dev, "conversions")
 print "  value 'adc_value'=%d (simulation end)" % sim.getWordByName(dev, "adc_value")
예제 #9
0
파일: tester.py 프로젝트: bitsman/pintarOS
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()
# readbyte()
# readbyte()
# readbyte()
# readbyte()
# readbyte()
# readbyte()

sim.doRun(sim.getCurrentTime() + etu)

# testWrite([0x1,0x2,0x3,0x4,0x5],0x80)
# testRead(5,0x80)

#Select(0x1234)

sim.dmanStop()
예제 #10
0
파일: tester.py 프로젝트: orhan89/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()
# readbyte()
# readbyte()
# readbyte()
# readbyte()
# readbyte()
# readbyte()

sim.doRun(sim.getCurrentTime() + etu)

# testWrite([0x1,0x2,0x3,0x4,0x5],0x80)
# testRead(5,0x80)

#Select(0x1234)

sim.dmanStop()
        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:
            print "\tvalue '%s' = %d" % (word, simulator.getWordByName(device, word))

        simulator.dmanStop()
        del device