Ramon Fried Posted April 26, 2022 Report Share Posted April 26, 2022 I'm wondering why there's no standard method to clear/reset a fifo. Doing so activly, by looping and running: while (nb_read(t)) ; has the unplesent effect of sending data_read_event(). What's the process of suggesting an addtional functionality to the spec ? Quote Link to comment Share on other sites More sharing options...
David Black Posted April 26, 2022 Report Share Posted April 26, 2022 You only get a single read event. If you need more, simply implement your own fifo by derivation or composition. You might also consider the tlm_fifo, which has slightly more functionality but still no reset per se. You could also disable the readers for one delta cycle if you know their identities. Perhaps override data_read_event to capture that information: // File: my_fifo.h #pragma once #if __cplusplus < 201402L // Might allow C++11 #error "Requires C++14 or better" #endif #include <systemc> #include <forward_list> struct my_fifo : sc_core::sc_fifo { my_fifo( int size = 16 ) : sc_fifo{ size } { sc_assert( size >= 0 ); } const sc_core::sc_event& data_read_event() override { observer.push_back( sc_core::sc_get_current_process_handle() ); return sc_core::data_read_event(); } void reset() { //< blocking // Disable observers for( auto& observer : observers ) observer.disable(); // Empty the fifo while( nb_read() ); // Exit this delta cycle wait( SC_ZERO_TIME ); // Reenable observers for( auto& observer : observers ) observer.enable(); } private: std::forward_list<sc_core::sc_process_handle> observers{}; }; Above is untested, and you might want to add a my_fifo_if.h to support the reset functionality via a port. YMMV maehne and karthickg 2 Quote Link to comment Share on other sites More sharing options...
David Black Posted May 4, 2022 Report Share Posted May 4, 2022 Reflection: It might be better to store the observers in a std::unordered_set rather than the std::forward_list. This avoids the list getting duplicate entries and thus getting out of control (size). This would be the case if code dynamically waited on the event. Quote Link to comment Share on other sites More sharing options...
Ramon Fried Posted May 4, 2022 Author Report Share Posted May 4, 2022 Thanks David ! Quote Link to comment Share on other sites More sharing options...
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.