stdlib: Add _post_instantiate function

This function will be called on the board after m5.instantiate is
called. This is useful, for instance, to start traffic generators.
Currently all implementations simply `pass`.

Change-Id: Ie2ab3fdddca5f3978d98191e5c08504561587fbb
Signed-off-by: Jason Lowe-Power <jason@lowepower.com>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/64016
Reviewed-by: Bobby Bruce <bbruce@ucdavis.edu>
Maintainer: Bobby Bruce <bbruce@ucdavis.edu>
Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
Jason Lowe-Power
2022-09-30 17:39:54 -07:00
committed by Jason Lowe-Power
parent 55f80ae0a1
commit d2a6d2f7ee
5 changed files with 23 additions and 0 deletions

View File

@@ -338,3 +338,10 @@ class AbstractBoard:
# Incorporate the processor into the motherboard.
self.get_processor().incorporate_processor(self)
def _post_instantiate(self):
"""Called to set up anything needed after m5.instantiate"""
self.get_processor()._post_instantiate()
if self.get_cache_hierarchy():
self.get_cache_hierarchy()._post_instantiate()
self.get_memory()._post_instantiate()

View File

@@ -70,3 +70,7 @@ class AbstractCacheHierarchy(SubSystem):
:returns: True if the cache hierarchy is ruby. Otherwise False.
"""
raise NotImplementedError
def _post_instantiate(self):
"""Called to set up anything needed after m5.instantiate"""
pass

View File

@@ -71,3 +71,7 @@ class AbstractMemorySystem(SubSystem):
will be raised.
"""
raise NotImplementedError
def _post_instantiate(self) -> None:
"""Called to set up anything needed after m5.instantiate"""
pass

View File

@@ -74,3 +74,7 @@ class AbstractProcessor(SubSystem):
@abstractmethod
def incorporate_processor(self, board: AbstractBoard) -> None:
raise NotImplementedError
def _post_instantiate(self) -> None:
"""Called to set up anything needed after m5.instantiate"""
pass

View File

@@ -405,6 +405,10 @@ class Simulator:
m5.instantiate(self._checkpoint_path)
self._instantiated = True
# Let the board know that instantiate has been called so it can do
# any final things.
self._board._post_instantiate()
def run(self, max_ticks: int = m5.MaxTick) -> None:
"""
This function will start or continue the simulator run and handle exit