Skip to content

Commit 8d4fd79

Browse files
author
Yasuhiro Nitta
committed
update counter test with interval #54
1 parent 92ae5ef commit 8d4fd79

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

tests/extension/thread_/stream_counter/thread_stream_counter.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,15 @@ def mkLed():
2525
ram_c = vthread.RAM(m, 'ram_c', clk, rst, datawidth, addrwidth)
2626

2727
strm = vthread.Stream(m, 'mystream', clk, rst)
28-
cnt = strm.Counter()
28+
cnt1 = strm.Counter()
29+
cnt2 = strm.Counter(initval=1)
30+
cnt3 = strm.Counter(initval=2, size=3)
31+
cnt4 = strm.Counter(initval=3, interval=3)
32+
cnt5 = strm.Counter(initval=4, interval=3, size=4)
33+
cnt6 = strm.Counter(initval=4, step=2, interval=2)
2934
a = strm.source('a')
3035
b = strm.source('b')
31-
c = a + b + cnt
36+
c = a + b - a - b + cnt1 + cnt2 + cnt3 + cnt4 + cnt5 + cnt6
3237
strm.sink(c, 'c')
3338

3439
def comp_stream(size, offset):
@@ -39,14 +44,19 @@ def comp_stream(size, offset):
3944
strm.join()
4045

4146
def comp_sequential(size, offset):
42-
sum = 0
4347
cnt = 0
4448
for i in range(size):
49+
cnt1 = cnt
50+
cnt2 = 1 + cnt
51+
cnt3 = cnt%3 + 2
52+
cnt4 = (cnt//3) + 3
53+
cnt5 = (cnt//3)%4 + 4
54+
cnt6 = (cnt//2)*2 + 4
4555
a = ram_a.read(i + offset)
4656
b = ram_b.read(i + offset)
47-
cnt += 1
48-
sum = a + b + cnt
57+
sum = a + b - a - b + cnt1 + cnt2 + cnt3 + cnt4 + cnt5 + cnt6
4958
ram_c.write(i + offset, sum)
59+
cnt += 1
5060

5161
def check(size, offset_stream, offset_seq):
5262
all_ok = True

0 commit comments

Comments
 (0)