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.

Five questions this page answers
Question
1What is fixed in an FPGA SoC, what is fabric, and when is a soft processor the better choice?
2Which ports, lines and clocks join the two halves?
3Why does one read of a fabric register cost 11 to 14 cycles, when SRAM costs 1?
4How do the processor and a manager in the fabric share one memory map?
5With 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

New words on this page
WordMeaning
FPGAField-programmable gate array: a chip whose logic and wiring are set by loading a design after manufacture.
Lookup tableA small memory inside an FPGA. Its contents make it give any function of its few inputs.
FPGA fabricThe programmable part of an FPGA: lookup tables, flip-flops, memory blocks and the wires between them. Fabric, for short.
BitstreamThe file that fills every lookup table and sets every connection of the fabric. Loading it is called configuration.
Hard processor systemThe processors, caches, memory controller and common peripherals of an FPGA SoC, built as fixed silicon. The hard half, for short.
FPGA SoCOne chip with a hard processor system and fabric, joined by ports, interrupt lines and clocks.
Soft processorA processor built from the lookup tables and flip-flops of the fabric.
ap_fpgaThe exercise chip of this page and the next: ap_soc v1.0 as the hard half, beside a fabric.
Fabric windowA range of addresses of the hard half that is sent into the fabric. ap_fpga uses 4000_0000 to 4000_0FFF.
Fabric portA port of the bus matrix where a manager in the fabric enters the hard half.
Toggle signalA 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

Two Halves and the Seam Between ThemStep through the picture. The left column is ap_soc, unchanged. The right column is fabric. Every arrow between them crosses from one clock to another.
  • Processor
  • Bus
  • Memory
  • Control / FSM
  • Peripheral
Two Halves and the Seam Between ThemStep through the picture. The left column is ap_soc, unchanged. The right column is fabric. Every arrow between them crosses from one clock to another. component ap_rv32 the hard processor,100 MHz component Bus matrix decodes everyaddress of the hardhalf component SRAM 8000_0000: onememory for bothhalves component ap_plic source 8 comes fromthe fabric component Fabric window 4000_0000: acrossing into thefabric component Fabric port a crossing out of thefabric component Fabric registers built from thebitstream, on thefabric clock component Fabric manager an engine of thecustomer load, storeone cycle4000_0xxxrequest, answerwritea fourth managerinterrupt
  1. component ap_rv32the hard processor, 100 MHz
    • load, store → Bus matrix
  2. component Bus matrixdecodes every address of the hard half
    • one cycle → SRAM
    • 4000_0xxx → Fabric window
  3. component SRAM8000_0000: one memory for both halves
  4. component ap_plicsource 8 comes from the fabric
  5. component Fabric registersbuilt from the bitstream, on the fabric clock
  6. component Fabric manageran engine of the customer
    • write → Fabric port
    • interrupt → ap_plic
  7. component Fabric window4000_0000: a crossing into the fabric
    • request, answer → Fabric registers
  8. component Fabric porta crossing out of the fabric
    • a fourth manager → Bus matrix
  1. The hard half

    ap_rv32, the bus matrix, SRAM and ap_plic are fixed silicon. They are ap_soc v1.0, with nothing changed.

  2. The fabric

    The right column is whatever the bitstream builds. Here: four registers and one engine, on a clock of their own.

  3. Into the fabric

    Addresses 4000_0000 to 4000_0FFF leave the bus matrix through the fabric window. A crossing carries each request over.

  4. Out of the fabric

    The engine writes SRAM through the fabric port. To the bus matrix it is one more manager.

  5. 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.

One write into the fabric, sent at 55 ns
TimeClockWhat happens
55 nshardThe processor flips the request toggle. This is edge 1 of the count.
93 nsfabricThe first fabric edge after 55 ns: the toggle enters the first flip-flop
133 nsfabricThe toggle reaches the second flip-flop. The fabric sees a new request
173 nsfabricThe fabric writes its register and flips the answer toggle
175 nshardThe answer toggle enters the first flip-flop of the hard side
185 nshardIt 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

  1. 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.

  2. 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.

  3. 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.

  4. 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.

  5. 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.

  6. 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.

