Bobby R. Bruce has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/52883 )
Change subject: stdlib: Call `setup_memory_ranges()` from the constructor
......................................................................
stdlib: Call `setup_memory_ranges()` from the constructor
`setup_memory_ranges()`, now `_setup_memory_ranges()`, had to be called
by subclasses. Since `setup_memory_ranges() was always called at the top
of the `_setup_board()` function (or could be), this function is now
automatically called within the AbstractBoard's constructor prior to
`_setup_board` and `_connect_things`.
Change-Id: I6bf3231666b86059ffc484cfca44e45cfde52ea6
---
M src/python/gem5/components/boards/simple_board.py
M src/python/gem5/components/boards/riscv_board.py
M src/python/gem5/components/boards/test_board.py
M src/python/gem5/components/boards/x86_board.py
M src/python/gem5/components/boards/abstract_board.py
5 files changed, 41 insertions(+), 24 deletions(-)
diff --git a/src/python/gem5/components/boards/abstract_board.py
b/src/python/gem5/components/boards/abstract_board.py
index 4055e17..a27cecd 100644
--- a/src/python/gem5/components/boards/abstract_board.py
+++ b/src/python/gem5/components/boards/abstract_board.py
@@ -86,6 +86,8 @@
self.memory = memory
self.cache_hierarchy = cache_hierarchy
+ # Setup the board and memory system's memory ranges.
+ self._setup_memory_ranges()
# Setup board properties unique to the board being constructed.
self._setup_board()
@@ -143,8 +145,9 @@
"""
This function is called in the AbstractBoard constructor, before
the
memory, processor, and cache hierarchy components are incorporated
via
- `_connect_thing()`. This function should be overridden by boards to
- specify components, connections unique to that board.
+ `_connect_thing()`, but after the `_setup_memory_ranges()`
function.
+ This function should be overridden by boards to specify components,
+ connections unique to that board.
"""
raise NotImplementedError
@@ -212,18 +215,24 @@
raise NotImplementedError
@abstractmethod
- def setup_memory_ranges(self) -> None:
+ def _setup_memory_ranges(self) -> None:
"""
- Set the memory ranges for this board.
+ Set the memory ranges for this board and memory system.
- This is called by at the end of the constructor. It can query the
- board's memory to determine the size and the set the memory ranges
on
- the memory if it needs to move the memory devices.
+ This is called in the constructor, prior to `_setup_board` and
+ `_connect_things`. It should query the board's memory to determine
the
+ size and the set the memory ranges on the memory system and on the
+ board.
- The simplest implementation just sets the board's memory range to
be
- the size of memory and memory's memory range to be the same as the
- board. Full system implementations will likely need something more
- complicated.
+ The simplest implementation sets the board's memory range to the
size
+ of memory and memory system's range to be the same as the board.
Full
+ system implementations will likely need something more complicated.
+
+ Notes
+ -----
+ * This *must* be called prior to the incorporation of the cache
+ hierarchy (via `_connect_things`) as cache hierarchies depend upon
+ knowing the memory system's ranges.
"""
raise NotImplementedError
diff --git a/src/python/gem5/components/boards/riscv_board.py
b/src/python/gem5/components/boards/riscv_board.py
index f64640c..8945f22 100644
--- a/src/python/gem5/components/boards/riscv_board.py
+++ b/src/python/gem5/components/boards/riscv_board.py
@@ -121,9 +121,6 @@
self._on_chip_devices = [self.platform.clint, self.platform.plic]
self._off_chip_devices = [self.platform.uart, self.disk]
- # Set up the memory ranges
- self.setup_memory_ranges()
-
def _setup_io_devices(self) -> None:
"""Connect the I/O devices to the I/O bus"""
@@ -189,7 +186,7 @@
return self.iobus.mem_side_ports
@overrides(AbstractBoard)
- def setup_memory_ranges(self):
+ def _setup_memory_ranges(self):
memory = self.get_memory()
mem_size = memory.get_size()
self.mem_ranges = [AddrRange(start=0x80000000, size=mem_size)]
diff --git a/src/python/gem5/components/boards/simple_board.py
b/src/python/gem5/components/boards/simple_board.py
index c011132..d0f4f2a 100644
--- a/src/python/gem5/components/boards/simple_board.py
+++ b/src/python/gem5/components/boards/simple_board.py
@@ -67,8 +67,7 @@
@overrides(AbstractBoard)
def _setup_board(self) -> None:
- # Set up the memory ranges
- self.setup_memory_ranges()
+ pass
@overrides(AbstractBoard)
def has_io_bus(self) -> bool:
@@ -104,7 +103,7 @@
)
@overrides(AbstractBoard)
- def setup_memory_ranges(self) -> None:
+ def _setup_memory_ranges(self) -> None:
memory = self.get_memory()
# The simple board just has one memory range that is the size of
the
diff --git a/src/python/gem5/components/boards/test_board.py
b/src/python/gem5/components/boards/test_board.py
index 3d5b304..d39e25d 100644
--- a/src/python/gem5/components/boards/test_board.py
+++ b/src/python/gem5/components/boards/test_board.py
@@ -65,7 +65,7 @@
@overrides(AbstractBoard)
def _setup_board(self) -> None:
- self.setup_memory_ranges()
+ pass
@overrides(AbstractBoard)
def has_io_bus(self) -> bool:
@@ -101,7 +101,7 @@
)
@overrides(AbstractBoard)
- def setup_memory_ranges(self) -> None:
+ def _setup_memory_ranges(self) -> None:
memory = self.get_memory()
# The simple board just has one memory range that is the size of
the
diff --git a/src/python/gem5/components/boards/x86_board.py
b/src/python/gem5/components/boards/x86_board.py
index 3b5effa..6f53001 100644
--- a/src/python/gem5/components/boards/x86_board.py
+++ b/src/python/gem5/components/boards/x86_board.py
@@ -96,9 +96,6 @@
# North Bridge
self.iobus = IOXBar()
- # Figure out the memory ranges.
- self.setup_memory_ranges()
-
# Set up all of the I/O.
self._setup_io_devices()
@@ -276,7 +273,7 @@
return self.iobus.mem_side_ports
@overrides(AbstractBoard)
- def setup_memory_ranges(self):
+ def _setup_memory_ranges(self):
memory = self.get_memory()
if memory.get_size() > toMemorySize("3GB"):
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/52883
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: I6bf3231666b86059ffc484cfca44e45cfde52ea6
Gerrit-Change-Number: 52883
Gerrit-PatchSet: 1
Gerrit-Owner: Bobby R. Bruce <bbr...@ucdavis.edu>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s