systemc-clang 2.0.0
Parsing SystemC constructs
Loading...
Searching...
No Matches
function_param_marker.py
Go to the documentation of this file.
1import warnings
2from .top_down import TopDown
3from ..utils import dprint
4from lark import Tree, Token
5import copy
6
7
9 def __init__(self):
10 """
11 This pass marks the function parameters as input/output or inout, so that the synthesis tool can handle
12 function parameters correctly
13 """
14 super().__init__()
15 self.expanded = list()
17 self.__driven_signals = set()
18
20 self.__driven_signals = set()
21
22 def __record_driven_signal(self, sig_name):
23 """This function records which signal is driven in the process"""
24 self.__driven_signals.add(sig_name)
25
26 def __get_driven_sig_name(self, tree: Tree):
27 """
28 determines which signal is the signal that is being driven
29 currently, it returns the first hvarref node, which is true.
30 But this might be changed at a later point
31 """
32 for t in tree.iter_subtrees_topdown():
33 if type(t) == Tree and t.data == 'hvarref':
34 return t.children[0]
35
36 def hbinop(self, tree):
37 """binary op"""
39 if tree.children[0] == '=':
40 sig = self.__get_driven_sig_name(tree)
42 return tree
43
44 def blkassign(self, tree):
45 """block assignment"""
47 sig = self.__get_driven_sig_name(tree)
49 return tree
50
51 def hfunction(self, tree):
54 self.__push_up(tree)
56
57 # mark the input/output direction of the function parameters
58 funct_param = tree.children[2]
59 for param in funct_param.children:
60 # param = vardeclinit
61 par_name = param.children[0]
62 param_type = 'sc_in'
63 # if par_name in self.__driven_signals: # determines whether such signal is driven within the function body
64 if param.data in ['funcparamio']: # determines whether such signal is driven within the function body
65 param_type = '__func_inout'
66
67 param = param.children[1]
68 # param = htypeinfo
69 original_param_children = copy.deepcopy(param.children)
70 param.children = [Tree('htype', children=[Token('TYPESTR', param_type), *original_param_children])]
71
72 return tree
73
74
__push_up(self, current_node)
Definition top_down.py:29