gem5-users@gem5.org

The gem5 Users mailing list

View all threads

How to pass the reference of a simobject as a parameter of another simobject as configuration parameter

KS
Khan Shaikhul Hadi
Wed, Nov 8, 2023 11:03 PM

Can you pass reference of a simobject as a parameter to another simobject
in the configuration ( config.py ) file? How?

For example, I have an independent simobject class like Center_Ctrl and a
class  Cache. ( Center_Ctrl could not be a variable of the class object
Cache but Cache could have reference ( pointer) of center_ctrl to call some
demo function and vice versa) Now, I want something like this:

center_ ctrl = Center_Ctrl( parameters)
cache1 = Cache( parameters)
cache2=Cache(parameters)
cache1.cctrl = center_ctrl
cache2.cctrl = center_ctrl

and inside the Cache class, this cctrl variable will have the pointer or
reference to the center_ctrl simobject. How could I do that ?

Can you pass reference of a simobject as a parameter to another simobject in the configuration ( config.py ) file? How? For example, I have an independent simobject class like Center_Ctrl and a class Cache. ( Center_Ctrl could not be a variable of the class object Cache but Cache could have reference ( pointer) of center_ctrl to call some demo function and vice versa) Now, I want something like this: center_ ctrl = Center_Ctrl( parameters) cache1 = Cache( parameters) cache2=Cache(parameters) cache1.cctrl = center_ctrl cache2.cctrl = center_ctrl and inside the Cache class, this cctrl variable will have the pointer or reference to the center_ctrl simobject. How could I do that ?
GB
gabriel.busnot@arteris.com
Fri, Nov 10, 2023 6:59 AM

You need to add an attribute to the Cache python SimObject class:

cctrl = Param.Center_Ctrl(“<description>”)

You will need to import Center_Ctrl from m5.objects before as well.

You can find hundreds of examples of this construct in most python SimObject classes.

Regards,

Gabriel

You need to add an attribute to the Cache python SimObject class: > cctrl = Param.Center_Ctrl(“<description>”) You will need to import Center_Ctrl from m5.objects before as well. You can find hundreds of examples of this construct in most python SimObject classes. Regards, Gabriel