Also known as: LoRa interleaver, diagonal interleaver, offset interleaver
The LoRa diagonal interleaver is the bit-permutation that spreads each forward-error-correction codeword across all the symbols of a block along a rotating offset, so a channel burst that wipes out one whole symbol damages only a single bit of each codeword — exactly the pattern the Hamming code around it can repair.1 It is one link in the LoRa physical-layer chain: Gray mapping, then this interleaving, then Hamming(4+CR, 4) coding.2
How it works
A LoRa interleaver block is a rectangle: PPM rows (the spreading factor — or SF−2 in a
reduced-rate block) and (4+CR) columns, where CR is the coding rate 1..4. GopherTrunk’s
Interleave and Deinterleave are exact inverses built on one rule:
symbol[k]bit((r+k) mod ppm)=codeword[r]bitk
That +k offset per column is what makes it diagonal rather than a plain transpose: as the
column index k advances, the bit is rotated one more position around the symbol, so a single
codeword’s bits are smeared across every symbol at staggered positions. The payoff is fading
resilience — corrupting one received symbol removes at most one bit from any codeword, leaving
the per-codeword Hamming decoder a single-error problem it can solve.
Around the interleaver sit two more transforms, all inverse pairs so the whole chain is round-trip testable:
| Stage | TX direction | RX direction |
|---|---|---|
| Gray mapping | v ^ (v>>1) |
cumulative XOR |
| Diagonal interleave | Interleave |
Deinterleave |
| FEC | HammingEncode4 |
HammingDecode4 |
The Gray code mapping ensures adjacent chirp frequencies differ by one bit, so a small frequency slip in demodulation costs a single bit rather than several.
Coding rates and the Hamming code
The FEC is a family of Hamming(4+CR, 4) codes selected by the coding-rate field, carrying four
data bits per codeword and CR parity bits:
| CR | Rate | Parity | Capability |
|---|---|---|---|
| 1 | 4/5 | 1 (even parity) | detect only |
| 2 | 4/6 | 2 | detect |
| 3 | 4/7 | 3 (Hamming(7,4)) | single-error correct |
| 4 | 4/8 | 4 (Hamming(7,4) + overall) | correct + double-error detect |
At CR 3 and 4, GopherTrunk computes a 3-bit syndrome from the parity equations and maps it to the flipped bit position to correct it; CR 4 adds an overall-parity bit so a corrected single error can be told apart from an uncorrectable double error. The explicit header is always sent at the most robust rate, 4/8, because a receiver must decode it — to learn the payload length, coding rate and whether a payload CRC follows — before it knows the payload’s own coding rate.
Calibration caveat
As with the rest of LoRa’s reverse-engineered PHY, GopherTrunk implements these transforms as a self-consistent, round-trip-verified chain and flags exact bit-level interoperability with Semtech silicon — the interleaver’s rotation sign and the codeword bit order — as a calibration step gated behind captured golden vectors, not something assumed correct from the datasheet.
Sources
-
LoRa — Wikipedia, on the LoRa CSS physical layer, its interleaving and coding rates. ↩
-
Hamming code — Wikipedia, on the single-error-correcting block code the LoRa FEC is built from. ↩