Jump to content


  • Content Count

  • Joined

  • Last visited

About thekamz

  • Rank

Profile Information

  • Gender
    Not Telling
  1. Philipp -- thanks very much for all the help and effort! I'll follow the steps you recommended and post as I get more info.
  2. I have added to the playground. Not getting segfault in the simplified model, but getting another unexpected result. Data seems to be constructed, but I don't generate data anywhere. I'm obviously overlooking something basic. The problem seems to be in the type that I'm passing between modules.
  3. There is no error when adding the line after sc_start, so you may be right. Skipping the sc_start results in no segfault. The module does have only the members I listed. Like I said, the my_packet_type does have (one) unique_ptr member, but I'm sure it is used appropriately. Moving your line to before the call to sc_start, then debugging, shows something new. Specifically, inside mod I am trying to wait on a data_written_event to any of the sc_fifo_in contained in sc_vector<sc_fifo_in<my_packet_type>>. The way I am doing that is with this function: template <typename T> static sc_event_or_list multi_data(const sc_vector<sc_fifo_in<T>>& input_ports) { sc_event_or_list my_or_events = input_ports[0].data_written_event() | input_ports[0].data_written_event(); for(auto& port : input_ports) { my_or_events |= port.data_written_event(); } return my_or_events; } The debugger points to the line in red. When I modify that function as follows: template <typename T> static sc_event_or_list multi_data(const sc_vector<sc_fifo_in<T>>& input_ports) { sc_event_or_list my_or_events; for(auto& port : input_ports) { my_or_events |= port.data_written_event(); } return my_or_events; } GDB then points to the function in mod that uses this to wait on an event from any of the input ports. The function in mod that tries to use this: void mod::do_mod() { while(1) { if(nums_available<my_packet_type>(mod_in) == 0) { wait(multi_data<my_packet_type>(mod_in)); } else { for(auto& channel: mod_in) { my_packet_type d; if(channel.num_available()) { channel.read(d); help_mod(d); } } } } } Apologies for the delay in putting up a minimal example. This system is huge and, unfortunately, the mod is at the center of it. I'm trying to find a way to isolate it and still get something illustrative -- putting up the whole thing is not possible due to an NDA that prevents sharing. Edit: I should probably add, SystemC 2.3.1.
  4. Thank you for your responses dakupoto and Philipp. Philipp - I will post a simple compilable example ASAP. It may take an hour or so because mod, while simple, is connected to a bunch of other stuff in main. In the mean time, mod has: 4 private members (3 unsigned ints and 1 static unsigned int) public sc_vector<sc_fifo_in<my_packet_type>> public sc_vector<sc_fifo_out<my_packet_type>> No pointers or smart pointers. Adding your line to sc_main had no effect (I added it after the call to sc_start, i.e., immediately before the call to return from sc_main). EDIT: Ah, my_packet_type does use a single std::unique_ptr. I'll wrap up this whole thing into a small compilable example to post here soon.
  5. I am trying to use an sc_vector of modules with a custom creator to pass constructor arguments. It seems to work and run through the entire program, but at exit causes a segfault. GDB shows that this is due to to sc_vector calling the destructor of the module. I have no dynamically-allocated memory or pointers in the module. Here's the overview: outside of sc_main (global -- but I also tried inside of sc_main): -------------------------- struct create_mod { unsigned int m_arg1; unsigned int m_arg2; create_mod(unsigned int arg1, unsigned int arg2) : m_arg1(arg1), m_arg2(arg2) {} mod* operator()(const char* name, size_t) { return new mod(name, m_arg1, m_arg2); } }; Inside sc_main: --------------------------- unsigned int num_of_mods = 8; unsigned int args1 = 5, args2 = 4; sc_vector<mod> vec_mod("mods"); vec_mod.init(num_of_mods, create_mod(args1, args2)); // ... use vec_mod, bind ports, etc ... return 0; So the program runs, then segfaults at the end with "core dumped". GDB results: Backtracing shows: Note the bit in red. Also note that line 334 is the closing brace of sc_main. Also: As I said, I have no dynamically-allocated memory in the class. I have tried an empty destructor (as well as = default since I'm using C++11) but got the same result. Any ideas? Thanks in advance.
  • Create New...