GNSS-SDR 0.0.21
An Open Source GNSS Software Defined Receiver
Loading...
Searching...
No Matches
HistogramBitSynchronizer Class Reference

Histogram-based navigation data bit synchronizer. More...

#include <bit_synchronizer.h>

Classes

struct  Config
 Configuration parameters for HistogramBitSynchronizer. More...

Public Member Functions

 HistogramBitSynchronizer (const Config &cfg)
 Construct a histogram bit synchronizer with the provided configuration.
void reset ()
 Reset the synchronizer state.
bool update (const std::complex< float > &prompt, bool tracking_quality_ok)
 Update the synchronizer once per epoch.
bool locked () const
 Query whether the synchronizer has achieved lock.
int edge_phase () const
 Get the estimated bit edge phase bin.
bool is_edge_epoch (std::int64_t k) const
 Predict whether a given epoch index corresponds to a bit edge.
int bins () const
 Return the number of histogram bins.
const std::vector< int > & get_histogram () const
 Access the internal histogram (read-only).
std::int64_t get_total_events () const
 Total number of detected transition events accumulated into the histogram.
std::int64_t get_epoch_count () const
 Total number of epochs processed by update().
int epochs_until_next_edge () const
 Return the number of epochs until the next predicted navigation bit edge.

Detailed Description

Histogram-based navigation data bit synchronizer.

Definition at line 34 of file bit_synchronizer.h.

Constructor & Destructor Documentation

◆ HistogramBitSynchronizer()

HistogramBitSynchronizer::HistogramBitSynchronizer ( const Config & cfg)
inlineexplicit

Construct a histogram bit synchronizer with the provided configuration.

Initializes internal counters and allocates the histogram with bins() entries, all set to zero.

Parameters
cfgConfiguration parameters.

Definition at line 148 of file bit_synchronizer.h.

References bins().

Member Function Documentation

◆ bins()

int HistogramBitSynchronizer::bins ( ) const

Return the number of histogram bins.

Derived from the bit period and epoch duration, e.g.: bins = bit_period_ms / epoch_ms

Returns
Number of histogram bins.

Referenced by HistogramBitSynchronizer().

◆ edge_phase()

int HistogramBitSynchronizer::edge_phase ( ) const
inline

Get the estimated bit edge phase bin.

The edge phase is expressed as an integer histogram bin index in the range [0, bins()-1] when locked. The interpretation is “which epoch phase within the bit period is most likely to contain a navigation bit transition.”

Returns
Estimated edge phase bin index, or -1 if not locked.

Definition at line 213 of file bit_synchronizer.h.

◆ epochs_until_next_edge()

int HistogramBitSynchronizer::epochs_until_next_edge ( ) const

Return the number of epochs until the next predicted navigation bit edge.

When the synchronizer is locked, this function computes the forward distance (in epochs) from the most recently processed epoch to the next epoch that is aligned with the estimated bit-edge phase.

The result is expressed modulo the bit period and has the following meaning:

  • 0 : the current epoch corresponds to the predicted start of a new navigation bit
  • >0 : number of epochs remaining until the next bit boundary

The computation is based on the internal epoch counter advanced by update(), assuming that update() is called once per epoch with a constant cadence equal to Config::epoch_ms.

If the synchronizer is not locked, or if the configuration yields an invalid number of bins, this function returns -1.

Returns
Number of epochs until the next predicted bit edge, or -1 if not locked or if the bit period configuration is invalid.

◆ get_epoch_count()

std::int64_t HistogramBitSynchronizer::get_epoch_count ( ) const
inline

Total number of epochs processed by update().

This counter increments once per call to update(), regardless of whether a transition is detected or whether tracking_quality_ok is true.

Returns
Total processed epochs.

Definition at line 264 of file bit_synchronizer.h.

◆ get_histogram()

const std::vector< int > & HistogramBitSynchronizer::get_histogram ( ) const
inline

Access the internal histogram (read-only).

Each entry counts how many detected candidate transitions occurred at the corresponding phase bin within the bit period.

Returns
Reference to the histogram vector.

Definition at line 247 of file bit_synchronizer.h.

◆ get_total_events()

std::int64_t HistogramBitSynchronizer::get_total_events ( ) const
inline

Total number of detected transition events accumulated into the histogram.

Returns
Total detected events.

Definition at line 254 of file bit_synchronizer.h.

◆ is_edge_epoch()

bool HistogramBitSynchronizer::is_edge_epoch ( std::int64_t k) const

Predict whether a given epoch index corresponds to a bit edge.

For a given epoch index k (0-based), this function returns true when k is aligned with the currently estimated edge phase (i.e., the predicted transition epoch), and false otherwise.

If not locked, this always returns false.

Parameters
kEpoch index (0-based, consistent with the caller's epoch counting).
Returns
True if k is the predicted edge epoch; false otherwise.

◆ locked()

bool HistogramBitSynchronizer::locked ( ) const
inline

Query whether the synchronizer has achieved lock.

Returns
True if lock has been declared, false otherwise.

Definition at line 202 of file bit_synchronizer.h.

◆ reset()

void HistogramBitSynchronizer::reset ( )

Reset the synchronizer state.

Clears the histogram and all internal counters/flags, returning the instance to the pre-lock state:

◆ update()

bool HistogramBitSynchronizer::update ( const std::complex< float > & prompt,
bool tracking_quality_ok )

Update the synchronizer once per epoch.

This method should be called at a fixed cadence defined by Config::epoch_ms

The method:

  • Advances the internal epoch counter,
  • Optionally performs candidate transition detection if tracking quality is acceptable,
  • Updates the phase histogram on detected transitions,
  • Evaluates lock once enough events have been gathered.
Parameters
promptPrompt correlator output for the current epoch.
tracking_quality_okIndicates whether tracking quality is sufficient to trust the prompt sample for transition detection (e.g., code/carrier lock metrics).
Returns
True only on the epoch when lock is first declared; false otherwise (including subsequent epochs after lock has been achieved).

The documentation for this class was generated from the following file: