Last active
June 26, 2018 05:35
-
-
Save buttercutter/6db9343af8b25a007687f287b34cef6c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"# Data Sharing\n", | |
"\n", | |
"http://vectorblox.github.io/mxp/mxp_guide_xilinx.html#data_sharing" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"### Step 1: Load the overlay" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"from pynq import Overlay\n", | |
"Overlay(\"vbx.bit\").download()\n" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"### Create user function" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"2882\n" | |
] | |
} | |
], | |
"source": [ | |
"from pynq.iop.mxp_data_sharing import MXP_data_sharing\n", | |
"\n", | |
"data_sharing_text=\"\"\"\n", | |
"void data_sharing()\n", | |
"{\n", | |
" int A[] = {1, 2, 3, 4};\n", | |
" int B[] = {5, 6, 7, 8};\n", | |
" int C[] = {-1, -1, -1, -1};\n", | |
"\n", | |
" int vector_len = 4;\n", | |
" int num_bytes = vector_len * sizeof(int);\n", | |
"\n", | |
" /* step 1 */\n", | |
" vbx_word_t *va = vbx_sp_malloc( num_bytes );\n", | |
" vbx_word_t *vb = vbx_sp_malloc( num_bytes );\n", | |
" vbx_word_t *vc = vbx_sp_malloc( num_bytes );\n", | |
"\n", | |
" /* step 2 */\n", | |
" vbx_dcache_flush( A, num_bytes );\n", | |
" vbx_dcache_flush( B, num_bytes );\n", | |
" vbx_dma_to_vector( va, A, num_bytes );\n", | |
" vbx_dma_to_vector( vb, B, num_bytes );\n", | |
"\n", | |
" /* step 3 */\n", | |
" vbx_set_vl( vector_len );\n", | |
" vbx( VVW, VADD, vc, va, vb );\n", | |
"\n", | |
" /* step 4 */\n", | |
" vbx_dcache_flush( C, num_bytes );\n", | |
" vbx_dma_to_host( C, vc, num_bytes );\n", | |
"\n", | |
" /* step 5 */\n", | |
" vbx_sp_free();\n", | |
"\n", | |
" printf( \"C[] = %d, %d, %d, %d\\n\",\n", | |
" C[0], C[1], C[2], C[3] );\n", | |
" //return 0;\n", | |
"}\"\"\"\n", | |
"data_sharing_bin=MXP_data_sharing(data_sharing_text)\n", | |
"\n", | |
" " | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"### Step 2. Call mxp filter\n" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": { | |
"scrolled": true | |
}, | |
"outputs": [ | |
{ | |
"ename": "TypeError", | |
"evalue": "call() missing 5 required positional arguments: 'vid_in', 'vid_out', 'columns', 'rows', and 'pitch'", | |
"output_type": "error", | |
"traceback": [ | |
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", | |
"\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", | |
"\u001b[0;32m<ipython-input-3-de7420124e42>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0mdata_sharing_bin\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mstart\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 3\u001b[0;31m \u001b[0mdata_sharing_bin\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcall\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 4\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0mdata_sharing_bin\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mstop\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", | |
"\u001b[0;31mTypeError\u001b[0m: call() missing 5 required positional arguments: 'vid_in', 'vid_out', 'columns', 'rows', and 'pitch'" | |
] | |
} | |
], | |
"source": [ | |
"data_sharing_bin.start()\n", | |
"\n", | |
"data_sharing_bin.call()\n", | |
"\n", | |
"data_sharing_bin.stop()\n" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.6.0" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment