FSL Events Tutorial


Learning Objectives

  1. Learn how to incorporate a new core (FSL Peripheral) into a project.
  2. Learning the basic operation of the FSL Event Handler Peripheral.


Learning Resources

  1. Course lectures.
  2. EDK documentation (located in C:\EDK\Docs).


Tutorial Overview

    This tutorial will walk you through adding an existing IP core to a project you create. In addition, you will learn the basics of using the FSL Event Handler to create interactive MicroBlaze C programs.


Preparing for the tutorial

  1. Copy your Hello_World EDK project to a new directory where you will modify it. This tutorial will use FslEvents as the project directory name.
  2. Download the supplied system.c file into your project directory (the FslEvents directory).


The Tutorial - Quick Steps

  1. Open your project
  2. Add the public peripherals directory to your project.
  3. Add IP cores to the project.
  4. Modify the system.ucf file.
  5. Configure the peripherals.
  6. Build and download your bit file.


The Tutorial - Detailed steps

  1. Open the newly copied EDK Project
    Double click on the system.xmp file in your FslEvents Directory.
  2. Click on the "Project" menu and select "Project Options..."
    The "Project Options" Dialog box will open.
  3. Type "P:\EDK_Peripherals" in the "Peripheral Repository Directory" text area.
  4. Click "OK".
  5. It will tell you that you have changed the library search path, and it will ask you if you want to save the settings now and rescan the directories.
  6. Click "Yes".
  7. Quit out of EDK by going to the "File" menu and selecting "Exit"
  8. Re-Open the EDK Project
    by double clicking on the system.xmp file in your FslEvents Directory.
  9. Add IP Cores.
    1. Click on the "Project" menu and select the option "Add/Edit Cores..."
    2. In the "Add/Edit Hardware Platform Specifications" dialog box, do the following:
    3. Add the new Peripherals
      1. Select the "Peripherals" tab if it is not already selected.
      2. Add an fsl_event_handler peripheral.
      3. Add an opb_gpio peripheral.
      4. Add a reset_debounce peripheral.
      5. Click the Apply button. (This just saves your changes without closing the dialog box)
    4. Add and configure buses.
      1. Select the "Bus Connections" tab.
      2. Add two FSL buses (fsl_v20_v2_00_a).
      3. Attach the GPIO peripheral as a slave on the OPB Bus.
      4. Select the "Parameters" tab.
      5. On the right hand side select "MicroBlaze_0"
      6. Add the "C_FSL_Links" parameter and change its value to "1". (This creates one bi-directional FSL Port on the MicroBlaze)
      7. Go back to the "Bus Connections" tab.
      8. Attach the MicroBlaze and the event handler to the FSL buses.
      9. When finished, the Bus Connections tab should appear as follows:



      10. Click the Apply button.
    5. Assign Peripheral Addresses.
      1. Select the "Addresses" tab.
      2. Set the base address of the OPB_GPIO peripheral to the next available address (It should be 0x80000200).
      3. Set the size of the OPB_GPIO peripheral to 512.
      4. Click the Apply button.
    6. Update ports.
      1. Select the "Ports" tab.
      2. For the fsl_v20_0, do the following:
        1. Add FSL_Clk
        2. Add SYS_Rst
        3. Rename FSL_Clk Net Name to Clk50Mhz.
        4. Rename SYS_Rst Net Name to RstSig.
      3. For the fsl_v20_1, do the same.
      4. For the obp_gpio_0, do the following:
        1. Add GPIO_IO
        2. Rename GPIO Net Name to IO.
        3. Select the IO Net and click "Make External"
        4. Set the IO range field (In the top window pane) to [0:13].
      5. For the fsl_event_handler_0, do the following:
        1. Add sys_clk
        2. Add sys_rst
        3. Add Buttons
        4. Rename sys_clk Net Name to Clk50Mhz.
        5. Rename sys_rst Net Name to RstSig.
        6. Rename Buttons Net Name to EHButtons.
        7. Select the EHButtons Net and click "Make External"
        8. Set the EHButtons range field (In the top window pane) to [0:1].
      6. For the reset_debounce, do the following:
        1. Add CLK
        2. Add BTN_IN
        3. Add RST_OUT
        4. Rename CLK Net Name to Clk50Mhz.
        5. Rename BTN_IN Net Name to BTN0.
        6. Rename RST_OUT Net Name to RstSig.
        7. Change all other BTN0 signals (except for the BTN_IN of the reset_debounce) to RstSig. You should only need to change them in both the LMB Buses, and the OPB Bus.
      7. When finished, the Bus Connections tab should appear as follows:



      8. Click the Apply button.
    7. Update your ucf file.
      1. In the windows explorer, open your project directory (the FslEvents directory)
      2. In your project directory there should be a "data" directory. Open it.
      3. In the data directory there should be a system.ucf file. Open it in emacs by double clicking it.
      4. In your ucf file you will need to add SW0, SW1, SW2, BTN1, the signals for the 7-segment display.
        1. BTN1 should be renamed to EHButtons<0>
        2. SW0 should be renamed to EHButtons<1>
        3. SW2 should be renamed to IO<0>
        4. SW1 should be renamed to IO<1>
        5. AN3 should be renamed to IO<2>
        6. AN2 should be renamed to IO<3>
        7. AN1 should be renamed to IO<4>
        8. AN0 should be renamed to IO<5>
        9. CA should be renamed to IO<6>
        10. CB should be renamed to IO<7>
        11. CC should be renamed to IO<8>
        12. CD should be renamed to IO<9>
        13. CE should be renamed to IO<10>
        14. CF should be renamed to IO<11>
        15. CG should be renamed to IO<12>
        16. CDP should be renamed to IO<13>
      5. Save your changes and quit out of emacs.
      6. Return to Platform Studio (EDK) where we left it. You should still have the "Add/Edit Hardware Platform Specifications" dialog open to the "Ports" Tab.
      7. Set the Parameters for the new peripherals.
        1. Select the "Parameters" tab.
        2. On the right hand side select "event_handler_0" and set the following parameters
          1. Add the "C_USE_CUSTOMS" parameter and change its value to "0".
          2. Add the "C_USE_KEYBOARD" parameter and change its value to "0".
          3. Add the "C_USE_MOUSE" parameter and change its value to "0".
          4. Add the "C_NUM_TIMERS" parameter and change its value to "2".
          5. Add the "C_NUM_BUTTONS" parameter and change its value to "2".
          6. Add the "C_DEBOUNCE_CLKS" parameter and change its value to "16384".
        3. On the right hand side select "opb_gpio_0" and set the following parameters
          1. Add the "C_GPIO_WIDTH" parameter and change its value to "14".
    8. Click the OK button. This will close the "Add/Edit Hardware Platform Specifications" dialog.
  10. Build and download your bit file.
    1. Click the download button on the toolbar (to compile and download your project to the Xilinx board):