On 8/14/2023 11:58 AM, Khan Shaikhul Hadi via gem5-users wrote:
In my code I'll have a simobject which has its own cache. As classical cache use CpuSidePort and MemSidePort to receive and respond to request, I want to create some internal CpuSidePort and MemSidePort in my simobject like below

    class SimObject : public ClockedObject
    {
      Cache cache;
    CpuSidePort  cacheMemSidePortConnection;
MemSidePort cacheCpuSidePortConnection;

    // CpuSidePort and MemSidePort class could follow same structure as 
BaseCache CpuSidePort and
    MemSidePort


    ...
    ...
    ...
    }

My question is how could I connect this ports with cache such that when I schedule some request pkt using cacheCpuSidePortConnection, cache's cpuSidePort will catch that packet, when cache's memSidePort schedule some req pkt, cacheMemSidePort will catch that pkt. In the front end, I could see in the library, we could do that using param ( cache.cpu_side_port = cpu.mem_side_port). But could not find any reference that connects to port within a simobject.
Any suggestions  or resources which I could follow ?

Why not just do this?

CpuSidePort cacheMemSidePortConnection = cache.memSidePort;
MemSidePort cacheCpuSidePortConnection = cache.cpuSidePort;

Then whatever is connected with the cache is exactly what;s connected to your 
thing -
though I am not sure what you get by doing this.

The connecting up is generally done by Python code in terms of parameters
in the Python classes.  Thus Cache.py has class BaseCache  with:

    cpu_side = ResponsePort(...)
    mem_side = RequestPort(...)

and in cache/base.cc the constructor has:

    cpuSidePort(p.name + ".cpu_side_port", *this, "CpuSidePort"),
    memSidePort(p.name + ".mem_side_port", this, "MemSidePort"),

cache/base.hh has (after a whole series of class definitions):

   CpuSidePort cpuSidePort;
   MemSidePort memSidePort;

Here's another possibility: write your thing as a subclass of Cache, assuming 
it is
supposed to act somewhat like a cache.

I don't feel totally confident in guiding you here since it's not clear what 
you're
really hoping to do ...

Maybe others will have other, more useful, perspectives for you ...   EM
_______________________________________________
gem5-users mailing list -- gem5-users@gem5.org
To unsubscribe send an email to gem5-users-le...@gem5.org

Reply via email to