FPGA Prototypes
An FPGA prototype runs the chip's RTL on a real FPGA, fast enough for software and real interfaces. Getting there changes clocks, memories and pads. This page builds ap_soc for an FPGA and reads the report; no board is used.
You Will Be Able To
- Say what an FPGA prototype is for, and how it differs from an emulator.
- Name what changes when ASIC RTL goes onto an FPGA: clocks, memories, pads.
- Read a synthesis and place-and-route report: resources, block RAM, clock estimates.
- Say what a build report does not prove.
- Lesson
- V13.7
- Time
- 24 min
- Runs on
- Your browser
- Check
- 5 questions
The software team wants a board on their desks with the chip on it, long before silicon. The hardware team has RTL and an FPGA. Between them is a build that must fit, close timing and keep the chip's behaviour.
- File
- Clock / reset
- Tool
- Report
- External
- Data
- Clock
- Swap what an FPGA cannot be
The oscillators, PLL and power-on cell become a small digital model driven by one board clock.
- Synthesize and place
Yosys maps the chip onto LUTs, flops and block RAM; nextpnr places and routes it.
- Read the report
Resources used, and an estimate of the fastest clock for each clock net.
- Stop there
No pin constraints, no bitstream on a board. This is where our prototype ends.
Read the diagram as text
- ap_soc RTL: core, fabric, peripherals
- analog.sv: replaces the analog model
- Yosys synth_ecp5: LUTs, flops, block RAM
- nextpnr-ecp5: place and route
- 10,424 logic cells: 3,982 flops, 34 block RAMs
- 28.37 MHz lowest: target 25 MHz
- Board: none: nothing was loaded
- ap_soc RTL → Yosys synth_ecp5
- analog.sv → Yosys synth_ecp5: one board clock
- Yosys synth_ecp5 → nextpnr-ecp5: netlist
- nextpnr-ecp5 → 10,424 logic cells: resources
- nextpnr-ecp5 → 28.37 MHz lowest: timing
Yosys 0.70+290, nextpnr nextpnr-0.11.1-85-ga2c64799; LFE5U-85F, CABGA381, speed 6, seed 1. Rebuilt in 133 s by npm run build:fast-fpga.
Before You Start
Read Emulation, Honestly first. Synthesis reports are read in the RTL track; this page reads one for a whole chip.
| Question | |
|---|---|
| 1 | What is an FPGA prototype for, and how is it unlike an emulator? |
| 2 | What must change in ASIC RTL to build it for an FPGA? |
| 3 | What does ap_soc use on an ECP5 FPGA? |
| 4 | How fast might it run, and what does that estimate rest on? |
| 5 | What does a build report not prove? |
The Idea: The Same RTL on Hardware You Can Buy
An FPGA is a chip of programmable logic. Build the RTL for it and the design runs as real hardware on a board with real connectors. It runs far faster than any simulation. Software can run on it for hours, and real cables can plug in.
Unlike an emulator, a prototype is built for speed and copies, not for debug. Seeing inside it is hard. It is used once the design works, so that software teams and system tests get a fast, cheap stand-in for the chip.
ASIC RTL does not go onto an FPGA unchanged. Its clocks come from analog parts the FPGA lacks; its memories must fit the FPGA's block RAM; its pads become FPGA pins.
New Words
| Word | Meaning |
|---|---|
| FPGA | A chip of programmable logic: look-up tables, flip-flops, block RAM and IO cells. |
| LUT | Look-up table: a small programmable logic cell, here with four inputs (LUT4). |
| Block RAM | A fixed memory block of the FPGA; on ECP5, DP16KD holds 16 Kbit of data (18 with parity). |
| Place and route | Choosing where each cell goes on the FPGA and how they are wired. |
| Clock estimate | The fastest clock at which the router's delays still meet timing, for one clock net. |
| Derived clock | A clock made by logic inside the design, not by a clock pin or a PLL. |
| Prototype | The chip's RTL running on FPGAs, for software and system tests before silicon. |
The Smallest Example: Where 64 KiB of SRAM Goes
One DP16KD block holds 16 Kbit of data: 2 KiB. ap_soc has 64 KiB of SRAM and a 4 KiB ROM. Work out how many blocks they need before you look at the report.
| Memory | Size | Blocks of 2 KiB |
|---|---|---|
| SRAM | 64 KiB | 32 |
| ROM | 4 KiB | 2 |
| Total | 34 |
The report shows 34 DP16KD blocks. The memories went into block RAM, as they should; nothing was built from flip-flops.
That only works if each memory is written in the shape a block RAM has. Rule 2 below says what that shape is.
The Rules
Rule 1: Replace what an FPGA cannot be.
Oscillators, PLLs, power-on cells and power switches become simple digital models, or FPGA clock resources.
Rule 2: Write memories in the FPGA's shape.
A block RAM has a write port and a read port registered on the clock, and nothing more. Code that asks for anything else is built from logic cells or flip-flops.
Rule 3: Keep one RTL with a switch.
The ASIC and FPGA builds differ in IO, clocks and memories. Select those few parts; keep the core logic one code.
Rule 4: Read the report per clock.
Each clock net has its own estimate. The lowest may be on a clock made by logic, and the tool's net names do not say which.
Rule 5: A report is not a board.
Without pin constraints, board timing and a run on hardware, the report proves fit and an estimate, nothing more.
Sources for These Rules
Emulation and prototyping; how an emulator differs from an FPGA prototype: MEHTA-DV 12.2.1, 12.2.3.
ASIC and FPGA builds differ in IO, clocks (PLL against DLL) and memories, selected at integration: MEHTA-DV 15.4.4. Timing closure after place and route: 15.4.3.
This build: tools/soc/fast-platforms/README.md, "ECP5 implementation report", and facts 27.14. They say what analog.sv replaces and what is not checked.
The Lab: The Build Report of ap_soc
The command npm run build:fast-fpga synthesized the whole digital chip, with the RTL core, for an ECP5 LFE5U-85F. Then it placed and routed it. The analog model was replaced by this file:
// Single external FPGA clock. The digital boot controller still sequences its grants.
module ap_analog_model(input wire clk_ref, osc_start, pll_start, per_power_on,
output wire clk_rc, clk_aon, clk_pll, osc_ready, pll_locked, por_n, per_pwr_good);
reg [3:0] startup = 0;
always @(posedge clk_ref) startup <= {startup[2:0], 1'b1};
assign por_n = startup[3];
assign clk_rc = clk_ref, clk_aon = clk_ref, clk_pll = clk_ref;
assign osc_ready = osc_start, pll_locked = pll_start, per_pwr_good = per_power_on;
endmodule| Resource | Used | Available | Per cent |
|---|---|---|---|
| Logic cells | 10,424 | 83,640 | 12 |
| Flip-flops | 3,982 | 83,640 | 4 |
| Block RAM (DP16KD) | 34 | 208 | 16 |
| IO cells | 23 | 365 | 6 |
Rule 2 at work: 34 block RAMs, the 32 plus 2 of the worked example. Rule 1: one board clock feeds every clock the chip expected from its analog parts.
28.37 MHz $glbnet$u_watchdog.supervisor.first_key_LUT4_D_Z_LUT4_D_Z_LUT4_Z_D_LUT
45.72 MHz $glbnet$TDO_$_TBUF__Y_A_TRELLIS_FF_Q_DI_LUT4_Z_B_LUT4_D_Z_TRELLIS_FF_D
84.07 MHz $glbnet$u_uart.fifo_q.0.0_DO_LUT4_D_Z_LUT4_Z_D_LUT4_Z_D_PFUMX_Z_ALUT_LRule 4 at work. The lowest estimate, 28.37 MHz, carries a long name that starts in the watchdog. That name is made up by the synthesis tool from nearby connections, so do not read it as a place. So we followed the net in the synthesized netlist. A look-up table drives it, fed by the board clock pad and the two grant flip-flops of the clock mux, ap_clk_mux. It is clk_sys, the system clock, and it clocks 976 flip-flops.
So the slowest paths are the chip's own, on its main clock, and the estimate still beats the 25 MHz target. The board clock's net itself clocks 183 flip-flops and reached 90.61 MHz. On this build clk_sys is made by logic from the board clock: a derived clock. The tool times paths inside each clock net only. Paths between the two nets, and the delay through the mux, need their own timing analysis, as the kit manual says.
Rule 5: there was no pin constraint file, the pins were placed automatically, and nothing was loaded onto a board.
Why It Is Built This Way
Why replace the analog parts with a model of a few lines? Because the FPGA has no RC oscillator or the chip's PLL. What matters for the digital logic is that clocks arrive and reset is released in order; analog.sv keeps that and nothing more.
Why place and route at all, with no board? Because synthesis alone says nothing about wires. Only after routing are the delays known, and with them a clock estimate.
Why so few IO cells? The chip has few pads: a clock, reset, a strap, JTAG and sixteen IO pads. A prototype of a phone chip would need hundreds.
Traps
The first trap is an ASIC memory model written for simulation comfort. It simulates neatly, but asks for something a block RAM cannot do, and on the FPGA it becomes thousands of cells.
The second is reading the clock pin's estimate and stopping. Here the pin's net looked fast. The real system clock came out of the clock mux, under a generated name, and was the slowest.
The third is calling a routed report a working prototype. Real pins, real board delays and real devices on the board are a separate job, and none was done here.
At Scale
This section looks ahead. ap_soc fits one mid-size FPGA.
Many FPGAs
A large chip is split across several FPGAs; the signals between them pass through pins and slow the clock.
Visibility added
Teams add trace buffers in block RAM to see inside, at a cost in resources.
Copies
Once it works, the prototype is copied for many software engineers.
Try It
Run it: the FPGA's replacement for the chip's analog block, edge by edge.
On which edge is power-on reset released? Why that edge?
Start the PLL later. What does pll_locked do?
edge 1: por_n 0 pll_locked 0 clk_pll follows clk_ref: 1 edge 2: por_n 0 pll_locked 1 clk_pll follows clk_ref: 1 edge 3: por_n 0 pll_locked 1 clk_pll follows clk_ref: 1 edge 4: por_n 1 pll_locked 1 clk_pll follows clk_ref: 1 edge 5: por_n 1 pll_locked 1 clk_pll follows clk_ref: 1 edge 6: por_n 1 pll_locked 1 clk_pll follows clk_ref: 1 edge 7: por_n 1 pll_locked 1 clk_pll follows clk_ref: 1Check Yourself
Common Mistakes
Wrong Read a memory combinationally in code meant for the FPGA.
Block RAM reads on a clock edge; the tool builds the memory from logic cells.
Fix Register the read on the clock, as the block RAM does.
Wrong Read only the clock pin's estimate, and trust net names.
A derived clock can be the slowest, under a name the tool made up.
Fix Read every clock net, and trace the slowest one in the netlist.
Wrong Call a routed report a prototype.
No pins, no board timing, no run on hardware.
Fix Say what the report proves: fit and an estimate.
Remember
- A prototype runs the RTL on FPGAs: fast, few signals visible, for software and system tests.
- Clocks, memories and pads change between the ASIC and the FPGA build; the logic stays one code.
- ap_soc on an ECP5: 10,424 logic cells, 3,982 flops, 34 block RAMs; lowest estimate 28.37 MHz, on clk_sys.
- The report proves fit and an estimate; no board was used.