------------------------------------------- Developing Ada Applications in Xilinx Vitis ------------------------------------------- .. toctree:: .. _creating-vitis-ada-project-tutorial: This chapter is intended for users already familiar with Xilinx Vitis and GNATbench. Some familiarity with GNAT Pro is also useful. For more information on *GNAT Pro* please refer to the *GNAT Pro User's Guide* and the *GNAT User’s Guide Supplement for Cross Platforms*, available on *GNAT Tracker*. Note: at the moment, importing existing Ada projects into GNATbench on Xilinx Vitis is not tested. If you have such projects, follow the tutorial on how to create a new Ada application and copy the code and configuration files from your previous project to the new project. Do note that if you have an existing GPR file, look at the GPR file created by GNATbench for any modification you may need to apply to your own GPR file. This process works with Xilinx Vitis 2021.x and 2022.x. On 2022.x however installing GNATbench fails due to a problem in Vitis. The problem with a workaround is described in `this support thread `_. Please contact AdaCore if you need any help. Installing GNATbench ==================== Requirements ------------ Prior to installing GNATbench, first install *GNAT Pro* and ensure its binaries are located on your path before starting Xilinx Vitis. On Windows, the installer will update your environment path to include *GNAT Pro* if the option is selected during installation. On Linux, the installer will provide instructions on how to update ``PATH`` variable at the end of the install. Downloading GNATbench --------------------- GNATbench is downloadable from GNAT Tracker and can be found on the *Release Download* page under the *IDE* section. Download the GNATbench ZIP archive that corresponds to your host platform. Once downloaded, you will install the plug-in through the Eclipse plug-in installer, so there is no need to expand the ZIP archive. Installing ---------- Install GNATbench in Vitis. To do this click on ``Help`` → ``Install New Software``. The plugin install window will open. Click on ``Add`` to add the gnatbench archive. .. image:: images/install_new_software.png .. image:: images/add_repository.png The GNATbench plugins will show up in the installation window. Select ``AdaCore Plugins for Eclipse``, click on ``Next`` and follow the installation process. .. image:: images/install_new_software_gnatbench.png Once the installation has finished, restart the Vitis. Once GNATbench is installed and Xilinx Vitis has been restarted, confirm that GNATbench can find the *GNAT Pro* toolchain for your target by opening the Eclipse properties and selecting the ``GNATbench properties`` page. *GNAT Pro* for your target should be listed below. Creating an Ada Application in Xilinx Vitis =========================================== This tutorial walks you through the process of creating a new Ada application for the Xilinx Zynq UltraScale+ MPSoC ZCU102 Evaluation Kit in Xilinx Vitis. Create a new Platform Project ----------------------------- To create an Ada application for the ZCU102, first create a new platform project by selecting ``File`` → ``New`` → ``Platform Project...``. In the ``New Platform Project`` window, enter ``zcu102_platform`` as the platform project name and click ``Next``. .. image:: images/zcu102_platform_project.png Under ``Hardware Specification``, select ``zcu102`` from the ``XSA`` dropdown menu. Keep the default values and click ``Finish``. .. image:: images/xsa_zcu102.png Create a new Application Project -------------------------------- Create a new application project by selecting ``File`` → ``New`` → ``Application Project..``. In the wizard that opens, select the previously created ``zcu102_platform`` platform project. .. image:: images/select_platform.png Click ``Next`` and name the application ``ada_hello_world``. .. image:: images/application_project_details.png Click ``Next`` until template selection window appears. Chose ``Empty Application (C)`` and click ``Finish``. .. image:: images/template_selection.png This will create two new projects, a system project called ``ada_hello_world_system`` and the application project called ``ada_hello_world``. Convert the Application Project ------------------------------- To convert the ``ada_hello_world`` project to an Ada project right click on the project and select ``New`` → ``other``. Expand the ``Ada`` folder and select ``Convert to an Ada project``. .. image:: images/convert_to_ada.png The next screen will ask which project file is going to be used with the newly created Ada project. Select ``Create a new GNAT project file``. .. image:: images/new_project_file.png In the last step you can decide if the project is a single project or a library. Select ``Single Project`` and keep the project unit name as ``ada_hello_world``. .. image:: images/project_unit_name.png Click Next until you reach the ``Ada Building Setting`` page. Ensure ``Ada`` is selected under languages and the ``aarch64-elf`` is selected as the toolchain. .. image:: images/builder_settings.png Click the ``Finish`` button to perform the conversion. Build the Project ----------------- The project is now ready for development. Build the application by right clicking on the ``ada_hello_world`` project and select ``Build project``. .. image:: images/build_project.png The project will then be built. Vitis may show that there is nothing to build for this project. .. image:: images/build_console.png The build consolse will indicate a successful build with ``Nothing to build for project ada_hello_world`` as the IDE does not check for ``gprbuild`` by itself. You can validate that the build was successfull by checking that ``main`` exists in the ``obj`` directory: .. image:: images/main_object.png Running and Debugging the Project --------------------------------- To debug an Ada project a new debug configuration needs to be added. This can be done by clicking ``Debug As`` → ``Debug Configurations``. In the window that opens double click on ``Single Application Debug`` to create a new configuration. Go to the ``Application`` tab and change the default value of ``Application`` which is ``Debug/ada_hello_world.elf`` to the file generated by ``gprbuild``. In our case that is ``obj/main``. Click ``Apply`` to create the new debug configuration. .. image:: images/debug_configuration.png You can now debug the application by selecting the newly created configuration from the debugging menu. .. image:: images/debug_application.png