Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: m-labs/artiq
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 969f282de941
Choose a base ref
...
head repository: m-labs/artiq
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: a714be1c9948
Choose a head ref
  • 3 commits
  • 4 files changed
  • 1 contributor

Commits on Feb 23, 2016

  1. examples/transport: cleanup

    jordens committed Feb 23, 2016
    Copy the full SHA
    8568218 View commit details
  2. sim: align API closer to non-sim

    * add Output
    * also clear timeline after it has been printed (multiple kernel invocations)
    
    The sim core device API has diverged quite a bit from the non-sim API.
    More work is needed.
    jordens committed Feb 23, 2016
    Copy the full SHA
    5599ec1 View commit details
  3. Copy the full SHA
    a714be1 View commit details
55 changes: 47 additions & 8 deletions artiq/sim/devices.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from random import Random

from artiq.language.core import delay, kernel
from artiq.language import units
from artiq.language.core import delay, at_mu, kernel
from artiq.sim import time


@@ -16,6 +15,7 @@ def run(self, k_function, k_args, k_kwargs):
self._level -= 1
if self._level == 0:
print(time.manager.format_timeline())
time.manager.timeline.clear()
return r


@@ -27,19 +27,58 @@ def __init__(self, dmgr, name):
self.prng = Random()

@kernel
def wait_edge(self):
duration = self.prng.randrange(0, 20)*units.ms
time.manager.event(("wait_edge", self.name, duration))
def gate_rising(self, duration):
time.manager.event(("gate_rising", self.name, duration))
delay(duration)

@kernel
def count_gate(self, duration):
result = self.prng.randrange(0, 100)
time.manager.event(("count_gate", self.name, duration, result))
def gate_falling(self, duration):
time.manager.event(("gate_falling", self.name, duration))
delay(duration)

@kernel
def gate_both(self, duration):
time.manager.event(("gate_both", self.name, duration))
delay(duration)

@kernel
def count(self):
result = self.prng.randrange(0, 100)
time.manager.event(("count", self.name, result))
return result

@kernel
def timestamp_mu(self):
result = time.manager.get_time_mu()
result += self.prng.randrange(100, 1000)
time.manager.event(("timestamp_mu", self.name, result))
at_mu(result)
return result


class Output:
def __init__(self, dmgr, name):
self.core = dmgr.get("core")
self.name = name

@kernel
def set_o(self, value):
time.manager.event(("set", self.name, value))

@kernel
def pulse(self, duration):
time.manager.event(("pulse", self.name, duration))
delay(duration)

@kernel
def on(self):
self.set_o(True)

@kernel
def off(self):
self.set_o(False)


class WaveOutput:
def __init__(self, dmgr, name):
self.core = dmgr.get("core")
Original file line number Diff line number Diff line change
@@ -36,7 +36,7 @@ def one(self):
return self.pmt.count()

def run(self):
offsets = np.linspace(0, 10, 3)
offsets = np.arange(0, 3)
for o in offsets:
self.setup(o)
self.one()
Original file line number Diff line number Diff line change
@@ -82,7 +82,6 @@ def repeat(self):

def scan(self, stops):
for s in stops:
self.histogram = [0 for _ in range(self.bins)]
# non-kernel, build frames
# could also be rpc'ed from repeat()
self.calc_waveforms(s)
10 changes: 6 additions & 4 deletions examples/sim/al_spectroscopy.py
Original file line number Diff line number Diff line change
@@ -20,7 +20,8 @@ def build(self):
def run(self):
state_0_count = 0
for count in range(100):
self.mains_sync.wait_edge()
self.mains_sync.gate_rising(1*s/60)
at_mu(self.mains_sync.timestamp_mu() + 100*us)
delay(10*us)
self.laser_cooling.pulse(100*MHz, 100*us)
delay(5*us)
@@ -34,9 +35,10 @@ def run(self):
delay(5*us)
with parallel:
self.state_detection.pulse(100*MHz, 10*us)
photon_count = self.pmt.count_gate(10*us)
if (photon_count < self.photon_limit_low
or photon_count > self.photon_limit_high):
self.pmt.gate_rising(10*us)
photon_count = self.pmt.count()
if (photon_count < self.photon_limit_low or
photon_count > self.photon_limit_high):
break
if photon_count < self.photon_limit_low:
state_0_count += 1