Arjun_07 Posted June 9, 2020 Report Share Posted June 9, 2020 Hello everyone, I am trying to design memory in systemC , first i tried with regular array it worked perfectly. sc_uint<32> mem[MEMORY_DEPTH]; bur storing higher no of bytes, regular array is not working. thats why i tried with dynamic allocation of memory by new keyword. int *mem= new int [MEMORY_DEPTH]; but it produces following errors, can anyone please help me, how to solve this problem. error: 'new' cannot appear in a constant-expression error: ISO C++ forbids initialization of member 'mem' [-fpermissive] error: making 'mem' static [-fpermissive] error: invalid in-class initialization of static data member of non-integral type 'int*' thanks and regards Arjun Quote Link to comment Share on other sites More sharing options...
AmeyaVS Posted June 9, 2020 Report Share Posted June 9, 2020 Hello @Arjun_07, Can you post your minimal code which reproduces the behavior? Regards, Ameya Vikram Singh Quote Link to comment Share on other sites More sharing options...
Eyck Posted June 9, 2020 Report Share Posted June 9, 2020 Actually using new is not recommended at all. You should do something like: std::array<sc_dt::sc_uint<32>, MEMORY_DEPTH> mem; or (C++11): std::vector<sc_dt::sc_uint<32>> mem{MEMORY_DEPTH}; As far as I can see you try to initialize mem in-class (during declaration) and this is not allowed in C++. You can do this only in the constructor. And if you need to use new, don't forget to delete. maehne 1 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.