U18.2.1 Make the Order Come Out Right

MediumImplementUVM · serverReview the topic

Register three callbacks in two phases so every lane driver calls them in a set order. The environment adds a fourth by itself.

Hardware context: Lane environment whose own callback joins the test's. Register callbacks so every lane calls them in a set order.

A test adds three callbacks to the lane drivers of an environment: trace, perr and cov. The environment adds its own monitor callback to every lane driver, typewide, in its build_phase.

Every lane must call trace first and cov last, with the environment's monitor in between. The lanes whose names match the glob lanes also call perr, after the monitor and before cov. Write the two registration functions so this order comes out on every lane, with no callback warning in the log.

Full specification
What you write
// Called in the test's build_phase, right after env is created. env's lanes do not exist yet.
function void early(lane_env env, lane_cb trace, lane_cb perr, lane_cb cov, string lanes);

endfunction

// Called in the test's connect_phase. Every lane of env exists.
function void late(lane_env env, lane_cb trace, lane_cb perr, lane_cb cov, string lanes);

endfunction
LaneCalling order
Name matches lanestrace, env monitor, perr, cov
Any other lanetrace, env monitor, cov

Order of events: the test creates env and calls early. Then env's build_phase builds lanes lane_a, lane_b, ... and adds its monitor. Then connect_phase calls late. Each lane driver is at env.lane(name).drv, and its full name is like uvm_test_top.env0.lane_b.drv.

lanes is a glob that uses only * and ?, such as "lane_b" or "lane_*". It always matches at least one lane of env. The checks count callback warnings per environment, and any call of another environment's perr on this environment's lanes.

Examples

Example 1

Three Lanes, Perr on lane_b
Input
3 lanes; lanes = "lane_b"
Output
lane_a_order = 0x1240, lane_b_order = 0x1234, lane_c_order = 0x1240, lane_d_order = 0x0, cb_warnings = 0, lanes = 3, other_cases_callbacks_called = 0

lane_b calls 1 2 3 4: trace, env monitor, perr, cov. lane_a and lane_c call 1 2 4.

Example 2

Two Lanes, Perr on Both
Input
2 lanes; lanes = "lane_*"
Output
lane_a_order = 0x1234, lane_b_order = 0x1234, lane_c_order = 0x0, lane_d_order = 0x0, cb_warnings = 0, lanes = 2, other_cases_callbacks_called = 0

The glob matches both lanes, so both call 1 2 3 4. Unused lane slots read 0.

Example 3

Four Lanes, Perr on lane_d
Input
4 lanes; lanes = "lane_d"
Output
lane_a_order = 0x1240, lane_b_order = 0x1240, lane_c_order = 0x1240, lane_d_order = 0x1234, cb_warnings = 0, lanes = 4, other_cases_callbacks_called = 0

Only lane_d gets perr; the other three call 1 2 4.

Constraints and Contract

  • Use uvm_callbacks #(lane_driver, lane_cb) for every registration.
  • No CBPREG, CBUNREG or CBNOMTC warning may appear.
  • Each case is its own environment; register only on that environment's lanes.

Hints

Hint 1

A typewide add reaches drivers built later. An add on one driver needs the driver to exist. Which of your adds can go in early?

Hint 2

The first instance add on a driver copies the typewide queue as it is at that moment, then appends. Where does perr land if cov is already typewide?

Hint 3

add_by_name matches the pattern against full names, and only under the root you give it.

What the grader checks: Your two functions register callbacks on six real environments with different lane counts and globs. Each lane driver runs one item. The checks read the order its hook point called the callbacks in. They count the warnings each environment's own calls made, and calls of another environment's perr.

6 checks on UVM · server. Run the examples first, then check the full regression. Full checks use the server judge. Downloads contain public samples only. A passing result establishes the tested cases, not a proof for all possible inputs.

See all 1 problem on this path

Report a problem with this page

Your code SystemVerilogSaved locally
Ln 1, Col 1Tab indents · Ctrl/⌘ + Enter runs samples
Not run yet

Three Lanes, Perr on lane_b

Input
3 lanes; lanes = "lane_b"
Expected output
lane_a_order = 0x1240, lane_b_order = 0x1234, lane_c_order = 0x1240, lane_d_order = 0x0, cb_warnings = 0, lanes = 3, other_cases_callbacks_called = 0

lane_b calls 1 2 3 4: trace, env monitor, perr, cov. lane_a and lane_c call 1 2 4.

Run samples executes all 3 public checks. Check all tests runs 6 checks on the server.

UVM · server