Skip to the selected question
ASIC.FYI

ASIC Question Bank

1,000+ hardware interview questions
DescriptionQ256
Q256DVDesignASIC interview problem

Downcasting

TechniquesSystemVerilogObject-oriented dispatch
DifficultyEasy
TopicSV
LanguageSystemVerilog
Format4 choices
01

Problem

What is the result of the cast?

Class declarationSystemVerilog
class B; endclass
class D extends B; int tag = 9; endclass
B b; D original, d;
initial begin
  original = new;
  b = original;
  if ($cast(d, b)) $display("%0d", d.tag);
  else             $display("fail");
end
02

Answer choices (4)