Adam Taylor玩转MicroZed系列第86部分: SDSoC之二:让 SDSoC 转起来

热度210票  浏览8068次 【共0条评论】【我要评论 时间:2015年6月24日 16:47


By Adam Taylor



Having looked introduced SDSoC in the last column, it’s now time to start working on how we get SDSoC up and running with a first example. We are going to be using the ZedBoard for this. As always, we will go more or less step by step with description as we do.


The first thing we need to do is create a new project. We can do this from either the welcome screen, shown below, or by selecting File -> New -> SDSoC project from the menu.






Selecting this will open a dialog box that allows us to name the project, and select the board, and select the operating system as seen below.


One great thing about SDSoC is that unlike the traditional SDK approach—where we need to define a BSP, HW description and FSBL—with SDSoC we do not need to do this because SDSoC already knows what these are for the selected target. (We will address bespoke SW platforms later.)






Selection of the ZedBoard







Selection of the operating system




For this example, we will be using the Linux operating system. However on the journey through the SDSoC tools, we will of course be examining the standalone and FreeRTOS options as well.


The next tab allows us to select the demo application. Initially, we are going to run within the PS (processor system) side of the Zynq SoC. We’ll characterize the code and then move it to the PL (programmable logic). In this case, select the Matrix Multiplier and Addition template as shown below:







This will create a project under the Project Explorer on the left-hand side of the SDSoC GUI. Under this project you will see the following:


  • SDSoC hardware functions –this is where you will see the functions we have moved into the hardware. We have not done so at this point so you will see nothing underneath this, yet.
  • Includes – Expanding this will show all of the C/C++ header files used in the build. We will be looking at this in a lot of detail in future blogs on this topic.
  • Src – The source code for the demonstration.


The next step to ensure we have everything correctly configured with not only our SDSoC installation and environment but also our development board is to build the demo so that it will run on the PS side of the device.



Before we do this we must set the correct build configuration. With the project selected in the project explorer, right click and select Build Configurations -> Set Active -> SDRelease. Then, with the project still selected on the menu, select Project -> Build Project. The build should not take too long. When it completes, you will see the following appear under the Project within the project Explorer:







  • Binaries – Under here you will find the Extensible Linker File (ELF) files created from the software compilation process.
  • Archives – Under here you will find the object files, which are linked to create the binaries.
  • SDRRelease – This contains your boot files and will not be present until do a build.


Now we’ve built the first demo, which runs only on the Zynq PS. At this point I need to explain how we know it’s working. If you remember in the first blog, I told you that SDSoC worked by profiling the application and then using profiled information to determine which functions to move.


How we achieve this at the basic level is by using a provided library called sds_lib.h. This library provides a basic time-stamp API that enables us to measure how long functions take based on a 64-bit global counter. This API enables us to easily determine the execution time taken by a function. We simply record the start and stop time and the difference is the process execution time.


There are two versions of an algorithm in this demo, which performs a matrix multiply and addition. The first version is called the golden version and is not intended for offloading to the PL. The second version is.


Building and running these applications just within the PS allows us to ensure that we are comparing eggs with eggs and that both processes take roughly the same time to execute. Otherwise it’s an unfair comparison.


With the build complete, we copy all of the files under the SDRelease -> sd_card folder under the project explorer onto an SD card and insert it into the ZedBoard. With a terminal program connected to the ZedBoard and the boot sequence completed, you need to run the program. You do this by typing in:



(where mult_add is the name of the project you created)


When I ran this on my Zed board I obtained the following result, which shows that both functions take roughly the same amount of time to execute:






Execution time for both functions running in the Zynq SoC’s PS



In the next blog we will look at how we can reduce the function’s execution time by more than 70%. You will be amazed by how easily we will do this.




 MicroZed Chronicles.jpg




Now, you can have convenient, low-cost Kindle access to the first year of Adam Taylor’s MicroZed Chronicles for a mere $7.50. Click here.


TAG: Taylor
当前平均分:-0.86 (102次打分)
上一篇 下一篇