Skip to content

Commit 6674bd9

Browse files
authored
Merge pull request #120 from siliconcompiler/breakout-impl
breakout impl file to make it reusable
2 parents e0d5d1c + ed98236 commit 6674bd9

File tree

4 files changed

+25
-9
lines changed

4 files changed

+25
-9
lines changed

lambdalib/ramlib/_common.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from pathlib import Path
2+
from typing import Union, Optional
3+
4+
from lambdalib.lambdalib import Lambda
5+
6+
7+
class _RAMLib(Lambda):
8+
def __init__(self, name: str, path: Union[str, Path],
9+
impl_file: Optional[Union[str, Path]] = None):
10+
super().__init__(name, path)
11+
12+
if impl_file:
13+
with self.active_dataroot(name), self.active_fileset("rtl.impl"):
14+
self.add_file(impl_file)
15+
with self.active_fileset("rtl"):
16+
self.add_depfileset(self, "rtl.impl")

lambdalib/ramlib/la_dpram/la_dpram.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
from lambdalib.lambdalib import Lambda
1+
from lambdalib.ramlib._common import _RAMLib
22

33

4-
class Dpram(Lambda):
4+
class Dpram(_RAMLib):
55
def __init__(self):
66
name = 'la_dpram'
7-
super().__init__(name, __file__, extrasources=['rtl/la_dpram_impl.v'])
7+
super().__init__(name, __file__, impl_file='rtl/la_dpram_impl.v')
88

99

1010
if __name__ == "__main__":

lambdalib/ramlib/la_spram/la_spram.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
from lambdalib.lambdalib import Lambda
1+
from lambdalib.ramlib._common import _RAMLib
22

33

4-
class Spram(Lambda):
4+
class Spram(_RAMLib):
55
def __init__(self):
66
name = 'la_spram'
7-
super().__init__(name, __file__, extrasources=['rtl/la_spram_impl.v'])
7+
super().__init__(name, __file__, impl_file='rtl/la_spram_impl.v')
88

99

1010
if __name__ == "__main__":

lambdalib/ramlib/la_tdpram/la_tdpram.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
from lambdalib.lambdalib import Lambda
1+
from lambdalib.ramlib._common import _RAMLib
22

33

4-
class Tdpram(Lambda):
4+
class Tdpram(_RAMLib):
55
def __init__(self):
66
name = 'la_tdpram'
7-
super().__init__(name, __file__, extrasources=['rtl/la_tdpram_impl.v'])
7+
super().__init__(name, __file__, impl_file='rtl/la_tdpram_impl.v')
88

99

1010
if __name__ == "__main__":

0 commit comments

Comments
 (0)