stdlib: AbstractMemorySystem.get_mem_interfaces.
This change adds a new method to AbstractMemorySystem to allow getting its objects of the class MemInterface. This is useful when certain other classes require a list of MemInterface objects to create physical memory. In addition, ChanneledMemory and HighBandwidthMemory implement this function.
This commit is contained in:
committed by
Bobby R. Bruce
parent
c0c0955178
commit
1948155fb2
@@ -37,6 +37,7 @@ from typing import (
|
||||
from m5.objects import (
|
||||
AddrRange,
|
||||
MemCtrl,
|
||||
MemInterface,
|
||||
Port,
|
||||
Root,
|
||||
SubSystem,
|
||||
@@ -79,6 +80,12 @@ class AbstractMemorySystem(SubSystem):
|
||||
"""Get all of the memory controllers in this memory system."""
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
def get_mem_interfaces(self) -> List[MemInterface]:
|
||||
"""Get all memory interfaces in this memory system.
|
||||
Useful when creating physical memory objects."""
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
def get_size(self) -> int:
|
||||
"""Returns the total size of the memory system."""
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
from math import log
|
||||
from typing import (
|
||||
List,
|
||||
Optional,
|
||||
Sequence,
|
||||
Tuple,
|
||||
@@ -40,6 +41,7 @@ from m5.objects import (
|
||||
AddrRange,
|
||||
DRAMInterface,
|
||||
HBMCtrl,
|
||||
MemInterface,
|
||||
Port,
|
||||
)
|
||||
|
||||
@@ -172,6 +174,12 @@ class HighBandwidthMemory(ChanneledMemory):
|
||||
(addr_ranges[i], ctrl.port) for i, ctrl in enumerate(self.mem_ctrl)
|
||||
]
|
||||
|
||||
@overrides(ChanneledMemory)
|
||||
def get_mem_interfaces(self) -> List[MemInterface]:
|
||||
return [ctrl.dram for ctrl in self.get_memory_controllers()] + [
|
||||
ctrl.dram_2 for ctrl in self.get_memory_controllers()
|
||||
]
|
||||
|
||||
|
||||
def HBM2Stack(
|
||||
size: Optional[str] = "4GiB",
|
||||
|
||||
@@ -185,6 +185,10 @@ class ChanneledMemory(AbstractMemorySystem):
|
||||
def get_memory_controllers(self) -> List[MemCtrl]:
|
||||
return [ctrl for ctrl in self.mem_ctrl]
|
||||
|
||||
@overrides(AbstractMemorySystem)
|
||||
def get_mem_interfaces(self) -> List[DRAMInterface]:
|
||||
return self._dram
|
||||
|
||||
@overrides(AbstractMemorySystem)
|
||||
def get_size(self) -> int:
|
||||
return self._size
|
||||
|
||||
Reference in New Issue
Block a user