Hi Shougang, I think you can use <stat>.value() to get the actual value out of the stat. That should be easy to cast to an unsigned, if needed.
However, I think there might be some confusion on how to register/use the stats. If you've registered it correctly and it is updated during simulation (e.g., stat++ is executed) then it should be non-zero at the end. *Importantly* you cannot access the stats directly from C++. You must call "stats.prepare()" in python before they are ready to be processed. If you want all of the details, you can see the file `src/python/m5/stats/__init__.py` These details are supposed to be hidden, and they could change at any moment. If you simply want a counter, I suggest using the `Counter` type. Cheers, Jason On Tue, Sep 22, 2020 at 7:06 PM Shougang Yuan via gem5-users < gem5-users@gem5.org> wrote: > Hi, All, > > I am trying to use gem5 internal scalar data type(Stats:Scalar), I tried > to initialize it to a fixed value and register it in the regStats() > function, but after the simulation, I found the value dumped out is 0. > > And also, if I want to do some calculation based on this value and convert > it into unsigned value, there are errors in compilation. So how can I > convert it to unsigned value? > > Thanks for the help. > > Best regards. > > Shougang > _______________________________________________ > gem5-users mailing list -- gem5-users@gem5.org > To unsubscribe send an email to gem5-users-le...@gem5.org > %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s
_______________________________________________ gem5-users mailing list -- gem5-users@gem5.org To unsubscribe send an email to gem5-users-le...@gem5.org %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s