Skip to content

Commit b2af724

Browse files
committed
modify cnt analyzer test
1 parent 1f7ca88 commit b2af724

File tree

4 files changed

+42
-26
lines changed

4 files changed

+42
-26
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
module TOP(CLK, RSTN);
2+
input CLK,RSTN;
3+
4+
reg [2:0] up_cnt;
5+
6+
always @(posedge CLK or negedge RSTN) begin
7+
if(!RSTN) begin
8+
up_cnt <= 0;
9+
end else if(up_cnt >= 3'd5) begin
10+
up_cnt <= 0;
11+
end else begin
12+
up_cnt <= up_cnt + 'd1;
13+
end
14+
end
15+
16+
17+
reg now;
18+
always @(posedge CLK or negedge RSTN) begin
19+
if(!RSTN) begin
20+
now <= 0;
21+
end else if(up_cnt[1] == 'd2) begin
22+
now <= 0;
23+
end else begin
24+
now <= 1;
25+
end
26+
end
27+
28+
endmodule
29+

pyverilog_toolbox/testcode/test_ra.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,15 @@ def test_cnt_analyzer(self):
9191
c_analyzer.make_cnt_event_all()
9292
cnt_event_result = str(c_analyzer.cnt_dict['TOP.up_cnt'].cnt_event_dict).replace('"','')
9393

94-
self.assertEqual(set(c_analyzer.cnt_dict['TOP.up_cnt'].cnt_event_dict[2]),
95-
set(["TOP.now=TOP_now @(!((TOP_up_cnt=='d2)&&(TOP_up_cnt2=='d2)))",
96-
"TOP.now='d1 @((TOP_up_cnt=='d2)&&(TOP_up_cnt2=='d2))"]))
94+
#maybe depend on funcdict
95+
ok1 = (set(c_analyzer.cnt_dict['TOP.up_cnt'].cnt_event_dict[2]) ==
96+
set(["TOP.now=TOP_now @(!((TOP_up_cnt=='d2)&&(TOP_up_cnt2=='d2)))",
97+
"TOP.now='d1 @((TOP_up_cnt=='d2)&&(TOP_up_cnt2=='d2))"]))
98+
ok2 = (set(c_analyzer.cnt_dict['TOP.up_cnt'].cnt_event_dict[2]) ==
99+
set(["TOP.now=TOP_now @(!((TOP_up_cnt=='d2)&&(TOP_up_cnt2=='d2)))",
100+
"TOP.now='d1 @(TOP_up_cnt==3'd2)"]))
101+
self.assertTrue(ok1 or ok2)
102+
97103
self.assertEqual(c_analyzer.cnt_dict['TOP.up_cnt'].cnt_event_dict[4],
98104
["TOP.now='d0 @(TOP_up_cnt==3'd4)"])
99105
self.assertEqual(set(c_analyzer.cnt_dict['TOP.up_cnt'].cnt_event_dict[5]),

pyverilog_toolbox/verify_tool/cnt_analyzer.py

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -281,27 +281,8 @@ def get_ope(self):
281281
if len(ref_cnt) != 1:
282282
raise Exception('Found redundunt condition description @' + term_name)
283283
ref_cnt = tuple(ref_cnt)[0]
284-
if ref_cnt.mother_node.operator in self.compare_ope:
285-
root_ope_info_dict[ref_cnt, value] = root_ope_info(ref_cnt.mother_node, 0, [1,], branch)
286-
elif ref_cnt.mother_node.operator == 'Ulnot' and ref_cnt.mother_node.children()[0].operator in self.compare_ope:
287-
root_ope_info_dict[ref_cnt, value] = root_ope_info(ref_cnt.mother_node.children()[0], 0, [1,], branch)
288-
elif isinstance(ref_cnt.mother_node, pyverilog.dataflow.dataflow.DFPartselect):
289-
if ref_cnt.mother_node.mother_node.operator in self.compare_ope:
290-
root_ope = ref_cnt.mother_node.mother_node
291-
cond_lsb = ref_cnt.mother_node.lsb
292-
inverted = False
293-
elif ref_cnt.mother_node.mother_node.operator == 'Ulnot' and \
294-
ref_cnt.mother_node.mother_node.children()[0].operator in self.compare_ope:
295-
root_ope = ref_cnt.mother_node.mother_node.children()[0]
296-
cond_lsb = ref_cnt.mother_node.children()[0].lsb
297-
inverted = True
298-
else:
299-
continue
300-
if ref_cnt.mother_node.msb == self.msb:
301-
diff_list = [1,]
302-
else:
303-
diff_list = [i for i in range(1,self.msb - ref_cnt.mother_node.msb)]
304-
root_ope_info_dict[ref_cnt, value] = root_ope_info(root_ope, cond_lsb, diff_list, branch)
284+
root_ope = ref_cnt.mother_node
285+
root_ope_info_dict[ref_cnt, value] = root_ope_info(root_ope, 0, [1,], branch)
305286

306287
for ref_cnt, value in root_ope_info_dict.keys():
307288
root_info = root_ope_info_dict[ref_cnt, value]
@@ -361,6 +342,6 @@ def calc_cnt_period(self):
361342
return 2 ** (self.msb + 1) - 1
362343

363344
if __name__ == '__main__':
364-
cnt_analyzer = CntAnalyzer("../testcode/norm_cnt2.v")
345+
cnt_analyzer = CntAnalyzer("../testcode/norm_cnt3.v")
365346
cnt_analyzer.show()
366347

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import re
44
import os
55

6-
version = '0.0.4'
6+
version = '0.0.5'
77

88
def read(filename):
99
return open(os.path.join(os.path.dirname(__file__), filename)).read()

0 commit comments

Comments
 (0)