Skip to content

Bind sdr link metrics — EVM, MER, BER, I/Q imbalance #121

Description

@Ravenwater

Bind the SDR link-quality metrics — the measurement layer the whole
mixed-precision SDR study reports against.

Upstream source: include/sw/dsp/sdr/metrics.hpp (closes upstream #97).
Upstream tests: tests/test_sdr_metrics.cpp.

Surface

Result structs: EvmResult, BerResult, IqImbalance.

Free functions:

  • evm(reference, measured) -> EvmResult
  • mer_db(reference, measured) -> double
  • ber(transmitted, received) -> BerResult
  • theoretical_ber_awgn(Modulation, ebn0_db) -> double
  • iq_imbalance(reference, measured) -> IqImbalance
  • q_function(x) -> double

Binding notes

  • The templated ones are on typename Complex, not DspField — they are
    measurement code and run in double. No dtype= on these. That is the
    same reasoning that makes signal generators reference-precision: a metric
    that quantized itself would confound the thing it is measuring.
  • evm, mer_db and iq_imbalance take pairs of complex spans. This is the
    heaviest consumer of the inbound complex-array convention — whatever the
    foundations issue decides, these four signatures are where it shows.
  • ber takes std::span<const std::uint8_t> bit vectors; same uint8 ndarray
    typedef needed by the constellation issue.
  • theoretical_ber_awgn needs the Modulation enum bound by the constellation
    issue. If metrics lands first, bind the enum here instead — but bind it
    exactly once.
  • Result structs get def_ro properties. They are plain scalar aggregates, so
    the take_ownership rule does not bite here.
  • require_paired throws on length mismatch upstream; confirm the exception
    surfaces as a Python ValueError and test it.

Depends on

Foundations issue (complex array marshalling); Modulation from the
constellation issue.

Deliverables

  • Bindings in src/sdr_bindings.cpp.
  • Exported by explicit name in python/mpdsp/__init__.py.
  • tests/test_sdr_metrics.py, including a check that measured BER tracks
    theoretical_ber_awgn within a tolerance that scales with the error
    count (upstream hit exactly this flake — see 787cc37).
  • scripts/build_api_ref.py tables updated, docs/api_reference.md
    regenerated.

Part of the SDR binding epic #130.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions