MCPcopy Create free account
hub / github.com/davidgiven/fluxengine / readBit

Method readBit

lib/decoders/fluxdecoder.cc:30–91  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28}
29
30bool FluxDecoder::readBit()
31{
32 if (_leading_zeroes > 0)
33 {
34 _leading_zeroes--;
35 return false;
36 }
37 else if (_leading_zeroes == 0)
38 {
39 _leading_zeroes--;
40 return true;
41 }
42
43 while (!_fmr->eof() && (_flux < (_clock / 2)))
44 {
45 _flux += nextFlux() * _flux_scale;
46 ;
47 _clocked_zeroes = 0;
48 }
49
50 _flux -= _clock;
51 if (_flux >= (_clock / 2))
52 {
53 _clocked_zeroes++;
54 _goodbits++;
55 return false;
56 }
57
58 /* PLL adjustment: change the clock frequency according to the phase
59 * mismatch */
60 if (_clocked_zeroes <= 3)
61 {
62 /* In sync: adjust base clock */
63
64 _clock += _flux * _pll_adjust;
65 }
66 else
67 {
68 /* Out of sync: adjust the base clock back towards the centre */
69
70 _clock += (_clock_centre - _clock) * _pll_adjust;
71
72 /* We require 256 good bits before reporting another sync loss event. */
73
74 if (_goodbits >= 256)
75 _sync_lost = true;
76 _goodbits = 0;
77 }
78
79 /* Clamp the clock's adjustment range. */
80
81 _clock = std::min(std::max(_clock_min, _clock), _clock_max);
82
83 /* I'm not sure what this does, but the original comment is:
84 * Authentic PLL: Do not snap the timing window to each flux transition
85 */
86
87 _flux = _flux * (1.0 - _pll_phase);

Callers 2

mainInspectFunction · 0.80
OnPaintMethod · 0.80

Calls 1

eofMethod · 0.45

Tested by 1

mainInspectFunction · 0.64