Andy Tomlin Posted January 11, 2022 Report Share Posted January 11, 2022 I am trying to replace array of objects with the sc_vector as it seems like a better solution to the problem after some research /home/tools/libraries/systemc-2.3.3/include/sysc/utils/sc_vector.h: In instantiation of ‘void sc_core::sc_vector<T>::clear() [with T = mm_ready_valid_in<busy_st>]’: /home/tools/libraries/systemc-2.3.3/include/sysc/utils/sc_vector.h:749:3: required from ‘sc_core::sc_vector<T>::~sc_vector() [with T = mm_ready_valid_in<busy_st>]’ ./xxx.h:171:74: required from here /home/tools/libraries/systemc-2.3.3/include/sysc/utils/sc_vector.h:707:5: error: deleting object of polymorphic class type ‘mm_ready_valid_in<busy_st>’ which has non-virtual destructor might cause undefined behavior [-Werror=delete-non-virtual-dtor] 707 | delete &( (*this)[i] ); | ^~~~~~ / We have some classes we have created which we are using to instantiate our architecture for modelling. busy_st, and busy_t is simple classes which we generate. These are used then as input to our interface templates. The template class creates all the interface signaling etc to implement the ready busy. When I try and convert this to a sc_vector sc_vector<mm_ready_valid_in<busy_st>> I get this error. I'm kind of stuck, can anyone help? struct busy_t : public sc_uint<1> { using sc_uint<1>::sc_uint; std::string prt() const { switch (m_val) { case 0x0: return("BUSY_NOT"); case 0x1: return("BUSY"); }; return("BADVAL");}; }; // 0 = Not Busy, 1 = Busy struct busy_t : public sc_uint<1> { using sc_uint<1>::sc_uint; std::string prt() const { switch (m_val) { case 0x0: return("BUSY_NOT"); case 0x1: return("BUSY"); }; return("BADVAL");}; }; // 0 = Not Busy, 1 = Busy struct busy_st { busy_t busy; // 0 = Not Busy, 1 = Busy busy_st() { zero_fields(); fields[0].pfield = &busy; fields[0].pbigfield = NULL; fields[0].pos = 0; fields[0].bits = 1; } std::string prt() const { std::string s; s += "busy:" + busy.prt(); return(s); } void zero_fields() { busy = 0; } bool is_all_zeros() const { bool ret = true; ret = ret && (busy == 0); return ret; } static const unsigned int field_count = 1; // field count static const unsigned int bit_count = 1; // bit count (all fields) FIELD_ATTR fields[field_count]; inline bool operator == (const busy_st& r) const { return (busy == r.busy); } inline busy_st& operator = (const busy_st& r) { busy = r.busy; return *this; } inline busy_st& make_copy (const busy_st& r) { busy = r.busy; return *this; } inline friend void sc_trace(sc_trace_file* ptf, const busy_st& v, const std::string& NAME) { if (v.fields[0].pfield) { sc_trace(ptf, *v.fields[0].pfield, "busy"); } else { sc_trace(ptf, *v.fields[0].pbigfield, "busy"); } } inline friend ostream& operator << (ostream& os, busy_st const & v) { if (v.fields[0].pfield) { os << "busy: " << v.fields[0].pfield << endl; } else { os << "busy: " << v.fields[0].pbigfield << endl; } return os; } }; Quote Link to comment Share on other sites More sharing options...
Bas Arts Posted January 12, 2022 Report Share Posted January 12, 2022 Where is your class mm_ready_valid_in coming from? Are you able to change that? Seems to be a C++ issue rather than a SystemC issue. Andy Tomlin 1 Quote Link to comment Share on other sites More sharing options...
maehne Posted January 12, 2022 Report Share Posted January 12, 2022 I concur with @Bas Arts, you need to declare the destructor of mm_ready_valid_in to be virtual. Depending on your class hierarchy, this may make sense also for its base class(es). Andy Tomlin 1 Quote Link to comment Share on other sites More sharing options...
Andy Tomlin Posted January 12, 2022 Author Report Share Posted January 12, 2022 Doh! You guys were correct. That had not caused any issue before without the sc_vector usage. Anyway, thanks. 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.