The error message is telling you that it couldn’t $cast what the factory provided to the variable type it is being assigned to. While there is not enough code posted to pinpoint the problem, you should take a look at the code for sb_top and sb_top_new.
You need to make sure that both sb_top and sb_top_new are registered with the factory, and that sb_top_new extends from sb_top. If sb_top_new doesn’t extend sb_top, then the $cast would fail and you will receive that error message.
The sb_top_new doesn’t extend from sb_top.
In fact, I didn’t extend sb_top_new from sb_top because I need to change the TLM interface (analysis_port) for sb_top_new.
My current question is if I have to change the TLM interface of certain component, I can’t use set_*_override_by_type() to replace it. Is this correct?
Do you have any recommandation to deal with this kind of problem?
Instance override requires that you maintain the same TLM interfaces since the components will be utilized in the same location in the environment.
Without specifics of what you are doing, it is hard to provide a detailed answer, but is it possible to add an additional analysis_port instead of replacing the existing one? You wouldn’t need to utilize the existing one, just the new one.
I am also having similar problem of getting that error message, while overrides one class by another. In my case, i have two classes “A” and “B” , both derived from a “base” class. I have the class A, instantiated in my environment. Now i want to override this class “A” with class “B”. Since in this case, both “A” and “B” are derived from the same “base” class, is it not possible to override one by another?
Pavan,
If you desire to override class “A” with class “B”, then “B” needs to be derived from “A”. You can not override if “A” and “B” are derived from the same base class. The only potential way to do this would be to instantiate the base class in the environment, and provide an override of the base class with “A” or “B” as required.