Subsystems, Stimulus and Response

Cut the chip into subsystems, each with a clear input and a clear output. Then choose, for each one, where the stimulus comes from and what checks the response.

You Will Be Able To

  • Cut a chip into subsystems with a clear input and output each.
  • Choose the stimulus source and the checker for a subsystem test.
  • Explain why a check at the pads proves more than a check on an internal wire.
Lesson
V1.5
Time
24 min
Runs on
Your browser
Check
5 questions

Faced with the whole chip, a new engineer asks where to even start. The answer is to stop looking at the whole chip. Find groups of blocks with one door in and one door out, and test each group through its doors.

ap_soc Cut into SubsystemsStep through the subsystems. Each one has a clear place where stimulus goes in and a clear place where a checker can see the result.
  • Peripheral
  • Pads
  • Memory
  • Control / FSM
  • Manager
  • Clock / reset
  • Debug
  • Interrupt
  • Reset
ap_soc Cut Into SubsystemsStep through the subsystems. Each one has a clear place where stimulus goes in and a clear place where a checker can see the result. peripheral Console in: RX pad; out: TXpad pads Pins in: GPIO pads; out:GPIO pads memory Memory and boot in: strap, image; out:first fetch control Time andinterrupts in: timer setup; out:handler runs manager Data mover in: DMA registers;out: memory clock reset Clock, reset,power in: reset, wake; out:domain state debug Debug in: JTAG pads; out:JTAG pads receive requestdone requestreset release
  1. peripheral Consolein: RX pad; out: TX pad
    • receive request → Time and interrupts
  2. pads Pinsin: GPIO pads; out: GPIO pads
  3. memory Memory and bootin: strap, image; out: first fetch
  4. control Time and interruptsin: timer setup; out: handler runs
  5. manager Data moverin: DMA registers; out: memory
    • done request → Time and interrupts
  6. clock reset Clock, reset, powerin: reset, wake; out: domain state
    • reset release → Memory and boot
  7. debug Debugin: JTAG pads; out: JTAG pads
  1. Console

    A byte enters at the receive pad and leaves at the transmit pad. Pad models drive and check both ends.

  2. Pins and boot

    Pins go in and come out of the same pads. Boot starts from a strap and an image, and ends at the first fetch.

  3. Inside the chip

    Timers, interrupts and the DMA start from register writes and end in a handler or in memory. Requests join subsystems together.

  4. Around the chip

    Clock, reset and power start from reset and wake events; debug enters and leaves through JTAG.

Read the diagram as text
  • Console: in: RX pad; out: TX pad
  • Pins: in: GPIO pads; out: GPIO pads
  • Memory and boot: in: strap, image; out: first fetch
  • Time and interrupts: in: timer setup; out: handler runs
  • Data mover: in: DMA registers; out: memory
  • Clock, reset, power: in: reset, wake; out: domain state
  • Debug: in: JTAG pads; out: JTAG pads
  • Console → Time and interrupts: receive request
  • Data mover → Time and interrupts: done request
  • Clock, reset, power → Memory and boot: reset release

A subsystem view of ap_soc. Blocks can belong to more than one subsystem; the core takes part in most.

Before You Start

Read The Chip-Level Verification Plan first. The console example uses the UART of Serial Peripherals. Monitors and scoreboards come from 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 makes a group of blocks a subsystem?
2What are the subsystems of ap_soc?
3Where can stimulus come from at chip level?
4Which checkers can check the response?
5Why check at the pads when you could check a wire?

The Idea: One Door in, One Door Out

Mehta gives a short test for a subsystem. It has a clear place to put stimulus in, and a clear place to check the result. The console of ap_soc passes it. A byte goes in at the receive pad, and the echo comes out at the transmit pad. Everything between, UART0, the interrupt, the core and the handler, is inside.

Cutting the chip this way does two things. Each subsystem gets its own stimulus and its own checker, so the plan has fewer, clearer rows. And each subsystem test checks a chain of joins at once, which is exactly what the chip level is for.

New Words

