what is extern in syetm verilog ?

Companies Related Questions, System Verilog 0 Comments

What is extern ?

extern qualifier indicates that the body of the method (its implementation) is to be found outside the class declaration.

before the method name, class name should be specified with class resolution operator to specify to which class the method corresponds to.

Example-1:

In the example below,

creating the object of virtual class gives an compilation error.

//class with extern function

class packet;

bit [31:0] addr;

bit [31:0] data;

//function declaration – extern indicates out-of-body declaration

extern virtual function void display();

endclass

 

//function implementation outside class body

function void packet::display();

$display(“Addr = %0d Data = %0d”,addr,data);

endfunction

module extern_method;

initial begin

packet p;

p = new();

p.addr = 10;

p.data = 20;

p.display();

end

endmodule

Leave a Reply