nortl 1.4.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- nortl/__init__.py +85 -0
- nortl/components/__init__.py +8 -0
- nortl/components/channel.py +132 -0
- nortl/components/timer.py +73 -0
- nortl/core/__init__.py +40 -0
- nortl/core/checker.py +135 -0
- nortl/core/common/__init__.py +4 -0
- nortl/core/common/access.py +25 -0
- nortl/core/common/debug.py +6 -0
- nortl/core/common/naming_helper.py +33 -0
- nortl/core/constructs/__init__.py +13 -0
- nortl/core/constructs/condition.py +143 -0
- nortl/core/constructs/fork_join.py +84 -0
- nortl/core/constructs/loop.py +138 -0
- nortl/core/engine.py +575 -0
- nortl/core/exceptions.py +139 -0
- nortl/core/manager/__init__.py +6 -0
- nortl/core/manager/scratch_manager.py +128 -0
- nortl/core/manager/signal_manager.py +71 -0
- nortl/core/modifiers.py +136 -0
- nortl/core/module.py +181 -0
- nortl/core/operations.py +834 -0
- nortl/core/parameter.py +88 -0
- nortl/core/process.py +451 -0
- nortl/core/protocols.py +628 -0
- nortl/core/renderers/__init__.py +0 -0
- nortl/core/renderers/operations/__init__.py +34 -0
- nortl/core/renderers/operations/arithmetics.py +38 -0
- nortl/core/renderers/operations/base.py +111 -0
- nortl/core/renderers/operations/comparison.py +44 -0
- nortl/core/renderers/operations/logic.py +38 -0
- nortl/core/renderers/operations/misc.py +26 -0
- nortl/core/renderers/operations/slice.py +30 -0
- nortl/core/signal.py +878 -0
- nortl/core/state.py +201 -0
- nortl/py.typed +0 -0
- nortl/renderer/__init__.py +5 -0
- nortl/renderer/mermaid_renderer.py +38 -0
- nortl/renderer/networkx_renderer.py +29 -0
- nortl/renderer/verilog_renderer.py +325 -0
- nortl/renderer/verilog_utils/__init__.py +6 -0
- nortl/renderer/verilog_utils/formatter.py +29 -0
- nortl/renderer/verilog_utils/process.py +226 -0
- nortl/renderer/verilog_utils/structural.py +146 -0
- nortl/renderer/verilog_utils/utils.py +23 -0
- nortl/utils/__init__.py +0 -0
- nortl/utils/parse_utils.py +37 -0
- nortl/utils/templates/testbench.sv +41 -0
- nortl/utils/test_wrapper.py +218 -0
- nortl/utils/type_aliases.py +15 -0
- nortl/verilog_library/__init__.py +74 -0
- nortl/verilog_library/nortl_clock_gate.sv +20 -0
- nortl/verilog_library/nortl_count_down_timer.sv +50 -0
- nortl/verilog_library/nortl_delay.sv +66 -0
- nortl/verilog_library/nortl_edge_detector.sv +34 -0
- nortl/verilog_library/nortl_sync.sv +28 -0
- nortl-1.4.0.dist-info/METADATA +105 -0
- nortl-1.4.0.dist-info/RECORD +60 -0
- nortl-1.4.0.dist-info/WHEEL +4 -0
- nortl-1.4.0.dist-info/licenses/LICENSE +11 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"""Base classes for renderers."""
|
|
2
|
+
|
|
3
|
+
from abc import ABCMeta, abstractmethod
|
|
4
|
+
from typing import Optional, Protocol, Union
|
|
5
|
+
|
|
6
|
+
__all__ = [
|
|
7
|
+
'SingleRenderer',
|
|
8
|
+
'SliceRenderer',
|
|
9
|
+
'TwoSideRenderer',
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class Renderable(Protocol):
|
|
14
|
+
@property
|
|
15
|
+
def is_primitive(self) -> bool: ...
|
|
16
|
+
|
|
17
|
+
def render(self, target: Optional[str] = None) -> str: ...
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class SingleContainerProto(Protocol):
|
|
21
|
+
@property
|
|
22
|
+
def value(self) -> Renderable: ...
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class TwoSideContainerProto(Protocol):
|
|
26
|
+
@property
|
|
27
|
+
def left(self) -> Renderable: ...
|
|
28
|
+
|
|
29
|
+
@property
|
|
30
|
+
def right(self) -> Renderable: ...
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class SliceContainerProto(Protocol):
|
|
34
|
+
@property
|
|
35
|
+
def value(self) -> Renderable: ...
|
|
36
|
+
|
|
37
|
+
@property
|
|
38
|
+
def index(self) -> Union[int, slice]: ...
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class RendererABC(metaclass=ABCMeta):
|
|
42
|
+
"""Abstract baseclass for renderers."""
|
|
43
|
+
|
|
44
|
+
@abstractmethod
|
|
45
|
+
def __call__(self, target: Optional[str] = None) -> str:
|
|
46
|
+
"""Render value to target language.
|
|
47
|
+
|
|
48
|
+
Arguments:
|
|
49
|
+
target: Target language.
|
|
50
|
+
"""
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
class SingleRenderer(RendererABC):
|
|
54
|
+
"""Base class for renderers for operations with a single value."""
|
|
55
|
+
|
|
56
|
+
def __init__(self, container: SingleContainerProto) -> None:
|
|
57
|
+
"""Initialize the renderer.
|
|
58
|
+
|
|
59
|
+
Arguments:
|
|
60
|
+
container: Operation wrapper container for the renderer.
|
|
61
|
+
"""
|
|
62
|
+
self.container = container
|
|
63
|
+
|
|
64
|
+
@property
|
|
65
|
+
def value(self) -> Renderable:
|
|
66
|
+
"""Value to which the operation is applied."""
|
|
67
|
+
return self.container.value
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
class TwoSideRenderer(RendererABC):
|
|
71
|
+
"""Base class for renderers for operations with two values."""
|
|
72
|
+
|
|
73
|
+
def __init__(self, container: TwoSideContainerProto) -> None:
|
|
74
|
+
"""Initialize the renderer.
|
|
75
|
+
|
|
76
|
+
Arguments:
|
|
77
|
+
container: Operation wrapper container for the renderer.
|
|
78
|
+
"""
|
|
79
|
+
self.container = container
|
|
80
|
+
|
|
81
|
+
@property
|
|
82
|
+
def left(self) -> Renderable:
|
|
83
|
+
"""Left or first value for the operation."""
|
|
84
|
+
return self.container.left
|
|
85
|
+
|
|
86
|
+
@property
|
|
87
|
+
def right(self) -> Renderable:
|
|
88
|
+
"""Right or second value for the operation."""
|
|
89
|
+
return self.container.right
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
class SliceRenderer(RendererABC):
|
|
93
|
+
"""Base class for renderers for slicing operations."""
|
|
94
|
+
|
|
95
|
+
def __init__(self, container: SliceContainerProto) -> None:
|
|
96
|
+
"""Initialize the renderer.
|
|
97
|
+
|
|
98
|
+
Arguments:
|
|
99
|
+
container: Operation wrapper container for the renderer.
|
|
100
|
+
"""
|
|
101
|
+
self.container = container
|
|
102
|
+
|
|
103
|
+
@property
|
|
104
|
+
def value(self) -> Renderable:
|
|
105
|
+
"""Value to which the slice is applied."""
|
|
106
|
+
return self.container.value
|
|
107
|
+
|
|
108
|
+
@property
|
|
109
|
+
def index(self) -> Union[int, slice]:
|
|
110
|
+
"""Slicing index."""
|
|
111
|
+
return self.container.index
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"""Comparison operations."""
|
|
2
|
+
|
|
3
|
+
from typing import Optional
|
|
4
|
+
|
|
5
|
+
from nortl.core.renderers.operations.base import TwoSideRenderer
|
|
6
|
+
|
|
7
|
+
__all__ = [
|
|
8
|
+
'Equality',
|
|
9
|
+
'Greater',
|
|
10
|
+
'GreaterOrEqual',
|
|
11
|
+
'Less',
|
|
12
|
+
'LessOrEqual',
|
|
13
|
+
'Unequality',
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class Equality(TwoSideRenderer):
|
|
18
|
+
def __call__(self, target: Optional[str] = None) -> str:
|
|
19
|
+
return f'({self.left} == {self.right})'
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class Unequality(TwoSideRenderer):
|
|
23
|
+
def __call__(self, target: Optional[str] = None) -> str:
|
|
24
|
+
return f'({self.left} != {self.right})'
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class Less(TwoSideRenderer):
|
|
28
|
+
def __call__(self, target: Optional[str] = None) -> str:
|
|
29
|
+
return f'({self.left} < {self.right})'
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class LessOrEqual(TwoSideRenderer):
|
|
33
|
+
def __call__(self, target: Optional[str] = None) -> str:
|
|
34
|
+
return f'({self.left} <= {self.right})'
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class Greater(TwoSideRenderer):
|
|
38
|
+
def __call__(self, target: Optional[str] = None) -> str:
|
|
39
|
+
return f'({self.left} > {self.right})'
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class GreaterOrEqual(TwoSideRenderer):
|
|
43
|
+
def __call__(self, target: Optional[str] = None) -> str:
|
|
44
|
+
return f'({self.left} >= {self.right})'
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"""Logic operations."""
|
|
2
|
+
|
|
3
|
+
from typing import Optional
|
|
4
|
+
|
|
5
|
+
from nortl.core.renderers.operations.base import TwoSideRenderer
|
|
6
|
+
|
|
7
|
+
__all__ = [
|
|
8
|
+
'And',
|
|
9
|
+
'ExclusiveOr',
|
|
10
|
+
'LeftShift',
|
|
11
|
+
'Or',
|
|
12
|
+
'RightShift',
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class And(TwoSideRenderer):
|
|
17
|
+
def __call__(self, target: Optional[str] = None) -> str:
|
|
18
|
+
return f'({self.left} & {self.right})'
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class Or(TwoSideRenderer):
|
|
22
|
+
def __call__(self, target: Optional[str] = None) -> str:
|
|
23
|
+
return f'({self.left} | {self.right})'
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class ExclusiveOr(TwoSideRenderer):
|
|
27
|
+
def __call__(self, target: Optional[str] = None) -> str:
|
|
28
|
+
return f'({self.left} ^ {self.right})'
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class LeftShift(TwoSideRenderer):
|
|
32
|
+
def __call__(self, target: Optional[str] = None) -> str:
|
|
33
|
+
return f'({self.left} << {self.right})'
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class RightShift(TwoSideRenderer):
|
|
37
|
+
def __call__(self, target: Optional[str] = None) -> str:
|
|
38
|
+
return f'({self.left} >> {self.right})'
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"""Miscellaneous operations."""
|
|
2
|
+
|
|
3
|
+
from typing import Optional
|
|
4
|
+
|
|
5
|
+
from nortl.core.renderers.operations.base import SingleRenderer
|
|
6
|
+
|
|
7
|
+
__all__ = [
|
|
8
|
+
'Inversion',
|
|
9
|
+
'Negative',
|
|
10
|
+
'Positive',
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class Negative(SingleRenderer):
|
|
15
|
+
def __call__(self, target: Optional[str] = None) -> str:
|
|
16
|
+
return f'-{self.value}'
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class Positive(SingleRenderer):
|
|
20
|
+
def __call__(self, target: Optional[str] = None) -> str:
|
|
21
|
+
return f'+{self.value}'
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class Inversion(SingleRenderer):
|
|
25
|
+
def __call__(self, target: Optional[str] = None) -> str:
|
|
26
|
+
return f'~({self.value})'
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"""Contant value."""
|
|
2
|
+
|
|
3
|
+
from typing import Optional
|
|
4
|
+
|
|
5
|
+
from nortl.core.renderers.operations.base import SliceRenderer
|
|
6
|
+
|
|
7
|
+
__all__ = [
|
|
8
|
+
'Slice',
|
|
9
|
+
]
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class Slice(SliceRenderer):
|
|
13
|
+
def __call__(self, target: Optional[str] = None) -> str:
|
|
14
|
+
if self.value.is_primitive:
|
|
15
|
+
if isinstance(self.index, int):
|
|
16
|
+
return f'{self.value}[{self.index}]'
|
|
17
|
+
else:
|
|
18
|
+
return f'{self.value}[{self.index.start}:{self.index.stop}]'
|
|
19
|
+
else:
|
|
20
|
+
if isinstance(self.index, int):
|
|
21
|
+
mask = 1
|
|
22
|
+
offset = self.index
|
|
23
|
+
else:
|
|
24
|
+
mask = 2 ** (max(self.index.start, self.index.stop) - min(self.index.start, self.index.stop) + 1) - 1
|
|
25
|
+
offset = self.index.stop
|
|
26
|
+
|
|
27
|
+
if offset != 0:
|
|
28
|
+
return f'(({self.value} >> {offset}) & {mask})'
|
|
29
|
+
else:
|
|
30
|
+
return f'({self.value} & {mask})'
|