-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathartiq.py
80 lines (49 loc) · 1.08 KB
/
artiq.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# ARTIQ mock environment
import logging
import typing
logger = logging.getLogger(__name__)
TInt32 = int
TFloat32 = float
TList = typing.List
Hz = 1.0
kHz = 1e3 * Hz
MHz = 1e6 * Hz
s = 1.0
ms = 1e-3 * s
us = 1e-6 * s
ns = 1e-9 * s
rtio_period = 4 * ns
class Timeline:
def __init__(self):
self.cursor = 0
self.events = []
__timeline = Timeline()
def rtio_output(addr, data):
logger.debug(f"RTIO @{__timeline.cursor:#010x}: {addr:#04x} < {data:#010x}")
__timeline.events.append((__timeline.cursor, addr, data))
def rtio_get_all():
global __timeline
events = __timeline.events[:]
del __timeline.events[:]
__timeline.cursor = 0
return events
def now_mu():
return __timeline.cursor
def at_mu(t):
global __timeline
__timeline.cursor = t
def delay_mu(t):
global __timeline
__timeline.cursor += t
def delay(t):
delay_mu(seconds_to_mu(t))
def seconds_to_mu(t):
return int(round(t / rtio_period))
class EnvExperiment:
pass
def kernel(f):
return f
def rpc(f):
return f
def portable(f):
return f