systemc-clang
2.0.0
Parsing SystemC constructs
Loading...
Searching...
No Matches
plugins
hdl
parselib
transforms
passes.py
Go to the documentation of this file.
1
"""Different pass of the translation"""
2
from
.alias_translation
import
AliasTranslation
3
from
.literal_expansion
import
LiteralExpansion, LiteralExpansion2
4
from
.node_merge
import
NodeMergePass
5
from
.sort_var_decl
import
SortVarDecl
6
from
.typedef_expansion
import
TypedefExpansion
#, BlkAssignTypeDefExpansion
7
from
.typedef_filter
import
TypeDefFilter, TypeDefCleanup
8
from
.verilog_tranlation
import
VerilogTranslationPass
9
from
.port_expansion
import
PortExpansion
10
from
.slice_merge
import
SliceMerge
11
from
.node_movement
import
NodeMovement, ArrayPortMovement
12
from
.function_param_marker
import
FunctionParamMarker
13
from
.reorder_mod_init_block
import
ReorderModInitBlock
14
from
.function_info_pass
import
FunctionInfoPass, FunctionInfoPass2
15
from
.function_transformation_pass
import
FunctionTransformationPass
16
from
.comma_transformation
import
CommaTransformation
17
from
.structure_collector
import
StructureCollector
18
from
.sensevar_movement
import
SensevarMovement
19
from
.portbinding_recollect
import
PortbindingRecollect, PortbindingPrecheck, PortDirectionCollector, LowerComplexPort
20
from
.interface_generation
import
InterfaceGeneration, InterfaceReplacement
21
22
from
..utils
import
dprint, terminate_with_no_trace
23
24
25
from
parselib.transforms
import
TopDown
26
27
class
PrettyPrintModule
(
TopDown
):
28
def
__init__
(self, name):
29
self.
name
= name
30
31
def
hmodule
(self, tree):
32
if
tree.children[0].value == self.
name
:
33
dprint(tree.pretty())
34
assert
False
35
return
36
return
tree
37
38
39
class
VerilogTranslator
:
40
"""Translate hcode to verilog"""
41
@staticmethod
42
def
translate
(tree):
43
# we need some form of `level' of the tree, lower level meaning it is loosing more information, but more lenient
44
# to hardware language
45
prev = tree
46
prev =
ReorderModInitBlock
().visit(prev)
47
prev =
NodeMovement
().visit(prev)
48
prev =
SortVarDecl
().visit(prev)
49
prev =
AliasTranslation
().visit(prev)
50
sc =
StructureCollector
()
51
sc.visit(prev)
52
prev =
LiteralExpansion
(structure=sc.hier).visit(prev)
53
54
prev =
SliceMerge
().visit(prev)
55
# prev = CommaTransformation().visit(prev)
56
# dprint(prev.pretty())
57
f =
TypeDefFilter
()
58
prev = f.visit(prev)
59
prev =
NodeMergePass
().visit(prev)
60
# prev = ArrayPortMovement().visit(prev)
61
62
prev =
PortExpansion
().visit(prev)
63
prev =
TypedefExpansion
(f.types).visit(prev)
64
65
ig =
InterfaceGeneration
()
66
prev = ig.visit(prev)
67
# terminate_with_no_trace()
68
# PrettyPrintModule('fifo_cc_sc_module_11').visit(prev)
69
# terminate_with_no_trace()
70
# prev = BlkAssignTypeDefExpansion(f.types).visit(prev)
71
prev =
SensevarMovement
().visit(prev)
72
prev =
FunctionInfoPass
().visit(prev)
73
prev =
FunctionInfoPass2
().visit(prev)
74
prev =
FunctionParamMarker
().visit(prev)
75
prev =
FunctionTransformationPass
().visit(prev)
76
prev =
TypeDefCleanup
().visit(prev)
77
78
# PrettyPrintModule('fifo_cc_sc_module_11').visit(prev)
79
# terminate_with_no_trace()
80
81
port_directions =
PortDirectionCollector
()
82
port_directions.visit(prev)
83
# PrettyPrintModule('encode_sc_module_1').visit(prev)
84
# terminate_with_no_trace()
85
86
87
88
prev =
PortbindingPrecheck
().visit(prev)
89
prev =
PortbindingRecollect
(ports=port_directions.ports).visit(prev)
# this pass should only work when PreCheck passes
90
prev =
LowerComplexPort
(ig.interface_meta_data).visit(prev)
91
92
prev=
LiteralExpansion2
().visit(prev)
93
prev =
InterfaceReplacement
(ig.interface_meta_data).visit(prev)
94
# PrettyPrintModule('decode_sc_module_1').visit(prev)
95
# terminate_with_no_trace()
96
# PrettyPrintModule('encode_block_sc_module_5').visit(prev)
97
# terminate_with_no_trace()
98
99
# PrettyPrintModule('rvfifo_cc_sc_module_9').visit(prev)
100
prev =
VerilogTranslationPass
(itf_meta=ig.interface_meta_data).visit(prev)
101
# terminate_with_no_trace()
102
return
prev
103
parselib.transforms.alias_translation.AliasTranslation
Definition
alias_translation.py:7
parselib.transforms.function_info_pass.FunctionInfoPass2
Definition
function_info_pass.py:186
parselib.transforms.function_info_pass.FunctionInfoPass
Definition
function_info_pass.py:13
parselib.transforms.function_param_marker.FunctionParamMarker
Definition
function_param_marker.py:8
parselib.transforms.function_transformation_pass.FunctionTransformationPass
Definition
function_transformation_pass.py:11
parselib.transforms.interface_generation.InterfaceGeneration
Definition
interface_generation.py:30
parselib.transforms.interface_generation.InterfaceReplacement
Definition
interface_generation.py:156
parselib.transforms.literal_expansion.LiteralExpansion2
Definition
literal_expansion.py:153
parselib.transforms.literal_expansion.LiteralExpansion
Definition
literal_expansion.py:11
parselib.transforms.node_merge.NodeMergePass
Definition
node_merge.py:4
parselib.transforms.node_movement.NodeMovement
Definition
node_movement.py:7
parselib.transforms.passes.PrettyPrintModule
Definition
passes.py:27
parselib.transforms.passes.PrettyPrintModule.name
name
Definition
passes.py:29
parselib.transforms.passes.PrettyPrintModule.hmodule
hmodule(self, tree)
Definition
passes.py:31
parselib.transforms.passes.PrettyPrintModule.__init__
__init__(self, name)
Definition
passes.py:28
parselib.transforms.passes.VerilogTranslator
Definition
passes.py:39
parselib.transforms.passes.VerilogTranslator.translate
translate(tree)
Definition
passes.py:42
parselib.transforms.port_expansion.PortExpansion
Definition
port_expansion.py:9
parselib.transforms.portbinding_recollect.LowerComplexPort
Definition
portbinding_recollect.py:215
parselib.transforms.portbinding_recollect.PortDirectionCollector
Definition
portbinding_recollect.py:180
parselib.transforms.portbinding_recollect.PortbindingPrecheck
Definition
portbinding_recollect.py:10
parselib.transforms.portbinding_recollect.PortbindingRecollect
Definition
portbinding_recollect.py:15
parselib.transforms.reorder_mod_init_block.ReorderModInitBlock
Definition
reorder_mod_init_block.py:6
parselib.transforms.sensevar_movement.SensevarMovement
Definition
sensevar_movement.py:9
parselib.transforms.slice_merge.SliceMerge
Definition
slice_merge.py:7
parselib.transforms.sort_var_decl.SortVarDecl
Definition
sort_var_decl.py:4
parselib.transforms.structure_collector.StructureCollector
Definition
structure_collector.py:11
parselib.transforms.top_down.TopDown
Definition
top_down.py:24
parselib.transforms.typedef_expansion.TypedefExpansion
Definition
typedef_expansion.py:12
parselib.transforms.typedef_filter.TypeDefCleanup
Definition
typedef_filter.py:62
parselib.transforms.typedef_filter.TypeDefFilter
Definition
typedef_filter.py:7
parselib.transforms.verilog_tranlation.VerilogTranslationPass
Definition
verilog_tranlation.py:25
parselib.transforms
Definition
__init__.py:1
Generated by
1.12.0