Configuration, Boot Order and Partial Reconfiguration
Most fabric forgets its design when the power goes off. Who writes it back, and when, decides which half is ready first. Part of the fabric can even change while the rest runs, if it is fenced off first.
You Will Be Able To
- Compare three boot orders of an FPGA SoC, and work out when each half is ready.
- Explain partial reconfiguration: one region rewritten while the static logic runs.
- Say what a decoupler must do while a region changes, and why a plain gate is not enough.
- Lesson
- S10.19
- Time
- 30 min
- Runs on
- Your browser
- Check
- 5 questions
A camera board swaps the image filter in its fabric while video keeps flowing. One swap in fifty, the processor freezes.
The old filter is fine, and so is the new one. What froze the processor?
Before You Start
You need FPGA SoCs: ap_fpga, the fabric, the bitstream and the fabric window.
You need The Multi-Stage Secure Boot Chain: a boot ROM, then a loader that checks the next image.
You need Power at Chip Level: clamps hold the outputs of a domain steady while it is off.
It helps to have read The Power-Up Sequence.
| Question | |
|---|---|
| 1 | Who writes the bitstream into the fabric, and which half is ready first? |
| 2 | What is partial reconfiguration, and what keeps running during it? |
| 3 | Why must a region be fenced off while it changes? |
| 4 | Why is a plain gate on the region's wires not enough? |
| 5 | With a bitstream of 100 words, what does the lab print for the hard-first order? |
The Idea: An Empty Fabric, and a Region That Changes
Most fabric keeps its design in SRAM cells. When the power goes off, the design is gone. At every power-up the fabric is empty, and somebody must write the bitstream again.
That somebody sets the boot order. If the loader of the hard half writes it, the processor runs first. If a small block of its own loads it from flash, the fabric is ready first. Some fabric keeps its design without power, and is ready almost at once.
The second idea is bolder. The fabric need not change all at once. One region can be rewritten while the rest keeps running. This is partial reconfiguration. A camera board can change its filter between two frames, and never stop the video.
While a region changes, its wires carry noise. So it must be fenced off, much as clamps fence off a power domain that is off. The fence has one more job: it must not cut a request in half.
New Words
| Word | Meaning |
|---|---|
| Configuration port | The port through which a bitstream is written into the fabric. In the lab it takes one word in each tick. |
| Configuration block | A small fixed block that loads the bitstream from flash by itself, before any processor runs. |
| Kept design | A fabric whose cells hold their design without power, so nothing is loaded at power-up. |
| Static logic | The part of the fabric that stays the same, and keeps running, while a region is rewritten. |
| Partial bitstream | The bitstream of one region only. |
| Decoupler | A block between a region and the static logic that fences the region off while it changes. |
| Open request | A request that has been sent and not yet answered. |
| Drain | Letting the open requests finish before the fence closes. |
One Picture: One Region, Swapped
- Processor
- Control / FSM
- Peripheral
- Bus
- Memory
- Running
Requests reach the region through the decoupler. Its stream and its interrupt come back the same way.
- Fence first
Software asks the decoupler to isolate the region. From now on nothing the region does reaches the static logic.
- Rewrite the region
The loader writes the partial bitstream through the configuration port. Meanwhile the wires of the region are noise.
- The rest goes on
The static logic never stops. Video keeps flowing past the region, and the window still answers.
- Open the fence
The new design has started. Software lets go of decouple, and the region joins again.
Read the diagram as text
- Hard half: ap_soc: the processor and its loader
- Configuration port: takes a bitstream one word at a time
- Static logic: stays the same: the window, the video path
- Decoupler: the fence between static logic and region
- Region: today a sharpening filter, soon a blur
- Partial bitstream: the design of the region only
- Hard half → Static logic: requests
- Static logic → Decoupler: requests
- Decoupler → Region: requests
- Region → Decoupler: stream, interrupt
- Hard half → Decoupler: decouple
- Partial bitstream → Configuration port: words
- Configuration port → Region: new design
A region of ap_fpga, the exercise chip of S10.14. The filter names are an example. Real tools name these parts in their own words.
The Smallest Example, Worked by Hand
No simulator yet. In ap_fpga the boot ROM runs for 5 ticks, and then the loader needs 20 to check its next image. The bitstream has 64 words, one a tick. The fabric needs 3 ticks to wake its logic. The two halves may talk once both are ready.
| Order | Loader done | Fabric live | Halves may talk |
|---|---|---|---|
| Kept design: nothing to load | 5 + 20 = 25 | 3 | 25 |
| Fabric first: a configuration block loads it; the hard half waits in reset | 67 + 5 + 20 = 92 | 64 + 3 = 67 | 92 |
| Hard half first: the loader writes it | 5 + 20 = 25 | 25 + 64 + 3 = 92 | 92 |
Two orders end at the same tick, 92, but for opposite reasons. In fabric first, the fabric works from tick 67 while the processor is still in reset. In hard half first, the processor runs from tick 25 while the fabric is still empty.
Now the swap. The region of the lab sends a stream word every 4 ticks and an interrupt every 8. While it is rewritten, for 16 ticks, its three output wires carry noise. Each one is 1 about half the time. Without a fence, about 8 false events on each wire reach the static logic.
The Rules
Rule 1: Fabric in SRAM cells is empty after power-up.
Something must write its bitstream at every power-up.
Rule 2: Whoever writes the bitstream sets the boot order.
The loader: the hard half first. A configuration block: the fabric first. A kept design: the fabric is ready almost at once.
Rule 3: The halves may talk only when both are ready.
The bridge opens at the later of the two times.
Rule 4: A region can change while the static logic runs.
Only its own partial bitstream is written. Its wires carry noise until the new design has started.
Rule 5: Fence the region before the swap, and open the fence after its new design has started.
Nothing the region does in between may reach the static logic.
Rule 6: A fence must not cut an open request in half.
Let the open request drain first. Then answer for the region, so that no request waits for ever.
Sources for These Rules
Fabric configured from SRAM loses its design without power and is loaded at power-up, from a computer or a memory chip. Some parts keep it on chip instead. Source: Harris and Harris, Digital Design and Computer Architecture, ARM edition, section 5.6.2.
Clamps at the boundary of a domain that is off: see Power at Chip Level and its sources.
Rules 2 to 6 are common practice for FPGA SoCs, stated on ap_fpga. The vendor guides to boot and to partial reconfiguration are not in our reference library. The tick counts are exercise values.
Now Run It
The lab at the end of this page has two parts. The first adds up the three boot orders. The second is a circuit: one region, swapped three times behind a plain decoupler that gates four wires.
order=kept-design loader_done=25 fabric_live=3 bridge_open=25
order=fabric-first loader_done=92 fabric_live=67 bridge_open=92
order=hard-first loader_done=25 fabric_live=92 bridge_open=92
swap without decoupling: stray valid=8 irq=8 answers=7
swap with decoupling: stray valid=0 irq=0 answers=0
read open when decoupling starts: answered=0 after 20 ticksRules 2 and 3 in the first three rows, exactly as in the hand table.
Rule 4 in the fourth row. With no fence, the static logic sees 8 false stream words and 8 false interrupts in 16 ticks. It also sees 7 answers to no request.
Rule 5 in the fifth row. The decoupler closes one tick before the swap and opens one tick after. Nothing gets through.
Rule 6 in the last row. A read of the region is open when the plain decoupler closes. The gate hides the answer, and the static side waits. After 20 ticks the lab gives up. A processor would not.
This lab leaves things out. It writes no real bitstream, and its region is a few counters. The plain decoupler has no drain and no answer of its own: building those is problem S10.19.1.
Why It Is Built This Way
| Design choice | The alternative | What the choice buys, and costs |
|---|---|---|
| The loader writes the bitstream (hard half first) | A configuration block (fabric first) | The boot chain can check the bitstream with its own keys, and software can choose it. The fabric is empty until late. |
| A configuration block loads the fabric | The loader does it | The fabric can work before any software, for example to sequence supplies. The processor waits in reset. |
| Rewrite one region | Rewrite the whole fabric | The rest keeps running, and the partial bitstream is short. The region needs a fence and fixed borders. |
| A decoupler that drains, then answers | A plain gate | No request is cut in half, and a stray access fails at once. The decoupler needs states and a status bit. |
The Trap: The Read That Never Came Back
This is the camera board from the top of the page. Its driver set decouple, then wrote the new filter. The decoupler was a plain gate.
Most of the time no request was open, and the swap was clean. One time in fifty, the processor had just read a register of the filter. The gate closed between the request and the answer. The processor waited for an answer that the gate now hid.
The fix is rule 6. Let the open request finish, then close the fence. Afterwards answer any new request with an error at once. Software also needs a status bit that says the fence is really closed.
The second trap is opening the fence too early. The new design has just been written, but has not left reset. Its first output is noise, and it reaches the static logic.
The third trap is a pin. In the hard-first order, a fabric pin that switches a supply is not driven until tick 92. Decide its level with a resistor on the board.
At Scale
This section names what real families do. The vendor guides are not in our reference library: each fact is labelled "not checked".
Three boot orders in real families
AMD Zynq parts boot the processor system first, which then loads the fabric. Intel (Altera) parts have a manager block that configures, with either half first. PolarFire SoC fabric keeps its design without power. All not checked.
Names for the same idea
AMD calls partial reconfiguration Dynamic Function eXchange, and its tools offer a decoupler block. Intel uses the name partial reconfiguration. Not checked.
A bitstream is an image
It can be encrypted and signed like any boot image, and checked by the same chain. Then an old or altered fabric design is refused too.
Verifying a swap
A bench for a swap drives noise on the wires of the region, as the lab does. It then checks that nothing reaches the static logic, and that no request hangs.
The next lesson, Two Case Studies From Public Documents, reads a real FPGA SoC and a real RISC-V chip. It maps each block to a lesson of this module.
Try It
Run the lab. Check the first three rows against the hand table.
Set BIT_WORDS to 200. Which order now opens the bridge last, and by how much?
Set SWAP_TICKS to 4, then to 40. Which counts of stray events change, and which stay at 0?
Names Printed by the Lab
| Name | Meaning |
|---|---|
| order | Who writes the bitstream: nobody (kept-design), a configuration block (fabric-first) or the loader (hard-first). |
| loader_done | The tick at which the loader of the hard half has finished. |
| fabric_live | The tick at which the fabric logic has left reset with its design. |
| bridge_open | The tick from which the two halves may talk: the later of the two above. |
| stray valid, irq, answers | Events that reached the static logic during the swap: stream words, interrupts, and answers to no request. |
| answered | Whether a read that was open when decoupling began ever got its answer. |
order=kept-design loader_done=25 fabric_live=3 bridge_open=25 order=fabric-first loader_done=92 fabric_live=67 bridge_open=92 order=hard-first loader_done=25 fabric_live=92 bridge_open=92 swap without decoupling: stray valid=8 irq=8 answers=7 swap with decoupling: stray valid=0 irq=0 answers=0 read open when decoupling starts: answered=0 after 20 ticksCheck Yourself
Common Mistakes
Wrong Expect the fabric to hold its design after power-up.
Fabric in SRAM cells is empty at every power-up.
Fix Decide who writes the bitstream, and when.
Wrong Gate the region's wires the moment software asks.
An open request is cut in half, and its owner waits for ever.
Fix Drain the open request, then isolate and answer for the region.
Wrong Open the fence as soon as the bitstream is written.
The new design has not left reset, and its first outputs are noise.
Fix Open the fence after the new design has started.
Remember
- Fabric in SRAM cells is empty at power-up; whoever writes the bitstream sets the boot order.
- The halves may talk only when both are ready.
- Partial reconfiguration rewrites one region while the static logic runs.
- Fence the region during the swap, and drain any open request before the fence closes.