← Design Verification Interviews

Interview Question · Concept

Components vs Objects

L0 FresherL1 JuniorL2 Mid-Leveluvmclass hierarchy

The Question

The interviewer asks

What is the difference between a uvm_component and a uvm_object? Is a transaction a component?

Reveal the Model Answer

A component is a fixed part of the testbench tree. It is built once in the build phase, has a parent and a full name, and runs every phase. An object is data with no place in the tree and no phases. You can create and discard it at any time. Drivers, monitors, agents and scoreboards are components. Transactions, sequences and configuration objects are objects.

Components Form the Tree; Objects Move Through ItBoxes marked component are built once, in the build phase, and stay for the whole run. Boxes marked object are made and thrown away while the test runs. Arrows show who creates, reads or carries what.
Components form the tree; objects move through itBoxes marked component are built once, in the build phase, and stay for the whole run. Boxes marked object are made and thrown away while the test runs. Arrows show who creates, reads or carries what. component uvm_test_top The test: root of thetree component env Built by the test component agent Built by env; buildsits children object agent config Settings passed downduring build component sequencer Lives for the wholerun component driver Pulls items and drivesthe pins object sequence Runs for a while onthe sequencer object sequence item One transaction, thendiscarded createscreatescreatescreates, setsread in buildhands itemsruns oncreates each
Read the diagram as text
  • uvm_test_top: The test: root of the tree
  • env: Built by the test
  • agent: Built by env; builds its children
  • agent config: Settings passed down during build
  • sequencer: Lives for the whole run
  • driver: Pulls items and drives the pins
  • sequence: Runs for a while on the sequencer
  • sequence item: One transaction, then discarded
  • uvm_test_top → env: creates
  • env → agent: creates
  • agent → sequencer: creates
  • uvm_test_top → agent config: creates, sets
  • agent config → agent: read in build
  • sequencer → driver: hands items
  • sequence → sequencer: runs on
  • sequence → sequence item: creates each

A sequence runs over time, but it is still an object. It borrows the sequencer, and the sequencer is the component.

Component

class my_driver extends uvm_driver #(item);
  `uvm_component_utils(my_driver)
  function new(string name, uvm_component parent);
    super.new(name, parent);
  endfunction
endclass

Has a parent, lives for the whole run, gets phases

Object

class item extends uvm_sequence_item;
  `uvm_object_utils(item)
  function new(string name = "item");
    super.new(name);
  endfunction
endclass

No parent, made and thrown away freely, no phases

Self-Check

Tick each key point you covered in your answer.

What Interviewers Listen For (Fresher)

A good fresher answer sorts the usual classes into the right group. It points to the two constructors: a component takes a name and a parent, an object takes only a name.

Cross-Questions

Where the interviewer goes next. Open a node to practise that follow-up.

WhyWhat IfProve ItCompare

  1. Components vs Objects
  2. WhyWhy Components Are Fixed After BuildL1 JuniorL2 Mid-Level

    Why can't the scoreboard be created in connect_phase or run_phase?

    Reveal the Model Answer

    Every phase after build walks a tree that must already be complete. Connections, configuration lookups and end-of-elaboration checks all assume that no new parts appear. The library enforces this. Once build is done, new() on a component reports a fatal ILLCRT error.

    Self-Check

    Tick each key point you covered in your answer.

    Misconception

    "Creating it in connect_phase is fine because nothing runs yet."

    Build is over by then, so the library refuses. Its children would also miss their own build phase.

    Source uvm-core 2020.3.1 (IEEE 1800.2 library) source, base/uvm_component.svh, new(): "illegal to create a component ... after the build phase has ended"

  3. CompareSequence Item vs SequenceL1 Junior

    Compare a sequence item with a sequence. Both are objects, so what is the difference?

    Reveal the Model Answer

    An item is one transaction's data, such as an address and a payload. A sequence is an object whose body() task creates items and sends them through a sequencer. A sequence can also start other sequences, which is how you build long scenarios from small ones.

    Self-Check

    Tick each key point you covered in your answer.

    Wrong Altitude

    "Put the randomization loop in the item class."

    An item should describe one transaction. Ordering and scenario logic belong in the sequence, so the same item can serve many scenarios.

    Source Accellera, UVM 1.1 User's Guide, §3.10 Enabling Scenario Creation (PDF p55)

  4. What IfWho Owns an Item After It Is SentL2 Mid-Level

    What if a driver changes an item after item_done(), while the sequence still holds the same handle?

    Reveal the Model Answer

    Both sides see the change, because they share one object. Agree on ownership. After sending, the sender does not touch the item. A receiver that must change it works on a clone(). Check this when a sequence reads back fields of an item it already sent.

    Self-Check

    Tick each key point you covered in your answer.

    Misconception

    "finish_item copies the item into the sequencer."

    It passes the handle. The driver receives the very object the sequence created.

    Source Verification Academy, UVM Cookbook, Driver/Sequence API: the driver gets a pointer to the same item (PDF p216)

  5. Prove ItSolve U2.4.1: Pack a Frame Whose Payload Has Its Own LengthSimulator-graded

    Show it, don't just say it: this Silicon Lab problem is graded by the simulator.

    Open Problem U2.4.1

What People Get Wrong

Common wrong answers and why they fail.

Misconception

"A sequence is a component, because it runs over time."

A sequence derives from uvm_sequence_item, which is an object. It runs its body() on a sequencer, and the sequencer is the component.

Source uvm-core 2020.3.1 (IEEE 1800.2 library) source, seq/uvm_sequence_base.svh (class uvm_sequence_base extends uvm_sequence_item)

Buzzword Without Mechanism

"Components are static and objects are dynamic."

Both are class instances made at run time. The real difference is the tree: a parent, a name and phases.

Missed Corner

"You can add a component whenever a test needs one, even in run_phase."

The library stops the run with a fatal error if a component is created after the build phase has ended.

Source uvm-core 2020.3.1 (IEEE 1800.2 library) source, base/uvm_component.svh, fatal ILLCRT in new()

Learn It, Then Prove It