forked from M-Labs/artiq
sim/time: use second as reference unit
This commit is contained in:
parent
2e9410464d
commit
7422a919cc
|
@ -6,7 +6,7 @@ from artiq.language import core as core_language
|
||||||
class SequentialTimeContext:
|
class SequentialTimeContext:
|
||||||
def __init__(self, current_time):
|
def __init__(self, current_time):
|
||||||
self.current_time = current_time
|
self.current_time = current_time
|
||||||
self.block_duration = 0*ps
|
self.block_duration = 0*s
|
||||||
|
|
||||||
def take_time(self, amount):
|
def take_time(self, amount):
|
||||||
self.current_time += amount
|
self.current_time += amount
|
||||||
|
@ -15,7 +15,7 @@ class SequentialTimeContext:
|
||||||
class ParallelTimeContext:
|
class ParallelTimeContext:
|
||||||
def __init__(self, current_time):
|
def __init__(self, current_time):
|
||||||
self.current_time = current_time
|
self.current_time = current_time
|
||||||
self.block_duration = 0*ps
|
self.block_duration = 0*s
|
||||||
|
|
||||||
def take_time(self, amount):
|
def take_time(self, amount):
|
||||||
if amount > self.block_duration:
|
if amount > self.block_duration:
|
||||||
|
@ -23,7 +23,7 @@ class ParallelTimeContext:
|
||||||
|
|
||||||
class Manager:
|
class Manager:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.stack = [SequentialTimeContext(0*ps)]
|
self.stack = [SequentialTimeContext(0*s)]
|
||||||
self.timeline = []
|
self.timeline = []
|
||||||
|
|
||||||
def enter_sequential(self):
|
def enter_sequential(self):
|
||||||
|
@ -46,7 +46,7 @@ class Manager:
|
||||||
|
|
||||||
def set_time(self, t):
|
def set_time(self, t):
|
||||||
dt = t - self.get_time()
|
dt = t - self.get_time()
|
||||||
if dt < 0*ps:
|
if dt < 0*s:
|
||||||
raise ValueError("Attempted to go back in time")
|
raise ValueError("Attempted to go back in time")
|
||||||
self.take_time(dt)
|
self.take_time(dt)
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ class Manager:
|
||||||
|
|
||||||
def format_timeline(self):
|
def format_timeline(self):
|
||||||
r = ""
|
r = ""
|
||||||
prev_time = 0*ps
|
prev_time = 0*s
|
||||||
for time, description in sorted(self.timeline, key=itemgetter(0)):
|
for time, description in sorted(self.timeline, key=itemgetter(0)):
|
||||||
r += "@{:10} (+{:10}) ".format(str(time), str(time-prev_time))
|
r += "@{:10} (+{:10}) ".format(str(time), str(time-prev_time))
|
||||||
for item in description:
|
for item in description:
|
||||||
|
|
Loading…
Reference in New Issue