Vivado: Creating Custom AXI IP and Integrating with Zynq

Xilinx Vivado Design Suite is a comprehensive FPGA/SoC design environment covering HDL authoring, simulation, synthesis, implementation, all the way to on-board hardware debugging. In this article, we walk through an end-to-end tutorial on creating a custom AXI IP core from scratch and integrating it with Zynq.

1. Creating a Custom AXI IP

Launch Vivado and create a new project. In this example, we create a project named project_1.

Create an IP by clicking Tools -> Create and Package New IP.

Create and Package New IP

Select Create a new AXI4 peripheral.

Create AXI4 Peripheral

Name the IP as desired. In this example, name it myip.

IP Name

In the Interfaces configuration, you can add AXI interfaces and configure the number of registers. For this simple example, we keep the default settings (AXI4-Lite).

Interface Configuration

If you select Verify Peripheral IP using AXI4 VIP, the system will automatically generate a simulation testbench.

Verify Peripheral IP

Once generated, you can run the simulation as shown below.

Simulation Waveform

Additionally, myip_v1.0 will be added to the IP Catalog.

IP Catalog

Note: To change which IP to simulate, right-click the target module under Simulation Sources in the Sources window and select Set as Top. Then right-click sim_1 in Sources and select Run Simulation -> Run Behavioral Simulation.

Set as Top
Run Behavioral Simulation

2. Modifying the Generated IP

The automatically generated HDL source files for the IP are stored in ./ip_repo/myip_1.0/hdl.

HDL Directory

Example: Adding an output port myip_out by declaring the output port in the myip_v1_0_S00_AXI.v module as shown below.

Edit AXI Slave HDL

Note: The generated HDL language depends on your Vivado project settings. You can configure this at Settings -> General -> Target language.

Target Language Settings

Next, also add the output port myip_out in the top-level module myip_v1_0.v.

Edit Top Module HDL

In the IP Catalog pane, right-click myip_v1.0 and select Edit in IP Packager.

Edit in IP Packager

Click OK with the default settings.

IP Packager Dialog

A separate Vivado window will open automatically. Click Ports and Interfaces, then click Merge changes from Ports and Interfaces Wizard.

Merge Ports and Interfaces

Click Review and Package, then click Re-Package IP to update the IP. Close the IP Packager Vivado window and return to the main project.

Re-Package IP

Double-click myip_1_0_bfm_1_i in the Block Design sources.

BFM Block Design

Click Show IP Status and upgrade myip_v1_0_bfm_1.

Upgrade IP

The myip_out port will now appear on the block. Right-click myip_out and select Make External.

Make External

Right-click sim_1 in Sources and select Run Simulation -> Run Behavioral Simulation to restart simulation.

Run Simulation Again

The myip_out port is now added to myip_v1_0_bfm, which acts as the DUT.

DUT Port Added

3. Modifying the Testbench

The testbench for simulation is located at project_1\project_1.srcs\sim_1\imports\bfm_design\myip_v1_0_tb.sv. By adding the following Read and Write tasks to this file, you can customize the simulation sequence.

// Write value 0x12345678 to address 0x0 (Register 0 of myip)
mst_agent_0.AXI4LITE_WRITE_BURST(32'h00000000, 0, 32'h12345678, mtestBresp );

