systemc-clang 2.0.0
Parsing SystemC constructs
Loading...
Searching...
No Matches
passes.py
Go to the documentation of this file.
1"""Different pass of the translation"""
2from .alias_translation import AliasTranslation
3from .literal_expansion import LiteralExpansion, LiteralExpansion2
4from .node_merge import NodeMergePass
5from .sort_var_decl import SortVarDecl
6from .typedef_expansion import TypedefExpansion #, BlkAssignTypeDefExpansion
7from .typedef_filter import TypeDefFilter, TypeDefCleanup
8from .verilog_tranlation import VerilogTranslationPass
9from .port_expansion import PortExpansion
10from .slice_merge import SliceMerge
11from .node_movement import NodeMovement, ArrayPortMovement
12from .function_param_marker import FunctionParamMarker
13from .reorder_mod_init_block import ReorderModInitBlock
14from .function_info_pass import FunctionInfoPass, FunctionInfoPass2
15from .function_transformation_pass import FunctionTransformationPass
16from .comma_transformation import CommaTransformation
17from .structure_collector import StructureCollector
18from .sensevar_movement import SensevarMovement
19from .portbinding_recollect import PortbindingRecollect, PortbindingPrecheck, PortDirectionCollector, LowerComplexPort
20from .interface_generation import InterfaceGeneration, InterfaceReplacement
21
22from ..utils import dprint, terminate_with_no_trace
23
24
25from parselib.transforms import TopDown
26
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
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)
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
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