One programme on two radios at once: FM and DAB+, each the other's backup, in the FPGA of a software-defined radio.
The receivers are written from the radio samples up, in the l8 language: an FM receiver and a complete DAB+ receiver (OFDM, the frequency loop, the service list, Viterbi, Reed-Solomon, the AAC decoder), side by side on one wide sample stream in the FPGA. The two copies of the programme are lined up in time and ONE audio stream leaves the board: DAB while it is good, the delayed FM in its gaps.
The hardware: a LimeSDR Mini 2.0 -- a Lattice ECP5 FPGA beside an LMS7002M radio chip. RECEIVE ONLY.
Status: ON THE AIR -- both methods receive SR P1 (FM + DAB+) and give one aligned audio stream (2026-12-01)
Download: nbrr-run.tar.gz -- the two board
images, the PC programs, the Verilog and its build scripts,
retune.py for your own stations (Reproduce it). nbrr-planner.tar.gz -- the
frequency planner (Your own
country).
Sveriges Radio P1 in Göteborg, received twice at once:
| frequency | what | |
|---|---|---|
| FM | 89.3 MHz | P1 (the receiver plays it mono) |
| DAB+ | block 12B, 225.648 MHz | ensemble SR GÖTEBORG, P1 = SId 0xE201, 168 kbit/s, AAC-LC |
The two are 136 MHz apart -- far more than the radio chip's sample stream is wide at its usual rates. Two ways to get both into the FPGA at once are built, and both work on the air.
Y antenna
│
│
┌─ radio chip ─────┐ ┌─ FPGA ECP5 (l8) ─────────────┐ ┌─ PC ────────────────┐
│ LMS7002M │ I/Q │ front: tune FM and DAB │ USB 3 │ ft601_pcm.py │
│ LNA, mixers │ ───▶ │ out of the wide stream │ ─────▶│ ft_pcm.py -> p1.wav │
│ (LO), 12-bit ADC │ │ DAB receiver FM receiver │ │ probe.py (state) │
└──────────────────┘ │ aligner + switch: ONE stream │ JTAG └─────────────────────┘
└──────────────────────────────┘ ◀────▶
One mono audio stream, 48 kHz, as mu-law bytes over USB 3 (24 000 words a second); the PC writes it to a WAV. JTAG only reads the receiver's state now and then (DAB lock, good FIBs, the lag, which source plays).
the air: the oscillator (LO) at 76 MHz -- and its 3rd harmonic, 228 MHz, which a square-wave mixer has too
LO 76.0 FM 89.3 DAB 12B 225.648 3 x LO = 228.0
│ │ │ │
────┴───────┴─────────────────────────────────────────────────┴──────────┴────▶ MHz
└ +13.3 ┘ └ -2.35 ───┘
the chip's output, 32.768 MS/s (-16 .. +16 MHz around the LO): both at once
-16 ──────────────────────── 0 ─────┬─────────────────────────┬──────── +16 MHz
│ │
DAB at +2.35 (mirrored: the FM at +13.3
FPGA takes the conjugate) (the fundamental)
The chip's mixers are driven by an almost square-wave oscillator, and a square wave has a third harmonic (a third of the amplitude). So the chip mixes Band III down at 3 x LO as well, with the spectrum turned around (the quadrature pair's third harmonic rotates the other way). ONE oscillator setting brings both stations into a 32.768 MS/s stream; the FPGA cuts them out (FM 256 kS/s, DAB 2.048 MS/s; DAB from the conjugated stream). The board's own sample rate, a slow FPGA clock (40 MHz) for the rest -- cheap; but the DAB arrives 9.5 dB weaker than directly.
the air: the window: LO 155.0 MHz +- 77.8 MHz (155.648 MS/s)
77.2 ├────────────────────────────────┼───────────────────────────────────┤ 232.8 MHz
│ LO 155.0 │
FM P1 89.3 DAB 12B 225.648
-65.7 MHz from the LO +70.65 MHz from the LO
in the FPGA, at 155.648 MHz (one sample a clock): two oscillators turn each station to 0 Hz (a CORDIC),
two CIC filters decimate (/ 304 FM, / 38 DAB), half-band filters at 40 MHz: FM 256 kS/s, DAB 2.048 MS/s
Sample the whole span and tune both stations in the FPGA. It needs the radio-to-FPGA bus at five times its documented 30.72 MS/s: it runs at 155.648 MS/s with the right sample point (the chip's clock delay and the FPGA's input delays, found by a scan of the bus with the chip's test pattern), and the front of the receiver runs at one sample per clock at 155.648 MHz. An ECP5 multiplier does not reach that clock in this design (118 MHz), so the oscillator-and-mixer is a pipelined CORDIC -- shifts and adds, one stage a clock -- and the CIC filters' final subtractions are spread over the clocks after each output (187 MHz reached).
| harmonic mixing | digital tuning | |
|---|---|---|
| DAB lock | the whole run | the whole run |
| audio units (AUs) | 7082 of 7165 good (1 %, covered by FM) | all good |
| Reed-Solomon corrections | ~6 bytes a super frame | 0 (a 4 s capture) |
| DAB null depth | 6.6 dB | 10.4 dB |
| FM stereo pilot over its surroundings | +32.7 dB | +44.8 dB |
| the FM / DAB lag | locked at 2.11 s after ~22 s | locked at 2.12 s after ~24 s |
| FPGA (ECP5-45) | 92 % of the logic, 108 of 108 block RAMs | 98 % of the logic, 102 of 108 block RAMs |
Digital tuning gives the cleaner signal; harmonic mixing needs no fast front and keeps room in the FPGA.
┌─ FM path ──────────────────────┐ ┌─ DAB path ───────────────────┐
│ FM: discriminator, de-emphasis │ │ DAB: OFDM, FIC, MSC, Viterbi │
│ -> 8 kHz mono │ │ -> DAB+ super frame, RS │
│ -> ADPCM ring, 3 s │ │ -> AAC-LC 48 kHz │
│ read back lag x 80 late │ │ -> a FIFO of AUs │
└────────────────────────────────┘ └──────────────────────────────┘
│ envelope │ envelope
┌─ aligner ───────────────────────────┐
│ the loudness envelopes of both │
│ (100 Hz) correlated over 5 s: │
│ the lag, a vote a second, │
│ the longer held, the harder to move │
└─────────────────────────────────────┘
│ lag (2.12 s)
┌─ switch ──────────────────────┐
│ every 20 ms: the DAB AU if it │
│ arrived whole, else the │
│ delayed FM (8 -> 48 kHz) │
└───────────────────────────────┘
│
▼ ONE mono mu-law stream, 48 kHz -> USB
DAB+ arrives about 2.1 s after FM (coding, interleaving, the audio codec's frames) -- a fixed delay: once measured it does not change. So the aligner searches slowly and with a shared correlator, and only after 6 s of good signal on both sides; then one vote a second, and the longer a lag held, the harder it is to move. The FM waits in a 3 s ring (8 kHz ADPCM: 4 bits a sample) and is read back that much late. Every 20 ms the switch plays the next DAB audio unit when it arrived whole, else the delayed FM. For a test of the switch the FPGA can make either side worse on purpose (noise or a dropout, from a JTAG command). Measured (harmonic image, 90 s): DAB cut at 46.8 s -- within 2 s the stream plays the delayed FM, the lag stays locked; DAB back at 61.1 s -- the stream returns to DAB by 63 s; 90.11 s of audio in 90.10 s, no gap at either switch (the FM part audibly duller: its 4 kHz band).
A DAB transmission frame (mode I, Band III):
┌──────┐┌──────┐┌────────────┐┌────────────────────────────────────────────────┐
│ null ││ PRS ││ FIC 3 sym ││ MSC: 72 symbols = 4 CIFs of 18 │
└──────┘└──────┘└────────────┘└────────────────────────────────────────────────┘
1.297 ms 1.246 3 x 1.246 ms 72 x 1.246 ms = 96 ms, 76 symbols after the null
a symbol: 2048 samples (2.048 MS/s) + a 504-sample guard (a copy of its end); 1536 carriers, 1 kHz apart,
each carries 2 bits as the CHANGE of its phase from the symbol before (D-QPSK) -- no channel estimate needed
From the samples to the audio -- every stage in the FPGA:
┌─────────────────────────┐
│ samples 2.048 MS/s │ null sync: the frame start by its silence (the frame clock)
└─────────────────────────┘
▼
┌─────────────────────────┐
│ frequency loop │ the guard's correlation (fraction of a carrier) + the PRS (whole carriers)
└─────────────────────────┘
▼
┌─────────────────────────┐
│ FFT 2048 │ 1536 carriers a symbol; D-QPSK: 3072 soft bits a symbol
└─────────────────────────┘
▼
┌─────────────────────────┐
│ frequency de-interleave │ the standard's carrier permutation
└─────────────────────────┘
▼
┌─────────────────────────┐
│ FIC: 3 symbols │ depuncture, Viterbi (K 7), energy dispersal, CRC -> 12 FIBs a frame
└─────────────────────────┘
▼
┌─────────────────────────┐
│ FIGs │ 0/1 sub-channels, 0/2 services, 1/1 labels: "P1 is SId E201, sub-channel at CU x"
└─────────────────────────┘
▼
┌─────────────────────────┐
│ MSC: the sub-channel │ its CUs out of each CIF (24 ms), time de-interleave over 16 CIFs
└─────────────────────────┘
▼
┌─────────────────────────┐
│ Viterbi (shared) │ EEP depuncture, Viterbi, energy dispersal -> 504 bytes a CIF (168 kbit/s)
└─────────────────────────┘
▼
┌─────────────────────────┐
│ DAB+ super frame │ 5 CIFs = 120 ms; Reed-Solomon (120, 110) over its columns; Fire code header
└─────────────────────────┘
▼
┌─────────────────────────┐
│ AUs │ 6 AAC access units, each with its CRC; AAC-LC -> 48 kHz PCM
└─────────────────────────┘
DAB+ adds a layer over the plain sub-channel: the super frame.
one super frame = 5 logical frames x 504 bytes = 2520 bytes, written in 21 columns of 120:
┌─ header ─────┐┌─ 6 AUs (168 kbit/s, 48 kHz) ─┐┌─ RS (120, 110) ─┐
│ Fire code 16 ││ AU 0 + CRC ││ 10 parity bytes │
│ rate, SBR, ││ AU 1 + CRC ││ a column │
│ AU starts ││ ... │└─────────────────┘
└──────────────┘│ AU 5 + CRC │
└──────────────────────────────┘
the RS code corrects up to 5 bad bytes in each column -- bytes the Viterbi left wrong, spread by the columns
The archive (above): the two board images, the PC programs (Python
3), the Verilog. You need a LimeSDR Mini 2.0 (on a USB 3 port), a JTAG
cable on the board's J5 (FT2232H based; openFPGALoader's
-c ft2232), an antenna for Band II and Band III, and an FM
station plus the DAB+ multiplex that carries the same programme. The
images are built for SR P1 in Göteborg (FM 89.3, 12B, SId 0xE201);
another pair needs a rebuild (the frequencies and the SId are constants
in the design).
tar xzf nbrr-run.tar.gz && cd nbrr-run
make check # tools, Python packages, the board
make prog-harmonic # or: make prog-digital (loads the FPGA, the radio chip boots itself)
make listen SECS=60 # p1.wav, and the receiver's state every 2 s
make switchover # harmonic image: DAB cut for 15 s -- the stream goes on with the delayed FM
The state lines: DAB lock and good, FM good, the lag's lock / value / confidence, the source playing (DAB or FM), frames, AAC frames, bad AUs, the frequency correction (Hz) and good FIBs a second (124 = all).
The radio chip's oscillator and sample rate stay as built: each method sees a fixed window, and inside it the FPGA's two digital oscillators pick the stations. So another station pair is a change of four numbers in the Verilog and a rebuild -- no other tool:
| the window | FM | DAB+ | |
|---|---|---|---|
| harmonic mixing | LO 76.0 MHz +- 15.4, and its 3rd harmonic 228.0 +- 15.4 | 87.5 .. 91.4 MHz | blocks 10C .. 13F |
| digital tuning | LO 155.0 MHz +- 76.3 | 87.5 .. 108 MHz (all) | blocks 5A .. 13A |
cd nbrr-run/verilog
python3 retune.py digital --show # what the image is tuned to
python3 retune.py digital --fm 101.7 --dab 11C --sid 0xE21A --kbps 96 # your FM station, DAB block, service, rate
make -C digital # yosys, nextpnr-ecp5, ecppack: top.bit
openFPGALoader -c ft2232 digital/top.bit
The service id (SId) and the sub-channel's rate come from your
country's DAB listings (or any DAB receiver's service information); up
to 168 kbit/s. The receiver finds the service's place in the ensemble
itself, from the service list it decodes. For digital tuning a block in
202 .. 222.5 MHz can be disturbed by a strong FM station's I/Q mirror
(retune.py warns). An FM station and a DAB block OUTSIDE
these windows need another oscillator setting -- the planner above finds
one; that is a rebuild from the design source (not in the archive).
nbrr-run/verilog/harmonic and
verilog/digital: each image's emitted Verilog (the l8
compiler's output; the l8 design source is not shipped), its pin and
timing constraints (top.lpf) and the Makefile of the open
ECP5 tool chain -- yosys, nextpnr-ecp5 (speed grade 6, the placement
seed that met timing), ecppack -- and a check of the pins' timing
against the board. make -C verilog/digital rebuilds
top.bit (some 20 minutes, 8 GB of memory).
The board's FPGA is a Lattice ECP5 LFE5U-45F (speed grade 6): 43 848 logic cells, 108 block RAMs of 18 kbit, 72 multipliers. After placement and routing:
| harmonic mixing | digital tuning | |
|---|---|---|
| logic cells | 39762/ 43848 90% | 43227/ 43848 98% |
| flip-flops | 14602/ 43848 33% | 16515/ 43848 37% |
| block RAMs (18 kbit) | 106/ 108 98% | 102/ 108 94% |
| multipliers 18 x 18 | 44/ 72 61% | 36/ 72 50% |
| LUT RAM cells | 51/ 5481 0% | 57/ 5481 1% |
| pins | 109/ 245 44% | 109/ 245 44% |
| the design clock (40 MHz) | 41.27 MHz (needs 40.00) | 40.91 MHz (needs 40.00) |
| the radio bus clock | 211.33 MHz (needs 125.00) | 185.12 MHz (needs 160.00) |
| USB 3 (100 MHz) | 133.03 MHz (needs 100.00) | 134.86 MHz (needs 100.00) |
| JTAG | 232.34 MHz (needs 40.00) | 217.25 MHz (needs 40.00) |
By block (yosys without flattening, each block's cells summed up its tree; before nextpnr packs and optimises across blocks, so the numbers run ~15 % above the totals above -- the shares are what to compare):
Harmonic mixing (top_comb6)
| block | logic cells | share | flip-flops | block RAMs | multipliers |
|---|---|---|---|---|---|
| the whole image | 51034 | 100 % | 16859 | 102 | 45 |
| the receiver back end (below) | 33855 | 66 % | 9923 | 95 | 32 |
| front: oscillators, mixers, CIC + half-band filters | 8128 | 16 % | 2922 | 0 | 12 |
| the radio chip's set-up (boot table, SPI, synthesizer tuning) | 4866 | 10 % | 1319 | 3 | 1 |
| switchover test (noise / dropout) | 606 | 1 % | 114 | 0 | 0 |
| UART echo, LED | 168 | 0 % | 103 | 0 | 0 |
| clock-crossing FIFOs | 153 | 0 % | 114 | 0 | 0 |
| the radio bus (LimeLight) | 136 | 0 % | 130 | 0 | 0 |
| switchover test control | 27 | 0 % | 10 | 0 | 0 |
| reset synchronisers | 12 | 0 % | 30 | 0 | 0 |
| the stream onto USB | 2 | 0 % | 0 | 0 | 0 |
| board support (sensors, LEDs, glue) | 3081 | 6 % | 2194 | 4 | 0 |
| the back end, inside | |||||
| DAB: sync, OFDM, demodulation, FIC, MSC, Viterbi | 15487 | 30 % | 3971 | 60 | 21 |
| AAC-LC decoder | 7793 | 15 % | 2201 | 19 | 3 |
| DAB+: super frame, Reed-Solomon, AUs | 5717 | 11 % | 1373 | 4 | 0 |
| FM: half-band | 956 | 2 % | 722 | 0 | 2 |
| FM discriminator | 722 | 1 % | 85 | 0 | 0 |
| FM delay: ADPCM encoder | 484 | 1 % | 89 | 0 | 0 |
| aligner: correlator | 436 | 1 % | 604 | 3 | 1 |
| aligner: envelopes | 399 | 1 % | 136 | 0 | 0 |
| FM delay: ADPCM decoder | 393 | 1 % | 24 | 0 | 0 |
| FM: decimation | 229 | 0 % | 183 | 0 | 0 |
| memories (FIFOs, rings) | 111 | 0 % | 145 | 9 | 0 |
| FM level meter | 110 | 0 % | 69 | 0 | 2 |
| FM: de-emphasis | 88 | 0 % | 24 | 0 | 3 |
| aligner: lock | 73 | 0 % | 30 | 0 | 0 |
| its own logic (switch, FIFOs, counters) | 857 | 2 % | 267 | 0 | 0 |
Digital tuning (top_cdt5)
| block | logic cells | share | flip-flops | block RAMs | multipliers |
|---|---|---|---|---|---|
| the whole image | 49791 | 100 % | 18466 | 102 | 37 |
| the receiver back end (below) | 34033 | 68 % | 9906 | 95 | 32 |
| front at 155.648 MHz: CORDIC mixers + CIC filters | 4908 | 10 % | 2842 | 0 | 0 |
| the radio chip's set-up (boot table, SPI, synthesizer tuning) | 4838 | 10 % | 1319 | 3 | 1 |
| half-band filters (FM, DAB) | 2526 | 5 % | 1902 | 0 | 4 |
| clock-crossing FIFOs | 184 | 0 % | 152 | 0 | 0 |
| UART echo, LED | 168 | 0 % | 103 | 0 | 0 |
| the radio bus (LimeLight) | 46 | 0 % | 24 | 0 | 0 |
| reset synchronisers | 16 | 0 % | 40 | 0 | 0 |
| the stream onto USB | 2 | 0 % | 0 | 0 | 0 |
| board support (sensors, LEDs, glue) | 3070 | 6 % | 2178 | 4 | 0 |
| the back end, inside | |||||
| DAB: sync, OFDM, demodulation, FIC, MSC, Viterbi | 15419 | 31 % | 3964 | 60 | 21 |
| AAC-LC decoder | 7969 | 16 % | 2201 | 19 | 3 |
| DAB+: super frame, Reed-Solomon, AUs | 5875 | 12 % | 1373 | 4 | 0 |
| FM: half-band | 956 | 2 % | 722 | 0 | 2 |
| FM discriminator | 615 | 1 % | 85 | 0 | 0 |
| FM delay: ADPCM encoder | 484 | 1 % | 89 | 0 | 0 |
| aligner: correlator | 456 | 1 % | 604 | 3 | 1 |
| aligner: envelopes | 399 | 1 % | 136 | 0 | 0 |
| FM delay: ADPCM decoder | 393 | 1 % | 24 | 0 | 0 |
| FM: decimation | 229 | 0 % | 183 | 0 | 0 |
| memories (FIFOs, rings) | 111 | 0 % | 145 | 9 | 0 |
| FM level meter | 110 | 0 % | 69 | 0 | 2 |
| FM: de-emphasis | 88 | 0 % | 24 | 0 | 3 |
| aligner: lock | 73 | 0 % | 30 | 0 | 0 |
| its own logic (switch, FIFOs, counters) | 856 | 2 % | 257 | 0 | 0 |
The best LO for each of SR's FM programmes with SR's DAB+ multiplex in the same city (the 3rd harmonic; the other SR FM channels of the city kept off the two signals' places; margin = the smallest distance in MHz to a band edge, the other signal, DC or an SR channel). FM and DAB positions are where the two land in the baseband (DAB mirrored). From public frequency listings, not official figures; * the DAB block assumed.
| city / transmitter | SR DAB | prog | FM MHz | 30.72 MS/s: best LO MHz | 61.44 MS/s: best LO MHz |
|---|---|---|---|---|---|
| Stockholm / Nacka | 12C | P1 | 92.4 | LO 79.27 (margin 1.6; FM +13.1, DAB +10.4) | LO 72.47 (margin 8.9; FM +19.9, DAB -10.0) |
| Stockholm / Nacka | 12C | P2 | 96.2 | no | LO 78.71 (margin 7.7; FM +17.5, DAB +8.8) |
| Stockholm / Nacka | 12C | P3 | 99.3 | no | LO 79.15 (margin 9.0; FM +20.2, DAB +10.1) |
| Stockholm / Nacka | 12C | P4 | 103.3 | no | LO 80.55 (margin 7.4; FM +22.8, DAB +14.3) |
| Göteborg | 12B | P1 | 89.3 | LO 77.68 (margin 3.1; FM +11.6, DAB +7.4) | LO 80.96 (margin 7.8; FM +8.3, DAB +17.2) |
| Göteborg | 12B | P3 | 99.4 | no | LO 78.43 (margin 8.6; FM +21.0, DAB +9.6) |
| Göteborg | 12B | P4 | 101.9 | no | LO 79.65 (margin 7.9; FM +22.3, DAB +13.3) |
| Malmö / Jägersro | 12B* | P1 | 87.9 | LO 77.12 (margin 4.0; FM +10.8, DAB +5.7) | LO 80.43 (margin 7.1; FM +7.5, DAB +15.6) |
| Malmö / Jägersro | 12B* | P2 | 93.3 | LO 79.28 (margin 0.7; FM +14.0, DAB +12.2) | LO 71.94 (margin 8.8; FM +21.4, DAB -9.8) |
| Malmö / Jägersro | 12B* | P3 | 98.0 | no | LO 78.70 (margin 7.8; FM +19.3, DAB +10.4) |
| Malmö / Jägersro | 12B* | P4 | 100.6 | no | LO 79.13 (margin 8.6; FM +21.5, DAB +11.7) |
4 of 11 programme/city pairs work at 30.72 MS/s, 11 at 61.44 MS/s (* = the DAB block assumed)
At the board's documented 30.72 MS/s only the lower FM channels pair with Band III (|f_DAB - 3 f_FM| must stay under 2 x the sample rate); at 61.44 MS/s -- the radio-to-FPGA bus runs it without an error, the FPGA decimates before USB -- every pair works.
nbrr-planner.tar.gz --
harmonic_plan.py (Python 3, no packages, no radio needed):
give it ANY pair -- your FM station and the DAB block of the same
programme (from your country's frequency listings) -- and
--all lists every way the board can receive the two at
once, ranked: FM and DAB on the oscillator's harmonics 1, 3, 5, 7
(digital tuning in one wide window, harmonic mixing as above, or a
weaker combination), at 30.72, 61.44 or 92.16 MS/s, with the LO, the
margin and where both land.
python3 harmonic_plan.py 103.3 12B --all;
--avoid takes other strong stations near you,
--region (eu, se, us, japan, kr, ...) the region's FM band
and DAB blocks (the USA and Japan have no DAB: HD Radio in the USA,
nothing in Japan). The table above is its sweden_plan.py
example.
The receiver's scan list (the European block table); bold the block above.
| block | MHz | block | MHz | block | MHz |
|---|---|---|---|---|---|
| 5A | 174.928 | 5B | 176.640 | 5C | 178.352 |
| 5D | 180.064 | 6A | 181.936 | 6B | 183.648 |
| 6C | 185.360 | 6D | 187.072 | 7A | 188.928 |
| 7B | 190.640 | 7C | 192.352 | 7D | 194.064 |
| 8A | 195.936 | 8B | 197.648 | 8C | 199.360 |
| 8D | 201.072 | 9A | 202.928 | 9B | 204.640 |
| 9C | 206.352 | 9D | 208.064 | 10A | 209.936 |
| 10N | 210.096 | 10B | 211.648 | 10C | 213.360 |
| 10D | 215.072 | 11A | 216.928 | 11N | 217.088 |
| 11B | 218.640 | 11C | 220.352 | 11D | 222.064 |
| 12A | 223.936 | 12N | 224.096 | 12B | 225.648 |
| 12C | 227.360 | 12D | 229.072 | 13A | 230.784 |
| 13B | 232.496 | 13C | 234.208 | 13D | 235.776 |
| 13E | 237.488 | 13F | 239.200 |