// Read back from address 0x0 (Read data is stored in mtestRDataL)
mst_agent_0.AXI4LITE_READ_BURST(32'h00000000, 0, mtestRDataL, mtestRresp );

Arguments in order: address, protection type (prot), data, response (mtestBresp / mtestRresp).

Testbench Code
Simulation Results

4. Connecting with Zynq

Click IP INTEGRATOR -> Create Block Design.

Create Block Design

Name the Block Design. In this example, name it design_1.

Block Design Name

Click ADD IP (+) and add the ZYNQ7 Processing System IP.

Add Zynq IP

Click ADD IP (+) and add myip.

Add myip

Connect the blocks together (Clicking Run Connection Automation will automatically wire up the interfaces, but always verify the connections afterwards).

Connection Automation
Connected Block Design

Right-click myip_out in the myip block and click Make External. The port will be routed outside the block design automatically.

Make External Port

Assign the base address for myip in the Address Editor tab.

Address Editor

Right-click design_1 under Design Sources in the Sources window and select Create HDL Wrapper to generate the wrapper for the Block Design automatically.

Create HDL Wrapper

Create a top-level FPGA file and instantiate the Block Design wrapper. In this example, create a top-level file named prj_top.v.

Top-level Source

Add prj_top.v to Vivado, right-click Sources -> Design Sources -> prj_top, and select Set as Top.

Set Top Level

5. Simulating IP with Zynq VIP

Create a testbench named zynq_tb.v with the following code (adjust the TODO sections according to your design; refer to the Zynq-7000 VIP documentation (DS940) or Vivado example designs for the PS VIP reset sequence):

`timescale 1ns / 1ps
module tb;
    reg [31:0] read_data;
    reg [1:0]  resp;

    // TODO: Instantiate prj_top (Section 5) as prj_top_u
    //       and drive the PS clock/reset according to DS940 example

    initial begin
        // TODO: Complete the PS VIP reset sequence before issuing commands

        // Write from Zynq (PS) -> myip
        tb.prj_top_u.design_1_wrapper_u.design_1_i.processing_system7_0.inst.write_data(32'h43C0_0000, 4, 32'h12345678, resp);
        // Read from myip -> Zynq (PS)
        tb.prj_top_u.design_1_wrapper_u.design_1_i.processing_system7_0.inst.read_data(32'h43C0_0000, 4, read_data, resp);

        $display("read_data = %h, resp = %b", read_data, resp);
        $finish;
    end
endmodule

Using Zynq VIP:

For Write transactions (Zynq PS → IP):

xxx.inst.write_data(32'h43C0_0000, 4, 32'h12345678, resp);

For Read transactions (IP → Zynq PS):

xxx.inst.read_data(32'h43C0_0000, 4, read_data, resp);

Argument Meaning
1 Target memory address (must match Address Editor)
2 Data size in bytes (4 = 32 bits)
3 Data to write / Variable receiving read data
4 Response status (resp)

(The hierarchy xxx depends on your design structure. In this design it is: tb.prj_top_u.design_1_wrapper_u.design_1_i.processing_system7_0)

Zynq VIP Simulation Setup
Zynq VIP Waveform

6. On-Board Hardware Debugging

This section uses Vitis IDE to write a C program running on the PS (ARM) processor to access the registers of myip on the physical board. Workflow overview:

Step Environment Action
1 Vivado Run Generate Bitstream, then File -> Export -> Export Hardware and select Include bitstream (generates .xsa file)
2 Vitis Set Workspace and create a Platform Project from the .xsa file
3 Vitis Create an Application Project using the Empty Application (C) template
4 Vitis Add C source code, build the application, and run on the board via JTAG

When you created the custom AXI IP in Section 1, Vivado automatically generated sample driver source files as shown below.

Sample Driver Source

Start with Export Hardware in Vivado.

Export Hardware Dialog

Select Include bitstream.

Include Bitstream Option

Then open Vitis IDE.

Launch Vitis IDE

Select the Workspace directory.

Workspace Launcher

Click New -> Application Project.

New Application Project

Click Next with default settings.

Application Project Wizard

Click Create a new platform from hardware (XSA), browse and select the .xsa file exported earlier, then click Next.

Select XSA File

Enter the project application name, then click Next.

Project Name

Click Next with default settings.

Domain Settings

Since we are performing basic register operations, select Empty Application (C).

Select Empty Application
Application Structure
Add Source Files
Vitis Project Explorer
Edit Code
Makefile Configuration

Example Makefile modification to automatically gather all .c, .cpp, and .S files in the directory using wildcards (the three lines starting with # are the original commented-out lines):

#INCLUDEFILES=*.h

#LIBSOURCES=*.c

#OUTS = *.o

INCLUDEFILES=$(wildcard *.h)

LIBSOURCES=$(wildcard *.c *.cpp)

OUTS = $(addsuffix .o, $(basename $(wildcard *.c)))

OBJECTS = $(addsuffix .o, $(basename $(wildcard *.c *.cpp)))

ASSEMBLY_OBJECTS = $(addsuffix .o, $(basename $(wildcard *.S)))

Build the Project.

Build Project

Debug on real hardware via Run As -> Run Configurations.

Run Configuration
Debug Target

6.1 Sample C Code Accessing myip Registers

A simple main.c example for Empty Application (C) that writes to and reads back from the myip register (the base address must match the one specified in the Address Editor in Section 5; here assumed as 0x43C00000):

#include "xil_io.h"
#include "xil_printf.h"

#define MYIP_BASEADDR 0x43C00000 /* Must match Address Editor */

int main(void)
{
    u32 rd;

    Xil_Out32(MYIP_BASEADDR + 0x00, 0x12345678); /* Write register 0 */
    rd = Xil_In32(MYIP_BASEADDR + 0x00);         /* Read back */
    xil_printf("reg0 = 0x%08x\r\n", rd);

    return 0;
}
  • The sample driver file generated by Vivado (myip.h) provides helper macros for writing/reading registers that can be used instead of Xil_Out32 / Xil_In32 (macro names depend on the IP name).
  • Run the program by right-clicking the project -> Run As -> Launch on Hardware (System Debugger) and open a serial terminal to view the xil_printf output.

7. Verifying IP with Chipscope (ILA)

Run SYNTHESIS once.

Run Synthesis

Then click SYNTHESIS -> Open Synthesized Design -> Set Up Debug.

Set Up Debug

Click Find Nets to Add, search for the internal signals you wish to monitor, and register them.

Find Nets to Add
Select Nets

Right-click the Clock Domain column for each signal and assign the appropriate sampling clock.

Select Clock Domain
Clock Domain Assigned

Next, click Run Implementation followed by Generate Bitstream.

In Hardware Manager, click Open Target and select Auto Connect.

Auto Connect Target

Click Program device to download the FPGA bitstream into the PL side of Zynq.

Program Device
Program Dialog

Configure the Trigger setup just as you would with a hardware logic analyzer.

Trigger Setup

Click Run. When the trigger condition occurs, the waveform will be captured and displayed as shown below.

Captured ILA Waveform

8. Advanced Trigger

Basic trigger setup evaluates signal values against a single condition. However, complex triggering sequences—such as "trigger when a signal goes HIGH and then transitions LOW in sequence"—require an Advanced Trigger, which expresses conditions as a Trigger State Machine (TSM) program executed by the ILA in hardware.

How to Use:

1. The ILA core must be configured to support Advanced Triggering during core generation/insertion (in Set Up Debug or the ILA IP customization GUI).

2. In Hardware Manager, set the Trigger mode in the ILA Properties pane to ADVANCED_ONLY (or ADVANCED_OR_TRIG_IN).

3. The Basic Trigger Setup tab is replaced by the Trigger State Machine editor. Click Create new trigger state machine (generates a .tsm file).

4. Write your TSM script and click Run Trigger (the TSM is recompiled whenever Run is clicked, or you can click the Compile button to check syntax without arming the ILA).

Example: Trigger when myip_out rises to 1 and subsequently falls back to 0 (use probe names as shown in the ILA dashboard):

state s0:
  if (myip_out == 1'b1) then
    goto s1;
  else
    goto s0;
  endif

state s1:
  if (myip_out == 1'b0) then
    trigger;
  else
    goto s1;
  endif

For complete details on the TSM language syntax (counters, flags, state transitions), refer to UG908: Vivado Design Suite User Guide - Programming and Debugging (Trigger State Machine Language Description chapter).

Additional Reference (Japanese): 【FPGA Verification Knowledge】Making Vivado™ Logic Analyzer More Convenient (Using Advanced Trigger) - Preparation & Overview:

https://www.paltek.co.jp/techblog/techinfo/231127_01

9. Jupyter Environment for On-Board Custom IP Debugging

Debugging custom IP on actual hardware typically requires U-Boot or custom bare-metal/Linux debug firmware. However, preparing custom debug firmware involves many prerequisites. Here we introduce a convenient, interactive debugging approach using Jupyter Notebook.

Jupyter Notebook is a web-based interactive development environment (traditionally used on PC). For Zynq devices, the open-source PYNQ framework enables developers to interact with and control FPGA logic using Python. The Zynq processor (PS) runs embedded Linux hosting the Jupyter server, allowing you to configure and interact with the FPGA (PL) through Python scripts in your browser.

PYNQ Architecture

Boards supported by the PYNQ framework are listed at http://www.pynq.io/board.html

Debugging Steps:

1. Power on the target board and wait for Linux to finish booting. Run ifconfig in serial terminal to find the Zynq board's IP address (e.g. 192.168.1.55).

ifconfig IP Address

2. Open a web browser on your PC and enter the IP address to connect to Zynq. Enter the login password (default is xilinx).

Jupyter Login

3. Switch back to Vivado and click Program device to configure the FPGA bitstream onto the Zynq PL.

Program FPGA

4. In the Jupyter dashboard, click New → Python 3.

New Python Notebook

5. Enter the script below to read and write FPGA (PL) registers interactively:

Jupyter Python Script
from pynq import MMIO

MYIP_BASE = 0x43C00000          # Must match Address Editor
mmio = MMIO(MYIP_BASE, 0x1000)  # (base address, memory span)

mmio.write(0x00, 0x12345678)    # Write to register 0
print(hex(mmio.read(0x00)))     # Read back register 0

pynq.MMIO(base_addr, length) defines the memory mapped address space and byte range for access.

mmio.write(offset, data) performs a 32-bit register write.

mmio.read(offset) performs a 32-bit register read.

Note: You can simultaneously observe signal waveforms with Chipscope/ILA in Vivado to verify register access transactions in real time.

ILA Waveform Capture from Jupyter

10. Additional Topic: Exposing the AXI Bus Outside the Block Design

To add an AXI master bus port, increase the number of Master Interfaces on the AXI Interconnect (e.g. increase from 1 to 2).

AXI Interconnect Configuration

In this example, we want to bring out an AXI-Lite bus, so we add an AXI Protocol Converter to convert full AXI → AXI-Lite.

Add AXI Protocol Converter

Double-click the AXI Protocol Converter and configure the Address Width (set to 12 bits in this example).

Address Width Configuration

Right-click M_AXI on the AXI Protocol Converter and select Make External.

Make External M_AXI

The M_AXI_0 bus interface is now exposed outside the Block Design.

M_AXI_0 Bus Port

Assign the address space for the external AXI bus (M_AXI_0) in the Address Editor tab.

Address Editor for M_AXI_0

To route the CLK and reset signals outside the Block Design along with the AXI bus, right-click on the Block Design canvas and choose Create Port.

Create Port

Configure the CLK and reset port properties as shown below.

Clock Port Properties
Reset Port Properties

When clicking Validate Design, an error may occur as shown below (indicating that M_AXI_0 has no associated clock).

Validation Error

To resolve this error, select M_CLK_0_CLK, go to the Properties -> CONFIG section, and enter M_AXI_0 into ASSOCIATED_BUSIF. Then run Validate Design again—the warning/error will disappear.

ASSOCIATED_BUSIF Fix

Right-click design_1_i and select Create HDL Wrapper.

Update HDL Wrapper

The M_AXI_0 bus signals are now brought out to the top level as shown.

Top-level Wrapper Signals

Connect the bus to your custom AXI IP at the top level of the project.

Top-level Custom IP Connection

Add read and write operations to the memory locations mapped for M_AXI_0 in the simulation testbench.

Simulation Testbench Transactions

Running behavioral simulation allows you to verify your custom AXI IP module functionality.

Verification Simulation Waveform