UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 

MicroZed Chronicles: Power Analysis with PYNQ & PMBus

Xilinx Employee
Xilinx Employee
0 0 313

Editor’s Note: This content is republished from the MicroZed Chronicles, with permission from the author and Hackster.io.

 

Last week I introduced how we can use PYNQ to access telemetry data on a boards power system, if it uses PMBus. In this article, we are going to look at how we can use the this capability in PYNQ to log and analyze power data.

318_Fig1.jpg

The main element we will be using to do this is the DataRecorder contained within the PMBus package.

The DataRecorder provides the ability to stop, start and reset sampling on selected PMBus sensors. We can achieve fine grained control of the sampling period as we are able to define the sampling period when the DataRecorder is started.

The output from the DataRecorder is a pandas frame; if you are not familiar with pandas, it is built upon NumPy and enables us to easily plot the results using MathPlotLib.

In pandas there are two basic structures, series and frames. A series is essentially a column of values, while a frame is a multidimensional array of values.

318_Fig2.jpgPandas frame for ZCU104 input power

Setting up the data recorder is simple; the first thing to do is define the rails that we wish to monitor. We can monitor several rails, and can determine the rails and the capabilities in our system by using the commands shown below.

318_Fig3.jpgGetting the PMBus dictionary

Running pmbus.get_rails() will return a dictionary of the rails and available in the power system along with there values. To understand what rails are available we can print the dictionary.

When I did this for the ZCU104 I am generating this example on, the following was returned. Note how you can see not only the voltage but also the current and power, also visible is the input bus voltage.

318_Fig4.jpgPrinting the dictionary for the ZCU104

We can create a data recorder, using this information. For example, to sample the input voltage and current we can configure the data recorder as below.

This samples the sensors every 0.2 seconds and samples for 30 seconds.

318_Fig5.jpgDataRecorder example

This information can then be plotted.

318_Fig6.jpgSimple plotting of results

However, the example above is measuring steady state conditions on the PYNQ board. What we really want to know is how the power fluctuates when we are executing algorithms on either the processors (PS) or the programmable logic (PL).

To do this, we can add in the DataRecorder configuration and start / stop functions, in line with the code we wish to profile.

318_Fig7.jpgExample of inserting the PMBus & DataRecorder within a SW optical flow example

Using the ZCU104, I downloaded the PYNQOpenCV package, instrumented the code with the DataRecorder and ran the application on both on the SW and PL to determine the power demands of both implementations.

318_Fig8.jpgSW Implementation of the Optical Flow

Running the same optical flow algorithm with acceleration on the PL

318_Fig9.jpgPL implementation of optical flow

Of course, the results show what you might expect the PL implementation takes slightly higher power for a much shorter duration. If desired, we could analyze the pandas frame data to determine the actual power efficiency of both solutions.

The DataRecorder is like the FSM generator, signal generator, logic tracing, IOP another function in PYNQ which allows us to work with Python and hardware effectively.

It also lets us understand the behavior of our system in more depth, too.

 

See My FPGA / SoC Projects: Adam Taylor on Hackster.io

Get the Code: ATaylorCEngFIET (Adam Taylor)

Access the MicroZed Chronicles Archives with over 300 articles on the FPGA / Zynq / Zynq MpSoC updated weekly at MicroZed Chronicles.