Thursday, December 29, 2016

What is the functionality of $sformat()?

We can observe the usage of $sformat by seeing the below example.

====================

xbus_slave_agent slave[2];

string instance_name;

for(int i=0; i < 2; i++)
begin
// string will be stored in the instance_name by replacing the %d with the value of i
$sformat(instance_name, "slave[%d]", i);
slave[0] = xbus_slave::type_id::create(instance_name, this);
end

// Two slaves will be created with the instance names... slave[0], slave[1]

=============================

No comments:

Post a Comment