Web Simulation 

 

 

 

 

Gold Sequence Visualizer 

This interactive tutorial visualizes Gold sequences, a family of deterministic binary pseudo-random sequences made by XORing two maximum-length sequences. Gold sequences are widely used in spread spectrum and cellular systems because they provide many code choices with bounded, predictable correlation behavior.

Mathematical Foundation

1. Maximum-Length Sequences

A Gold sequence starts from two binary LFSR sequences, usually called a(n) and b(n). If the register length is m, each maximum-length sequence has period:

N = 2m − 1

The simulator uses example LFSR tap sets for m = 5, 7, and 10. The exact bit pattern depends on the feedback taps and seed, but the key idea is the same: a deterministic shift register produces a random-looking periodic sequence.

2. Gold Sequence Construction

A Gold code is generated by XORing one m-sequence with a cyclically shifted version of the other:

gs(n) = a(n) ⊕ b((n + s) mod N)

Different values of s generate different members of the Gold family. Including the two original m-sequences, the family size is:

Family size = 2m + 1
3. Correlation Measurement

Correlation is usually evaluated with bipolar symbols, where bit 1 maps to +1 and bit 0 maps to −1:

Rx,y(k) = ∑n=0N−1 X(n) Y((n + k) mod N)

A perfect match produces a large peak. Different Gold codes do not give zero correlation, but their cross-correlation is bounded compared with the match peak.

4. Timing Offset and CFO Impairments

In the simulator, Gold bits can be mapped to either BPSK chips or a QPSK-like constellation. For BPSK, bit 1 maps to +1 and bit 0 maps to −1. For the QPSK-like option, adjacent Gold bits are mapped to I and Q:

s(n) = [(2c(n) - 1) + j(2c(n+1) - 1)] / √2

A timing offset shifts the received sequence in samples:

r(n) = X(n + τ)

This should move the correlation peak to a different cyclic-shift bin. CFO is modeled as a progressive phase rotation of the selected received constellation symbols:

Δf = CFOppm × 10−6 × Fc
r(n) = X(n) exp(j 2π Δf n / Fs)

The receiver still correlates against a CFO-free reference, so the phase ramp reduces coherent correlation peak energy.

5. Strengths and Weaknesses

Strength

Many deterministic codes can be created from two LFSRs by changing only the relative shift.

Strength

Gold sequences look noise-like and are nearly balanced over one period.

Strength

Cross-correlation is bounded, making the family useful for code separation and acquisition.

Weakness

Cross-correlation is not zero. Multiple users or cells can still interfere.

Weakness

Short sequences have limited processing gain and fewer usable code choices.

Simulation

The interactive simulator is below. Use the preset dropdown to jump between important properties and practical limitations.

Bit Sequences
Periodic Correlation
Reference Constellation
Received Constellation
Gold: gs(n) = a(n) ⊕ b((n + s) mod N)   |   Correlation: R(k) = |∑ X(n) Y*((n + k) mod N)|
Preset Scenario
Sequence Parameters
5
5
0
Impairment and View
0
0.0 ppm (0 Hz, 0.000 cyc/N)
3500 MHz
7.68 MHz
0%
96
Period N
Family Size
Ones Ratio
Peak
Max Floor
Generated Gold A Bits

 

Usage

  1. Preset Scenario: Select a strength or weakness case. The controls update automatically. Presets that use cross-correlation demonstrate code separation or interference behavior, not a matched-code detection peak.
  2. Register length m: Changes the period N = 2m − 1 and family size.
  3. Gold shift A/B: Selects which family member is generated by shifting the second m-sequence before XOR.
  4. Correlation mode: Auto compares a code to a shifted copy and should produce a strong match peak. Cross compares two different Gold family members and should show bounded, nonzero correlation rather than a full peak.
  5. Constellation: Selects the symbol mapping used for the reference/received constellation plots and for the correlation calculation. BPSK is a chip-level correlation view; QPSK-like uses adjacent bits as I/Q.
  6. Timing Offset: Shifts the received/compared sequence in samples. In auto-correlation mode, the peak should move with this offset.
  7. CFO: Applies oscillator error in ppm. The simulator converts ppm to frequency offset using carrier frequency, then converts it to phase rotation per sample using sample rate.
  8. Bit flip probability: Adds deterministic random bit errors to the compared sequence to show degradation.
  9. Step/Run: Moves the bit window forward or backward. Step buttons stop animation before stepping.

Visualizations

  • Bit Sequences: Shows x1, x2, Gold A, and the compared sequence. Color indicates bit value.
  • Periodic Correlation: Shows correlation for all cyclic shifts. A tall single peak means good synchronization detection. A raised floor means interference or impairment.
  • Reference/Received Constellation: Shows the exact symbols used in correlation. Timing offset changes symbol order; CFO rotates the received constellation progressively.
  • Summary Panel: Reports period, family size, balance, strongest correlation peak, and strongest non-peak floor.

Key Insights

  • Deterministic pseudo-randomness: Gold sequences look random, but both transmitter and receiver can reproduce them exactly from the same generator setup.
  • Useful code family: Many codes come from two LFSRs and a relative shift, which is efficient for hardware and protocol design. This strength is about code generation capacity, not about producing a high cross-correlation peak.
  • Bounded but nonzero interference: Gold sequences are not perfectly orthogonal. Cross-correlation is controlled, not eliminated.
  • Timing vs CFO: Timing offset mainly moves the peak. CFO mainly lowers and spreads the coherent correlation magnitude because samples no longer share the same phase.
  • Processing gain depends on length: Longer periods give better discrimination but need longer acquisition and more computation.

Limitations

  • Teaching-oriented LFSRs. The simulator uses example tap pairs for visual clarity. Specific standards may use different initialization, taps, offsets, and scrambling formulas.
  • Simplified channel. The channel includes cyclic timing offset, CFO phase rotation, and bit flipping. Multipath, sample clock offset, soft decisions, pulse shaping, and receiver thresholds are not modeled.
  • Correlation-only receiver. Real receivers search over code phase, frequency/timing hypotheses, and thresholds under false-alarm constraints.