Jump to content

destruct objects


amitk3553

Recommended Posts

Hello,

 

I have to reset the fifo, I was doing like that cmd_fifo.nb_read(Flush), currently need to read each location to reset the whole fifo, So I want to know is there any method like cmd_fifo.reset() or we can destroy the object as done below?

 

sc_fifo<int> cmd_fifo;

 

SC_CTOR()

{

   host_hci_tar_socket.register_b_transport(this, (&hci_top::PI_decode));

}

 

void PI_decode()

{

   if(value==1)

   {

     ~cmd_fifo();           //destructor

   }

}

 

I used destructor like above but its not working, so suggest something about this.

 

 

Regards

cam

Link to comment
Share on other sites

Hello,

 

I have to reset the fifo, I was doing like that cmd_fifo.nb_read(Flush), currently need to read each location to reset the whole fifo, So I want to know is there any method like cmd_fifo.reset() or we can destroy the object as done below?

 

sc_fifo<int> cmd_fifo;

 

SC_CTOR()

{

   host_hci_tar_socket.register_b_transport(this, (&hci_top::PI_decode));

}

 

void PI_decode()

{

   if(value==1)

   {

     ~cmd_fifo();           //destructor

   }

}

 

I used destructor like above but its not working, so suggest something about this.

 

 

Regards

cam

Hello Sir,

May we request that you get a good reference book on C++ and read it up ?

The destructor for a class is ALWAYS placed inside the class, for example:

class foo

{

 foo(){}

~foo(){} /* destructor */

};

Most importantly, a destructor is NEVER, EVER invoked by the programmer.

A destructor is invoked ONLY by the runtime system when the instance of a

class(the object) is destroyed.

Hope that helps.

Link to comment
Share on other sites

The methods of sc_fifo are described in the LRM, see section 6.23.2.

 

If you look at that, there are no functions for clearing a fifo. However it would be quite easy to write a helper function, e.g.

void function reset_fifo (sc_fifo<int> & f) {
    int dummy;
     while ( f.nb_read(dummy) )
         ;
}

regards

Alan

 

P.S. Making it a template function is left as an exercise for the reader :-)

Link to comment
Share on other sites

The methods of sc_fifo are described in the LRM, see section 6.23.2.

 

If you look at that, there are no functions for clearing a fifo. However it would be quite easy to write a helper function, e.g.

void function reset_fifo (sc_fifo<int> & f) {
    int dummy;
     while ( f.nb_read(dummy) )
         ;
}

regards

Alan

 

P.S. Making it a template function is left as an exercise for the reader :-)

 

Yes, I had Implemented in the same way as you said.

But I was looking for some inbuilt function or something else to reset the fifos to reduce my code.

k, its fine.

 

Thanks

cam

Link to comment
Share on other sites

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...