Jason Lowe-Power has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/64017?usp=email )

Change subject: stdlib: Update TestBoard to work with Simulator
......................................................................

stdlib: Update TestBoard to work with Simulator

This change makes minor updates to the TestBoard so that it can work
nicely with the Simulator module.

This change also makes the cache hierarchy optional for the TestBoard.

Change-Id: If46d53779164e87b6fc06176355be6b4ae05aa99
Signed-off-by: Jason Lowe-Power <ja...@lowepower.com>
---
M src/python/gem5/components/boards/test_board.py
M src/python/gem5/components/processors/abstract_generator.py
M src/python/gem5/simulate/exit_event.py
3 files changed, 45 insertions(+), 8 deletions(-)



diff --git a/src/python/gem5/components/boards/test_board.py b/src/python/gem5/components/boards/test_board.py
index 7267f2a..eca8c61 100644
--- a/src/python/gem5/components/boards/test_board.py
+++ b/src/python/gem5/components/boards/test_board.py
@@ -26,15 +26,15 @@

 from m5.objects import Port, IOXBar, AddrRange

-from .mem_mode import MemMode, mem_mode_to_string
 from ...utils.override import overrides
+from .abstract_board import AbstractBoard
 from .abstract_system_board import AbstractSystemBoard
-from ..processors.abstract_processor import AbstractProcessor
+from ..processors.abstract_generator import AbstractGenerator
 from ..memory.abstract_memory_system import AbstractMemorySystem
from ..cachehierarchies.abstract_cache_hierarchy import AbstractCacheHierarchy


-from typing import List
+from typing import List, Optional


 class TestBoard(AbstractSystemBoard):
@@ -43,21 +43,24 @@
     architecture.

     To work as a traffic generator board, pass a generator as a processor.
+
+    This board does not require a cache hierarchy (it can be none) in which
+ case the processor (generator) will be directly connected to the memory.
     """

     def __init__(
         self,
-        clk_freq: str,
-        processor: AbstractProcessor,
+        generator: AbstractGenerator,
         memory: AbstractMemorySystem,
-        cache_hierarchy: AbstractCacheHierarchy,
+        cache_hierarchy: Optional[AbstractCacheHierarchy],
     ):
         super().__init__(
-            clk_freq=clk_freq,
-            processor=processor,
+            clk_freq="1GHz",  # Clock frequency is ignored
+            processor=generator,
             memory=memory,
             cache_hierarchy=cache_hierarchy,
         )
+        self._set_fullsystem(False)

     @overrides(AbstractSystemBoard)
     def _setup_board(self) -> None:
@@ -108,3 +111,16 @@
     @overrides(AbstractSystemBoard)
     def has_dma_ports(self) -> bool:
         return False
+
+    @overrides(AbstractBoard)
+    def _connect_things(self) -> None:
+        super()._connect_things()
+
+        if not self.get_cache_hierarchy():
+            # If we have no caches, then there must be a one-to-one
+            # connection between the generators and the memories.
+            assert len(self.get_processor().get_cores()) == 1
+            assert len(self.get_memory().get_mem_ports()) == 1
+            self.get_processor().get_cores()[
+                0
+            ].generator.port = self.get_memory().get_mem_ports()[0][1]
diff --git a/src/python/gem5/components/processors/abstract_generator.py b/src/python/gem5/components/processors/abstract_generator.py
index 41cbf5c..ff5387d 100644
--- a/src/python/gem5/components/processors/abstract_generator.py
+++ b/src/python/gem5/components/processors/abstract_generator.py
@@ -65,3 +65,6 @@
this method needs to be implemented in detail or implmeneted as pass.
         """
         raise NotImplementedError
+
+    def _post_instantiate(self) -> None:
+        self.start_traffic()
diff --git a/src/python/gem5/simulate/exit_event.py b/src/python/gem5/simulate/exit_event.py
index 691e41a..29d434c 100644
--- a/src/python/gem5/simulate/exit_event.py
+++ b/src/python/gem5/simulate/exit_event.py
@@ -87,6 +87,9 @@
             return ExitEvent.SIMPOINT_BEGIN
         elif exit_string == "a thread reached the max instruction count":
             return ExitEvent.MAX_INSTS
+        elif exit_string.endswith("will terminate the simulation.\n"):
+            # This is for the traffic generator exit event
+            return ExitEvent.EXIT
         raise NotImplementedError(
             "Exit event '{}' not implemented".format(exit_string)
         )

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/64017?usp=email To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: If46d53779164e87b6fc06176355be6b4ae05aa99
Gerrit-Change-Number: 64017
Gerrit-PatchSet: 1
Gerrit-Owner: Jason Lowe-Power <power...@gmail.com>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org

Reply via email to