Let's take a walk down memory lane and remember the fun times we had in college. For a few weeks at the end of the semester, though, things had to get serious, because exam season was starting. I wasn't a really big note taker, so I found myself having to loan notes from my friends. While studying, I couldn't well start scribbling on my friends' notes, as that would have made them really mad. The solution was to make copies on which I could then write to my heart's content. This way I could give the originals back to their owners in the same state as I got them.
This is a companion discussion topic for the original entry at https://verificationgentleman.netlify.app/2015/09/22/of-copies-and-clones.html
covariant return types are a -2012 only feature. before that they were illegal. thats why UVM doesn’t utilise them in various functions such as copy().
ps: actually IUS implemented functions return types as covariant in its initial implementation - however we had to drop that in the light of LRM compliance.
Take it as a suggestion for when you decide to migrate to SV-2012 (I guess 10 years from now :P).
Great post, as always!
If I may, though, a couple of comments:
- For creation of new instances you use “new”. The UVM recommendation is to use “create” for factory overriding - this would also help you find out faster that you forgot the factory registration.
- Just the same as the overloading of the “copy” in the non-uvm classes that you wrote, that is not “good” because SV does not (supposed to) support overloading, also implementing “clone” function to a class that inherits uvm_sequence_item doesn’t seem to be a good idea, as it is an overloading of that function (since the return type is changed), isn’t it so?
there are several places where new language features would be beneficial for the UVM implementation. unfortunately this is a big task and would affect lots of API (so maybe you are right)
there is no overloading in SV. all you get is the ability to redeclare a function in a derived class with the same signature (then it can be virtual), with a different signature (then it can’t be virtual) or since lrm-2012 with the same signature+virtual and only the return type more specialized (a covariant return type). at no point of inheritance you see more than one function with a given name.
uvm_object has clone method, it calls copy as well as do_copy. do_copy is virtual. we can just override do_copy and use already existing clone method in uvm_object. this will be much more simpler.
@Amar Then you’ll have to create your own object, so it won’t be a one liner anymore.