|
10 | 10 |
|
11 | 11 | import sys
|
12 | 12 | import os
|
| 13 | +import pyverilog |
13 | 14 |
|
14 | 15 | sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) )
|
15 | 16 |
|
16 |
| -import pyverilog.utils.version |
17 | 17 | from pyverilog.dataflow.dataflow import *
|
18 | 18 | from pyverilog_toolbox.verify_tool.dataflow_facade import *
|
19 | 19 | from pyverilog_toolbox.verify_tool.bindlibrary import *
|
@@ -91,19 +91,20 @@ def make_cnt_event_all(self):
|
91 | 91 | funcdict = splitter.split(target_tree)
|
92 | 92 | funcdict = splitter.remove_reset_condition(funcdict)
|
93 | 93 | if not funcdict: continue
|
94 |
| - branch_dict = {func[-1]: value for func, value in funcdict.items()}#extract last condition |
| 94 | + last_branch_dict = {func[-1]: value for func, value in funcdict.items()}#extract last condition |
95 | 95 |
|
96 | 96 | cnt_ref_branch=[]
|
97 | 97 | m_setter.disable_dfxxx_eq()
|
98 |
| - for branch, value in branch_dict.items(): |
| 98 | + for branch, value in last_branch_dict.items(): |
99 | 99 | ref_cnt_set = m_setter.extract_all_dfxxx(branch, set([]), 0, pyverilog.dataflow.dataflow.DFTerminal)
|
100 | 100 | ref_cnt_set = set([term[0] for term in ref_cnt_set])
|
101 | 101 | ref_cnt_set = set([term for term in ref_cnt_set if str(term) == cnt_name])
|
102 |
| - cnt_ref_branch.append((ref_cnt_set, value)) |
| 102 | + if ref_cnt_set: |
| 103 | + cnt_ref_branch.append((ref_cnt_set, value, branch)) |
103 | 104 | if cnt_ref_branch:
|
104 | 105 | cnt_ref_dict[term_name] = cnt_ref_branch
|
105 |
| - m_setter.enable_dfxxx_eq() |
106 | 106 | counter.make_cnt_event_dict(cnt_ref_dict)
|
| 107 | + m_setter.enable_dfxxx_eq() |
107 | 108 |
|
108 | 109 | def get_reset_value(self, cnt_name, target_tree, reset_name):
|
109 | 110 | if target_tree.condnode.operator == 'Ulnot':
|
@@ -258,38 +259,69 @@ def make_cnt_event_dict(self, cnt_ref_dict):
|
258 | 259 | cnt_ref_dict[term_name] = cnt_ref_branch
|
259 | 260 | cnt_event_dict[num] = term_name + "=" + value.tocode()
|
260 | 261 | """
|
| 262 | + class root_ope_info(object) : |
| 263 | + def __init__(self, root_ope, cond_lsb, diff_list, branch): |
| 264 | + self.root_ope = root_ope |
| 265 | + self.cond_lsb = cond_lsb |
| 266 | + self.diff_list = diff_list |
| 267 | + self.branch = branch |
| 268 | + def get_ope(self): |
| 269 | + return self.branch.tocode() |
| 270 | +## if not self.inverted: |
| 271 | +## return self.root_ope.tocode() |
| 272 | +## else: |
| 273 | +## if self.root_ope.operator == 'Eq': |
| 274 | +## return self.root_ope.tocode().replace('==','!=') |
| 275 | +## elif self.root_ope.operator == 'NotEq': |
| 276 | +## return self.root_ope.tocode().replace('!=','==') |
| 277 | +## elif '>' in self.root_ope.tocode(): |
| 278 | +## return self.root_ope.tocode().replace('>','<') |
| 279 | +## elif '<' in self.root_ope.tocode(): |
| 280 | +## return self.root_ope.tocode().replace('<','>') |
| 281 | +## else: |
| 282 | +## raise Exception('Unexpected exception') |
| 283 | + |
261 | 284 | self.cnt_event_dict = {}
|
262 | 285 | for term_name, ref_cnt_set in cnt_ref_dict.items():
|
263 |
| - root_opes = [] |
264 |
| - for ref_cnt,value in ref_cnt_set: |
| 286 | + root_ope_info_dict = {} |
| 287 | + for ref_cnt, value, branch in ref_cnt_set: |
265 | 288 | if len(ref_cnt) != 1:
|
266 | 289 | raise Exception('Found redundunt condition description @' + term_name)
|
267 | 290 | ref_cnt = tuple(ref_cnt)[0]
|
268 |
| - |
269 | 291 | if ref_cnt.mother_node.operator in self.compare_ope:
|
270 |
| - root_opes.append(ref_cnt.mother_node) |
271 |
| - cond_lsb = 0 |
272 |
| - diff_list = [1,] |
| 292 | + root_ope_info_dict[ref_cnt, value] = root_ope_info(ref_cnt.mother_node, 0, [1,], branch) |
| 293 | + elif ref_cnt.mother_node.operator == 'Ulnot' and ref_cnt.mother_node.children()[0].operator in self.compare_ope: |
| 294 | + root_ope_info_dict[ref_cnt, value] = root_ope_info(ref_cnt.mother_node.children()[0], 0, [1,], branch) |
273 | 295 | elif isinstance(ref_cnt.mother_node, pyverilog.dataflow.dataflow.DFPartselect):
|
274 | 296 | if ref_cnt.mother_node.mother_node.operator in self.compare_ope:
|
275 |
| - root_opes.append(ref_cnt.mother_node.mother_node) |
| 297 | + root_ope = ref_cnt.mother_node.mother_node |
276 | 298 | cond_lsb = ref_cnt.mother_node.lsb
|
| 299 | + inverted = False |
| 300 | + elif ref_cnt.mother_node.mother_node.operator == 'Ulnot' and \ |
| 301 | + ref_cnt.mother_node.mother_node.children()[0].operator in self.compare_ope: |
| 302 | + root_ope = ref_cnt.mother_node.mother_node.children()[0] |
| 303 | + cond_lsb = ref_cnt.mother_node.children()[0].lsb |
| 304 | + inverted = True |
| 305 | + else: |
| 306 | + continue |
277 | 307 | if ref_cnt.mother_node.msb == self.msb:
|
278 | 308 | diff_list = [1,]
|
279 | 309 | else:
|
280 | 310 | diff_list = [i for i in range(1,self.msb - ref_cnt.mother_node.msb)]
|
| 311 | + root_ope_info_dict[ref_cnt, value] = root_ope_info(root_ope, cond_lsb, diff_list, branch) |
281 | 312 |
|
282 |
| - for root_ope in root_opes: |
| 313 | + for ref_cnt, value in root_ope_info_dict.keys(): |
| 314 | + root_info = root_ope_info_dict[ref_cnt, value] |
| 315 | + root_ope = root_info.root_ope |
283 | 316 | if str(root_ope.nextnodes[0]) == str(ref_cnt.name):
|
284 | 317 | comp_pair = eval_value(root_ope.nextnodes[1])
|
285 | 318 | elif str(root_ope.nextnodes[1]) == str(ref_cnt.name):
|
286 | 319 | comp_pair = eval_value(root_ope.nextnodes[0])
|
287 |
| - num_list = [comp_pair * (2 ** cond_lsb) * diff for diff in diff_list] |
| 320 | + num_list = [comp_pair * (2 ** root_info.cond_lsb) * diff for diff in root_info.diff_list] |
288 | 321 | for num in num_list:
|
289 | 322 | if num not in self.cnt_event_dict.keys():
|
290 | 323 | self.cnt_event_dict[num] = []
|
291 |
| - self.cnt_event_dict[num].append(term_name + '=' + value.tocode() + ' @' + root_ope.tocode()) |
292 |
| - #print self.name, self.cnt_event_dict |
| 324 | + self.cnt_event_dict[num].append(term_name + '=' + value.tocode() + ' @' + root_info.get_ope()) |
293 | 325 |
|
294 | 326 | def calc_cnt_period(self):
|
295 | 327 | if hasattr(self, 'change_cond'):
|
|
0 commit comments