Analog-Digital Conversion¶

Analog-digital conversion refers to the process of converting continous electromagnetic signals into discrete digital signals that can be processed by digital systems. Vice versa, digital-analog conversion is the process of converting discrete digital signals back into continuous analog signals. In the process of conversion, various impairments such as quantizzation noise, thermal noise, jitter and non-linear distortion may be introduced.
This module provides blocks modeling the respective conversion harware components.
- class ADC(num_quantization_bits=None, gain=None, quantizer_type=QuantizerType.MID_RISER, num_ports=1, noise_model=None, noise_level=None, seed=None)[source]¶
Bases:
ConverterBase,DSPOutputBlockModel of an analog-digital converter (ADC).
The ADC quantizes the input signal to a given number of bits, applying a gain control model before quantization. The quantizer can be configured to behave as either a mid-riser or mid-tread quantizer.
- Parameters:
num_quantization_bits (
int|None) – ADC resolution in bits. Default is infinite resolution (no quantization)gain (
GainControlBase|None) – Amplitude gain control at ADC input. Default is Gain(1.0), i.e., no gain.quantizer_type (
QuantizerType) – Determines quantizer behaviour at zero. Default is QuantizerType.MID_RISER.num_ports (
int) – Number of analog ports of the ADC.seed (
int|None) – Seed with which to initialize the block’s random state.
- classmethod Deserialize(process)[source]¶
Deserialize an object’s state.
Objects cannot be deserialized directly, instead a
Factorymust be instructed to carry out the deserialization process.- Parameters:
process (
DeserializationProcess) – The current stage of the deserialization process. This object is generated by theFactoryand provides an interface to deserialization methods supporting multiple backends.- Return type:
- Returns:
The deserialized object.
- plot_quantizer(input_samples=None, label='', fig_axes=None)[source]¶
Plot the quantizer characteristics.
Generates a matplotlib plot depicting the staircase amplitude response. Note that only the real part is plotted, as the quantizer is applied separately in the real and imaginary parts.
- Parameters:
input_samples (
ndarray|None) – Sample points at which to evaluate the characteristics, i.e., the x-axis of the resulting characteristics plot. It should be a sorted number sequence.label (
str) – A label describing the desired plot.fig_axes (
Axes|None) – Axes to which to plot the charateristics. By default, a new figure is created.
- Return type:
- realize(bandwidth, oversampling_factor, carrier_frequency)[source]¶
Return the current state of the radio-frequency block.
- Parameters:
- Return type:
- Returns:
Current state of the radio-frequency block.
- serialize(process)[source]¶
Serialize this object’s state.
Objects cannot be serialized directly, instead a
Factorymust be instructed to carry out the serialization process.- Parameters:
process (
SerializationProcess) – The current stage of the serialization process. This object is generated by theFactoryand provides an interface to serialization methods supporting multiple backends.- Return type:
- NO_RESAMPlING: float = 0.0[source]¶
Magic number of the ADC’s sampling rate indicating no resampling is applied.
- property i: RFBlockPort[ADC][source]¶
Input ports of the analog-digital converter.
- property quantizer_type: QuantizerType[source]¶
Type of quantizer
- QuantizationType.MID_TREAD: 0 can be the output of a quantization step. Since the number of quantization step
must be even, negative values will have one step more than positive values
- QuantizerType.MID_RISE: input values around zero are quantized as either -delta/2 or delta/2, with delta the
quantization step
- class DAC(num_quantization_bits=None, num_ports=1, noise_model=None, noise_level=None, seed=None)[source]¶
Bases:
ConverterBase,DSPInputBlock- Parameters:
- classmethod Deserialize(process)[source]¶
Deserialize an object’s state.
Objects cannot be deserialized directly, instead a
Factorymust be instructed to carry out the deserialization process.- Parameters:
process (
DeserializationProcess) – The current stage of the deserialization process. This object is generated by theFactoryand provides an interface to deserialization methods supporting multiple backends.- Return type:
- Returns:
The deserialized object.
- realize(bandwidth, oversampling_factor, carrier_frequency)[source]¶
Return the current state of the radio-frequency block.
- Parameters:
- Return type:
- Returns:
Current state of the radio-frequency block.
- serialize(process)[source]¶
Serialize this object’s state.
Objects cannot be serialized directly, instead a
Factorymust be instructed to carry out the serialization process.- Parameters:
process (
SerializationProcess) – The current stage of the serialization process. This object is generated by theFactoryand provides an interface to serialization methods supporting multiple backends.- Return type:
- property o: RFBlockPort[DAC][source]¶
Output ports of the digital-analog converter.
- class ConverterBase(num_quantization_bits=None, num_ports=1, seed=None)[source]¶
Bases:
RFBlockBase class for analaog-digital and digital-analog converters.
- Parameters:
- property num_input_ports: int[source]¶
Number of physical ports feeding into this radio-frequency block.
If the returned number is negative, the block can accept an arbitrary number of input ports.
- property num_output_ports: int[source]¶
Number of physical ports emerging from this radio-frequency block.
- property num_quantization_bits: int | None[source]¶
Quantization resolution in bits
- Returns:
Bit resolution, None if no quantization is applied.
- Raises:
ValueError – If resolution is less than zero.
- class GainControlBase(rescale_quantization=False)[source]¶
Bases:
SerializableBase class for all ADC gain control models.
- Parameters:
rescale_quantization (
bool) – If enabled, the quantized signal is rescaled to the original signal range before gain adjustment. Disabled by default.
- adjust_signal(input_signal, gain)[source]¶
Adjust the signal to the ADC input range.
- Parameters:
- Return type:
Returns: The adjusted signal.
- abstract estimate_gain(input_signal)[source]¶
Estimate the gain required to adjust the signal to the ADC input range.
Returns: Linear gain to be applied to the input_signal’s Voltage samples.
- scale_quantized_signal(quantized_signal, gain)[source]¶
Scale the quantized signal back to the original signal range before gain adjustment.
Only applied if
rescale_quantizationis enabled.- Parameters:
- Return type:
Returns: The scaled qzanitized signal.
- class Gain(gain=1.0, rescale_quantization=False)[source]¶
Bases:
GainControlBaseConstant gain model.
- Parameters:
- classmethod Deserialize(process)[source]¶
Deserialize an object’s state.
Objects cannot be deserialized directly, instead a
Factorymust be instructed to carry out the deserialization process.- Parameters:
process (
DeserializationProcess) – The current stage of the deserialization process. This object is generated by theFactoryand provides an interface to deserialization methods supporting multiple backends.- Return type:
- Returns:
The deserialized object.
- estimate_gain(input_signal)[source]¶
Estimate the gain required to adjust the signal to the ADC input range.
Returns: Linear gain to be applied to the input_signal’s Voltage samples.
- serialize(process)[source]¶
Serialize this object’s state.
Objects cannot be serialized directly, instead a
Factorymust be instructed to carry out the serialization process.- Parameters:
process (
SerializationProcess) – The current stage of the serialization process. This object is generated by theFactoryand provides an interface to serialization methods supporting multiple backends.- Return type:
- property gain: float[source]¶
Linear gain before ADC quantization.
Quantizer operates by default between -1. and +1. Signal can be adjusted by to this range by appropriate gain setting.
Returns: Gain in Volt.
- Raises:
ValueError – If gain is smaller or equal to zero.
- class AutomaticGainControl(agc_type=GainControlType.MAX_AMPLITUDE, backoff=1.0, rescale_quantization=False)[source]¶
Bases:
GainControlBaseAnalog-to-digital conversion automatic gain control modeling.
- Parameters:
agc_type (
GainControlType) – Type of amplitude gain control at ADC input. Default is GainControlType.MAX_AMPLITUDE.backoff (
float) – this is the ratio between maximum amplitude and the rms value or maximum of input signal, depending on AGC type. Default value is 1.0.rescale_quantization (
bool) – If enabled, the quantized signal is rescaled to the original signal range before gain adjustment. Disabled by default.
- classmethod Deserialize(process)[source]¶
Deserialize an object’s state.
Objects cannot be deserialized directly, instead a
Factorymust be instructed to carry out the deserialization process.- Parameters:
process (
DeserializationProcess) – The current stage of the deserialization process. This object is generated by theFactoryand provides an interface to deserialization methods supporting multiple backends.- Return type:
- Returns:
The deserialized object.
- estimate_gain(input_signal)[source]¶
Estimate the gain required to adjust the signal to the ADC input range.
Returns: Linear gain to be applied to the input_signal’s Voltage samples.
- serialize(process)[source]¶
Serialize this object’s state.
Objects cannot be serialized directly, instead a
Factorymust be instructed to carry out the serialization process.- Parameters:
process (
SerializationProcess) – The current stage of the serialization process. This object is generated by theFactoryand provides an interface to serialization methods supporting multiple backends.- Return type:
- property agc_type: GainControlType[source]¶
Automatic Gain Control
The AGC may have the following types of gain control, which wil specify the quantizer range: - GainControlType.NONE: no gain control, range must be specified - GainControlType.MAX_AMPLITUDE: the range is given by the maximum amplitude of the - GainControlType.RMS_AMPLITUDE: the range is given by the rms value plus a given backoff Note the for complex numbers, amplitude is calculated for both real and imaginary parts separately, and the greatest value is considered.
- class GainControlType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
SerializableEnumType of automatig gain control