Dear @PeterOgden
I’ve tried to follow your tutorial on:
and
but it seems that DMA is passing 0 values to IP
from pynq import allocate
import numpy as np
in_buffer = allocate(shape=(5,), dtype=np.uint32)
out_buffer = allocate(shape=(5,), dtype=np.uint32)
for i in range(5):
in_buffer[i] = i
multiply.constant = 3
dma.sendchannel.transfer(in_buffer)
dma.recvchannel.transfer(out_buffer)
dma.sendchannel.wait()
dma.recvchannel.wait()
out_buffer
result:
PynqBuffer([0, 0, 0, 0, 0], dtype=uint32)
It is the same when I run driver:
from pynq import DefaultHierarchy
class StreamMultiplyDriver(DefaultHierarchy):
def __init__(self, description):
super().__init__(description)
def stream_multiply(self, stream, constant):
self.multiply.constant = constant
with allocate(shape=(len(stream),), \
dtype=np.uint32) as in_buffer,\
allocate(shape=(len(stream),), \
dtype=np.uint32) as out_buffer:
for i, v, in enumerate(stream):
in_buffer[i] = v
self.multiply_dma.sendchannel.transfer(in_buffer)
self.multiply_dma.recvchannel.transfer(out_buffer)
self.multiply_dma.sendchannel.wait()
self.multiply_dma.recvchannel.wait()
result = out_buffer.copy()
return result
@staticmethod
def checkhierarchy(description):
if 'multiply_dma' in description['ip'] \
and 'multiply' in description['ip']:
return True
return False
overlay.const_multiply.stream_multiply([1,2,3,4,5], 5)
result:
PynqBuffer([0, 0, 0, 0, 0], dtype=uint32)
Another issue, when running:
class TestOverlay(Overlay):
def __init__(self, bitfile, **kwargs):
super().__init__(bitfile, **kwargs)
def multiply(self, stream, constant):
return self.const_multiply.stream_multiply(stream, constant)
next
overlay = TestOverlay('tutorial_2.bit')
overlay.multiply([2,3,4,5,6], 4)
it generates error:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-30-16d1ba4263de> in stream_multiply(self, stream, constant)
14 self.multiply_dma.recvchannel.wait()
---> 15 result = out_buffer.copy()
16 return result
/usr/local/lib/python3.6/dist-packages/pynq/buffer.py in __exit__(self, exc_type, exc_value, traceback)
126 def __exit__(self, exc_type, exc_value, traceback):
--> 127 self.freebuffer()
128 return 0
AttributeError: 'PynqBuffer' object has no attribute 'free_buffer'
During handling of the above exception, another exception occurred:
AttributeError Traceback (most recent call last)
<ipython-input-35-694e2ce2dfe4> in <module>()
1 overlay = TestOverlay('tutorial_3.bit')
----> 2 overlay.multiply([2,3,4,5,6], 4)
<ipython-input-34-c467dd7f5306> in multiply(self, stream, constant)
4
5 def multiply(self, stream, constant):
----> 6 return self.const_multiply.stream_multiply(stream, constant)
<ipython-input-30-16d1ba4263de> in stream_multiply(self, stream, constant)
13 self.multiply_dma.sendchannel.wait()
14 self.multiply_dma.recvchannel.wait()
---> 15 result = out_buffer.copy()
16 return result
17
/usr/local/lib/python3.6/dist-packages/pynq/buffer.py in __exit__(self, exc_type, exc_value, traceback)
125
126 def __exit__(self, exc_type, exc_value, traceback):
--> 127 self.freebuffer()
128 return 0
129
AttributeError: 'PynqBuffer' object has no attribute 'free_buffer'
Some suggest to modify
pynq/buffer.py
then
change self.free_buffer() to self.freebuffer()
Any idea?
Thanks
Hendar