FPGA SoCs: Processor System Plus Programmable Fabric
An FPGA SoC puts a fixed processor system and programmable fabric on one chip. The two halves meet at a few ports. Every trip across a port costs a round trip between two clocks.
You Will Be Able To
- Say which parts of an FPGA SoC are fixed silicon and which are fabric. Say when a soft processor is the better choice.
- Name the ports, the interrupt lines and the clocks between the two halves, and follow one access across each.
- Read one memory map from both sides, and price an access into the fabric against an access to SRAM.
- Lesson
- S10.14
- Time
- 30 min
- Runs on
- Your browser
- Check
- 5 questions
A team moves a status word out of SRAM, into a register in the fabric. Four polls of it took 4 cycles, and now take 45.
Nothing is broken. Where did 41 cycles go?
Before You Start
You need From Microcontroller to Application Processor: the eight kinds of block in every chip.
You need The Memory Map and Many Managers: one map of addresses, and a bus matrix with several managers.
You need Planning Clock Domains: a signal from an unrelated clock passes two flip-flops before it is used.
It helps to have read The Interrupt Controller: A PLIC. Sources 7 to 16 of ap_plic are spare.
| Question | |
|---|---|
| 1 | What is fixed in an FPGA SoC, what is fabric, and when is a soft processor the better choice? |
| 2 | Which ports, lines and clocks join the two halves? |
| 3 | Why does one read of a fabric register cost 11 to 14 cycles, when SRAM costs 1? |
| 4 | How do the processor and a manager in the fabric share one memory map? |
| 5 | With a fabric clock of 80 ns, what does the lab print for the first write into the fabric? |
The Idea: Fixed Silicon Beside Logic You Load
Every chip so far was fixed when it was made. Each gate and each wire was decided before manufacture. An FPGA is different. It is a large array of small logic blocks, and its wiring is set by a file loaded after manufacture.
That freedom has a price. Logic built from the array runs at a slower clock than the same logic as fixed gates. It also takes more area. A processor is large, and every customer needs one. So vendors build the processor system as fixed silicon, beside the array.
The result is an FPGA SoC. One half boots, runs the operating system and owns the memory. The other half holds what the customer builds: an engine, an interface, a controller of motors.
The architect's work moves to the seam. Which ports join the halves? Which clock does each side run on? Where does the fabric appear in the memory map? This page answers those three questions on a small chip of our own.
New Words
| Word | Meaning |
|---|---|
| FPGA | Field-programmable gate array: a chip whose logic and wiring are set by loading a design after manufacture. |
| Lookup table | A small memory inside an FPGA. Its contents make it give any function of its few inputs. |
| FPGA fabric | The programmable part of an FPGA: lookup tables, flip-flops, memory blocks and the wires between them. Fabric, for short. |
| Bitstream | The file that fills every lookup table and sets every connection of the fabric. Loading it is called configuration. |
| Hard processor system | The processors, caches, memory controller and common peripherals of an FPGA SoC, built as fixed silicon. The hard half, for short. |
| FPGA SoC | One chip with a hard processor system and fabric, joined by ports, interrupt lines and clocks. |
| Soft processor | A processor built from the lookup tables and flip-flops of the fabric. |
| ap_fpga | The exercise chip of this page and the next: ap_soc v1.0 as the hard half, beside a fabric. |
| Fabric window | A range of addresses of the hard half that is sent into the fabric. ap_fpga uses 4000_0000 to 4000_0FFF. |
| Fabric port | A port of the bus matrix where a manager in the fabric enters the hard half. |
| Toggle signal | A signal that flips once for each event, so the far side can count events by watching it change. A toggle, for short. |
One Picture: Two Halves and the Seam
- Processor
- Bus
- Memory
- Control / FSM
- Peripheral
- The hard half
ap_rv32, the bus matrix, SRAM and ap_plic are fixed silicon. They are ap_soc v1.0, with nothing changed.
- The fabric
The right column is whatever the bitstream builds. Here: four registers and one engine, on a clock of their own.
- Into the fabric
Addresses 4000_0000 to 4000_0FFF leave the bus matrix through the fabric window. A crossing carries each request over.
- Out of the fabric
The engine writes SRAM through the fabric port. To the bus matrix it is one more manager.
- A line back
One interrupt line runs from the fabric to source 8 of ap_plic, through two flip-flops of the hard clock.
Read the diagram as text
- ap_rv32: the hard processor, 100 MHz
- Bus matrix: decodes every address of the hard half
- SRAM: 8000_0000: one memory for both halves
- ap_plic: source 8 comes from the fabric
- Fabric window: 4000_0000: a crossing into the fabric
- Fabric port: a crossing out of the fabric
- Fabric registers: built from the bitstream, on the fabric clock
- Fabric manager: an engine of the customer
- ap_rv32 → Bus matrix: load, store
- Bus matrix → SRAM: one cycle
- Bus matrix → Fabric window: 4000_0xxx
- Fabric window → Fabric registers: request, answer
- Fabric manager → Fabric port: write
- Fabric port → Bus matrix: a fourth manager
- Fabric manager → ap_plic: interrupt
ap_fpga, the exercise chip of this page and the next. It describes no product. The window, the port, source 8 and the fabric clock are exercise values.
The Smallest Example, Worked by Hand
No simulator yet. The hard clock of ap_fpga has rising edges at 5, 15, 25 ns and so on. The fabric clock of the lab is slower and unrelated. Its rising edges are at 13, 53, 93 ns, every 40 ns.
A request crosses with a toggle. The processor flips it on one edge. The fabric samples it through two flip-flops, so it notices after its second edge. It acts on the edge after that and flips a toggle back. The hard half samples that through two flip-flops of its own.
| Time | Clock | What happens |
|---|---|---|
| 55 ns | hard | The processor flips the request toggle. This is edge 1 of the count. |
| 93 ns | fabric | The first fabric edge after 55 ns: the toggle enters the first flip-flop |
| 133 ns | fabric | The toggle reaches the second flip-flop. The fabric sees a new request |
| 173 ns | fabric | The fabric writes its register and flips the answer toggle |
| 175 ns | hard | The answer toggle enters the first flip-flop of the hard side |
| 185 ns | hard | It reaches the second. The processor sees the answer: edge 14 |
From 55 ns to 185 ns is 13 periods, so 14 rising edges are counted. A read of SRAM in this lab takes 1.
Now the read that follows. It is sent at 205 ns. The next fabric edge is at 213 ns, only 8 ns later. The fabric acts at 293 ns, and the hard side sees the answer at 305 ns. That is 11 edges.
Same circuit, same clocks, and the cost moved by 3 cycles. The only difference is where the request fell between two fabric edges. The 38 ns wait at 55 ns became 8 ns at 205 ns.
The Rules
Rule 1: The hard half is fixed; the fabric is what the bitstream builds.
Processors, the memory controller and common peripherals are fixed silicon. Everything in the fabric changes with the design.
Rule 2: Every port between the halves is a crossing between clocks.
The fabric may run on any clock it likes. So each port treats the two clocks as unrelated, with two flip-flops on each receiving side.
Rule 3: One access across the seam costs a round trip.
Wait for the next fabric edge, two edges to notice, one to act, two hard edges back. Here that is 11 to 14 cycles.
Rule 4: The cost of one access depends on where it falls.
A request just after a fabric edge waits almost a whole fabric period. Software cannot count on the fastest case.
Rule 5: There is one memory map, with two doors.
The window puts fabric registers into the map of the processor. The port puts a fabric manager into the bus matrix, so it reaches the same SRAM.
Rule 6: Until the fabric holds a design, the window answers an error at once.
Nobody is there to answer. A window that waited would hang the processor.
Sources for These Rules
An FPGA is an array of logic blocks, each with a lookup table and a flip-flop. Loading the table contents and the routing sets it after manufacture. Source: Harris and Harris, Digital Design and Computer Architecture, ARM edition, section 5.6.2. The same section says modern FPGAs also hold memory blocks, multipliers and processors.
FPGAs have run at slower clocks than the same design as an ASIC: Sutherland, RTL Modeling with SystemVerilog, section 1.4.2. No number is quoted on this page.
Two flip-flops for a signal from an unrelated clock: see Planning Clock Domains and its sources.
Rules 3 and 4 are measured by the lab of this page. Rules 2, 5 and 6 are common practice for FPGA SoCs, stated on ap_fpga. The vendor manuals that describe real ports are not in our reference library.
Hard or Soft Processor
The fabric can hold a processor too: a soft processor, built from lookup tables. Why buy an FPGA SoC, then? Because the two kinds sit on opposite sides of the seam, and each side is good at different work.
| Question | Hard processor | Soft processor |
|---|---|---|
| Clock | Fast: fixed gates | Slower: logic built from lookup tables |
| Cost in the fabric | None | Lookup tables, flip-flops and memory blocks that the design could use |
| How many | Fixed when the chip was made | As many as the fabric can hold |
| Can it change | No | Yes: new instructions, other caches, a new bitstream |
| Fabric registers | Across the seam: 11 to 14 cycles each here | On the same side: no crossing at all |
| Runs a full operating system | Yes: caches and memory management are built in | Possible, but it uses much of the fabric and runs slowly |
So the choice follows the work. Code that talks to fabric registers all the time can live on a soft processor beside them. Code that needs speed, an operating system or large memory lives on the hard half.
Many designs use both. The hard half runs the operating system. A small soft processor in the fabric runs one tight control loop next to its registers.
Now Run It
The lab at the end of this page is ap_fpga, cut down to its seam. The hard half keeps its decoder and its SRAM. The fabric has four registers, one manager and one interrupt line. Both crossings are real circuits on two clocks.
clocks hard=10 ns fabric=40 ns
read 40000004 route=error cycles=1 (no design yet)
write 80000010 route=sram cycles=1
write 40000004 route=fabric cycles=14
read 40000004 route=fabric cycles=11 data=000000a5
port 80000020 from the fabric fabric_cycles=3
read 80000020 route=sram cycles=1 data=00005a5a
irq source=8 raised at 453 ns, through after 2 hard cycles
poll 4000000c x4 route=fabric cycles=45Rule 6 in the first row. The window is read before the fabric holds a design, and the bridge answers error in one cycle.
Rules 3 and 4 in rows four and five. The write costs 14 cycles and the read 11, exactly as worked by hand.
Rule 5 in rows six and seven. The fabric manager writes 5a5a into SRAM through the fabric port, in 3 fabric cycles. The processor then reads 5a5a from the same address in one cycle. One memory, two doors.
The interrupt line is the cheapest crossing: one wire, two flip-flops, 2 hard cycles. It carries no data, only the news that something happened.
The last row is the hook. Four polls of one fabric register cost 45 cycles. Four reads of SRAM cost 4.
This lab leaves things out. Real ports carry bursts and keep several requests open at once, with a queue on each side. One request at a time shows the round trip plainly.
Why It Is Built This Way
| Design choice | The alternative | What the choice buys, and costs |
|---|---|---|
| The processor system as fixed silicon | A soft processor in the fabric | A fast processor that runs an operating system and costs no fabric. Its count and features are fixed for ever. |
| Ports that treat the fabric clock as unrelated | Force the fabric onto the hard clock | The fabric may run at whatever its design can reach. Every port pays for a crossing. |
| The fabric inside the memory map of the processor | A separate bus with its own drivers | Software reaches fabric registers with ordinary loads and stores. The map must leave room for the fabric. |
| An error from an empty window | Let the access wait | A wrong access fails at once and can be reported. Software must check the error. |
The Trap: The Register That Moved
This is the team from the top of the page. Their status word lived in SRAM of the hard half. They moved it into a fabric register, beside the engine it describes. The driver was not changed.
Rule 3 explains the 41 lost cycles. Each poll is now a round trip between two clocks. Rule 4 explains why the sum is not a round number: each poll falls at another place between fabric edges.
There are two good fixes. Let the engine raise an interrupt line and stop polling. Or move the polling loop to a soft processor in the fabric, on the same side as the register.
The second trap is a window with no design behind it. A team built a bridge that waited for the fabric to answer. Software read the window before the bitstream was loaded, and the processor hung. Rule 6 forbids that.
At Scale
This section names real families. Their facts come from the vendors' public manuals, which are not in our reference library: each one is labelled "not checked".
Many ports, each way
Large FPGA SoCs have several ports from the hard half into the fabric, and more out of it. Wide ports carry bursts with a queue on each side. Not checked.
A coherent port
Some ports check every fabric access against the processor caches, as in An Engine That Shares Memory. AMD (Advanced Micro Devices) names such a port in its Zynq families. Not checked.
Three families
AMD Zynq: Arm processors beside fabric. Intel (Altera) SoC FPGAs: a hard processor system with bridges each way. Microchip PolarFire SoC: a RISC-V processor complex. All not checked.
Clocks from the hard half
The hard half usually offers the fabric a few clocks and resets of its own. The fabric may still use others, so the ports stay crossings.
The next lesson asks how the fabric gets its design. It also asks what happens while part of it is replaced.
Try It
Run the lab. Compare the cycles of the two fabric rows with the SRAM rows.
Set FABRIC_NS to 20, then to 80. How do the write and the read into the fabric change?
Set FABRIC_START to 23. Which rows change, and why does the sum of the polls move too?
Names Printed by the Lab
| Name | Meaning |
|---|---|
| route | Where the hard half sent the access: sram, fabric, or error when the window has no design behind it. |
| cycles | Rising edges of the hard clock, from the edge that sends the request to the edge that sees the answer, both counted. |
| fabric_cycles | The same count for the fabric manager, on the fabric clock. |
| through after | Rising edges of the hard clock until the interrupt line has passed its two flip-flops. |
| poll x4 | Four reads of one fabric register, one after another. The cycles are their sum. |
clocks hard=10 ns fabric=40 ns read 40000004 route=error cycles=1 (no design yet) write 80000010 route=sram cycles=1 write 40000004 route=fabric cycles=14 read 40000004 route=fabric cycles=11 data=000000a5 port 80000020 from the fabric fabric_cycles=3 read 80000020 route=sram cycles=1 data=00005a5a irq source=8 raised at 453 ns, through after 2 hard cycles poll 4000000c x4 route=fabric cycles=45Check Yourself
Common Mistakes
Wrong Treat a fabric register like any other register of the hard half.
Each access is a round trip between two clocks: 11 to 14 cycles here.
Fix Cross the seam rarely: use an interrupt line, bursts, or a soft processor beside the register.
Wrong Expect the same cost for every access across the seam.
The wait for the next fabric edge depends on where the request falls.
Fix Budget for the slowest case.
Wrong Let the window wait for an answer while the fabric holds no design.
Nobody answers, and the processor hangs.
Fix Answer an error at once until the fabric is ready.
Remember
- An FPGA SoC is a fixed processor system beside fabric that a bitstream builds.
- Every port between the halves crosses between unrelated clocks, and one access costs a round trip.
- The window and the port give both halves one memory map.
- Put code that talks to fabric registers all the time on the same side as the registers.