Source code for basil.HL.pulse_gen
#
# ------------------------------------------------------------
# Copyright (c) All rights reserved
# SiLab, Institute of Physics, University of Bonn
# ------------------------------------------------------------
#
"""Register-based interface to the pulse_gen hardware block."""
from basil.HL.RegisterHardwareLayer import RegisterHardwareLayer
[docs]
class pulse_gen(RegisterHardwareLayer):
"""Pulse generator."""
_registers = {
"RESET": {"descr": {"addr": 0, "size": 8, "properties": ["writeonly"]}},
"VERSION": {"descr": {"addr": 0, "size": 8, "properties": ["ro"]}},
"READY": {"descr": {"addr": 1, "size": 1, "properties": ["ro"]}},
"START": {"descr": {"addr": 1, "size": 8, "properties": ["writeonly"]}},
"EN": {"descr": {"addr": 2, "size": 1}},
"DELAY": {"descr": {"addr": 3, "size": 32}},
"WIDTH": {"descr": {"addr": 7, "size": 32}},
"REPEAT": {"descr": {"addr": 11, "size": 32}},
}
_require_version = "==3"
def __init__(self, intf, conf):
"""Initialize pulse generator layer."""
super(pulse_gen, self).__init__(intf, conf)
[docs]
def start(self):
"""Software start of pulse at random time."""
self.START = 0
[docs]
def reset(self):
"""Soft reset the pulse generator. Clears internal state on the next clock edge."""
self.RESET = 0
[docs]
def set_delay(self, value):
"""Set the pulse delay in clock cycles from start.
The delay is relative to the start trigger (software .start() or EXT_START pin).
"""
self.DELAY = value
[docs]
def get_delay(self):
"""Return the pulse delay in clock cycles."""
return self.DELAY
[docs]
def set_width(self, value):
"""Set the pulse width in terms of clock cycles."""
self.WIDTH = value
[docs]
def get_width(self):
"""Return the pulse width in clock cycles."""
return self.WIDTH
[docs]
def set_repeat(self, value):
"""Set the repeat count. 0 = repeat forever. The pulse repeats with the configured DELAY and WIDTH each time. Max 255."""
self.REPEAT = value
[docs]
def get_repeat(self):
"""Return the repeat count."""
return self.REPEAT
[docs]
def is_done(self):
"""Return True if the pulse generator has finished all repetitions, False if still active. Alias of is_ready."""
return self.is_ready
@property
def is_ready(self):
"""Return True when the pulse generator is idle and ready to accept a new start trigger.
Reads the READY register (addr 1, bit 0). While the pulse is running
(including all configured repetitions) this reads False.
The `@property` decorator makes this an attribute-like access - call it
without parentheses as ``daq["pulse0"].is_ready``, not ``.is_ready()``.
`.is_done()` is an alias that returns the same value.
"""
return self.READY
[docs]
def set_en(self, value):
"""Configure whether the pulse synchronizes with an external trigger.
If true: The pulse comes with a fixed delay with respect to the external trigger (EXT_START).
If false: The pulse comes only at software start.
"""
self.EN = value
[docs]
def get_en(self):
"""Return whether the pulse uses a fixed delay w.r.t. the shift register finish signal."""
return self.EN