类定义可能会变得很长,因为class和endclass之间有很多界限。 这使得很难理解类中所有功能和变量都存在什么,因为每个功能和任务都占用很多行。
在方法声明中使用extern限定符表示实现是在此类的主体之外完成的。
Example
class ABC;
// 让此函数在此处声明,然后由“ extern”限定符定义
extern function void display();
endclass
// 在类主体之外,我们具有声明为“ extern”的函数的实现
function void ABC::display();
$display ("Hello world");
endfunction
module tb;
//让我们简单地创建一个类对象并调用display方法
initial begin
ABC abc = new();
abc.display();
end
endmodule
Simulation Log
ncsim> run
Hello world
ncsim: *W,RNQUIE: Simulation is complete.
参考文献:
【1】https://www.chipverify.com/systemverilog/systemverilog-extern