# Synchonous IP: how to manage in Python?

**URL:** <https://discuss.pynq.io/t/synchonous-ip-how-to-manage-in-python/692>\
**Category:** Support\
**Created:** [November 23, 2019, 12:05pm UTC](https://discuss.pynq.io/t/synchonous-ip-how-to-manage-in-python/692 "2019-11-23T12:05:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stefano\_Centomo](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/stefano_centomo/32/451_2.png) [@Stefano\_Centomo](https://discuss.pynq.io/u/Stefano_Centomo)\
**Post date:** [November 23, 2019, 12:05pm UTC](https://discuss.pynq.io/t/synchonous-ip-how-to-manage-in-python/692/1 "2019-11-23T12:05:59Z")

</div>

Hi,

I have a synchronous IP that I would like to control via Python.  
This IP has a variable latency that could change depending on the incoming data. The IP raise a flag to notify the conclusion of its elaboration.

How can I capture this event that represents the end of the computation of my IP?  
Do I have to use Interrupts? How can I set them and link them in Python?

Thanks,

Stefano

---

<div class="post-metadata">

**Author:** ![cathalmccabe](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/cathalmccabe/32/3348_2.png) [@cathalmccabe](https://discuss.pynq.io/u/cathalmccabe)\
**Post date:** [November 25, 2019, 8:48am UTC](https://discuss.pynq.io/t/synchonous-ip-how-to-manage-in-python/692/2 "2019-11-25T08:48:47Z")

</div>

You could write the result to a register, and poll to check for the result, or use interrupts.  
You can use asyncio to use interrupts with PYNQ.  
[https://pynq.readthedocs.io/en/v2.5/overlay\_design\_methodology/pynq\_and\_asyncio.html](https://pynq.readthedocs.io/en/v2.5/overlay_design_methodology/pynq_and_asyncio.html)

Cathal

---

<div class="post-metadata">

**Author:** ![Stefano\_Centomo](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/stefano_centomo/32/451_2.png) [@Stefano\_Centomo](https://discuss.pynq.io/u/Stefano_Centomo)\
**Post date:** [December 3, 2019, 2:12pm UTC](https://discuss.pynq.io/t/synchonous-ip-how-to-manage-in-python/692/3 "2019-12-03T14:12:01Z")

</div>

Thank you,

I have tried to enable interrupts on my Custom IP,Zynq7 PS and then binded the ports.  
Finally, I have generated the bitstream.

The overlay can be loaded and the ip\_dict shows the name of my customIP (root\_0).  
overlay.ip\_dict:

{‘root\_0’: {‘addr\_range’: 65536,  
‘device’: \<pynq.pl\_server.device.XlnkDevice at 0xb02af3d0\>,  
‘driver’: pynq.overlay.DefaultIP,  
‘fullpath’: ‘root\_0’,  
‘gpio’: {},  
‘interrupts’: {‘irq’: {‘controller’: ‘’,  
‘fullpath’: ‘root\_0/irq’,  
‘index’: 0}},  
‘mem\_id’: ‘SEG\_root\_0\_S\_AXI\_INTR\_reg’,  
‘phys\_addr’: 1136721920,  
‘state’: None,  
‘type’: ‘[xilinx.com](http://xilinx.com):user:root:1.0’}}

Unfortunally, I can’t retrieve it and gives me this errors:

KeyError Traceback (most recent call last)  
 in ()  
----\> 1 overlay.root\_0

/usr/local/lib/python3.6/dist-packages/pynq/overlay.py in **getattr** (self, key)  
335 “”"  
336 if self.is\_loaded():  
 → 337 return getattr(self.\_ip\_map, key)  
338 else:  
339 raise RuntimeError(“Overlay not currently loaded”)

/usr/local/lib/python3.6/dist-packages/pynq/overlay.py in **getattr** (self, key)  
735 elif key in self.\_description[‘ip’]:  
736 ipdescription = self.\_description[‘ip’][key]  
 → 737 driver = ipdescription’driver’  
738 setattr(self, key, driver)  
739 return driver

/usr/local/lib/python3.6/dist-packages/pynq/overlay.py in **init** (self, description)  
600 self.\_gpio = {}  
601 for interrupt, details in self.\_interrupts.items():  
 → 602 setattr(self, interrupt, Interrupt(details[‘fullpath’]))  
603 for gpio, entry in self.\_gpio.items():  
604 gpio\_number = GPIO.get\_gpio\_pin(entry[‘index’])

/usr/local/lib/python3.6/dist-packages/pynq/interrupt.py in **init** (self, pinname)  
96 self.number = PL.interrupt\_pins[pinname][‘index’]  
97 self.parent = weakref.ref(  
—\> 98 \_InterruptController.get\_controller(parentname))  
99 self.event = asyncio.Event()  
100 self.waiting = False

/usr/local/lib/python3.6/dist-packages/pynq/interrupt.py in get\_controller(name)  
157 if con.name == name:  
158 return con  
 → 159 ret = \_InterruptController(name)  
160 \_InterruptController.\_controllers.append(ret)  
161 return ret

/usr/local/lib/python3.6/dist-packages/pynq/interrupt.py in **init** (self, name)  
175 “”"  
176 self.name = name  
 → 177 self.mmio = MMIO(PL.ip\_dict[name][‘phys\_addr’], 32)  
178 self.wait\_handles = [for \_ in range(32)]  
179 self.event\_number = 0

KeyError: ‘’

Any suggestions?

---

<div class="post-metadata">

**Author:** ![patocarr](https://avatars.discourse-cdn.com/v4/letter/p/d2c977/32.png) [@patocarr](https://discuss.pynq.io/u/patocarr)\
**Post date:** [December 4, 2019, 8:50pm UTC](https://discuss.pynq.io/t/synchonous-ip-how-to-manage-in-python/692/4 "2019-12-04T20:50:07Z")

</div>

Hi @Stefano_Centomo  
Looks like there’s a problem in the block design related to the AXI interrupt block. Could you please post a screenshot of the block design?

Thanks,  
-Pat