New words on this page
WordMeaning
SubsystemA group of blocks with a clear input for stimulus and a clear output for checking.
StimulusWhat the test puts into the chip: a byte on a pad, a register write, a program in memory.
ResponseWhat comes out that a checker can examine: a byte on a pad, memory contents, a report from firmware.
Pad-level modelA bench model that plays the outside world on a pad: it sends and receives like a real device.
ScoreboardA checker that compares what came out with what should have come out.
End to endChecked from the first input to the last output, with nothing in between trusted.

Stimulus Sources and Checkers

Where stimulus comes from at chip level
SourceGood for
Firmware on the coreAnything software does: drivers, handlers, start-up
A bus manager in the core's seatRegister traffic, stress, early tests
A pad-level modelThe outside world: serial bytes, pin levels, a flash chip
The JTAG driverThe debugger's view
A back-door loadPlacing a program in memory before reset, at no cycle cost
What can check the response
CheckerWhat it proves
Self-checking firmwareWhat software can see; it reports pass or fail
A passive bus monitorEvery transfer obeys the protocol, in every test
A scoreboard at the padsThe whole chain, end to end
A reference model of the coreEach retired instruction is right
An assertion on a wireOne local rule, every cycle

Mehta pairs each subsystem with its stimulus and its response checking, item by item. An agent drives packets in, and a monitor and a scoreboard check the output. The same pairing works on a small chip.

The Rules

  1. Rule 1: Define subsystems by their doors.

    A clear input and a clear output, or it is not a subsystem yet.

  2. Rule 2: Pick the stimulus that can really make the input.

    Only a pad model can play the outside world.

  3. Rule 3: Check at the far door.

    A check at the output pads covers every join inside; a wire check covers one.

  4. Rule 4: Add passive checks everywhere.

    Monitors cost nothing in stimulus and watch every test.

Sources for These Rules

Mehta, ASIC/SoC Functional Design Verification, sections 16.3 and 16.4: the subsystems of an SoC and their stimulus and response.

Mehta, sections 17.2 and 17.3: the same steps for a cache subsystem.

The subsystem list of ap_soc is this track's own cut, made from map v1.0 and the facts file.

Now Run It: The Console, Pad to Pad

The lab is the console subsystem in miniature. A pad-level model sends two bytes into a receiver. It sends one bit every four clocks, with a start bit and a stop bit (lab choices). A bus manager plays the software: it waits for a byte, reads it, and writes it back. A pad monitor decodes the transmit pad, and a scoreboard compares.

Printed by the lab (Icarus).
pad model sends   4f
manager reads    4f, writes it back
pad monitor sees  4f, expected 4f
pad model sends   6b
manager reads    6b, writes it back
pad monitor sees  6b, expected 6b
scoreboard: 2 of 2 bytes matched end to end

Follow the first byte. The pad model sends 4f; the manager reads 4f and writes it back; the pad monitor sees 4f, which matches. The second byte, 6b, makes the same trip. The last line says both bytes matched end to end.

Notice what the scoreboard never looked at: the receiver's registers, the ready flag, the bus. It trusted none of them, and it still proved the whole path. If any join inside were wrong, the byte at the transmit pad would differ.

The Trap: Checking Halfway

It is tempting to check the console by reading RXDATA and calling it done. That proves the receive half. The transmit half, the pin mux and the pad are never seen. A byte that never leaves the chip still passes the test.

The other half of the trap is software. In the predict question below, the "software" changes each byte before writing it back. Only a check at the far door catches a bug like that, because every block still behaves correctly.

Try It

Run the lab and follow each byte from pad to pad.

Make the manager write back rdata ^ 8'h20. Predict the last line.

Send 00 and ff instead. Predict whether the scoreboard still matches both.

RUNIcarus Verilog · in your browser
Edit the code, then run it
Expected: pad model sends 4f manager reads 4f, writes it back pad monitor sees 4f, expected 4f pad model sends 6b manager reads 6b, writes it back pad monitor sees 6b, expected 6b scoreboard: 2 of 2 bytes matched end to end

Check Yourself

