can somebody explain the meaning of the following statement,
scb = scoreboard::type_id::create("scb", this);
Here i have scoreboard class is derived from the ovm_component.
sometimes it is showing me error as type_id is not a class item when iam
using the above statement.
what does type_id stands for?
type_id::create() is a static method in the factory registration class
ovm_component_registry/
ovm_object_registry. When you create a class and want to register it with the factory, you add that type to your class.
class scoreboard extends ovm_scoreboard;
typedef ovm_component_registry #(scoreboard,"scoreboard") type_id;
This creates a specialization of the parametrized class ovm_component_registry that inside defines the static method create(). The two parameters are to register the class by type and by string name. So type_id is the specialized class that represents the factory registration. Not that since you only need to access the static methods of this class, there is no need to ever construct it, the typedef is sufficient.
The macro `ovm_component_utils(scoreboard) generates this typedef for you. So if scoreboard::type_id does not exist, you either need to add the typedef, or add the macro.
I have forgot to insert the macro.
Its working fine when i have inserted the macro(`ovm_component_utils).
But when i tried it with the typedef it is giving the following error.....
Error:
const static string type_name = scoreboard;
A declared type is not a legal rvalue in this context.
Not sure if you have called the macro with proper arguments (one with class type and one with class name as string). In case you are passing correctly, may be you can dig into the macro and see how it is getting expanded wrongly.
It should have been declared as
const static string type_name = āscoreboardā;
instead of
const static string type_name = scoreboard;
I have written a small code snippet. what i expect from it is just to run with out having any errors.
It is simulating fine when i have used the macro which is commented in the code.
But it is showing error when iam running it by placing the typedef statement.
module top;
`include "ovm.svh"
class scoreboard extends ovm_component;
// `ovm_component_utils(scoreboard)
typedef ovm_component_registry #(scoreboard, "scoreboard") type_id;
function void new(input string name = "scoreboard",
input ovm_component parent = null);
super.new(name, parent);
endfunction
endclass : scoreboard
scoreboard scb;
initial begin
//scb = new();
scb = scoreboard::type_id::create("scoreboard", this);
end
endmodule
Error:
typedef class scoreboard;
The class specified in the typedef is never declared.
Thanks a lot for your response.
I have solved the two things which i have asked earlier.
Iam running it with cadence tool.
It is giving the above mentioned errors when i used the ***-svpp*** option.
when i have removed the option they are working fine.
Do you guys have any idea why the ***-svpp*** option is generating such errors?
SVPP is a pre-processor that was used in the bad old days when Incisive didnāt have built-in support for parameterised classes.
Since Incisive 9.2 came out (about a year ago), the SVPP switch is redundant.
Not only that, its use is strongly discouraged, because SVPP has a number of limitations (itās just a basic pre-processor after all).
Please try Incisive 9.2 and do not use SVPP.
Dave, thereās not much point in the pot calling the kettle black; Cadence people could share a lot of stories about SV problems in other vendorsā tools too! :p
Dave, thereās not much point in the pot calling the kettle black; Cadence people could share a lot of stories about SV problems in other vendorsā tools too! :p
Iāve worked at Cadence and Synopsys for many years - I know all the stories.
The funny part, I thought, was being asked to explain why a competitors product behaves the way it does.
What I know is that earlier version of cadence was not having support for the parametrized classes and some other constructs, so they did this workaround. because the svpp directory is created where we run the simulation.
type_id::create() is a static method in the factory registration class
ovm_component_registry/
ovm_object_registry. When you create a class and want to register it with the factory, you add that type to your class.
class scoreboard extends ovm_scoreboard;
typedef ovm_component_registry #(scoreboard,"scoreboard") type_id;
This creates a specialization of the parametrized class ovm_component_registry that inside defines the static method create(). The two parameters are to register the class by type and by string name. So type_id is the specialized class that represents the factory registration. Not that since you only need to access the static methods of this class, there is no need to ever construct it, the typedef is sufficient.
The macro `ovm_component_utils(scoreboard) generates this typedef for you. So if scoreboard::type_id does not exist, you either need to add the typedef, or add the macro.
Dave Rich