Posts

Showing posts from February, 2019

THIS BLOG HAS MOVED to Facebook - https://www.facebook.com/edaplayground

Because Google are abandoning their Google+ idea, there doesn't seem much point publishing this blog here any more. So, I've moved it all to Facebook: https://www.facebook.com/edaplayground

Can I have a coverpoint for a transaction?

A customer asked me "can I have a coverpoint for a transaction?" What? Well, we might use a class to represent a transaction. So, can we have a coverpoint for that? Let's see. Suppose we have a class , eg   class C;     bit b1, b2;   endclass   Can we do:   covergroup CG;     coverpoint c;   endgroup    The answer is no. But we are allowed to do this:   covergroup CG;     coverpoint c.b1;     coverpoint c.b2;   endgroup Here's what the Stack Overflow folks call an MCVE : module M;     class C;     bit b1, b2;   endclass     C c = new;     covergroup CG;   //coverpoint c;      // THIS WON'T COMPILE     coverpoint c.b1;     coverpoint c.b2;   endgroup     CG cg = new;   endmodule https://www.edaplayground.com/x/ZV_ A customer asked me about this. I didn't know the answer, so I wrote a few lines of code on EDA Playground. EDA Playground is great for that, because it's always on. You don't have to queue for licences, wait for EDA tools to

Is a class virtual because it is marked as such or because it contains at least one pure virtual method?

I was asked; "Is a class virtual because it is marked as such or because it contains at least one pure virtual method?" Hmmm... Good question. Let's find out. This code compiles fine: module M;     class base_class;     virtual function void foo; endfunction   endclass         base_class p = new;       endmodule https://www.edaplayground.com/x/32HJ because the class base_class is not virtual. However, this does not: module M;     virtual class virtual_base_class;     virtual function void foo; endfunction   endclass         virtual_base_class p = new;       endmodule https://www.edaplayground.com/x/3RSk because the class is marked as virtual, even though it contains no pure virtual functions . This will not compile, either, because the class is not marked as virtual, but does contain a pure virtual function: module M;     class virtual_base_class;     pure virtual function void foo;   endclass             endmodule      https://www.edaplayground.com/x/