peripheral_tutorial
peripheral_tutorial
U a
8 Votes
Tutorial Overview
In this tutorial we’ll create a custom AXI IP block in Vivado and modify its functionality
by integrating custom VHDL code. We’ll be using the Zynq SoC and the MicroZed as a
hardware platform. For simplicity, our custom IP will be a multiplier which our
processor will be able to access through register reads and writes over an AXI bus.
The multiplier takes in two 16 bit unsigned inputs and outputs one 32 bit unsigned
output. A single 32 bit write to the IP will contain the two 16 bit inputs, separated by
the lower and higher 16 bits. A single 32 bit read from the peripheral will contain the
result from the multiplication of the two 16 bit inputs. The design doesn’t serve much
purpose, but it is a good example of integrating your own code into an AXI IP block.
Requirements
Before following this tutorial, you will need to do the following:
Vivado 2014.2
MicroZed
Platform Cable USB II (or equivalent JTAG programmer)
2. The Create and Package IP wizard opens. If you are used to the ISE/EDK tools you
can think of this as being similar to the Create/Import Peripheral wizard. Click “Next”.
http://www.fpgadeveloper.com/2014/08/creatingacustomipblockinvivado.html 2/36
9/20/2015 Creating a custom IP block in Vivado | FPGA Developer
3. On the next page, select “Create a new AXI4 peripheral”. Click “Next”.
4. Now you can give the peripheral an appropriate name, description and location.
http://www.fpgadeveloper.com/2014/08/creatingacustomipblockinvivado.html 3/36
9/20/2015 Creating a custom IP block in Vivado | FPGA Developer
Click “Next”.
5. On the next page we can configure the AXI bus interface. For the multiplier we’ll
use AXI lite, and it’ll be a slave to the PS, so we’ll stick with the default values.
http://www.fpgadeveloper.com/2014/08/creatingacustomipblockinvivado.html 4/36
9/20/2015 Creating a custom IP block in Vivado | FPGA Developer
6. On the last page, select “Edit IP” and click “Finish”. Another Vivado window will
open which will allow you to modify the peripheral that we just created.
http://www.fpgadeveloper.com/2014/08/creatingacustomipblockinvivado.html 5/36
9/20/2015 Creating a custom IP block in Vivado | FPGA Developer
At this point, the peripheral that has been generated by Vivado is an AXI lite slave
that contains 4 x 32 bit read/write registers. We want to add our multiplier code to
the IP and modify it so that one of the registers connects to the multiplier inputs and
another to the multiplier output.
https://github.com/fpgadeveloper/microzed-custom-
ip/blob/master/ip_repo/my_multiplier_1.0/src/multiplier.vhd
Note that these steps must be done in the Vivado window that contains the
peripheral we just created (not the base project).
http://www.fpgadeveloper.com/2014/08/creatingacustomipblockinvivado.html 6/36
9/20/2015 Creating a custom IP block in Vivado | FPGA Developer
2. In the window that appears, select “Add or Create Design Sources” and click “Next”.
http://www.fpgadeveloper.com/2014/08/creatingacustomipblockinvivado.html 7/36
9/20/2015 Creating a custom IP block in Vivado | FPGA Developer
The multiplier code is now added to the peripheral, however we still have to
instantiate it and connect it to the registers.
http://www.fpgadeveloper.com/2014/08/creatingacustomipblockinvivado.html 8/36
9/20/2015 Creating a custom IP block in Vivado | FPGA Developer
4. Now find the line that says “– Add user logic here” and add the following code
http://www.fpgadeveloper.com/2014/08/creatingacustomipblockinvivado.html 9/36
9/20/2015 Creating a custom IP block in Vivado | FPGA Developer
1. multiplier_0 : multiplier
2. port map (
3. clk => S_AXI_ACLK,
4. a => slv_reg0(31 downto 16),
5. b => slv_reg0(15 downto 0),
6. p => multiplier_out);
5. Find this line of code “reg_data_out <= slv_reg1;” and replace it with “reg_data_out
<= multiplier_out;”.
6. In the process statement just a few lines above, replace “slv_reg1” with
“multiplier_out”.
7. Save the file.
8. You should notice that the “multiplier.vhd” file has been integrated into the
hierarchy because we have instantiated it from within the peripheral.
9. Click on “IP File Groups” in the Package IP tab of the Project Manager.
http://www.fpgadeveloper.com/2014/08/creatingacustomipblockinvivado.html 10/36
9/20/2015 Creating a custom IP block in Vivado | FPGA Developer
10. Click the “Merge changes from IP File Group Wizard” link.
http://www.fpgadeveloper.com/2014/08/creatingacustomipblockinvivado.html 11/36
9/20/2015 Creating a custom IP block in Vivado | FPGA Developer
The peripheral will be packaged and the Vivado window for the peripheral should be
automatically closed. We should now be able to find our IP in the IP catalog. Now the
rest of this tutorial will be done from the original Vivado window.
http://www.fpgadeveloper.com/2014/08/creatingacustomipblockinvivado.html 12/36
9/20/2015 Creating a custom IP block in Vivado | FPGA Developer
3. The block should appear in the block diagram and you should see the message
“Designer Assistance available. Run Connection Automation”. Click the connection
automation link.
http://www.fpgadeveloper.com/2014/08/creatingacustomipblockinvivado.html 13/36
9/20/2015 Creating a custom IP block in Vivado | FPGA Developer
5. In the window that appears, set Clock connection to “Auto” and click “OK”.
http://www.fpgadeveloper.com/2014/08/creatingacustomipblockinvivado.html 14/36
9/20/2015 Creating a custom IP block in Vivado | FPGA Developer
8. When the bitstream is generated, select “Open the implemented design” and click
“OK”.
http://www.fpgadeveloper.com/2014/08/creatingacustomipblockinvivado.html 15/36