Changes between Version 2 and Version 3 of custom_periphs/file_structure


Ignore:
Timestamp:
Jul 11, 2006, 10:01:10 PM (18 years ago)
Author:
snovich
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • custom_periphs/file_structure

    v2 v3  
    11= The File Structure for XPS/EDK-based Peripherals =
    22
    3 [[Image(periph_heirch.png, align=center)]]
    4 
     3[[Image(periph_heirch.png, align=center)]][[BR]]
     4
     5== Intro ==
     6Discounting the PowerPC control elements in XPS-based peripherals, if the user is proficient in HDL-programming, he or she should have no issues putting a peripheral together in XPS-format and running it on the target board. Now onto the file types and they’re layouts, using WARP’s radio_controller_v1_03_a as an example. [[BR]]
     7
     8== The Hardware-Side ==
     9The hardware directory structure is as follows: the peripheral folder sits in the '''\pcores''' folder for an EDK repository or a project repository. '''Naming''' is key for everything here. For the peripherals main directory, the name of the '''top-level''' verilog or VHDL file must be used. If this peripheral has multiple versions, the user may append a _vX_XX_B, where the X’s are version numbers and B is the version letter. Beneath this directory there typically sit 3 or 4 folders: “data,” “hdl,” “netlist,” and sometimes “devl,” which is less important. [[BR]]
     10
     11=== \devl ===
     12  The '''“devl”''' directory is a sometimes auto-generated directory that contains a project-navigator version of the peripheral for debugging purposes. The folder is not utilized in XPS. [[BR]]
     13
     14=== \netlist ===
     15  The '''“netlist”''' directory is only required when black-box netlist files are used in place of HDL for certain modules. An example is the FIFO-generator in coregent. It will output NGC/EDN files which must be placed in the “netlist” directory if the FIFO is to be used as a sub-module for your peripheral.[[BR]]
     16
     17=== \hdl ===
     18  The '''“hdl”''' directory contains two sub-folders: one for verilog files and the other for vhdl files. All of the peripheral’s hdl files go into their respective folders based on extension-type. It should be noted that XPS allows for mixed-HDL peripherals. Secondarily, as stated early, it’s very important to use the peripherals '''top-level''' HDL files for naming the peripherals master directory and corresponding data files.[[BR]]
     19
     20=== \data ===
     21  The '''“data”''' directory contains a *.pao file, a *.mpd file, and sometimes a *.bbd file, which stand for “Peripheral Analysis Order,” “Microprocessor Peripheral Description,” and “Black Box Definition,” respectively. All of these files must have the same name of the top-level verilog file appended with “_v2_1_0” for use in EDK8. For example, the radio controller’s data files are named, “radio_controller_v2_1_0.mpd” and “radio_controller_v2_1_0.pao.” [[BR]]
     22
     23=== The PAO file ===
     24  The '''“pao”''' file is a list of all the verilog/vhdl files that appear in the peripheral and what library they belong to. Technically, if the reader is coding all of this by hand, the only library present will most likely be the top-level. The general format is as follows:[[BR]]
     25{{{
     26 lib <peripheral_name>_vX_XX_B <file/module-name> verilog/vhdl
     27}}}
     28Typically it’s good practice to list the modules in hierarchal order, but generating may still work so long as just the top-level module is listed last. Here is “radio_controller_v2_1_0.pao” as an example: [[BR]]
     29{{{
     30lib proc_common_v2_00_a proc_common_pkg vhdl
     31lib proc_common_v2_00_a family vhdl
     32lib proc_common_v2_00_a or_muxcy vhdl
     33lib proc_common_v2_00_a or_gate vhdl
     34lib proc_common_v2_00_a counter_bit vhdl
     35lib proc_common_v2_00_a counter vhdl
     36lib proc_common_v2_00_a inferred_lut4 vhdl
     37lib proc_common_v2_00_a srl_fifo2 vhdl
     38lib proc_common_v2_00_a pf_counter_bit vhdl
     39lib proc_common_v2_00_a pf_counter vhdl
     40lib proc_common_v2_00_a pf_counter_top vhdl
     41lib proc_common_v2_00_a pf_occ_counter vhdl
     42lib proc_common_v2_00_a pf_occ_counter_top vhdl
     43lib proc_common_v2_00_a pf_adder_bit vhdl
     44lib proc_common_v2_00_a pf_adder vhdl
     45lib proc_common_v2_00_a pf_dpram_select vhdl
     46lib proc_common_v2_00_a srl16_fifo vhdl
     47lib proc_common_v2_00_a pselect vhdl
     48lib proc_common_v2_00_a valid_be vhdl
     49lib proc_common_v2_00_a ld_arith_reg vhdl
     50lib proc_common_v2_00_a mux_onehot vhdl
     51lib proc_common_v2_00_a down_counter vhdl
     52lib proc_common_v2_00_a ipif_pkg vhdl
     53lib proc_common_v2_00_a ipif_steer vhdl
     54lib proc_common_v2_00_a direct_path_cntr_ai vhdl
     55lib interrupt_control_v1_00_a interrupt_control vhdl
     56lib wrpfifo_v1_01_b pf_dly1_mux vhdl
     57lib wrpfifo_v1_01_b ipif_control_wr vhdl
     58lib wrpfifo_v1_01_b wrpfifo_dp_cntl vhdl
     59lib wrpfifo_v1_01_b wrpfifo_top vhdl
     60lib rdpfifo_v1_01_b ipif_control_rd vhdl
     61lib rdpfifo_v1_01_b rdpfifo_dp_cntl vhdl
     62lib rdpfifo_v1_01_b rdpfifo_top vhdl
     63lib opb_ipif_v3_01_c reset_mir vhdl
     64lib opb_ipif_v3_01_c brst_addr_cntr vhdl
     65lib opb_ipif_v3_01_c opb_flex_addr_cntr vhdl
     66lib opb_ipif_v3_01_c brst_addr_cntr_reg vhdl
     67lib opb_ipif_v3_01_c opb_be_gen vhdl
     68lib opb_ipif_v3_01_c srl_fifo3 vhdl
     69lib opb_ipif_v3_01_c write_buffer vhdl
     70lib opb_ipif_v3_01_c opb_bam vhdl
     71lib opb_ipif_v3_01_c opb_ipif vhdl
     72lib radio_controller_v1_03_a user_logic verilog
     73lib radio_controller_v1_03_a spi_top verilog
     74lib radio_controller_v1_03_a spi_shift verilog
     75lib radio_controller_v1_03_a spi_clgen verilog
     76lib radio_controller_v1_03_a spi_defines verilog
     77lib radio_controller_v1_03_a timescale verilog
     78lib radio_controller_v1_03_a radio_controller vhdl 
     79}}}
     80
     81This particular example contains other EDK libraries that were auto-generated from XPS. Auto-generation processes will be discussed in later sections. [[BR]]
     82
     83=== The MPD file ===
     84The '''“mpd”''' file is the most important file XPS uses for the peripheral. This file firstly lists synthesis/peripheral options used by XPS, bus-interface definitions and parameters if used, and all of the top-level ports. The file may also contain code used for *.xbd integration. Here is “radio_controller_v2_1_0.mpd” as an example:
     85{{{
     86###################################################################
     87##
     88## Name     : radio_controller
     89## Desc     : Microprocessor Peripheral Description
     90##          : Automatically generated by PsfUtility
     91##
     92###################################################################
     93
     94BEGIN radio_controller
     95
     96## Peripheral Options
     97OPTION IPTYPE = PERIPHERAL
     98OPTION IMP_NETLIST = TRUE
     99OPTION CORE_STATE = ACTIVE
     100OPTION IP_GROUP = MICROBLAZE:PPC:USER
     101OPTION USAGE_LEVEL = BASE_USER
     102OPTION HDL = MIXED
     103
     104#OPTION IPTYPE = PERIPHERAL
     105#OPTION IMP_NETLIST = TRUE
     106#OPTION HDL = MIXED
     107#OPTION IP_GROUP = MICROBLAZE:PPC:USER
     108#OPTION CORE_STATE = DEVELOPMENT
     109#OPTION USAGE_LEVEL = BASE_USER
     110
     111IO_INTERFACE IO_IF = radio_controller, IO_TYPE = WARP_RADIOCONTROLLER_V1
     112
     113
     114## Bus Interfaces
     115BUS_INTERFACE BUS = SOPB, BUS_TYPE = SLAVE, BUS_STD = OPB
     116
     117## Generics for VHDL or Parameters for Verilog
     118PARAMETER C_BASEADDR = 0xffffffff, DT = std_logic_vector, MIN_SIZE = 0x100, BUS = SOPB, ADDRESS = BASE, PAIR = C_HIGHADDR
     119PARAMETER C_HIGHADDR = 0x00000000, DT = std_logic_vector, BUS = SOPB, ADDRESS = HIGH, PAIR = C_BASEADDR
     120PARAMETER C_OPB_AWIDTH = 32, DT = INTEGER, BUS = SOPB
     121PARAMETER C_OPB_DWIDTH = 32, DT = INTEGER, BUS = SOPB
     122PARAMETER C_FAMILY = virtex2p, DT = STRING
     123
     124## Ports
     125PORT OPB_Clk = "", DIR = I, SIGIS = Clk, BUS = SOPB
     126PORT OPB_Rst = OPB_Rst, DIR = I, SIGIS = Rst, BUS = SOPB
     127PORT Sl_DBus = Sl_DBus, DIR = O, VEC = [0:(C_OPB_DWIDTH-1)], BUS = SOPB
     128PORT Sl_errAck = Sl_errAck, DIR = O, BUS = SOPB
     129PORT Sl_retry = Sl_retry, DIR = O, BUS = SOPB
     130PORT Sl_toutSup = Sl_toutSup, DIR = O, BUS = SOPB
     131PORT Sl_xferAck = Sl_xferAck, DIR = O, BUS = SOPB
     132PORT OPB_ABus = OPB_ABus, DIR = I, VEC = [0:(C_OPB_AWIDTH-1)], BUS = SOPB
     133PORT OPB_BE = OPB_BE, DIR = I, VEC = [0:((C_OPB_DWIDTH/8)-1)], BUS = SOPB
     134PORT OPB_DBus = OPB_DBus, DIR = I, VEC = [0:(C_OPB_DWIDTH-1)], BUS = SOPB
     135PORT OPB_RNW = OPB_RNW, DIR = I, BUS = SOPB
     136PORT OPB_select = OPB_select, DIR = I, BUS = SOPB
     137PORT OPB_seqAddr = OPB_seqAddr, DIR = I, BUS = SOPB
     138
     139PORT spi_clk = "", DIR = O
     140PORT data_out = "", DIR = O
     141PORT radio1_cs = "", DIR = O
     142PORT radio2_cs = "", DIR = O
     143PORT radio3_cs = "", DIR = O
     144PORT radio4_cs = "", DIR = O
     145PORT dac1_cs = "", DIR = O
     146PORT dac2_cs = "", DIR = O
     147PORT dac3_cs = "", DIR = O
     148PORT dac4_cs = "", DIR = O
     149PORT radio1_SHDN = "", DIR = O
     150PORT radio1_TxEn = "", DIR = O
     151PORT radio1_RxEn = "", DIR = O
     152PORT radio1_RxHP = "", DIR = O
     153PORT radio1_LD = "", DIR = I
     154PORT radio1_24PA = "", DIR = O
     155PORT radio1_5PA = "", DIR = O
     156PORT radio1_ANTSW = "", DIR = O, VEC = [0:1], IO_IS = radio1_antsw
     157PORT radio1_LED = "", DIR = O, VEC = [0:2], IO_IS = radio1_LED
     158PORT radio1_ADC_RX_DCS = "", DIR = O
     159PORT radio1_ADC_RX_DFS = "", DIR = O
     160PORT radio1_ADC_RX_OTRA = "", DIR = I
     161PORT radio1_ADC_RX_OTRB = "", DIR = I
     162PORT radio1_ADC_RX_PWDNA = "", DIR = O
     163PORT radio1_ADC_RX_PWDNB = "", DIR = O
     164PORT radio1_DIPSW = "", DIR = I, VEC = [0:3], IO_IS = radio1_dipsw
     165PORT radio1_RSSI_ADC_CLAMP = "", DIR = O
     166PORT radio1_RSSI_ADC_HIZ = "", DIR = O
     167PORT radio1_RSSI_ADC_OTR = "", DIR = I
     168PORT radio1_RSSI_ADC_SLEEP = "", DIR = O
     169PORT radio1_RSSI_ADC_D = "", DIR = I, VEC = [0:9], IO_IS = radio1_rssi_ADC_D
     170PORT radio1_TX_DAC_PLL_LOCK = "", DIR = I
     171PORT radio1_TX_DAC_RESET = "", DIR = O
     172PORT radio1_RxHP_external = "", DIR = I
     173PORT radio2_SHDN = "", DIR = O
     174PORT radio2_TxEn = "", DIR = O
     175PORT radio2_RxEn = "", DIR = O
     176PORT radio2_RxHP = "", DIR = O
     177PORT radio2_LD = "", DIR = I
     178PORT radio2_24PA = "", DIR = O
     179PORT radio2_5PA = "", DIR = O
     180PORT radio2_ANTSW = "", DIR = O, VEC = [0:1], IO_IS = radio2_antsw
     181PORT radio2_LED = "", DIR = O, VEC = [0:2], IO_IS = radio2_LED
     182PORT radio2_ADC_RX_DCS = "", DIR = O
     183PORT radio2_ADC_RX_DFS = "", DIR = O
     184PORT radio2_ADC_RX_OTRA = "", DIR = I
     185PORT radio2_ADC_RX_OTRB = "", DIR = I
     186PORT radio2_ADC_RX_PWDNA = "", DIR = O
     187PORT radio2_ADC_RX_PWDNB = "", DIR = O
     188PORT radio2_DIPSW = "", DIR = I, VEC = [0:3], IO_IS = radio2_dipsw
     189PORT radio2_RSSI_ADC_CLAMP = "", DIR = O
     190PORT radio2_RSSI_ADC_HIZ = "", DIR = O
     191PORT radio2_RSSI_ADC_OTR = "", DIR = I
     192PORT radio2_RSSI_ADC_SLEEP = "", DIR = O
     193PORT radio2_RSSI_ADC_D = "", DIR = I, VEC = [0:9], IO_IS = radio2_rssi_ADC_D
     194PORT radio2_TX_DAC_PLL_LOCK = "", DIR = I
     195PORT radio2_TX_DAC_RESET = "", DIR = O
     196PORT radio2_RxHP_external = "", DIR = I
     197PORT radio3_SHDN = "", DIR = O
     198PORT radio3_TxEn = "", DIR = O
     199PORT radio3_RxEn = "", DIR = O
     200PORT radio3_RxHP = "", DIR = O
     201PORT radio3_LD = "", DIR = I
     202PORT radio3_24PA = "", DIR = O
     203PORT radio3_5PA = "", DIR = O
     204PORT radio3_ANTSW = "", DIR = O, VEC = [0:1], IO_IS = radio3_antsw
     205PORT radio3_LED = "", DIR = O, VEC = [0:2], IO_IS = radio3_LED
     206PORT radio3_ADC_RX_DCS = "", DIR = O
     207PORT radio3_ADC_RX_DFS = "", DIR = O
     208PORT radio3_ADC_RX_OTRA = "", DIR = I
     209PORT radio3_ADC_RX_OTRB = "", DIR = I
     210PORT radio3_ADC_RX_PWDNA = "", DIR = O
     211PORT radio3_ADC_RX_PWDNB = "", DIR = O
     212PORT radio3_DIPSW = "", DIR = I, VEC = [0:3], IO_IS = radio3_dipsw
     213PORT radio3_RSSI_ADC_CLAMP = "", DIR = O
     214PORT radio3_RSSI_ADC_HIZ = "", DIR = O
     215PORT radio3_RSSI_ADC_OTR = "", DIR = I
     216PORT radio3_RSSI_ADC_SLEEP = "", DIR = O
     217PORT radio3_RSSI_ADC_D = "", DIR = I, VEC = [0:9], IO_IS = radio3_rssi_ADC_D
     218PORT radio3_TX_DAC_PLL_LOCK = "", DIR = I
     219PORT radio3_TX_DAC_RESET = "", DIR = O
     220PORT radio3_RxHP_external = "", DIR = I
     221PORT radio4_SHDN = "", DIR = O
     222PORT radio4_TxEn = "", DIR = O
     223PORT radio4_RxEn = "", DIR = O
     224PORT radio4_RxHP = "", DIR = O
     225PORT radio4_LD = "", DIR = I
     226PORT radio4_24PA = "", DIR = O
     227PORT radio4_5PA = "", DIR = O
     228PORT radio4_ANTSW = "", DIR = O, VEC = [0:1], IO_IS = radio4_antsw
     229PORT radio4_LED = "", DIR = O, VEC = [0:2], IO_IS = radio4_LED
     230PORT radio4_ADC_RX_DCS = "", DIR = O
     231PORT radio4_ADC_RX_DFS = "", DIR = O
     232PORT radio4_ADC_RX_OTRA = "", DIR = I
     233PORT radio4_ADC_RX_OTRB = "", DIR = I
     234PORT radio4_ADC_RX_PWDNA = "", DIR = O
     235PORT radio4_ADC_RX_PWDNB = "", DIR = O
     236PORT radio4_DIPSW = "", DIR = I, VEC = [0:3], IO_IS = radio4_dipsw
     237PORT radio4_RSSI_ADC_CLAMP = "", DIR = O
     238PORT radio4_RSSI_ADC_HIZ = "", DIR = O
     239PORT radio4_RSSI_ADC_OTR = "", DIR = I
     240PORT radio4_RSSI_ADC_SLEEP = "", DIR = O
     241PORT radio4_RSSI_ADC_D = "", DIR = I, VEC = [0:9], IO_IS = radio4_rssi_ADC_D
     242PORT radio4_TX_DAC_PLL_LOCK = "", DIR = I
     243PORT radio4_TX_DAC_RESET = "", DIR = O
     244PORT radio4_RxHP_external = "", DIR = I
     245
     246END
     247}}}
     248
     249Aside from the top-level ports and XBD information, almost all of this code was auto-generated by XPS.  The IO_INTERFACE IO_IF = radio_controller, IO_TYPE = WARP_RADIOCONTROLLER_V1 and IO_IS =” ” are used for interfacing the peripheral with the XBD file. If netlists are used in the peripheral, in which this example they aren’t, '''“OPTION RUN_NGCBUILD = TRUE”''' must be added to the option’s section. [[BR]]
     250
     251=== The BBD file ===
     252  Finally, the '''“bbd”''' file, is simply a list of all netlist files that have been included with the project. Here is an example for a FIFO that was built in CoreGenerator:
     253{{{
     254FILES
     255################################################################################
     256xmit_buffer_fifo.edn, xmit_buffer_fifo_fifo_generator_v2_1_as_1.ngc, xmit_buffer_fifo_fifo_generator_v2_1_as_1_blkmemdp_v6_2_xst.edn
     257}}}
     258'''''More information on the proper formatting for all of these filetypes may be found in: //EDK/doc/psf_rm.pdf'''''[[BR]][[BR]]
     259
     260==  The Software-Side ==
     261At this point, the provided information is all that a HDL-proficient user should need to create a non-powerPC controlled peripheral in XPS. Implementing PowerPC control is not an easy task to accomplish by hand – as the PowerPC controls peripherals via a built-in BUS interface. XPS provides easy methods for accomplishing this through automatically generating templates that a user’s hdl can be inserted under.[[BR]]
     262In the '''“drivers”''' directory for the EDK repository or project, the peripheral’s driver folder will sit. It must use the '''same exact name''' as it’s counterpart in the '''"pcores"''' directory (top-level hdl name with version information appended if necessary). Within this folder, there sits the “data” and “src” directory. [[BR]]
     263
     264=== \src ===
     265  The '''“src”''' directory contains the peripherals associated C-code files and a file called “Makefile.” [[BR]]
     266
     267=== \data ===
     268The '''“data”''' directory contains two files: “<peripheral_name>_v2_1_0.mdd” and “<peripheral_name>_v2_1_0.tcl.” [[BR]]
     269
     270''All three of these files (the Makefile, MDD, and TCL) contain information XPS uses to essentially connect the drivers with hardware during bitstream generation''[[BR]]
     271       
     272Provided below are examples of each of these three files, but it is strongly suggested that the user allows XPS to generate these files automatically as will be described in later sections of this guide. '''THIS GUIDE WILL NOT EXPLAIN HOW TO BUILD POWER-PC-CONTROLLABLE PERIPHERALS BY HAND.''' [[BR]]
     273
     274=== “radio_controller_v2_1_0.mdd” ===
     275{{{
     276OPTION psf_version = 2.1.0;
     277
     278BEGIN DRIVER radio_controller
     279
     280  OPTION supported_peripherals = (radio_controller);
     281  OPTION depends = (common_v1_00_a);
     282  OPTION copyfiles = all;
     283
     284END DRIVER
     285}}}
     286
     287=== “radio_controller_v2_1_0.tcl” ===
     288{{{
     289#uses "xillib.tcl"
     290
     291proc generate {drv_handle} {
     292  xdefine_include_file $drv_handle "xparameters.h" "radio_controller" "NUM_INSTANCES" "DEVICE_ID" "C_BASEADDR" "C_HIGHADDR"
     293}
     294}}}
     295
     296=== “Makefile” ===
     297{{{
     298COMPILER=
     299ARCHIVER=
     300CP=cp
     301COMPILER_FLAGS=
     302EXTRA_COMPILER_FLAGS=
     303LIB=libxil.a
     304
     305RELEASEDIR=../../../lib
     306INCLUDEDIR=../../../include
     307INCLUDES=-I./. -I${INCLUDEDIR}
     308
     309INCLUDEFILES=*.h
     310LIBSOURCES=*.c
     311OUTS = *.o
     312
     313libs:
     314        echo "Compiling radio_controller"
     315        $(COMPILER) $(COMPILER_FLAGS) $(EXTRA_COMPILER_FLAGS) $(INCLUDES) $(LIBSOURCES)
     316        $(ARCHIVER) -r ${RELEASEDIR}/${LIB} ${OUTS}
     317        make clean
     318
     319include:
     320        ${CP} $(INCLUDEFILES) $(INCLUDEDIR)
     321
     322clean:
     323        rm -rf ${OUTS}
     324}}}