Sequence
rpps.sequence ¶
The sequence resource: bit and chip sequences, config/sequence/
One engine for every operator that uses a known sequence: a scrambler XORs one in (rp.code.scram), a spreader multiplies
by one (rp.symbol.Spread), a phase scrambler turns symbols by one (rp.symbol.PhaseScramble), a code-phase search looks
for one (rp.sync.acquire_code).
rp.sequence.load("lte_gold", c_init=77).bits(100) a Recurrence: 0/1 bits from any position
rp.sequence.load("gps_ca", prn=1).chips a Code: (count, length) of +/-1
A config/sequence/
{"type": "recurrence", "sequences": [...], "skip": 1600} see rpps.sequence.recurrence
{"type": "chips" | "set" | "gold", ...} see rpps.sequence.code
{"type": "word", "word": "0x1ACFFC1D", "bits": 32} a fixed word (sync marker, access address): rpps.sequence.word
{"type": "zc", "root": 25, "length": 63, "shift": 0} a Zadoff-Chu sequence: `.symbols` (complex)
Complex sequences are computed: rp.sequence.zadoff_chu(u, N, shift) (rpps.sequence.zc), the CAZAC roots of LTE and NR
(PSS, PRACH, SRS, uplink DM-RS); a "zc" definition names one, as a preamble a profile's sync frame step finds.
Any value can be a load-time parameter ("params", then {"param": ...} / {"expr": ...}). Chip rates are in "rate" (chips/s).
Modules:
| Name | Description |
|---|---|
code |
Chip codes: a set of M chip sequences of N chips each, as +/-1 floats (spreading codes) |
lfsr |
|
recurrence |
Binary sequences defined the way standards define them: a linear recurrence or a shift register, optionally XOR'd |
word |
A fixed bit word (a sync marker, an access address, a start-of-frame delimiter), as a sequence definition |
zc |
Zadoff-Chu sequences: constant amplitude, zero periodic autocorrelation (CAZAC) |
Functions:
| Name | Description |
|---|---|
ls |
The sequences there are: {type folder: [names]} |
init |
A sequence from a definition object |
load |
Load a sequence by name: |
ls ¶
init ¶
load ¶
Load a sequence by name: load("barker11"), load("gps_ca", prn=1). params: values of its "params"
code ¶
Chip codes: a set of M chip sequences of N chips each, as +/-1 floats (spreading codes)
chips {"base": "sequence", "type": "chips", "chips": [1, -1, ...]} one sequence, written out (Barker)
{..., "bits": "10110111000", "one": -1} or as bits; one is the chip a 1 bit becomes (default -1: 0 -> +1)
set {"base": "sequence", "type": "set", "sequences": ["1101...", ...], "one": 1} one per symbol value (802.15.4)
gold {"base": "sequence", "type": "gold", "length": 1023, "sequences": [component, component], ...}
register sequences XOR'd (GPS C/A); a component is the recurrence of rpps.sequence.recurrence
({"length": 10, "taps": [0, 7], "init": 1023}).
"select": the component whose output is read at a delay chosen by a parameter, so one definition covers
every code of the family: {"component": 1, "stages": {"param": "prn"}, "table": {"1": [2, 6], ...}}
XORs the register stages the table lists for that value (stage k, 1 = first, is the output k-1 chips ahead of
the last stage, which is the output itself).
Any of them may carry "rate": the chip rate in chips/s, and "period": chips per code period (default the length).
Classes:
| Name | Description |
|---|---|
Code |
A set of spreading sequences. |
Code ¶
A set of spreading sequences. chips is (count, length) of +/-1; rate the chip rate in chips/s if the definition gives one
Methods:
| Name | Description |
|---|---|
bits |
The chips as 0/1 ( |
spread |
Each symbol times the sequence: (n,) -> (n*length,). index: which sequence (an int, or one per symbol for a set) |
despread |
Correlate each length-N block with the sequence, normalised by N: (n*length,) -> (n,) |
autocorrelation |
Periodic autocorrelation of a sequence (integer lags 0..length-1) |
crosscorrelation |
Periodic cross-correlation of sequences a and b |
Attributes:
| Name | Type | Description |
|---|---|---|
count |
Sequences in the set (1 for a single code) |
|
length |
Chips per sequence |
Source code in src/rpps/sequence/code.py
bits ¶
spread ¶
Each symbol times the sequence: (n,) -> (n*length,). index: which sequence (an int, or one per symbol for a set)
Source code in src/rpps/sequence/code.py
despread ¶
Correlate each length-N block with the sequence, normalised by N: (n*length,) -> (n,)
autocorrelation ¶
Periodic autocorrelation of a sequence (integer lags 0..length-1)
crosscorrelation ¶
Periodic cross-correlation of sequences a and b
lfsr ¶
Classes:
| Name | Description |
|---|---|
LFSR |
|
LFSR ¶
Methods:
| Name | Description |
|---|---|
clone |
Independent copy, in its current state |
fresh |
Independent copy, at the seed |
advance |
One step of a self-synchronizing (feedthrough) scrambler: |
Source code in src/rpps/sequence/lfsr.py
clone ¶
fresh ¶
advance ¶
One step of a self-synchronizing (feedthrough) scrambler: bit in, the scrambled or descrambled bit out
The register holds what went through the scrambler, not a free-running keystream: the scrambler feeds its own output back (y[n] = d[n] ^ taps of the past y), the descrambler the bits it receives (d[n] = y[n] ^ the same taps of the past y). Joined mid-stream a descrambler is right after one register length of bits
Source code in src/rpps/sequence/lfsr.py
recurrence ¶
Binary sequences defined the way standards define them: a linear recurrence or a shift register, optionally XOR'd with a second one (a Gold sequence), from a seed that is often a load-time parameter
{"base": "sequence", "type": "recurrence",
"sequences": [component, ...], XOR'd together (two for a Gold sequence)
"skip": 1600} outputs dropped before the first one used (LTE's Nc)
A component is a recurrence s[t+L] = XOR of s[t+j] over taps, output s[t]:
{"length": 31, "taps": [0, 3], "init": 1, "init_order": "lsb"}
init: the first L outputs, as an integer (lsb: bit i is s[i]; msb: bit L-1-i is s[i]) or a list of bits
or a register as drawn (Galois form, as Bluetooth draws its whitening LFSR):
{"register": "galois", "length": 7, "taps": [4], "state": [1, 0, 1, 0, 0, 1, 1]}
positions 0..L-1; each step outputs position L-1, shifts toward it, feeds the output into position 0
and XORs it into each tap position
Taps here are positions, from 0. A feedthrough scrambler's "poly" (rpps.code.scram) is the polynomial's exponents instead, from 1, the way the standards write it (1 + x^14 + x^17 is [14, 17]): two things, two keys.
Classes:
| Name | Description |
|---|---|
Recurrence |
A binary sequence: its components XOR'd, |
Recurrence ¶
A binary sequence: its components XOR'd, skip outputs dropped first. bits(n, start) are its bits from position
start (0 = the first after skip); the sequence runs on as far as it is asked
Methods:
| Name | Description |
|---|---|
bits |
n bits from position |
Source code in src/rpps/sequence/recurrence.py
bits ¶
n bits from position start, as 0/1
word ¶
A fixed bit word (a sync marker, an access address, a start-of-frame delimiter), as a sequence definition
{"base": "sequence", "type": "word", "word": "0x1ACFFC1D", "bits": 32, "order": "msb"}
bits is the word in the order it is sent: most significant bit first ("msb", the default) or least ("lsb", Bluetooth).
A delimiter search (rp.sync.Delimiter) and a marker (rp.code.Marker) name one, so the two agree.
Classes:
| Name | Description |
|---|---|
Word |
A known bit word. |
Functions:
| Name | Description |
|---|---|
word_bits |
The bits of a word in transmission order: from an int (or hex string) of |
Word ¶
A known bit word. bits: the bits as sent (bool array); value, n, order as defined
Source code in src/rpps/sequence/word.py
word_bits ¶
The bits of a word in transmission order: from an int (or hex string) of bits bits, or from a list/array of bits as given
Source code in src/rpps/sequence/word.py
zc ¶
Zadoff-Chu sequences: constant amplitude, zero periodic autocorrelation (CAZAC)
rp.sequence.zadoff_chu(25, 63) root 25 of length 63 (LTE's PSS punctures its middle element)
rp.sequence.zadoff_chu(129, 839, 13) a PRACH root, cyclically shifted by 13
x_u[n] = exp(-j pi u n (n + N mod 2) / N), u coprime to N. Every element has magnitude 1 and the periodic autocorrelation is zero at every lag but 0, so a received period correlated with the root gives one peak (the channel) and noise alone at every other lag: rp.sync.quality.from_sequence reads the SNR from that. Two roots of a prime length cross-correlate at 1/sqrt(N) at every lag.
As a definition (a preamble a profile's sync frame step names): {"base": "sequence", "type": "zc", "root": 25,
"length": 63, "shift": 0}; loaded, .symbols is the sequence and .fields its root and shift.
Classes:
| Name | Description |
|---|---|
ZadoffChu |
A Zadoff-Chu sequence definition: |
Functions:
| Name | Description |
|---|---|
zadoff_chu |
Root u of length N (u coprime to N, 0 < u < N), cyclically advanced by |
ZadoffChu ¶
A Zadoff-Chu sequence definition: symbols (complex, unit magnitude), fields ({"root", "shift"})
Source code in src/rpps/sequence/zc.py
zadoff_chu ¶
Root u of length N (u coprime to N, 0 < u < N), cyclically advanced by shift: x[(n + shift) mod N]