show menu

Connected users can download this tutorial in pdf

Creating a custom IP in Vivado

Posted by Florent - 03 October 2017


This tutorial shows how to package a RTL project (VHDL) to create a custom IP in Vivado 2017.2.

Create the module

Open Vivado 2017.2 and create a new project. Create a new VHDL file called logic_function.vhd.

We will first create a 1-bit Logical AND. In the “Define Module” window, define two 1-bit inputs (A_inp and B_inp) and one 1-bit output (P_outp). - Vivado 2017.2 - Define the module

Figure 1 - Define the module

In the architecture of the module, just add the following line:

P_outp <= A_inp AND B_inp;

Package the module in an IP

Click on “Tools > Create and Package New IP…” to create a new project to package an IP. In the “Create Peripherals, Package IP or Package a Block Design” page, select “Package your current project”.

Vivado 2017.2 - Package your current project

Figure 2 - Package your current project

In the “Package your current project” page, choose where you want the IP to be created and select “Include .xci files”. If you are using revision control (GIT, SVN, etc…) with your custom IP definition, the UG1118 recommends to use an external repository location (outside the initial project) for your custom IP and to place the entire custom IP directory into the revision control system to preserve all the necessary outputs from the IP packager.


Vivado 2017.2 - Select Package IP Project Location

Figure 3 - Select Package IP Project Location

This create a temporary project where you can edit the IP configuration. You should have a window called “Package IP – logic_function” opened with various sections to configure the IP. The section “Identification” for example allow you to change how the IP will be identified in the Vivado IP catalog.


Vivado 2017.2 - Package IP – Identification

Figure 4 - Package IP – Identification

If you want to keep the IP project after packaging the IP (when using a revision control system for example), click on Edit Packaging settings (or go to project settings > IP > Packager) and disable Delete project after packaging.

Vivado 2017.2 - Keep project after packaging

Figure 5 - Keep project after packaging

We won’t do more changes for the moment. Go in the section “Review and Package”. Click on “Package IP”. Vivado will ask you if you want to close the project, click “Yes”.

Then, in your initial project, if you go in the IP catalog (“Window > IP catalog”) you should see the IP logic_function under UserIP.

Vivado 2017.2 - User IP in IP catalog

Figure 6 - User IP

Note: If you create a new Vivado project, you won’t see the IP in the user catalog. This is because the folder where the IP is located is not scanned by Vivado. You need to add this folder to the “IP repositories” in the Project Settings (IP > Repository).

If we select the IP, we can see the “IP Properties” window with the properties of the IP. We can see that the version of the IP is 1.0 with the Rev. 1. The revision will be incremented automatically each time we package the IP. The version can be changed in the IP packaging project.

Parameterize the size of the ports

We will modify the IP to do a logical AND on buses (not only on 1-bit signals). To modify the IP:

·        If you have kept the IP packager project, open this project

·        If you haven’t kept the IP project, open the IP catalog and search for the IP. Right click on the IP and click on “Edit in IP Packager”.

Vivado 2017.2 - Edit in IP Packager

Figure 7 - Edit in IP Packager

In the design sources, doubled click on the source file (logic_function.vhd) to modify it.

Vivado 2017.2 - Adding generic values
Change the entity by adding generics values to allow different size for the ports.


In the “Package IP” window, you can see that some sections don’t have a green mark. This is because we made some changes to the RTL which are not taken in account in the package IP project. To update the project, go in the section “Review and Package”. Click on one of the “Merge Changes” links under Edit IP Project Changes.

Note: If you do not see the package IP tab in vivado in you packaging IP project, you can open it by clicking on “Package IP” in the Flow Navigator

Vivado 2017.2 - Merge Changes

Figure 8 - Merge Changes

Then in Customization Parameters, under “Hidden Parameters”, double click on “DATA_SIZE”. In the window “Edit IP Parameter”, enable “Visible in customization GUI” to be able to change the value from the configuration GUI when adding the IP to a project from the IP catalog.

Vivado 2017.2 - Customization Parameters tab

Figure 9 - Customization Parameters tab

In the “Edit IP Parameter”, enable “Specify Range” and select “Range of Integer” for “Type”. Enter “32” as maximum value and click OK.

Vivado 2017.2 - Edit IP Parameter

Figure 10 - Edit IP Parameter

In the “Customization GUI” section, move the parameter “Data Size” under “Page 0”.

Vivado 2017.2 - Customization GUI

Figure 11 - Customization GUI

Then re-package the IP in the “Review and Package” section.

In the IP catalog, we can see that the IP revision value has been incremented (Rev. 2).

Now, if we add double click on the IP in the IP catalog, we can see that we can select the size of the data in the GUI.

Vivado 2017.2 - IP GUI

Figure 12 - IP GUI

Adding new functions

Now, we will add new functions to our IP: logical OR, logical NOR and logical NAND. And the user will be able to select the functionality he wants to use when adding the IP to a project.

Vivado 2017.2 - Add new functions

Open the IP in “IP Packager” and open the source code and modify it with the following code.


Save the source file and merge the changes in the “Package IP” window. Edit the parameter FUNC_SEL in Customization parameters:

·        enable “Visible in customization GUI

·        Specify range:

o   Pairs

o   Key: And, Value: 0

o   Key: Or, Value: 1

o   Key: Nor, Value: 2

o   Key: Nand, Value: 3

Vivado 2017.2 - Customization of parameter FUNC_SEL

Figure 13 - Customization of parameter FUNC_SEL

In the “Customization GUI”, move the parameter “Func Sel” under Page 0 and Re-package the IP.

Now, from the IP GUI, you can select which function you want.

Vivado 2017.2 - Function selection in the IP GUI

Figure 14 - Function selection in the IP GUI

Set a port as unused port

We will now add a new function to our IP: a logic NOT. For this we only need one input port. The other one will be unused so we will disable it from the IP when the function is selected in the customization GUI.

Vivado 2017.2 - Add logic NOT
Open the IP in “IP Packager” and open the source code and modify by adding the following code.


Save the source file and merge the changes in the “Package IP” window. Edit the parameter FUNC_SEL by adding a new pair (key: Not, Value: 4).

In the “Ports and Interfaces” section, double click on B_inp to open the “Edit Port” window. If the user want to use the logical NOT function, the input port B_inp will be useless. Thus we need to change Port Presence to “Optional”, set Driver Value to “0” and write “$FUNC_SEL != 4” in the box below as shown in the Figure 13.

Vivado 2017.2 - Edit port

Figure 15 - Edit port B_inp

Re-package the IP.

Now in our original project, we can see that if we select the function NOT, the input port B_inp will be disabled for the IP.

Port B disabled

Figure 16 - Port B disabled


2018-05-16 04:42:13

This is great! However, how do I get this module to work with the PS?

2018-05-19 02:35:09

It depends on what you want to do. If you want to get the result in the PS, you can use a DMA after the IP. If you need to control the IP or read the result from registers, you would need to add an AXI4 interface (memory mapped, full or lite)

Post a comment

Only connected users can post comments