# Path: pymoku/_instrument.py
# def to_reg_unsigned(_offset, _len, allow_set=None, allow_range=None,
#                     xform=lambda obj, x: x):
#     """ Returns a callable that will pack a new unsigned data value or
#     bitfield in to a register. Designed as shorthand for common use in
#     instrument register accessor lists. Supports single and compound
#     registers (i.e. data values that span more than one register).
# 
#     :param _offset: Offset of data field in the register (set)
#     :param _len: Length of data field in the register (set)
#     :param allow_set: Set containing all valid values of the data field.
#     :param allow_range: a two-tuple specifying the bounds of the data value.
#     :param xform: a callable that translates the user value written to the
#         attribute to the register value
#     """
# 
#     def __us(obj, val, old):
#         val = xform(obj, val)
#         mask = ((1 << _len) - 1) << _offset
# 
#         if allow_set and allow_range:
#             raise MokuException("Can't check against both ranges and sets")
# 
#         if allow_set and val not in allow_set:
#             return None
#         elif allow_range and (val < allow_range[0] or val > allow_range[1]):
#             return None
# 
#         v = _usgn(val, _len) << _offset
# 
#         try:
#             return (old & ~mask) | v
#         except TypeError:
#             r = []
#             for o in reversed(old):
#                 r.insert(0, (o & ~mask) | v & 0xFFFFFFFF)
# 
#                 v = v >> 32
#                 mask = mask >> 32
# 
#             return tuple(r)
# 
#     return __us


from ._instrument import to_reg_unsigned
import math
            i_interprate_cic2 = 0
            i_bitshift_cic2 = math.log(i_ratechange_cic2 ** 2, 2)
            i_ratechange_cic1 = 16
            i_bitshift_cic1 = 8
            i_interprate_cic1 = i_ratechange_cic2 - 1
            i_highrate_wdf1 = factor / 2 - 1
            i_highrate_wdf2 = factor / 4 - 1

        self._instr._accessor_set(
            self.regbase + self.REG_DECIMATION,
            to_reg_unsigned(0, 2), d_wdfmuxsel
        )
        self._instr._accessor_set(
            self.regbase + self.REG_DECIMATION,
            to_reg_unsigned(2, 2), d_outmuxsel
        )
        self._instr._accessor_set(
            self.regbase + self.REG_DECIMATION,
            to_reg_unsigned(4, 4), d_cic1_bitshift
        )
        self._instr._accessor_set(
            self.regbase + self.REG_DECIMATION,
            to_reg_unsigned(8, 4), d_cic2_bitshift
        )
        self._instr._accessor_set(
            self.regbase + self.REG_DECIMATION,
            to_reg_unsigned(12, 5), d_cic1_dec
        )
        self._instr._accessor_set(
            self.regbase + self.REG_DECIMATION,

# Path: pymoku/_instrument.py
# def to_reg_unsigned(_offset, _len, allow_set=None, allow_range=None,
#                     xform=lambda obj, x: x):
#     """ Returns a callable that will pack a new unsigned data value or
#     bitfield in to a register. Designed as shorthand for common use in
#     instrument register accessor lists. Supports single and compound
#     registers (i.e. data values that span more than one register).
# 
#     :param _offset: Offset of data field in the register (set)
#     :param _len: Length of data field in the register (set)
#     :param allow_set: Set containing all valid values of the data field.
#     :param allow_range: a two-tuple specifying the bounds of the data value.
#     :param xform: a callable that translates the user value written to the
#         attribute to the register value
#     """
# 
#     def __us(obj, val, old):
#         val = xform(obj, val)
#         mask = ((1 << _len) - 1) << _offset
# 
#         if allow_set and allow_range:
#             raise MokuException("Can't check against both ranges and sets")
# 
#         if allow_set and val not in allow_set:
#             return None
#         elif allow_range and (val < allow_range[0] or val > allow_range[1]):
#             return None
# 
#         v = _usgn(val, _len) << _offset
# 
#         try:
#             return (old & ~mask) | v
#         except TypeError:
#             r = []
#             for o in reversed(old):
#                 r.insert(0, (o & ~mask) | v & 0xFFFFFFFF)
# 
#                 v = v >> 32
#                 mask = mask >> 32
# 
#             return tuple(r)
# 
#     return __us


# Path: pymoku/_dec_filter.py
from ._instrument import to_reg_unsigned
import math

            i_interprate_cic2 = 0
            i_bitshift_cic2 = math.log(i_ratechange_cic2 ** 2, 2)
            i_ratechange_cic1 = 16
            i_bitshift_cic1 = 8
            i_interprate_cic1 = i_ratechange_cic2 - 1
            i_highrate_wdf1 = factor / 2 - 1
            i_highrate_wdf2 = factor / 4 - 1

        self._instr._accessor_set(
            self.regbase + self.REG_DECIMATION,
            to_reg_unsigned(0, 2), d_wdfmuxsel
        )
        self._instr._accessor_set(
            self.regbase + self.REG_DECIMATION,
            to_reg_unsigned(2, 2), d_outmuxsel
        )
        self._instr._accessor_set(
            self.regbase + self.REG_DECIMATION,
            to_reg_unsigned(4, 4), d_cic1_bitshift
        )
        self._instr._accessor_set(
            self.regbase + self.REG_DECIMATION,
            to_reg_unsigned(8, 4), d_cic2_bitshift
        )
        self._instr._accessor_set(
            self.regbase + self.REG_DECIMATION,
            to_reg_unsigned(12, 5), d_cic1_dec
        )
        self._instr._accessor_set(
            self.regbase + self.REG_DECIMATION,

            to_reg_unsigned(17, 5), d_cic2_dec