Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions tests/extension/thread_/stream_counter/thread_stream_counter.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,15 @@ def mkLed():
ram_c = vthread.RAM(m, 'ram_c', clk, rst, datawidth, addrwidth)

strm = vthread.Stream(m, 'mystream', clk, rst)
cnt = strm.Counter()
cnt1 = strm.Counter()
cnt2 = strm.Counter(initval=1)
cnt3 = strm.Counter(initval=2, size=3)
cnt4 = strm.Counter(initval=3, interval=3)
cnt5 = strm.Counter(initval=4, interval=3, size=4)
cnt6 = strm.Counter(initval=4, step=2, interval=2)
a = strm.source('a')
b = strm.source('b')
c = a + b + cnt
c = a + b - a - b + cnt1 + cnt2 + cnt3 + cnt4 + cnt5 + cnt6
strm.sink(c, 'c')

def comp_stream(size, offset):
Expand All @@ -39,14 +44,19 @@ def comp_stream(size, offset):
strm.join()

def comp_sequential(size, offset):
sum = 0
cnt = 0
for i in range(size):
cnt1 = cnt
cnt2 = 1 + cnt
cnt3 = cnt%3 + 2
cnt4 = (cnt//3) + 3
cnt5 = (cnt//3)%4 + 4
cnt6 = (cnt//2)*2 + 4
a = ram_a.read(i + offset)
b = ram_b.read(i + offset)
cnt += 1
sum = a + b + cnt
sum = a + b - a - b + cnt1 + cnt2 + cnt3 + cnt4 + cnt5 + cnt6
ram_c.write(i + offset, sum)
cnt += 1

def check(size, offset_stream, offset_seq):
all_ok = True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def mkLed():
#b = a0 + a1 + a2 + a3 + a4 + a5 + a6 + a7 + a8
b = strm.AddN(a0, a1, a2, a3, a4, a5, a6, a7, a8)

strm.sink(b, 'b', when=counter > img_width + img_width + 2)
strm.sink(b, 'b', when=counter >= img_width + img_width + 2)

def comp_stream(size, offset):
strm.set_source('a', ram_a, offset, size * 3)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def mkLed():
counter = strm.Counter()

a = strm.source('a')
a_addr = strm.Counter() - 1
a_addr = strm.Counter()
sp = strm.Scratchpad(a, a_addr, length=128)

a0 = a
Expand All @@ -49,7 +49,7 @@ def mkLed():
#b = a0 + a1 + a2 + a3 + a4 + a5 + a6 + a7 + a8
b = strm.AddN(a0, a1, a2, a3, a4, a5, a6, a7, a8)

strm.sink(b, 'b', when=counter > img_width + img_width + 2)
strm.sink(b, 'b', when=counter >= img_width + img_width + 2)

def comp_stream(size, offset):
strm.set_source('a', ram_a, offset, size * 3)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def mkLed():
strm = vthread.Stream(m, 'mystream', clk, rst)

a = strm.source('a')
r_addr = strm.Counter() - 1
r_addr = strm.Counter()
r_addr = strm.Mux(r_addr < 3, 3, r_addr)

r = strm.read_RAM('ext', r_addr)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def mkLed():

b = a + a_old

strm.sink(b, 'b', when=counter > img_width)
strm.sink(b, 'b', when=counter >= img_width)

def comp_stream(size, offset):
strm.set_source('a', ram_a, offset, size * 2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def mkLed():
#b = a0 + a1 + a2 + a3 + a4 + a5 + a6 + a7 + a8
b = strm.AddN(a0, a1, a2, a3, a4, a5, a6, a7, a8)

strm.sink(b, 'b', when=counter > img_width + img_width + 2)
strm.sink(b, 'b', when=counter >= img_width + img_width + 2)

def comp_stream(size, offset):
strm.set_source('a', ram_a, offset, size * 3)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def mkLed():

b = a + a_old

strm.sink(b, 'b', when=counter > wait_num)
strm.sink(b, 'b', when=counter >= wait_num)

def comp_stream(size, offset):
strm.set_source('a', ram_a, offset, size * 2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ def mkLed():
counter = strm.Counter()

a = strm.source('a')
a_addr = strm.Counter() - 1
a_addr = strm.Counter()

sp = strm.Scratchpad(a, a_addr, length=128)

a_old_addr = strm.Counter() - img_width - 1
a_old_addr = strm.Counter() - img_width
a_old = sp.read(a_old_addr)

b = a + a_old

strm.sink(b, 'b', when=counter > img_width)
strm.sink(b, 'b', when=counter >= img_width)

def comp_stream(size, offset):
strm.set_source('a', ram_a, offset, size * 2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def mkLed():
counter = strm.Counter()

a = strm.source('a')
a_addr = strm.Counter() - 1
a_addr = strm.Counter()
sp = strm.Scratchpad(a, a_addr, length=128)

a0 = a
Expand All @@ -49,7 +49,7 @@ def mkLed():
#b = a0 + a1 + a2 + a3 + a4 + a5 + a6 + a7 + a8
b = strm.AddN(a0, a1, a2, a3, a4, a5, a6, a7, a8)

strm.sink(b, 'b', when=counter > img_width + img_width + 2)
strm.sink(b, 'b', when=counter >= img_width + img_width + 2)

def comp_stream(size, offset):
strm.set_source('a', ram_a, offset, size * 3)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ def mkLed():
counter = strm.Counter()

a = strm.source('a')
a_addr = strm.Counter() - 1
a_addr = strm.Counter()

sp = strm.Scratchpad(a, a_addr, when=counter <= img_width, length=128)

a_old_addr = strm.Counter() - img_width - 1
a_old_addr = strm.Counter() - img_width
a_old = sp.read(a_old_addr)

b = a + a_old

strm.sink(b, 'b', when=counter > img_width)
strm.sink(b, 'b', when=counter >= img_width)

def comp_stream(size, offset):
strm.set_source('a', ram_a, offset, size * 2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@ def mkLed():
counter = strm.Counter()

a = strm.source('a')
a_addr = strm.Counter() - 1
a_addr = strm.Counter()

strm.write_RAM('write_ext', a_addr, a, when=counter <= img_width)
strm.write_RAM('write_ext', a_addr, a, when=counter < img_width)

a_old_addr = strm.Counter() - img_width - 1
a_old_addr = strm.Counter() - img_width
a_old = strm.read_RAM('read_ext', a_old_addr)

b = a + a_old

strm.sink(b, 'b', when=counter > img_width)
strm.sink(b, 'b', when=counter >= img_width)

def comp_stream(size, offset):
strm.set_source('a', ram_a, offset, size * 2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ def mkLed():
counter = strm.Counter()

a = strm.source('a')
a_addr = strm.Counter() - 1
a_addr = strm.Counter()

strm.write_RAM('write_ext', a_addr, a, when=counter <= img_width)
strm.write_RAM('write_ext', a_addr, a, when=counter < img_width)

a_old_addr = strm.Counter() - img_width - 1
a_old_addr = strm.Counter() - img_width
a_old = strm.read_RAM('read_ext', a_old_addr)

b = a + a_old

strm.sink(b, 'b', when=counter > img_width)
strm.sink(b, 'b', when=counter >= img_width)

def comp_stream(size, offset):
strm.set_source('a', ram_a, offset, size * 2)
Expand Down
Loading