Beispiel #1
0
    def __del__(self):
        del self.__net


def ns2us(t):
    return t / 1000.0


if __name__ == "__main__":

    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")
Beispiel #2
0
        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)
    def SetInState(self, pin):
        pysimulavr.Pin.SetInState(self, pin)
        #print("%s set to '%s' (t=%dns)" % (self.name, pin.toChar(), sim.getCurrentTime()))

    def __del__(self):
        del self.__net


if __name__ == "__main__":

    #proc, elffile = sys.argv[1].split(":")
    proc = "atmega328"
    dump0x20file = "dump0x20.raw"  # "-"
    elffile = sys.argv[1]

    sim = SimulavrAdapter()
    sim.dmanSingleDeviceApplication()
    dev = sim.loadDevice(proc, elffile)
    dev.SetClockFreq(63)  # 62.5ns = 16MHz
    rwout = pysimulavr.RWWriteToFile(dev, "FWRITE", dump0x20file)
    dev.ReplaceIoRegister(0x20, rwout)

    int1Period = round((1. / (8e6 / 256)) / 2 / 1e-9)

    sigs = ("IRQ.VECTOR9", "PORTA.PORT")
    sigs = (
        "PORTB.B2-Out",
        # DIN do DAC
        "PORTB.B3-Out",
        # SCK do DAC
        "PORTB.B5-Out",
Beispiel #4
0
  def __init__(self, dev, name, state = None):
    pysimulavr.Pin.__init__(self)
    self.dev=dev
    self.name = name
    devpin = dev.GetPin(name)
    if state is not None: self.SetPin(state)
    # 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(devpin)

if __name__ == "__main__":

  proc, elffile = argv[1].split(":")
  
  sim = SimulavrAdapter()
  sim.dmanSingleDeviceApplication()
  dev = sim.loadDevice(proc, elffile)
  #dev.SetClockFreq(250) # clock frequency is 4MHz by default
  print "before simulation start:"
  print "  value 'adc_value'=%d (before init)" % sim.getWordByName(dev, "adc_value")
  
  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()
Beispiel #5
0
  
  def __init__(self, name):
    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)
Beispiel #6
0
    self.name = name
    if state is not None: self.SetPin(state)
    # 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")
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()
  def __init__(self, dev, name, state = None):
    pysimulavr.Pin.__init__(self)
    self.dev=dev
    self.name = name
    devpin = dev.GetPin(name)
    if state is not None: self.SetPin(state)
    # 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(devpin)

if __name__ == "__main__":

  proc, elffile = argv[1].split(":")
  
  sim = SimulavrAdapter()
  sim.dmanSingleDeviceApplication()
  dev = sim.loadDevice(proc, elffile)
  #dev.SetClockFreq(250) # clock frequency is 4MHz by default
  print "before simulation start:"
  print "  value 'adc_value'=%d (before init)" % sim.getWordByName(dev, "adc_value")
  
  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()
Beispiel #9
0
        return response
    else:
        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()
Beispiel #10
0
        return response
    else:
        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()
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()
            for word in var_list: