Jump to content

Recommended Posts

Posted

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

Posted

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

Posted

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

Posted

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

Posted

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

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...