Created
July 8, 2018 10:49
-
-
Save cathalmccabe/cecba8f4804cd770a1d7cdc6f0432eda to your computer and use it in GitHub Desktop.
LED example
This file contains 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": [ | |
"# LED example" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"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", | |
"ol = Overlay(\"base.bit\")" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"{'audio_codec_ctrl_0': {'addr_range': 65536,\n", | |
" 'driver': pynq.lib.audio.AudioADAU1761,\n", | |
" 'fullpath': 'audio_codec_ctrl_0',\n", | |
" 'gpio': {},\n", | |
" 'interrupts': {},\n", | |
" 'phys_addr': 1136656384,\n", | |
" 'state': None,\n", | |
" 'type': 'xilinx.com:user:audio_codec_ctrl:1.0'},\n", | |
" 'btns_gpio': {'addr_range': 65536,\n", | |
" 'driver': pynq.lib.axigpio.AxiGPIO,\n", | |
" 'fullpath': 'btns_gpio',\n", | |
" 'gpio': {},\n", | |
" 'interrupts': {'ip2intc_irpt': {'controller': 'system_interrupts',\n", | |
" 'fullpath': 'btns_gpio/ip2intc_irpt',\n", | |
" 'index': 13}},\n", | |
" 'phys_addr': 1092681728,\n", | |
" 'state': None,\n", | |
" 'type': 'xilinx.com:ip:axi_gpio:2.0'},\n", | |
" 'iop_arduino/mb': {'addr_range': 65536,\n", | |
" 'driver': pynq.overlay.DefaultIP,\n", | |
" 'fullpath': 'iop_arduino/mb',\n", | |
" 'gpio': {},\n", | |
" 'interrupts': {},\n", | |
" 'phys_addr': 1140850688,\n", | |
" 'state': None,\n", | |
" 'type': 'xilinx.com:ip:microblaze:10.0'},\n", | |
" 'iop_arduino/mb_bram_ctrl': {'addr_range': 65536,\n", | |
" 'driver': pynq.overlay.DefaultIP,\n", | |
" 'fullpath': 'iop_arduino/mb_bram_ctrl',\n", | |
" 'gpio': {},\n", | |
" 'interrupts': {},\n", | |
" 'phys_addr': 1140850688,\n", | |
" 'state': None,\n", | |
" 'type': 'xilinx.com:ip:axi_bram_ctrl:4.0'},\n", | |
" 'iop_pmoda/mb': {'addr_range': 65536,\n", | |
" 'driver': pynq.overlay.DefaultIP,\n", | |
" 'fullpath': 'iop_pmoda/mb',\n", | |
" 'gpio': {},\n", | |
" 'interrupts': {},\n", | |
" 'phys_addr': 1073741824,\n", | |
" 'state': None,\n", | |
" 'type': 'xilinx.com:ip:microblaze:10.0'},\n", | |
" 'iop_pmoda/mb_bram_ctrl': {'addr_range': 65536,\n", | |
" 'driver': pynq.overlay.DefaultIP,\n", | |
" 'fullpath': 'iop_pmoda/mb_bram_ctrl',\n", | |
" 'gpio': {},\n", | |
" 'interrupts': {},\n", | |
" 'phys_addr': 1073741824,\n", | |
" 'state': None,\n", | |
" 'type': 'xilinx.com:ip:axi_bram_ctrl:4.0'},\n", | |
" 'iop_pmodb/mb': {'addr_range': 65536,\n", | |
" 'driver': pynq.overlay.DefaultIP,\n", | |
" 'fullpath': 'iop_pmodb/mb',\n", | |
" 'gpio': {},\n", | |
" 'interrupts': {},\n", | |
" 'phys_addr': 1107296256,\n", | |
" 'state': None,\n", | |
" 'type': 'xilinx.com:ip:microblaze:10.0'},\n", | |
" 'iop_pmodb/mb_bram_ctrl': {'addr_range': 65536,\n", | |
" 'driver': pynq.overlay.DefaultIP,\n", | |
" 'fullpath': 'iop_pmodb/mb_bram_ctrl',\n", | |
" 'gpio': {},\n", | |
" 'interrupts': {},\n", | |
" 'phys_addr': 1107296256,\n", | |
" 'state': None,\n", | |
" 'type': 'xilinx.com:ip:axi_bram_ctrl:4.0'},\n", | |
" 'iop_rpi/mb': {'addr_range': 65536,\n", | |
" 'driver': pynq.overlay.DefaultIP,\n", | |
" 'fullpath': 'iop_rpi/mb',\n", | |
" 'gpio': {},\n", | |
" 'interrupts': {},\n", | |
" 'phys_addr': 1174405120,\n", | |
" 'state': None,\n", | |
" 'type': 'xilinx.com:ip:microblaze:10.0'},\n", | |
" 'iop_rpi/mb_bram_ctrl': {'addr_range': 65536,\n", | |
" 'driver': pynq.overlay.DefaultIP,\n", | |
" 'fullpath': 'iop_rpi/mb_bram_ctrl',\n", | |
" 'gpio': {},\n", | |
" 'interrupts': {},\n", | |
" 'phys_addr': 1174405120,\n", | |
" 'state': None,\n", | |
" 'type': 'xilinx.com:ip:axi_bram_ctrl:4.0'},\n", | |
" 'leds_gpio': {'addr_range': 65536,\n", | |
" 'driver': pynq.lib.axigpio.AxiGPIO,\n", | |
" 'fullpath': 'leds_gpio',\n", | |
" 'gpio': {},\n", | |
" 'interrupts': {'ip2intc_irpt': {'controller': 'system_interrupts',\n", | |
" 'fullpath': 'leds_gpio/ip2intc_irpt',\n", | |
" 'index': 8}},\n", | |
" 'phys_addr': 1092943872,\n", | |
" 'state': None,\n", | |
" 'type': 'xilinx.com:ip:axi_gpio:2.0'},\n", | |
" 'rgbleds_gpio': {'addr_range': 65536,\n", | |
" 'driver': pynq.lib.axigpio.AxiGPIO,\n", | |
" 'fullpath': 'rgbleds_gpio',\n", | |
" 'gpio': {},\n", | |
" 'interrupts': {},\n", | |
" 'phys_addr': 1092878336,\n", | |
" 'state': None,\n", | |
" 'type': 'xilinx.com:ip:axi_gpio:2.0'},\n", | |
" 'switches_gpio': {'addr_range': 65536,\n", | |
" 'driver': pynq.lib.axigpio.AxiGPIO,\n", | |
" 'fullpath': 'switches_gpio',\n", | |
" 'gpio': {},\n", | |
" 'interrupts': {'ip2intc_irpt': {'controller': 'system_interrupts',\n", | |
" 'fullpath': 'switches_gpio/ip2intc_irpt',\n", | |
" 'index': 14}},\n", | |
" 'phys_addr': 1092616192,\n", | |
" 'state': None,\n", | |
" 'type': 'xilinx.com:ip:axi_gpio:2.0'},\n", | |
" 'system_interrupts': {'addr_range': 65536,\n", | |
" 'driver': pynq.overlay.DefaultIP,\n", | |
" 'fullpath': 'system_interrupts',\n", | |
" 'gpio': {},\n", | |
" 'interrupts': {},\n", | |
" 'phys_addr': 1098907648,\n", | |
" 'state': None,\n", | |
" 'type': 'xilinx.com:ip:axi_intc:4.1'},\n", | |
" 'trace_analyzer_pi/axi_dma_0': {'addr_range': 65536,\n", | |
" 'driver': pynq.lib.dma.DMA,\n", | |
" 'fullpath': 'trace_analyzer_pi/axi_dma_0',\n", | |
" 'gpio': {},\n", | |
" 'interrupts': {'s2mm_introut': {'controller': 'system_interrupts',\n", | |
" 'fullpath': 'trace_analyzer_pi/axi_dma_0/s2mm_introut',\n", | |
" 'index': 7}},\n", | |
" 'phys_addr': 2151874560,\n", | |
" 'state': None,\n", | |
" 'type': 'xilinx.com:ip:axi_dma:7.1'},\n", | |
" 'trace_analyzer_pi/trace_cntrl_64_0': {'addr_range': 65536,\n", | |
" 'driver': pynq.overlay.DefaultIP,\n", | |
" 'fullpath': 'trace_analyzer_pi/trace_cntrl_64_0',\n", | |
" 'gpio': {},\n", | |
" 'interrupts': {},\n", | |
" 'phys_addr': 2210463744,\n", | |
" 'state': None,\n", | |
" 'type': 'xilinx.com:hls:trace_cntrl_64:1.4'},\n", | |
" 'trace_analyzer_pmodb/axi_dma_0': {'addr_range': 65536,\n", | |
" 'driver': pynq.lib.dma.DMA,\n", | |
" 'fullpath': 'trace_analyzer_pmodb/axi_dma_0',\n", | |
" 'gpio': {},\n", | |
" 'interrupts': {'s2mm_introut': {'controller': 'system_interrupts',\n", | |
" 'fullpath': 'trace_analyzer_pmodb/axi_dma_0/s2mm_introut',\n", | |
" 'index': 6}},\n", | |
" 'phys_addr': 2151809024,\n", | |
" 'state': None,\n", | |
" 'type': 'xilinx.com:ip:axi_dma:7.1'},\n", | |
" 'trace_analyzer_pmodb/trace_cntrl_32_0': {'addr_range': 65536,\n", | |
" 'driver': pynq.overlay.DefaultIP,\n", | |
" 'fullpath': 'trace_analyzer_pmodb/trace_cntrl_32_0',\n", | |
" 'gpio': {},\n", | |
" 'interrupts': {},\n", | |
" 'phys_addr': 2210529280,\n", | |
" 'state': None,\n", | |
" 'type': 'xilinx.com:hls:trace_cntrl_32:1.4'},\n", | |
" 'video/axi_vdma': {'addr_range': 65536,\n", | |
" 'driver': pynq.lib.video.AxiVDMA,\n", | |
" 'fullpath': 'video/axi_vdma',\n", | |
" 'gpio': {},\n", | |
" 'interrupts': {'mm2s_introut': {'controller': 'system_interrupts',\n", | |
" 'fullpath': 'video/axi_vdma/mm2s_introut',\n", | |
" 'index': 1},\n", | |
" 's2mm_introut': {'controller': 'system_interrupts',\n", | |
" 'fullpath': 'video/axi_vdma/s2mm_introut',\n", | |
" 'index': 0}},\n", | |
" 'phys_addr': 1124073472,\n", | |
" 'state': None,\n", | |
" 'type': 'xilinx.com:ip:axi_vdma:6.3'},\n", | |
" 'video/hdmi_in/color_convert': {'addr_range': 65536,\n", | |
" 'driver': pynq.lib.video.ColorConverter,\n", | |
" 'fullpath': 'video/hdmi_in/color_convert',\n", | |
" 'gpio': {},\n", | |
" 'interrupts': {},\n", | |
" 'phys_addr': 1136984064,\n", | |
" 'state': None,\n", | |
" 'type': 'xilinx.com:hls:color_convert:1.0'},\n", | |
" 'video/hdmi_in/frontend/axi_gpio_hdmiin': {'addr_range': 65536,\n", | |
" 'driver': pynq.lib.axigpio.AxiGPIO,\n", | |
" 'fullpath': 'video/hdmi_in/frontend/axi_gpio_hdmiin',\n", | |
" 'gpio': {},\n", | |
" 'interrupts': {},\n", | |
" 'phys_addr': 1092747264,\n", | |
" 'state': None,\n", | |
" 'type': 'xilinx.com:ip:axi_gpio:2.0'},\n", | |
" 'video/hdmi_in/frontend/vtc_in': {'addr_range': 65536,\n", | |
" 'driver': pynq.overlay.DefaultIP,\n", | |
" 'fullpath': 'video/hdmi_in/frontend/vtc_in',\n", | |
" 'gpio': {},\n", | |
" 'interrupts': {},\n", | |
" 'phys_addr': 1136852992,\n", | |
" 'state': None,\n", | |
" 'type': 'xilinx.com:ip:v_tc:6.1'},\n", | |
" 'video/hdmi_in/pixel_pack': {'addr_range': 65536,\n", | |
" 'driver': pynq.lib.video.PixelPacker,\n", | |
" 'fullpath': 'video/hdmi_in/pixel_pack',\n", | |
" 'gpio': {},\n", | |
" 'interrupts': {},\n", | |
" 'phys_addr': 1136918528,\n", | |
" 'state': None,\n", | |
" 'type': 'xilinx.com:hls:pixel_pack:1.0'},\n", | |
" 'video/hdmi_out/color_convert': {'addr_range': 65536,\n", | |
" 'driver': pynq.lib.video.ColorConverter,\n", | |
" 'fullpath': 'video/hdmi_out/color_convert',\n", | |
" 'gpio': {},\n", | |
" 'interrupts': {},\n", | |
" 'phys_addr': 1137049600,\n", | |
" 'state': None,\n", | |
" 'type': 'xilinx.com:hls:color_convert:1.0'},\n", | |
" 'video/hdmi_out/frontend/axi_dynclk': {'addr_range': 65536,\n", | |
" 'driver': pynq.overlay.DefaultIP,\n", | |
" 'fullpath': 'video/hdmi_out/frontend/axi_dynclk',\n", | |
" 'gpio': {},\n", | |
" 'interrupts': {},\n", | |
" 'phys_addr': 1136721920,\n", | |
" 'state': None,\n", | |
" 'type': 'digilentinc.com:ip:axi_dynclk:1.0'},\n", | |
" 'video/hdmi_out/frontend/hdmi_out_hpd_video': {'addr_range': 65536,\n", | |
" 'driver': pynq.lib.axigpio.AxiGPIO,\n", | |
" 'fullpath': 'video/hdmi_out/frontend/hdmi_out_hpd_video',\n", | |
" 'gpio': {},\n", | |
" 'interrupts': {},\n", | |
" 'phys_addr': 1092812800,\n", | |
" 'state': None,\n", | |
" 'type': 'xilinx.com:ip:axi_gpio:2.0'},\n", | |
" 'video/hdmi_out/frontend/vtc_out': {'addr_range': 65536,\n", | |
" 'driver': pynq.overlay.DefaultIP,\n", | |
" 'fullpath': 'video/hdmi_out/frontend/vtc_out',\n", | |
" 'gpio': {},\n", | |
" 'interrupts': {},\n", | |
" 'phys_addr': 1136787456,\n", | |
" 'state': None,\n", | |
" 'type': 'xilinx.com:ip:v_tc:6.1'},\n", | |
" 'video/hdmi_out/pixel_unpack': {'addr_range': 65536,\n", | |
" 'driver': pynq.lib.video.PixelPacker,\n", | |
" 'fullpath': 'video/hdmi_out/pixel_unpack',\n", | |
" 'gpio': {},\n", | |
" 'interrupts': {},\n", | |
" 'phys_addr': 1137115136,\n", | |
" 'state': None,\n", | |
" 'type': 'xilinx.com:hls:pixel_unpack:1.0'}}" | |
] | |
}, | |
"execution_count": 2, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"ol.ip_dict" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"leds = ol.leds_gpio" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"leds.write(0x0, 0xa)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 5, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"1" | |
] | |
}, | |
"execution_count": 5, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"ol.switches_gpio.read()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 7, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import time\n", | |
"for i in range(16):\n", | |
" leds.write(0x0, i)\n", | |
" time.sleep(.1)" | |
] | |
} | |
], | |
"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": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment