Analog-Digital Conversion

Inheritance diagram of hermespy.simulation.rf.blocks.ad.ConverterBase, hermespy.simulation.rf.blocks.ad.ADC, hermespy.simulation.rf.blocks.ad.DAC

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, DSPOutputBlock

Model 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 Factory must be instructed to carry out the deserialization process.

Parameters:

process (DeserializationProcess) – The current stage of the deserialization process. This object is generated by the Factory and provides an interface to deserialization methods supporting multiple backends.

Return type:

ADC

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:

None

realize(bandwidth, oversampling_factor, carrier_frequency)[source]

Return the current state of the radio-frequency block.

Parameters:
  • bandwidth (float) – Bandwith of the proecessed signals in Hz.

  • oversampling_factor (int) – Oversampling factor of the modeling.

  • carrier_frequency (float) – Target carrier frequency of the modeled radio front-end in Hz.

Return type:

RFBlockRealization

Returns:

Current state of the radio-frequency block.

serialize(process)[source]

Serialize this object’s state.

Objects cannot be serialized directly, instead a Factory must be instructed to carry out the serialization process.

Parameters:

process (SerializationProcess) – The current stage of the serialization process. This object is generated by the Factory and provides an interface to serialization methods supporting multiple backends.

Return type:

None

NO_RESAMPlING: float = 0.0[source]

Magic number of the ADC’s sampling rate indicating no resampling is applied.

gain: GainControlBase[source]
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:
  • num_quantization_bits (int | None) – DAC resolution in bits. Default is infinite resolution (no quantization)

  • num_ports (int) – Number of analog ports of the DAC.

  • 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 Factory must be instructed to carry out the deserialization process.

Parameters:

process (DeserializationProcess) – The current stage of the deserialization process. This object is generated by the Factory and provides an interface to deserialization methods supporting multiple backends.

Return type:

DAC

Returns:

The deserialized object.

realize(bandwidth, oversampling_factor, carrier_frequency)[source]

Return the current state of the radio-frequency block.

Parameters:
  • bandwidth (float) – Bandwith of the proecessed signals in Hz.

  • oversampling_factor (int) – Oversampling factor of the modeling.

  • carrier_frequency (float) – Target carrier frequency of the modeled radio front-end in Hz.

Return type:

RFBlockRealization

Returns:

Current state of the radio-frequency block.

serialize(process)[source]

Serialize this object’s state.

Objects cannot be serialized directly, instead a Factory must be instructed to carry out the serialization process.

Parameters:

process (SerializationProcess) – The current stage of the serialization process. This object is generated by the Factory and provides an interface to serialization methods supporting multiple backends.

Return type:

None

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: RFBlock

Base class for analaog-digital and digital-analog converters.

Parameters:
  • num_quantization_bits (int | None) – ADC resolution in bits. Default is infinite resolution (no quantization)

  • num_ports (int) – Number of digital/analog ports of the converter.

  • seed (int | None) – Seed with which to initialize the block’s random state.

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.

property num_quantization_levels: float[source]

Number of quantization levels

Returns: Number of levels.

class GainControlBase(rescale_quantization=False)[source]

Bases: Serializable

Base 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:
  • input_signal (RFSignal) – Input signal to be adjusted.

  • gain (float) – Linear gain to be applied to the input_signal’s Voltage samples.

Return type:

RFSignal

Returns: The adjusted signal.

abstract estimate_gain(input_signal)[source]

Estimate the gain required to adjust the signal to the ADC input range.

Parameters:

input_signal (RFSignal) – Input signal to be adjusted.

Return type:

float

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_quantization is enabled.

Parameters:
  • quantized_signal (RFSignal) – Quantized signal to be adjusted.

  • gain (float) – Linear gain to applied to the input_signal’s Voltage samples before quantization.

Return type:

RFSignal

Returns: The scaled qzanitized signal.

property rescale_quantization: bool[source]

Rescale the quantized signal to the original signal range before gain adjustment.

class Gain(gain=1.0, rescale_quantization=False)[source]

Bases: GainControlBase

Constant gain model.

Parameters:
  • gain (float) – Linear signal gain to be applied before ADC quantization. Unit by default, meaning no gain adjustment.

  • 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 Factory must be instructed to carry out the deserialization process.

Parameters:

process (DeserializationProcess) – The current stage of the deserialization process. This object is generated by the Factory and provides an interface to deserialization methods supporting multiple backends.

Return type:

Gain

Returns:

The deserialized object.

estimate_gain(input_signal)[source]

Estimate the gain required to adjust the signal to the ADC input range.

Parameters:

input_signal (RFSignal) – Input signal to be adjusted.

Return type:

float

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 Factory must be instructed to carry out the serialization process.

Parameters:

process (SerializationProcess) – The current stage of the serialization process. This object is generated by the Factory and provides an interface to serialization methods supporting multiple backends.

Return type:

None

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: GainControlBase

Analog-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 Factory must be instructed to carry out the deserialization process.

Parameters:

process (DeserializationProcess) – The current stage of the deserialization process. This object is generated by the Factory and provides an interface to deserialization methods supporting multiple backends.

Return type:

AutomaticGainControl

Returns:

The deserialized object.

estimate_gain(input_signal)[source]

Estimate the gain required to adjust the signal to the ADC input range.

Parameters:

input_signal (RFSignal) – Input signal to be adjusted.

Return type:

float

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 Factory must be instructed to carry out the serialization process.

Parameters:

process (SerializationProcess) – The current stage of the serialization process. This object is generated by the Factory and provides an interface to serialization methods supporting multiple backends.

Return type:

None

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.

property backoff: float[source]

Quantizer backoff in linear scale

This quantity determines the ratio between the maximum quantization level and the signal rms value

Returns: The backoff in linear scale

class GainType[source]

Type of gain.

alias of TypeVar(‘GainType’, bound=Gain)

class GainControlType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: SerializableEnum

Type of automatig gain control

MAX_AMPLITUDE = 1[source]
NONE = 0[source]
RMS_AMPLITUDE = 2[source]
class QuantizerType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: SerializableEnum

Type of quantizer

MID_RISER = 0[source]
MID_TREAD = 1[source]