I really enjoyed my recent Roadtest of the Digilent Arty S7 board Digilent ARTY S7 Dev Board (Xilinx Spartan 7) - Review but I did struggle somewhat with the Verilog and Vivado software. I wanted to learn more but I also wanted to start utilising the raw FPGA power to build something interesting. I then found another Digilent board that required less Verilog/VHDL coding and allowed FGPA configuration from Python code....intrigued I decided to get one to find out some more. The board does sound very similar to that on offer in a new E14 Roadtest Digilent ARTY Z7 Dev Board (apart from it is actually pink in colour) and I took a keen interest in their findings.

PYNQ - Python productivity for Zynq - Home

Then other tasks took precedence and my Pynq board sat on the side a bit longer; I've still got those other tasks but I also was interested to play with the Pynq, so flashed it up and got hooked again.

 

Differences Pynq-Z1 and Digilent Arty-Z1

I'm going to try and explain what the Pynq-Z1 is but I'm still not entirely sure so this explanation could be wrong! I should add that I am no expert in Python, the Pynq explanation nor FPGA....if you spot something obviously incorrect I'd be pleased to hear from you.

 

The Pynq-Z1 is very similar (perhaps even the same) as the Arty-Z1. The Pynq board is designed to be used with an open-source framework called PYNQ whereby the System on Chip (SoC) fabric of the Z1 can be programmed by Python scripts rather than delving into VHDL or Verilog. There is a web-server, IPython Kernel, Linux OS and FPGA API all running in the Programmable System (PS) space of the Z1.

 

Jupyter Notebook

It is the webserver that is really interesting here, it is called Jupyter Notebook. This webserver is open-source and allows the creation of documents that contain text, equations, live code examples and visualisations - all the user interfacing is accomplished from a webbrowser. The notebook server is not limited to the Pynq-Z1 so you can install it and give it a go (using the link above) or even connect to their online server. At the server end there is a Kernel for each language that is chosen and are used to run those sections of the notebook. You can mix and match sections of code ! The notebook runs easily with C, C++, R, Julia but languages with Python wrappers are also easy to install - therefore Haskell and Octave can quickly be added.The easiest way to explain it is with an example or two (taken from https://wiki.python.org/moin/SimplePrograms  ):

 

Online Notebook - "Hello Element14" Example

This uses the online Jupyter Notebook Server. The Kernel selected is Python3. I typed in the print statement and when run, from my browser, the Jupiter Notebook Kernel ran that script and sent back the output to my browser.

 

Online Notebook - 'Bottles of Beer' Example

The code that I pasted into the Jupyter notebook on my browser was interpreted on the mybinder.org's server and the results (and any errors) sent back to my browser and displayed on the screen. I don't need either Python or Jupyter Notebook installed to achieve this...just a web browser.

 

Online Notebook - Cells With Different Content

In the example above I added another cell above my initial Python "Hello World" script to explain the function. I stated this was Markdown and so the Kernel will not try and interpret it as code. Instead it is just displayed. The text I entered was plain but you can easily add HTML as well. When the cell is 'run' the HTML will be interpreted and displayed on your browser. I haven't tried it but it should be possible to add other Kernels and mix and match the content in the different cells to suit the application. Time to get back to the Pynq-Z1 board....

 

Jupyter Notebook on My PYNQ-Z1

If I log on to my Pynq board via the router/switch using http://pynq:9090 I see the following in my web browser:

Using my web browser I am able to look through the folders on Jupyter Notebook that is running on my SoC/Linux OS within the Z1's ARM core. As part of the PYNQ image that is held on a flash card there are many examples already in here.

 

Pynq-Z1 Board - Buttons and LEDs Example

The first cell of this example Jupyter Notebook contains text detailing the example, as shown below. Executing that cell has no effect.

Buttons and LEDs demonstration

This demo shows how to use push-buttons (BTN0-3), LEDs (LD0-3), and RGB LEDs (LD4-5) on the board.

You can do the following to control the LEDs or RGB LEDs:

Button 0 pressed:        RGB LEDs change color. 
Button 1 pressed:        LEDs shift from right to left (LD0 -> LD3).
Button 2 pressed:        LEDs shift from left to right (LD3 -> LD0).
Button 3 pressed:        Turns off all the LEDS and ends this demo.

Running the Python script, which will execute on the Z1 ARM core and the FPGA fabric of the device we find we can actually control the board's LEDs - they are wired through the FPGA. We have effectively manipulated the FPGA fabric without directly writing any Hardware Description Language (HDL) or using Vivado....that is impressive.

Pynq-Z1 Board -The Microblaze Softcore

I knew from the Arty-S7 roadtest that theer was an IP block called Microblaze that allowed a configurable microcontroller to be placed into the FPGA fabric. Indeed if you wanted more that one you simply dragged and dropped another into place. Those microcontrollers were configurable in terms of the peripherals that the designer gives to them, and of course they run their own software just like any other microcontroller. The Jupyter Notebook also has a Microblaze example....

 

After instigating a Microblaze core from our Jupyter Notebook we carry on and write C code for it as well. Again no compiling is required on the host machine - my PC is just running Mozilla Firefox and all the interaction with the Pynq-Z1 is undertaken from there. In the example below the add function is running in the Microblaze

Another example shows a print function being used, as shown below.

Summary So Far

The Pynq-Z1 and the Jupyter Notebook combination are great. They are a quick way to get into using a complex board like this whilst still staying relatively 'safe' from the 'horrors' of a full on IDE. The two software technologies make the experience fun and allow makers to try things out with a board like this...getting to grips quickly with the concepts, the Microblaze cores, SPI, Arduino shields and PMOD. Then at a later stage they may decide to move onto the more complex Vivado, VHDL or Verilog.

 

To Follow

I plan to keep looking and experimenting with this Digilent Pynq-Z1 board and will blog about my progress (good and bad) in the coming months.