Perrinko9105 Posted March 18 Report Share Posted March 18 I am trying to simulate an SRAM memory using SystemC and have to allocate several 2D arrays. When I increase the number of bitcells to simulate I got std::dad_alloc error. I am suspecting stack size issue and went through several already opened topics here but couldn't fine the solution Beforre systemC compilation, I also set this SC_DEFAULT_STACK_SIZE_ 0x16000000 variable it helps me increase the array size but not enough as required. sc_vector<sc_vector<bitcell>> memory; sc_vector<sc_vector<sc_signal<sc_logic, SC_MANY_WRITERS>>> bit_value_in; sc_vector<sc_vector<sc_signal<sc_logic, SC_MANY_WRITERS>>> bit_value_out; sc_vector<sc_signal<sc_logic>> periphOutput; sc_vector<sc_signal<sc_logic, SC_MANY_WRITERS>> periphInput1; sc_vector<sc_signal<sc_logic, SC_MANY_WRITERS>> periphInput2; sc_vector<sc_signal<bool, SC_MANY_WRITERS>> periph_enable; sc_vector<sc_vector<sc_signal<bool, SC_MANY_WRITERS>>> wr_enable; sc_vector<sc_vector<sc_signal<bool, SC_MANY_WRITERS>>> rd_enable; For each declared 1D/2D vector I have a creator function to instantiate the objects. The SRAM has 1 bank of 4 arrays each with 128x256 bit-cell size Please can you direct me the parameter to change in order to get rid of this bad_alloc message ? Thanks Quote Link to comment Share on other sites More sharing options...
AmeyaVS Posted March 19 Report Share Posted March 19 Hello @Perrinko9105, Can you move your top-level SystemC object to heap? It might help to mitigate the issue. Regards, Ameya Vikram Singh Quote Link to comment Share on other sites More sharing options...
Perrinko9105 Posted March 19 Author Report Share Posted March 19 6 hours ago, AmeyaVS said: Hello @Perrinko9105, Can you move your top-level SystemC object to heap? It might help to mitigate the issue. Regards, Ameya Vikram Singh Hello @AmeyaVS, All instances are already create within top-level constructor. The top-level module is instantiate using std::make_unique<top>("") statement. They should be stored within the heap. The simulation crashes at the early stage of the simulation. I am suspecting during objects instantiation. Regards Quote Link to comment Share on other sites More sharing options...
AmeyaVS Posted March 19 Report Share Posted March 19 Hello @Perrinko9105, I would suggest to use a debugger to narrow down the source location from where the std::bad_alloc is thrown. Also, if possible can you share additional context on the source, just have a snippet does not provide enough context. I would prefer if you can share a minimal example which is causing this failure. Regards, Ameya Vikram Singh Quote Link to comment Share on other sites More sharing options...
Perrinko9105 Posted March 19 Author Report Share Posted March 19 2 hours ago, AmeyaVS said: Hello @Perrinko9105, I would suggest to use a debugger to narrow down the source location from where the std::bad_alloc is thrown. Also, if possible can you share additional context on the source, just have a snippet does not provide enough context. I would prefer if you can share a minimal example which is causing this failure. Regards, Ameya Vikram Singh Hello @AmeyaVS I resolved it by increasing the amount of memory mapping allowed by the Linux kernel by setting the parameter vm/max_map_count. The command is sudo sysctl vm/max_map_count=<number> Thanks for your suggestions. Regards, Perrin NT. 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.