The same job on two kinds of processor
QuestionHard processorSoft processor
ClockFast: fixed gatesSlower: logic built from lookup tables
Cost in the fabricNoneLookup tables, flip-flops and memory blocks that the design could use
How manyFixed when the chip was madeAs many as the fabric can hold
Can it changeNoYes: new instructions, other caches, a new bitstream
Fabric registersAcross the seam: 11 to 14 cycles each hereOn the same side: no crossing at all
Runs a full operating systemYes: caches and memory management are built inPossible, 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.

Printed by the lab on Icarus. Every cycle count is measured by the run.
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=45

Rule 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 choiceThe alternativeWhat the choice buys, and costs
The processor system as fixed siliconA soft processor in the fabricA 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 unrelatedForce the fabric onto the hard clockThe fabric may run at whatever its design can reach. Every port pays for a crossing.
The fabric inside the memory map of the processorA separate bus with its own driversSoftware reaches fabric registers with ordinary loads and stores. The map must leave room for the fabric.
An error from an empty windowLet the access waitA 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

ap_fpga1 window, 1 port, 1 line
A large FPGA SoCmany ports each way, many lines

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".

  1. 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.

  2. 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.

  3. 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.

  4. 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
NameMeaning
routeWhere the hard half sent the access: sram, fabric, or error when the window has no design behind it.
cyclesRising edges of the hard clock, from the edge that sends the request to the edge that sees the answer, both counted.
fabric_cyclesThe same count for the fabric manager, on the fabric clock.
through afterRising edges of the hard clock until the interrupt line has passed its two flip-flops.
poll x4Four reads of one fabric register, one after another. The cycles are their sum.
RUNIcarus Verilog · in your browser
Edit the code, then run it
Expected: 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=45

Check Yourself

Predict the outputIn this run the fabric clock has a period of 80 ns, with its first rising edge still at 13 ns. The run stops after the first write into the fabric. What is the last line? Its form is: write 40000004 route=fabric cycles=..
// ap_fpga: the hard half of ap_soc beside a fabric, joined by a crossing each way and one interrupt line.
// Test code. The hard half is cut down to its decoder and its SRAM; the fabric to four registers and one manager.
// One crossing: the asking side flips a toggle. The answering side sees it through two flip-flops of its own
// clock, acts on the next edge, and copies the toggle back. The asking side sees that through two flip-flops.
module crossing (input logic ask_clk, answer_clk, go, output logic open, act);
  logic req_t = 0, ack_t = 0;
  logic [1:0] req_s = 0, ack_s = 0;
  always @(posedge ask_clk) begin ack_s <= {ack_s[0], ack_t}; if (go) req_t <= ~req_t; end
  always @(posedge answer_clk) begin req_s <= {req_s[0], req_t}; if (act) ack_t <= req_s[1]; end
  assign act = (req_s[1] != ack_t);       // answering side: the request has crossed; act on this edge
  assign open = (req_t != ack_s[1]);      // asking side: the answer has not come back yet
endmodule

