SystemC-Components icon indicating copy to clipboard operation
SystemC-Components copied to clipboard

scc::memory can't be sized dynamically

Open mekarlst opened this issue 4 months ago • 0 comments

The scc::memory class requires the size as a template parameter, but we determine our memory sizes dynamically at runtime. As a result, we've been using scc::memory but giving each instance a worst-case constant size that is sufficient for any runtime configuration. This caused us to run into a DMI issue (see https://github.com/Minres/SystemC-Components/issues/72).

Ideally, we'd like to be able to set the size of the memory at runtime. As a workaround, I added a size override argument to the scc::memory constructor with a default value of std::numeric_limits<uint64_t>::max() and a member variable that is assigned the minimum of the constructor argument and the SIZE template parameter. Using this new member variable instead of SIZE in the implementation (e.g., in handle_operation and handle_dmi) seemed to fix our issue, although it doesn't address the overhead of allocating memory that won't be used.

I'm happy to put the workaround up as a PR, but I wanted to present this issue, in case there is a more preferred solution, such as creating a new memory component that is dynamically sized or changing scc::memory to be dynamically sized natively.

mekarlst avatar Aug 28 '25 17:08 mekarlst