sonalidutta Posted August 20, 2013 Report Posted August 20, 2013 Dear all, I have some questions about usage of SCV. Is it the right place to post them? Thanks Sonali Quote
apfitch Posted August 20, 2013 Report Posted August 20, 2013 Yes, you can ask about SCV here, Alan Quote
sonalidutta Posted August 20, 2013 Author Report Posted August 20, 2013 Dear Alan, Thanks for the quick reply. I want to use SCV to call a callback function f() whenever any member variable of an object "a" of class A will be written a new value. Also f() will use the object "a" inside it. My guess is that I can take any of the following two approaches: Approach 1. - define SCV_EXTENSIONS(A). - instantiate a as: scv_smart_ptr<A> a; - define callback function f() as: void f(scv_extensions_if& a_ext, scv_extensions_if::callback_reason r) { if ( r == scv_extensions_if::VALUE_CHANGE) { //Use a_ext to do some operation } - register callback f() to a as a->register_cb(f) My question here is: 1. How can I get a from a_ext? I need the object of type A or something similar inside f(). Approach 2: - define each member variables "v" of A as scv_smart_ptr. - register callback f() with each of them in the constructor of A. The manual has an example on Page 46. My question here is: 1. I like this approach better. But is there any way to get hold of object "a" inside callback f(). The object which is passed to it is a->v, not a. I need a. Does it mean I need to use approach 1? Or is there any other way? Thanks Sonali Quote
sonalidutta Posted August 20, 2013 Author Report Posted August 20, 2013 Here is a few general questions about the limitations SCV might have: 1. Hierarchical Types: To use scv_smart_ptr of class A, I need to define SCV_EXTENSIONS(A). Now suppose, class A is a subclass of class B. For example: class B{ public: int attB1; protected: int attB2; ... }; class A: public class B{ public: int attA1; private: std::string attA2; ... }; Now how do I define SCV_EXTENSIONS(A)? Does SCV support this? Do I need to define SCV_EXTENSIONS( B ) too? 2. C++ library types: std::vector, std::list, std::map ... SCV has already defined SCV_EXTENSIONS template class for C++ built-in types like int, float etc and also some systemC built-in types. That means we can create variables of type scv_smart_ptr<int> or scv_smart_ptr<float> etc. But can I create variable of type scv_smart_ptr<std::map> or scv_smart_ptr<std::list> or scv_smart_ptr<std::vector> etc? Is SCV_EXTENSIONS template class already defined for them or do I need to define it as I did for class A? Thanks Sonali Quote
sonalidutta Posted August 20, 2013 Author Report Posted August 20, 2013 This is an empty post. Not able to delete it. Quote
apfitch Posted August 20, 2013 Report Posted August 20, 2013 For your first question, you should be able to access the underlying object using methods of the scv_smart_ptr such as print() and read(). E.g. a_ext.print() cout << a_ext.read() << endl; Regarding derived classes, yes you can do it. I think you have to extend both classes, then use the SCV_EXTENSIONS_BASE_CLASS(base_type_name) macro to indicate in the derived class that the base class is extended. I don't know about your last question (using std::vector). regards Alan Quote
sonalidutta Posted August 22, 2013 Author Report Posted August 22, 2013 Dear Alan, Thanks for you reply. I would like to see some example how to use SCV_EXTENSIONS_BASE_CLASS macro. The scv package or the manual doe not have any example. Also I want to do the following: 1. Define a base class A. 2. Define two classes B, C derived from A. 3. I want to track the value changes of the member variables of class B and C. - So I need to define scv_extensions for them. 4. Now I want to use polymorphism: use base class point A* to point derived class objects new B() and new C(). Also I want to define function f(A* a) that actually receives objects of type B and C and determines in the runtime what kind of object it is. It finally does type cast on a as: (B*)a or (C*)a to use methods defined in B or C. I wonder if this kind of polymorphism is doable with scv_smart_pointer<A>, scv_smart_pointer<B> , scv_smart_pointer<C>. It will be really helpful if I can see some example about the syntax and everything. The manual really doe snot show anything. I also have gone through all the example programs scv package provides. Can you let me know whom I can talk to regarding this in the developer's group? Regards Sonali Quote
apfitch Posted August 23, 2013 Report Posted August 23, 2013 I think you should be able to join the Verification Working Group as an observer? I'm not sure I understand the Accellera rules myself, but I think people from non-member companies can be observers. Alan Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.