datasheets/examples/cache.py

36 lines
745 B
Python
Raw Normal View History

2022-08-09 17:31:27 +08:00
from artiq.experiment import *
class CachePut(EnvExperiment):
def build(self):
self.setattr_device("core")
self.setattr_device("core_cache")
@kernel
def put(self, key, value):
self.core_cache.put(key, value)
# First experiment
@kernel
def run(self):
self.put("data", [0xCAFE, 0xDEAD, 0xBEEF])
class CacheGet(EnvExperiment):
def build(self):
self.setattr_device("core")
self.setattr_device("core_cache")
@kernel
def get(self, key):
return self.core_cache.get(key)
@rpc(flags={"async"})
def p(self, p):
print([hex(_) for _ in p])
# Second experiment
@kernel
def run(self):
self.p(self.get("data"))