module tb;
  localparam int HARD_NS = 10;            // the clock of the hard half: the PLL of ap_soc, 100 MHz
  localparam int FABRIC_NS = 80;           // the clock of the fabric logic
  localparam int FABRIC_START = 13;        // its first rising edge, in ns: no fixed relation to the hard clock
  localparam int POLLS = 4;               // reads of a fabric status register in the last row
  localparam int IRQ_SOURCE = 8;          // the input of ap_plic that the fabric's line drives

  bit hclk, fclk;
  initial forever #(HARD_NS / 2) hclk = ~hclk;                 // rising edges at 5, 15, 25 ...
  initial begin #(FABRIC_START); forever begin fclk = 1; #(FABRIC_NS / 2); fclk = 0; #(FABRIC_NS / 2); end end

  // ---- The hard half: SRAM at 8000_0000, the fabric window at 4000_0000 (4 KiB), nothing else decoded here.
  logic [31:0] sram [0:15];
  logic configured = 0;                   // 1 once the fabric holds its design (the next lesson)
  // Hard half into the fabric: the processor asks, the fabric answers.
  logic go_h = 0;  wire open_h, act_f;
  logic [31:0] b_addr, b_wdata, b_rdata;  logic b_write;       // held still while a request is open
  logic [31:0] fab_reg [0:3];
  crossing into_fabric (.ask_clk(hclk), .answer_clk(fclk), .go(go_h), .open(open_h), .act(act_f));
  always @(posedge fclk) if (act_f) begin
    if (b_write) fab_reg[b_addr[3:2]] <= b_wdata; else b_rdata <= fab_reg[b_addr[3:2]];
  end
  // Fabric into the hard half: a manager in the fabric writes a word of SRAM through the fabric port.
  logic go_f = 0;  wire open_f, act_h;
  logic [31:0] p_addr, p_wdata;
  crossing from_fabric (.ask_clk(fclk), .answer_clk(hclk), .go(go_f), .open(open_f), .act(act_h));
  always @(posedge hclk) if (act_h) sram[p_addr[5:2]] <= p_wdata;
  // One interrupt line from the fabric, through two flip-flops of the hard clock.
  logic irq_f = 0;  logic [1:0] irq_s = 0;
  always @(posedge hclk) irq_s <= {irq_s[0], irq_f};

  // One access of the processor. Inputs change between edges; cycles counts rising edges of the hard clock
  // from the request to the answer.
  int cycles;
  task automatic access(input bit write, input logic [31:0] addr, input logic [31:0] wdata, output logic [31:0] rdata, output string route);
    @(negedge hclk);  cycles = 0;  rdata = 0;
    if (addr[31:16] == 16'h8000) begin                 // SRAM, on the fast bus: one cycle (a choice of the lab)
      route = "sram  ";  @(negedge hclk);  cycles = 1;
      if (write) sram[addr[5:2]] = wdata; else rdata = sram[addr[5:2]];
    end else if (addr[31:12] == 20'h40000 && !configured) begin
      route = "error ";  @(negedge hclk);  cycles = 1;   // no design yet: the bridge answers an error at once
    end else if (addr[31:12] == 20'h40000) begin
      route = "fabric";  b_addr = addr;  b_wdata = wdata;  b_write = write;  go_h = 1;
      @(negedge hclk);  go_h = 0;  cycles = 1;
      while (open_h) begin @(negedge hclk); cycles++; end
      rdata = b_rdata;
    end else begin
      route = "none  ";  @(negedge hclk);  cycles = 1;
    end
  endtask

  logic [31:0] d;  string r;  int t0, total, fcycles;
  initial begin
    $display("clocks hard=%0d ns fabric=%0d ns", HARD_NS, FABRIC_NS);
    access(0, 32'h4000_0004, 0, d, r);               $display("read  40000004 route=%s cycles=%0d (no design yet)", r, cycles);
    access(1, 32'h8000_0010, 32'h1111, d, r);        $display("write 80000010 route=%s cycles=%0d", r, cycles);
    configured = 1;
    access(1, 32'h4000_0004, 32'h00a5, d, r);        $display("write 40000004 route=%s cycles=%0d", r, cycles);
    $finish;                                        // this run stops after the first write into the fabric
    access(0, 32'h4000_0004, 0, d, r);               $display("read  40000004 route=%s cycles=%0d data=%h", r, cycles, d);
    // The fabric's manager writes 5a5a into SRAM; its cycles are counted on the fabric clock.
    @(negedge fclk);  p_addr = 32'h8000_0020;  p_wdata = 32'h5a5a;  go_f = 1;
    @(negedge fclk);  go_f = 0;  fcycles = 1;
    while (open_f) begin @(negedge fclk); fcycles++; end
    $display("port  80000020 from the fabric fabric_cycles=%0d", fcycles);
    access(0, 32'h8000_0020, 0, d, r);               $display("read  80000020 route=%s cycles=%0d data=%h", r, cycles, d);
    // The fabric raises its interrupt on one of its edges; count hard edges until the line is through.
    @(posedge fclk);  irq_f <= 1;  t0 = $time;  cycles = 0;
    do begin @(posedge hclk); #1; cycles++; end while (!irq_s[1]);
    $display("irq   source=%0d raised at %0d ns, through after %0d hard cycles", IRQ_SOURCE, t0, cycles);
    total = 0;
    repeat (POLLS) begin access(0, 32'h4000_000c, 0, d, r); total += cycles; end
    $display("poll  4000000c x%0d route=%s cycles=%0d", POLLS, r, total);
    $finish;
  end
endmodule
ConceptWhy does an FPGA SoC build its processors as fixed silicon?
ConceptWhich crossing in the lab is the cheapest?
ConceptThe fabric manager writes 5a5a to 8000_0020. What does the processor read there?
ConceptWhat should the window answer before the fabric holds a design?

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.

Practice

Report a problem with this page