Three Ways to Drive a Chip

Drive the chip with its own core, with a bus manager in the core's seat, or on a fast platform. Learn what each mode finds, what it misses, and why firmware on the real core is the rarest skill of the three.

You Will Be Able To

  • Say what each of the three modes is best at and weak at.
  • Choose a mode for a test from what the test needs to be real.
  • Decide from simulator speed when software is too long for RTL.
Lesson
V1.3
Time
24 min
Runs on
Your browser
Check
5 questions

Your register sweep found nothing in ten minutes, and the boot code still crashes. A colleague says the sweep could never have found it, because the crash needs a real trap on a real core. Which tool should the next test use?

One Chip, Three DriversStep through the three modes. The chip in the middle is the same each time; what sits in the core's seat changes.
  • File
  • Processor
  • Sequence
  • Manager
  • Model
  • DUT
  • Pads
  • Data
One Chip, Three DriversStep through the three modes. The chip in the middle is the same each time; what sits in the core's seat changes. file Firmware in C compiled, loaded intoSRAM processor Real core mode 1: with CPU sequence Bench test sequence or Cthrough DPI manager Bus manager mode 2: without CPU file Long software boot loader, drivers,an OS model Fast platform mode 3: model orhardware dut The rest of thechip bus, memories,peripherals pads Pad models UART, GPIO, flash instructionsloads, storestransfersany bus trafficbillions ofinstructionsfast, less visiblepins
  1. file Firmware in Ccompiled, loaded into SRAM
    • instructions → Real core
  2. processor Real coremode 1: with CPU
    • loads, stores → The rest of the chip
  3. dut The rest of the chipbus, memories, peripherals
    • pins → Pad models
  4. sequence Bench testsequence or C through DPI
    • transfers → Bus manager
  5. manager Bus managermode 2: without CPU
    • any bus traffic → The rest of the chip
  6. file Long softwareboot loader, drivers, an OS
    • billions of instructions → Fast platform
  7. model Fast platformmode 3: model or hardware
    • fast, less visible → The rest of the chip
  8. pads Pad modelsUART, GPIO, flash
  1. With CPU

    Firmware runs on the real core. Traps, handlers, start-up code and sleep are all real.

  2. Without CPU

    A bus manager takes the core's seat. It can make any traffic, including traffic the core never makes.

  3. Fast platform

    An instruction-level model, an emulator or an FPGA board runs long software far faster, with less to see.

  4. Same pads

    In every mode, the outside world is played by models on the pads.

Read the diagram as text
  • Firmware in C: compiled, loaded into SRAM
  • Real core: mode 1: with CPU
  • Bench test: sequence or C through DPI
  • Bus manager: mode 2: without CPU
  • Long software: boot loader, drivers, an OS
  • Fast platform: mode 3: model or hardware
  • The rest of the chip: bus, memories, peripherals
  • Pad models: UART, GPIO, flash
  • Firmware in C → Real core: instructions
  • Real core → The rest of the chip: loads, stores
  • Bench test → Bus manager: transfers
  • Bus manager → The rest of the chip: any bus traffic
  • Long software → Fast platform: billions of instructions
  • Fast platform → The rest of the chip: fast, less visible
  • The rest of the chip → Pad models: pins

One bench, one chip. Teams switch between the first two with one setting and move to the third for long software.

Before You Start

Read What the Block Bench Already Proved first. You should know how a program runs on a core and starts up: Start-Up Code. A first look at sequences and drivers helps: From a Layered Bench to UVM.

The labs of this module are small slices. They use the real addresses and interrupt numbers of ap_soc v1.5, and each page says so. The whole chip runs from module V2 on, and in the guided run of the fundamentals module.

Five questions this page answers
Question
1What are the three ways to drive a chip?
2What can only firmware on the real core find?
3What can only a bus manager do?
4Why do fast platforms exist, and what do they cost?
5Why is with-CPU verification rare, and why does that make it valuable?

The Idea: Who Sits in the Core's Seat

A chip has one seat that drives the bus: the core. Whatever sits in that seat decides what the test can do. Put the real core there, running compiled firmware, and the chip behaves exactly as it will on a board. Put a bus manager there, a model that issues transfers on command, and you can make any traffic you like.

The third choice changes the clock speed itself. Software teams need billions of instructions, and RTL simulation runs thousands to hundreds of thousands of cycles a second. A fast platform trades visibility and exact timing for speed. It can be a model of the core, an emulator, or an FPGA board.

New Words

New words on this page
WordMeaning
With CPUThe real core runs firmware written in C or assembly, and the bench checks the results.
Without CPUA bus manager takes the core's seat and issues transfers that a bench test asks for.
Bus managerA bench model that drives the bus like a processor would, one transfer at a time, on command.
Fast platformA way to run the design far faster than RTL simulation: a virtual platform, an emulator or an FPGA prototype.
Virtual platformA software model of the chip at instruction level, fast enough to boot an operating system.
EmulatorSpecial hardware that runs the RTL itself, millions of cycles a second, at very high cost.

What Each Mode Is For

Three modes on one chip
With CPUWithout CPUFast platform
Who drives the busThe real coreA bus managerA core model, or the real core in hardware
Best atBoot, traps, handlers, start-up code, sleep, real use casesRegister sweeps, bus stress, error injection, illegal trafficLong software: boot loaders, drivers, an OS
Weak atExact bus timing, traffic the core never makesAnything that needs real instructionsVisibility and fast turnaround after an RTL change
WhenFrom first integration to tape-outFrom week one, before the core is readyOnce the RTL is stable
How commonRare outside chip teamsCommonRare: the hardware costs a fortune

Built from docs/soc-verification-plan.md section 2.2. Mehta, ASIC/SoC Functional Design Verification, chapter 12 covers virtual platforms and emulation.

Most verification engineers grow up in the second column, because that is how block benches work. The first column is different work. You write C, you read a retire trace, you debug a handler that returned to the wrong place. Few people get to do it before they join a chip team, and teams notice those who can.

The Rules

  1. Rule 1: Ask what must be real.

    If the bug needs real instructions, use the core. If it needs traffic the core never makes, use a manager.

  2. Rule 2: Ask how long.

    Billions of cycles do not fit in RTL simulation. Move such software to a fast platform.

  3. Rule 3: Use both of the first two.

    One bench switches between them. The same chip, two tools.

Sources for These Rules

Mehta, ASIC/SoC Functional Design Verification, section 12.1 (why simulation is too slow for software, and what virtual platforms and emulators add).

The three-mode table and the switch on one bench are this track's plan (sections 2.2 and 3.6), from common practice.

Speeds were measured on the laptop with the five-stage core alone in its bench (plan section 6.2).

Icarus 12.0 ran about 9.2 thousand cycles a second, and Verilator 5.032 about 534 thousand.

Now Run It: The Same Four Writes, Three Ways

The lab is a toy, and it says so. One register block, acc_block, adds every value written to address 0x10, and a read of 0x14 returns the sum. The test adds 3, 4, 2 and 1, three times over.

First comes a "core", a four-step sequencer. It spends three clocks on reset and first fetch, then fetches each step before its bus write. Then a bus manager issues the same four writes directly. Last, a fast model does the same arithmetic as plain function calls, with no clock at all.

Printed by the lab (Icarus). The core here is a toy sequencer, not ap_rv32.
with CPU:     sum 10 after 15 clocks
without CPU:  sum 10 after 8 clocks
fast model:   sum 10 after 0 clocks, 4 calls

All three agree on the sum: 10. They differ in cost. The core run took 15 clocks, because fetches and boot cost cycles. The manager took 8, two clocks for each write. The fast model took no clocks at all, but it also has no bus to look at.

Scale that up. On the real chip, even a boot from a back-door load is planned at a few hundred cycles. Every with-CPU test pays it, and the manager saves it. A fast platform saves almost everything, and in return you cannot watch a single wire.

The Trap: One Mode for Everything

A team that knows only bus managers writes every chip test as a bench test. Its regression is fast and green. Then the first firmware runs on silicon. The stack was never set up, the trap vector points at nothing, and the handler returns to the wrong place.