Predict the outputThe bus manager now writes back rdata ^ 8'h20 instead of rdata. What is the last line the lab prints?
// The console subsystem in miniature: a pad-level model sends bytes into a receiver, a bus manager
// plays the software and writes each byte back, and a pad monitor decodes what leaves. 4 clocks a bit,
// 8 data bits, low start bit, high stop bit (lab choices). The scoreboard compares pad in with pad out.
module rx_tx (input logic clk, rx_pad, input logic rd, wr, input logic [7:0] wdata,
              output logic tx_pad, rx_ready, output logic [7:0] rdata);
  int rcnt = 0, tcnt = 0; logic [9:0] rsh, tsh = '1; logic [7:0] rbuf;
  initial begin rx_ready = 0; tx_pad = 1; end
  always_ff @(posedge clk) begin
    if (rcnt == 0 && !rx_pad) rcnt <= 1;                 // start bit seen
    else if (rcnt > 0) begin
      rcnt <= (rcnt == 38) ? 0 : rcnt + 1;
      if (rcnt % 4 == 2) rsh <= {rx_pad, rsh[9:1]};      // sample in the middle of each bit
      if (rcnt == 38) begin rbuf <= rsh[9:2]; rx_ready <= 1; end
    end
    if (rd) rx_ready <= 0;
    if (wr) begin tsh <= {1'b1, wdata, 1'b0}; tcnt <= 40; end
    else if (tcnt > 0) begin tcnt <= tcnt - 1; if (tcnt % 4 == 1) tsh <= {1'b1, tsh[9:1]}; end
    tx_pad <= (tcnt > 0) ? tsh[0] : 1'b1;
  end
  assign rdata = rbuf;
endmodule

module tb;
  logic clk = 0, rx_pad = 1, rd = 0, wr = 0, tx_pad, rx_ready; logic [7:0] wdata, rdata;
  logic [7:0] send [2];
  logic [7:0] expect_q [$];
  int matched = 0;
  always #5 clk = ~clk;
  rx_tx dut (.clk, .rx_pad, .rd, .wr, .wdata, .tx_pad, .rx_ready, .rdata);
  // Pad-level model: drives the receive pad, bit by bit.
  task automatic pad_send(input logic [7:0] b);
    logic [9:0] f = {1'b1, b, 1'b0};
    expect_q.push_back(b); $display("pad model sends   %h", b);
    for (int i = 0; i < 10; i++) repeat (4) @(negedge clk) rx_pad = f[i];
  endtask
  // Bus manager playing the software: wait for a byte, read it, write it back.
  always @(posedge clk) if (rx_ready && !rd) begin
    @(negedge clk) rd = 1; @(negedge clk) rd = 0;
    $display("manager reads    %h, writes it back", rdata);
    wdata = rdata ^ 8'h20; wr = 1; @(negedge clk) wr = 0;
  end
  // Pad monitor and scoreboard: decode the transmit pad, compare with what was sent.
  initial forever begin
    logic [7:0] got;
    @(negedge tx_pad); repeat (2) @(posedge clk);          // middle of the start bit
    for (int i = 0; i < 8; i++) begin repeat (4) @(posedge clk); got[i] = tx_pad; end
    if (got == expect_q[0]) matched++;
    $display("pad monitor sees  %h, expected %h", got, expect_q.pop_front());
  end
  initial begin
    send[0] = 8'h4f; send[1] = 8'h6b;
    repeat (3) @(negedge clk);
    foreach (send[i]) begin pad_send(send[i]); repeat (60) @(negedge clk); end
    $display("scoreboard: %0d of 2 bytes matched end to end", matched);
    $finish;
  end
endmodule
ConceptWhat makes a group of blocks a subsystem?
ConceptWhich stimulus source can play a serial device on a pad?
ConceptIn the lab, what does the scoreboard compare?
ConceptWhy add passive bus monitors to every subsystem test?

Common Mistakes

Wrong Check a subsystem at an internal register.

The joins after that register are never seen.

Fix Check at the far door, the output pads or memory.

Wrong Drive pads from the bus side.

Only a pad-level model behaves like the outside world.

Fix Use a pad model for anything that enters through a pin.

Wrong Call a group of blocks a subsystem without naming its doors.

Without a clear input and output there is nothing to drive or check.

Fix Name the input and the output first.

Remember

  • A subsystem has a clear input for stimulus and a clear output for checking.
  • Stimulus comes from firmware, a bus manager, pad models, JTAG or a back-door load.
  • A scoreboard at the far door proves every join inside; a wire check proves one.
  • Passive monitors ride along in every test.

Practice

Report a problem with this page