Skip to content

Commit 2dc45d3

Browse files
committed
CustomAcc -> CustomCounter
1 parent 0cd95f2 commit 2dc45d3

File tree

5 files changed

+22
-19
lines changed

5 files changed

+22
-19
lines changed

tests/extension/thread_/stream_custom_acc/test_thread_stream_custom_acc.py renamed to tests/extension/thread_/stream_custom_counter/test_thread_stream_custom_counter.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33

44
import os
55
import veriloggen
6-
import thread_stream_custom_acc
6+
import thread_stream_custom_counter
77

88

99
def test(request):
1010
veriloggen.reset()
1111

1212
simtype = request.config.getoption('--sim')
1313

14-
rslt = thread_stream_custom_acc.run(filename=None, simtype=simtype,
15-
outputfile=os.path.splitext(os.path.basename(__file__))[0] + '.out')
14+
rslt = thread_stream_custom_counter.run(filename=None, simtype=simtype,
15+
outputfile=os.path.splitext(os.path.basename(__file__))[0] + '.out')
1616

1717
verify_rslt = rslt.splitlines()[-1]
1818
assert(verify_rslt == '# verify: PASSED')

tests/extension/thread_/stream_custom_acc/thread_stream_custom_acc.py renamed to tests/extension/thread_/stream_custom_counter/thread_stream_custom_counter.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,17 @@ def op_func(x, y, x_size, y_size):
3333
x_cond = x == x_size - 1
3434
next_x = Mux(x_cond, 0, x + 1)
3535
y_cond = Ands(x_cond, y == y_size - 1)
36-
next_y = Mux(y_cond, 0, y + 1)
36+
next_y = PatternMux((y_cond, 0), (x_cond, y + 1), (None, y))
3737
return next_x, next_y
3838

39-
x, y = strm.CustomAcc(func=op_func,
40-
initvals=(0, 0), args=(size, size),
41-
width_list=(32, 32), signed_list=(True, True))
39+
x_size = 4
40+
y_size = 4
4241

43-
c = a + b + x + y
42+
x, y = strm.CustomCounter(func=op_func,
43+
initvals=(0, 0), args=(x_size, y_size),
44+
width_list=(32, 32), signed_list=(True, True))
45+
46+
c = a + b + x + y - a - b
4447
strm.sink(c, 'c')
4548

4649
def comp_stream(size, offset):
@@ -55,12 +58,12 @@ def comp_sequential(size, offset):
5558
sum = 0
5659
x = 0
5760
y = 0
58-
x_size = size
59-
y_size = size
61+
x_size = 4
62+
y_size = 4
6063
for i in range(size):
6164
a = ram_a.read(i + offset)
6265
b = ram_b.read(i + offset)
63-
sum = a + b + x + y
66+
sum = a + b + x + y - a - b
6467
ram_c.write(i + offset, sum)
6568
x_cond = x == x_size - 1
6669
if x_cond:
@@ -70,7 +73,7 @@ def comp_sequential(size, offset):
7073
y_cond = x_cond and (y == y_size - 1)
7174
if y_cond:
7275
y = 0
73-
else:
76+
elif x_cond:
7477
y = y + 1
7578

7679
def check(size, offset_stream, offset_seq):

veriloggen/stream/stypes.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3729,7 +3729,7 @@ def CounterValid(size, step=1, interval=None, initval=0, offset=None,
37293729
return data, valid
37303730

37313731

3732-
class _CustomAcc(_SpecialOperator):
3732+
class _CustomCounter(_SpecialOperator):
37333733
latency = 1
37343734

37353735
default_width = 32
@@ -3819,7 +3819,7 @@ def _implement(self, m, seq, svalid=None, senable=None):
38193819
next_vars = self.func(*func_args)
38203820

38213821
if len(next_vars) != len(vars):
3822-
raise ValueError('CustomAcc function must return %d values.' % len(vars))
3822+
raise ValueError('CustomCounter function must return %d values.' % len(vars))
38233823

38243824
for var, next_var in zip(vars, next_vars):
38253825
seq(var(next_var), cond=enable_cond)
@@ -3851,11 +3851,11 @@ def _implement(self, m, seq, svalid=None, senable=None):
38513851
)
38523852

38533853

3854-
def CustomAcc(func, initvals, args=None, reset=None,
3855-
width_list=None, point_list=None, signed_list=None):
3854+
def CustomCounter(func, initvals, args=None, reset=None,
3855+
width_list=None, point_list=None, signed_list=None):
38563856

3857-
v = _CustomAcc(func, initvals, args, reset,
3858-
width_list, point_list, signed_list)
3857+
v = _CustomCounter(func, initvals, args, reset,
3858+
width_list, point_list, signed_list)
38593859

38603860
return_values = []
38613861

veriloggen/thread/stream.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3762,7 +3762,7 @@ def __getattr__(self, attr):
37623762
f.__name__.startswith('Counter') or
37633763
f.__name__.startswith('Pulse') or
37643764
f.__name__.startswith('Producer') or
3765-
f.__name__.startswith('CustomAcc'))):
3765+
f.__name__.startswith('CustomCounter'))):
37663766

37673767
if self.reduce_reset is None:
37683768
self._make_reduce_reset()

0 commit comments

Comments
 (0)