Skip to content

Commit

Permalink
Add register map text to the overlay tutorial (#821)
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterOgden authored and schelleg committed Feb 22, 2019
1 parent e6668be commit d9c7521
Showing 1 changed file with 114 additions and 61 deletions.
175 changes: 114 additions & 61 deletions docs/source/overlay_design_methodology/overlay_tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,26 @@
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true
},
"outputs": [],
"metadata": {},
"outputs": [
{
"data": {
"application/javascript": [
"\n",
"require(['notebook/js/codecell'], function(codecell) {\n",
" codecell.CodeCell.options_default.highlight_modes[\n",
" 'magic_text/x-csrc'] = {'reg':[/^%%microblaze/]};\n",
" Jupyter.notebook.events.one('kernel_ready.Kernel', function(){\n",
" Jupyter.notebook.get_cells().map(function(cell){\n",
" if (cell.cell_type == 'code'){ cell.auto_highlight(); } }) ;\n",
" });\n",
"});\n"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"from pynq import Overlay\n",
"\n",
Expand All @@ -66,7 +82,6 @@
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": true,
"scrolled": true
},
"outputs": [],
Expand All @@ -85,7 +100,6 @@
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": true,
"scrolled": true
},
"outputs": [],
Expand All @@ -98,7 +112,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Reading the source code generated by HLS tells us that use the core we need to write the two arguments to offset `0x10` and `0x18` and read the result back from `0x20`."
"By providing the HWH file along with overlay we can also expose the register map associated with IP."
]
},
{
Expand All @@ -109,14 +123,75 @@
{
"data": {
"text/plain": [
"9"
"RegisterMap {\n",
" a = Register(a=0),\n",
" b = Register(b=0),\n",
" c = Register(c=0),\n",
" c_ctrl = Register(c_ap_vld=1, RESERVED=0)\n",
"}"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"add_ip.register_map"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can interact with the IP using the register map directly"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Register(c=7)"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"add_ip.register_map.a = 3\n",
"add_ip.register_map.b = 4\n",
"add_ip.register_map.c"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Alternatively by reading the driver source code generated by HLS we can determine that offsets we need to write the two arguments are at offsets `0x10` and `0x18` and the result can be read back from `0x20`."
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"9"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"add_ip.write(0x10, 4)\n",
"add_ip.write(0x18, 5)\n",
Expand All @@ -134,10 +209,8 @@
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": true
},
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"from pynq import DefaultIP\n",
Expand All @@ -163,10 +236,8 @@
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": true
},
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"overlay = Overlay('/home/xilinx/tutorial_1.bit')\n",
Expand All @@ -182,7 +253,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 9,
"metadata": {},
"outputs": [
{
Expand All @@ -191,7 +262,7 @@
"35"
]
},
"execution_count": 7,
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -215,10 +286,8 @@
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"collapsed": true
},
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
"overlay = Overlay('/home/xilinx/tutorial_2.bit')\n",
Expand Down Expand Up @@ -261,10 +330,8 @@
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"collapsed": true
},
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
"class ConstantMultiplyDriver(DefaultIP):\n",
Expand All @@ -291,10 +358,8 @@
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {
"collapsed": true
},
"execution_count": 12,
"metadata": {},
"outputs": [],
"source": [
"import pynq.lib.dma\n",
Expand All @@ -314,7 +379,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 13,
"metadata": {},
"outputs": [
{
Expand All @@ -323,7 +388,7 @@
"ContiguousArray([ 0, 3, 6, 9, 12], dtype=uint32)"
]
},
"execution_count": 11,
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
Expand Down Expand Up @@ -361,10 +426,8 @@
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {
"collapsed": true
},
"execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
"from pynq import DefaultHierarchy\n",
Expand Down Expand Up @@ -405,10 +468,8 @@
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {
"collapsed": true
},
"execution_count": 15,
"metadata": {},
"outputs": [],
"source": [
"overlay = Overlay('/home/xilinx/tutorial_2.bit')\n",
Expand All @@ -424,7 +485,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 16,
"metadata": {},
"outputs": [
{
Expand All @@ -433,7 +494,7 @@
"ContiguousArray([ 5, 10, 15, 20, 25], dtype=uint32)"
]
},
"execution_count": 14,
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -453,10 +514,8 @@
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {
"collapsed": true
},
"execution_count": 17,
"metadata": {},
"outputs": [],
"source": [
"base = Overlay('base.bit')\n",
Expand All @@ -477,10 +536,8 @@
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {
"collapsed": true
},
"execution_count": 18,
"metadata": {},
"outputs": [],
"source": [
"from pynq.overlays.base import BaseOverlay\n",
Expand All @@ -498,10 +555,8 @@
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {
"collapsed": true
},
"execution_count": 19,
"metadata": {},
"outputs": [],
"source": [
"base?"
Expand All @@ -518,10 +573,8 @@
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {
"collapsed": true
},
"execution_count": 20,
"metadata": {},
"outputs": [],
"source": [
"class TestOverlay(Overlay):\n",
Expand All @@ -541,7 +594,7 @@
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": 21,
"metadata": {},
"outputs": [
{
Expand All @@ -550,7 +603,7 @@
"ContiguousArray([ 8, 12, 16, 20, 24], dtype=uint32)"
]
},
"execution_count": 19,
"execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
Expand Down Expand Up @@ -598,7 +651,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.3"
"version": "3.6.5"
}
},
"nbformat": 4,
Expand Down

0 comments on commit d9c7521

Please sign in to comment.