This notebook demonstrates how to download an FPGA overlay and examine programmable logic state.
With the following overlay bundle present in the overlays
folder, users can instantiate the overlay easily.
For example, an overlay called base
can be loaded by:
from pynq.overlays.base import BaseOverlay
overlay = BaseOverlay("base.bit")
Users can also use the absolute file path of the bitstream to instantiate the overlay.
In this notebook, we get the current bitstream loaded on PL, and try to download it multiple times.
In [1]:
import os, warnings
from pynq import PL
from pynq import Overlay
if not os.path.exists(PL.bitfile_name):
warnings.warn('There is no overlay loaded after boot.', UserWarning)
Note: If you see a warning message in the above cell, it means that no overlay has been loaded after boot, hence the PL server is not aware of the current status of the PL. In that case you won't be able to run this notebook until you manually load an overlay at least once using:
from pynq import Overlay
ol = Overlay('your_overlay.bit')
If you do not see any warning message, you can safely proceed.
In [2]:
ol = Overlay(PL.bitfile_name)
Now we can check the download timestamp for this overlay.
In [3]:
ol.download()
ol.timestamp
Out[3]:
In [4]:
PL.bitfile_name
Out[4]:
In [5]:
PL.timestamp
Out[5]:
Users can verify whether an overlay instance is currently loaded using the Overlay is_loaded() method
In [6]:
ol.is_loaded()
Out[6]:
In [7]:
import time
import matplotlib.pyplot as plt
length = 50
time_log = []
for i in range(length):
start = time.time()
ol.download()
end = time.time()
time_log.append((end-start)*1000)
%matplotlib inline
plt.plot(range(length), time_log, 'ro')
plt.title('Bitstream loading time (ms)')
plt.axis([0, length, 0, 1000])
plt.show()