Skip to content

Building Driver Library for a Peripheral Core

mshahbaz edited this page Jul 23, 2012 · 2 revisions

In Xilinx EDK suite each peripheral core can be provided with an associated software driver. The driver can be a simple collection of register offsets, accessible from a host software, or a more complex set of functions for performing specialized tasks i.e. Flash I/O or MDIO etc.

Driver Organisation

Drivers in EDK have a predefined structure as shown in the table below:

|-- lib/sw/std|xilinx|contrib/drivers
|  |-- driver_vX-XX-a
|  |  |-- data
|  |  |  `-- .MDD
|  |  |  `-- .TCL
|  |  |-- src
|  |  |  `-- .C
|  |  |  `-- .H

.TCL

The .tcl script file copies the parameters we specify to the xparameters.h and other files during the library generation process.

Example: for nf10_mdio:

proc generate {drv_handle} {
  xdefine_include_file $drv_handle "xparameters.h" "XEmacLite" "NUM_INSTANCES" "DEVICE_ID" "C_BASEADDR" "C_HIGHADDR"    "C_TX_PING_PONG" "C_RX_PING_PONG" "C_INCLUDE_MDIO" "C_INCLUDE_INTERNAL_LOOPBACK"
  ...
}

This is the code generated in the xparameters.h file.

/* Definitions for driver NF10_MDIO */
#define XPAR_XEMACLITE_NUM_INSTANCES 1

/* Definitions for peripheral NF10_MDIO_0 */
#define XPAR_NF10_MDIO_0_DEVICE_ID 0
#define XPAR_NF10_MDIO_0_BASEADDR 0x7A000000
#define XPAR_NF10_MDIO_0_HIGHADDR 0x7A00FFFF
#define XPAR_NF10_MDIO_0_TX_PING_PONG 0
#define XPAR_NF10_MDIO_0_RX_PING_PONG 0
#define XPAR_NF10_MDIO_0_INCLUDE_MDIO 1
#define XPAR_NF10_MDIO_0_INCLUDE_INTERNAL_LOOPBACK 0

.MDD

The .mdd file looks like this. The "supported_peripherals" line tells which cores can use this driver and "copyfiles" line instructs the EDK tools to copy the source files into the user's sw directory.

OPTION psf_version = 2.1;

BEGIN driver nf10_mdio

  OPTION supported_peripherals = (nf10_mdio_v1_[0-9][0-9]_[a-z]);
  OPTION driver_state = ACTIVE;
  OPTION depends = (common_v1_00_a);
  OPTION copyfiles = all;

END driver

For more information visit [1] and [2].

Examples

Following are some examples provided with NetFPGA-10G platform:

  1. nf10_mdio
  2. emc

External References

  1. FPGA design from scratch. Part38 - Writing software for our embedded system
  2. xilinx_drivers_guide.pdf: EDK_install_dir/doc/usenglish/xilinx_drivers_guide.pdf
Clone this wiki locally