The opposite team writes everything in firmware. Its tests are slow, and they never reach the bus timings the core cannot make. Pick the mode per test, from what the test must make real.

Try It

Run the lab. Compare the three sums and the three clock counts.

Change the four values to 10, 20, 30 and 40. Predict the last line.

Remove the extra clock before each core write. Predict the new core clock count.

RUNIcarus Verilog · in your browser
Edit the code, then run it
Expected: with CPU: sum 10 after 15 clocks without CPU: sum 10 after 8 clocks fast model: sum 10 after 0 clocks, 4 calls

Check Yourself

Predict the outputThe test adds 10, 20, 30 and 40 instead. What is the last line the lab prints?
// One register block driven three ways. acc_block adds every value written to 0x10; a read of
// 0x14 returns the sum. A toy model: the "core" here is a four-step sequencer, not ap_rv32.
module acc_block (input logic clk, sel, wr, input logic [7:0] addr, input logic [7:0] wdata,
                  output logic [7:0] rdata);
  logic [7:0] sum = 0;
  always_ff @(posedge clk) if (sel && wr && addr == 8'h10) sum <= sum + wdata;
  assign rdata = (addr == 8'h14) ? sum : 8'h00;
endmodule

module tb;
  logic clk = 0, sel = 0, wr = 0; logic [7:0] addr, wdata, rdata;
  logic [7:0] prog [4];   // the values the test adds
  int cycles;
  always #5 clk = ~clk;
  always @(posedge clk) cycles++;
  acc_block dut (.clk, .sel, .wr, .addr, .wdata, .rdata);
  task automatic bus_write(input logic [7:0] a, d);
    @(negedge clk) begin sel = 1; wr = 1; addr = a; wdata = d; end
    @(negedge clk) begin sel = 0; wr = 0; end
  endtask
  // 3. Fast model: the same register behaviour as a function call. No clock at all.
  int model_sum, calls;
  function automatic void model_write(input logic [7:0] d); model_sum += d; calls++; endfunction
  initial begin
    prog[0] = 10; prog[1] = 20; prog[2] = 30; prog[3] = 40;
    // 1. With the "core": fetch each step from memory (one clock), then do its bus write.
    cycles = 0; repeat (3) @(negedge clk);              // reset vector and first fetch: 3 clocks
    foreach (prog[i]) begin @(negedge clk); bus_write(8'h10, prog[i]); end
    addr = 8'h14; #1 $display("with CPU:     sum %0d after %0d clocks", rdata, cycles);
    // 2. Without the core: a bus manager issues the same writes directly.
    @(negedge clk) dut.sum = 0; cycles = 0;
    foreach (prog[i]) bus_write(8'h10, prog[i]);
    addr = 8'h14; #1 $display("without CPU:  sum %0d after %0d clocks", rdata, cycles);
    foreach (prog[i]) model_write(prog[i]);
    $display("fast model:   sum %0d after 0 clocks, %0d calls", model_sum, calls);
    $finish;
  end
endmodule
ConceptWhich test needs a bus manager rather than firmware?
ConceptWhy do fast platforms exist?
ConceptIn the lab, why does the core run take more clocks than the manager run?
ConceptWhy is with-CPU verification valuable to learn?

Common Mistakes

Wrong Use a bus manager to test start-up code or handlers.

A manager runs no instructions, so start-up code and traps never happen.

Fix Use the real core for anything made of instructions.

Wrong Run billions of cycles of software in RTL simulation.

At hundreds of thousands of cycles a second, it takes days.

Fix Move long software to a fast platform.

Wrong Expect a fast platform to show bus timing.

It trades visibility and exact timing for speed.

Fix Debug timing in RTL simulation.

Remember

  • Three modes: firmware on the real core, a bus manager in the core's seat, a fast platform.
  • With CPU finds boot, traps, handlers, sleep and real use cases; without CPU makes any traffic, early and fast.
  • Fast platforms run long software and give up visibility and exact timing.
  • Teams use the first two on one bench, and pick the mode per test.

Practice

Report a problem with this page