amitk3553 Posted November 26, 2013 Report Posted November 26, 2013 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 Annossyenudge 1 Quote
dakupoto Posted November 26, 2013 Report Posted November 26, 2013 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. amitk3553 1 Quote
apfitch Posted November 26, 2013 Report Posted November 26, 2013 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 :-) amitk3553 1 Quote
amitk3553 Posted November 27, 2013 Author Report Posted November 27, 2013 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 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.