Skip to content

Commit a6230da

Browse files
committed
read_dataflow_reuse_pattern
1 parent 2980f58 commit a6230da

File tree

8 files changed

+4442
-896
lines changed

8 files changed

+4442
-896
lines changed

tests/extension/thread_/stream_reuse/test_thread_stream_reuse.py

Lines changed: 778 additions & 770 deletions
Large diffs are not rendered by default.

tests/extension/thread_/stream_reuse/thread_stream_reuse.py

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

28-
def comp_stream(strm, size, offset):
28+
def comp_stream(strm, size, roffset, woffset):
2929
a0, a1 = strm.read_reuse(
30-
ram_a, offset, size, reuse_size=reuse_size, num_outputs=2)
30+
ram_a, roffset, size, reuse_size=reuse_size, num_outputs=2)
3131
b0, b1 = strm.read_reuse(
32-
ram_b, offset, size, reuse_size=reuse_size, num_outputs=2)
32+
ram_b, roffset, size, reuse_size=reuse_size, num_outputs=2)
3333
sum = a0 + a1 + b0 + b1
34-
strm.write(ram_c, offset, size * (reuse_size // 2), sum)
34+
strm.write(ram_c, woffset, size * (reuse_size // 2), sum)
3535

36-
def comp_sequential(size, offset):
36+
def comp_sequential(size, roffset, woffset):
3737
sum = 0
3838
w = 0
3939
for i in range(0, size, 2):
4040
for r in range(reuse_size):
41-
a0 = ram_a.read(i + 0 + offset)
42-
a1 = ram_a.read(i + 1 + offset)
43-
b0 = ram_b.read(i + 0 + offset)
44-
b1 = ram_b.read(i + 1 + offset)
41+
a0 = ram_a.read(i + 0 + roffset)
42+
a1 = ram_a.read(i + 1 + roffset)
43+
b0 = ram_b.read(i + 0 + roffset)
44+
b1 = ram_b.read(i + 1 + roffset)
4545
sum = a0 + a1 + b0 + b1
46-
ram_c.write(w + offset, sum)
46+
ram_c.write(w + woffset, sum)
4747
w += 1
4848

4949
def check(size, offset_stream, offset_seq):
@@ -59,21 +59,23 @@ def check(size, offset_stream, offset_seq):
5959
print('NG')
6060

6161
def comp(size):
62-
offset = 0
63-
myaxi.dma_read(ram_a, offset, 0, size)
64-
myaxi.dma_read(ram_b, offset, 0, size)
65-
stream.run(size, offset)
62+
roffset = 0
63+
woffset = 0
64+
myaxi.dma_read(ram_a, roffset, 0, size)
65+
myaxi.dma_read(ram_b, roffset, 0, size)
66+
stream.run(size, roffset, woffset)
6667
stream.join()
67-
myaxi.dma_write(ram_c, offset, 1024, size)
68+
myaxi.dma_write(ram_c, woffset, 1024, size)
6869

69-
offset = size
70-
myaxi.dma_read(ram_a, offset, 0, size)
71-
myaxi.dma_read(ram_b, offset, 0, size)
72-
sequential.run(size, offset)
70+
roffset = size
71+
woffset = size * (reuse_size // 2)
72+
myaxi.dma_read(ram_a, roffset, 0, size)
73+
myaxi.dma_read(ram_b, roffset, 0, size)
74+
sequential.run(size, roffset, woffset)
7375
sequential.join()
74-
myaxi.dma_write(ram_c, offset, 1024 * 2, size)
76+
myaxi.dma_write(ram_c, woffset, 1024 * 2, size)
7577

76-
check(size, 0, offset)
78+
check(size * (reuse_size // 2), 0, woffset)
7779

7880
stream = vthread.Stream(m, 'mystream', clk, rst, comp_stream)
7981
sequential = vthread.Thread(m, 'th_sequential', clk, rst, comp_sequential)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
TARGET=$(shell ls *.py | grep -v test | grep -v parsetab.py)
2+
ARGS=
3+
4+
PYTHON=python3
5+
#PYTHON=python
6+
#OPT=-m pdb
7+
#OPT=-m cProfile -s time
8+
#OPT=-m cProfile -o profile.rslt
9+
10+
.PHONY: all
11+
all: test
12+
13+
.PHONY: run
14+
run:
15+
$(PYTHON) $(OPT) $(TARGET) $(ARGS)
16+
17+
.PHONY: test
18+
test:
19+
$(PYTHON) -m pytest -vv
20+
21+
.PHONY: check
22+
check:
23+
$(PYTHON) $(OPT) $(TARGET) $(ARGS) > tmp.v
24+
iverilog -tnull -Wall tmp.v
25+
rm -f tmp.v
26+
27+
.PHONY: clean
28+
clean:
29+
rm -rf *.pyc __pycache__ parsetab.py .cache *.out *.png *.dot tmp.v uut.vcd

0 commit comments

Comments
 (0)