Skip to content
Snippets Groups Projects
Commit 4a2cad1f authored by Oscar Gustafsson's avatar Oscar Gustafsson :bicyclist:
Browse files

Only use default naming for PlainMemoryVariable

parent b9b15648
No related branches found
No related tags found
1 merge request!296Support for Bireciprocal LWDF
Pipeline #94688 passed
...@@ -19,20 +19,14 @@ class Process: ...@@ -19,20 +19,14 @@ class Process:
Start time of process. Start time of process.
execution_time : int execution_time : int
Execution time (lifetime) of process. Execution time (lifetime) of process.
name : str, optional name : str, default: ""
The name of the process. If not provided, generate a name. The name of the process.
""" """
def __init__( def __init__(self, start_time: int, execution_time: int, name: str = ""):
self, start_time: int, execution_time: int, name: Optional[str] = None
):
self._start_time = start_time self._start_time = start_time
self._execution_time = execution_time self._execution_time = execution_time
if name is None: self._name = name
self._name = f"Proc. {Process._name_cnt}"
Process._name_cnt += 1
else:
self._name = name
def __lt__(self, other): def __lt__(self, other):
return self._start_time < other.start_time or ( return self._start_time < other.start_time or (
...@@ -60,9 +54,6 @@ class Process: ...@@ -60,9 +54,6 @@ class Process:
def __repr__(self) -> str: def __repr__(self) -> str:
return f"Process({self.start_time}, {self.execution_time}, {self.name!r})" return f"Process({self.start_time}, {self.execution_time}, {self.name!r})"
# Static counter for default names
_name_cnt = 0
class OperatorProcess(Process): class OperatorProcess(Process):
""" """
...@@ -117,8 +108,8 @@ class MemoryVariable(Process): ...@@ -117,8 +108,8 @@ class MemoryVariable(Process):
write_port : :class:`~b_asic.port.OutputPort` write_port : :class:`~b_asic.port.OutputPort`
The OutputPort that the memory variable originates from. The OutputPort that the memory variable originates from.
reads : dict reads : dict
Dictionary with :class:`~b_asic.port.InputPort` that reads the memory variable as key and Dictionary with :class:`~b_asic.port.InputPort` that reads the memory variable
for how long after the *write_time* it will read. as key and for how long after the *write_time* it will read.
name : str, optional name : str, optional
The name of the process. The name of the process.
""" """
...@@ -196,6 +187,10 @@ class PlainMemoryVariable(Process): ...@@ -196,6 +187,10 @@ class PlainMemoryVariable(Process):
self._life_times = tuple(reads.values()) self._life_times = tuple(reads.values())
self._write_port = write_port self._write_port = write_port
self._reads = reads self._reads = reads
if name is None:
name = f"Var. {PlainMemoryVariable._name_cnt}"
PlainMemoryVariable._name_cnt += 1
super().__init__( super().__init__(
start_time=write_time, start_time=write_time,
execution_time=max(self._life_times), execution_time=max(self._life_times),
...@@ -224,3 +219,6 @@ class PlainMemoryVariable(Process): ...@@ -224,3 +219,6 @@ class PlainMemoryVariable(Process):
f"PlainMemoryVariable({self.start_time}, {self.write_port}," f"PlainMemoryVariable({self.start_time}, {self.write_port},"
f" {reads!r}, {self.name!r})" f" {reads!r}, {self.name!r})"
) )
# Static counter for default names
_name_cnt = 0
...@@ -12,7 +12,7 @@ def test_PlainMemoryVariable(): ...@@ -12,7 +12,7 @@ def test_PlainMemoryVariable():
assert mem.execution_time == 2 assert mem.execution_time == 2
assert mem.life_times == (1, 2) assert mem.life_times == (1, 2)
assert mem.read_ports == (4, 5) assert mem.read_ports == (4, 5)
assert repr(mem) == "PlainMemoryVariable(3, 0, {4: 1, 5: 2}, 'Proc. 0')" assert repr(mem) == "PlainMemoryVariable(3, 0, {4: 1, 5: 2}, 'Var. 0')"
mem2 = PlainMemoryVariable(2, 0, {4: 2, 5: 3}, 'foo') mem2 = PlainMemoryVariable(2, 0, {4: 2, 5: 3}, 'foo')
assert repr(mem2) == "PlainMemoryVariable(2, 0, {4: 2, 5: 3}, 'foo')" assert repr(mem2) == "PlainMemoryVariable(2, 0, {4: 2, 5: 3}, 'foo')"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment