Skip to content

Commit

Permalink
Add second part of the tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
Mario Ruiz committed Mar 1, 2022
1 parent d523fef commit f0e78c5
Show file tree
Hide file tree
Showing 4 changed files with 644 additions and 204 deletions.
3 changes: 2 additions & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,5 @@ The Composable Overlays Overview
:caption: Tutorial
:hidden:

tutorial/composable_overlay.md
tutorial/composable_overlay.md
tutorial/tutorial.ipynb
2 changes: 2 additions & 0 deletions docs/source/tutorial/composable_overlay.md
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,8 @@ Finally, get the composable overlay files onto the board. You need to copy
* fir_paths.json
* tutorial.ipynb

These files can be found [here](https://github.com/Xilinx/PYNQ_Composable_Pipeline/tree/main/tutorial)

This step assumes that you have PYNQ up and running on the Kria KV260 Vision
AI Starter Kit. if this is not the case,
[follow the these instructions](https://github.com/Xilinx/Kria-PYNQ#installation).
Expand Down
20 changes: 18 additions & 2 deletions tutorial/fir.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,20 @@
import matplotlib.pyplot as plt
import numpy as np
from scipy import signal
from scipy.fft import fft, fftfreq

__author__ = "Mario Ruiz"
__copyright__ = "Copyright 2022, Xilinx"
__email__ = "pynq_support@xilinx.com"

fs = 44_100

class FIR:
coef = []
fs = 44100
_type = ""

def __init__(self):
self.w, self.h = signal.freqz(self.coef, fs= self.fs)
self.w, self.h = signal.freqz(self.coef, fs= fs)
self.taps = len(self.coef)
self.group_delay = (self.taps-1)//2

Expand Down Expand Up @@ -89,3 +90,18 @@ def plot(self):
axs[1, 1].tick_params(axis='x', rotation=30)
plt.xlim([0, 22050])
fig.tight_layout()

def plot_fft(data):
""" Returns a plot with the frequency response of data"""
yf = fft(data)
samples = len(data)
xf = fftfreq(samples, 1/fs)[:samples//2]

plt.figure(figsize=(20, 5));
plt.plot(xf, 2.0/samples * np.abs(yf[0:samples//2]), 'r');
plt.grid()
plt.title("Frequency Response", fontsize = 18);
plt.xlabel("Frequency (Hz)", fontsize = 14);
plt.ylabel("Amplitude", fontsize = 14);
plt.xlim([0, 22050]);
plt.xticks(np.arange(0, 22050, 1000), rotation=30);
823 changes: 622 additions & 201 deletions tutorial/tutorial.ipynb

Large diffs are not rendered by default.

0 comments on commit f0e78c5

Please sign in to comment.