An array as a transfer parameter does not work for me

Hello everyone, I am new here and i first built an adder where it was possible to pass the two summands as int variables and get back the calculation result. I would like to realize a simple decision tree in HLS, for which I have written the following function:
void decision_tree(int input, Node tree[MAX_NODES], int &result) {
#pragma HLS INTERFACE s_axilite port=input
#pragma HLS INTERFACE s_axilite port=result
#pragma HLS INTERFACE ap_ctrl_none port=return
#pragma HLS INTERFACE bram port=tree
int current_node = 0;
while (true) {
if (tree[current_node].output != -1) {
result = tree[current_node].output;
break;
}
if (input < tree[current_node].threshold) {
current_node = tree[current_node].left;
} else {
current_node = tree[current_node].right;
}
}
}
Here is a code artifact from my test function:
Node tree[MAX_NODES];
tree[0] = {10, 1, 2, -1}; // Wurzelknoten
tree[1] = {5, -1, -1, 1}; // Linkes Blatt
tree[2] = {15, -1, -1, 0}; // Rechtes Blatt
int result, returnCode;
decision_tree(8, tree, result);
I cannot achieve the same result in python as with my test routine - no matter which address I use for read or write. It would be great if you could help me solve the problem.
Here is the Python code:
from pynq import Overlay, allocate, MMIO
import numpy as np

overlay = Overlay(‘…/Entscheindungsbaum/baumi.bit’)
desicionTree = overlay.decision_tree_0
treeNodes = np.array([
[10, 1, 2, -1], # Beispiel-Knoten: (Wert, linker Kind-Knoten, rechter Kind-Knoten)
[5, -1, -1, 1],
[15, -1, -1, 0],
], dtype=np.int32)
#Inputwert für die Funktion
maxInputValue = 15

for inputValue in range(maxInputValue):
# write Inputvalues
desicionTree.write(0x10, inputValue) # input
desicionTree.write(0x18, tree.physical_address) # Physikalische Adresse von tree

# Get result
result = desicionTree.read(0x14)  # Ergebnisregister für result auslesen
print('inputValue: ', inputValue, ' result:', result)
1 Like

Hi,
“I cannot achieve the same result in python as with my test routine - no matter which address I use for read or write.” What was the result of your test routine, and what is displayed by your python jupyter notebook?

1 Like

Hi @aaron.pieper,

Welcome to the PYNQ community.

I do not see the part where you start your IP from python. How do you write the tree values to the IP?

Mario