• LOGIN

HThreads

Home › EECS 388 Laboratory

Laboratory 5

In laboratory 5 you will be creating a simple, interrupt-based system-on-chipi design. You will be instantiating three GPIOi devices in your system-on-chipi design and will write software which will respond to interrupts generated by those GPIOi devices. The software that you write for this laboratory will be a mixture of high-level C code and low-level assembly. Additionally, you will make use of some Xilinxi provided low-level interrupt routines. Reading and understanding the interrupt handling tutorial will help you complete this project.

Project Description

This purpose of this project is two fold. First, students should learn how to use functions written in assembly in C programs and how to use functions written in C in assembly programs. Second, students should learn how hardware interrupts are handled at the processor level, the assembly level, and the C level. Additionally, the software developed in this laboratory project should demonstrate how a running program can be interrupted by the processor so that another function can be executed. Because interrupts represent asynchronous, non-standard control flow in software programs the description of this project is complex, however, the developed software should be relatively simple.

The software for this project should consist of at least six functions. You are required to have these six functions in your demonstrated project. First, you should have a main function which enables interrupts in the system and then calls the main_loop function. The main_loop function should infinitely loop. Each loop should prompt the user for two numbers using the serial port, add the two numbers together, and then print out all of the prime numbers less than the result. This represents the main processing of the application.

You will also have four functions which perform auxiliary processing when interrupts occur. The first function should be intr_handler. This function, which should be written in assembly, will need to query the programmable interrupt controller to determine what interrupt occurs. If the interrupt was from the DIPSW GPIOi then the function handle_dipsw should be called and if the interrupt was from the push button GPIOi then the function handle_pb should be called. These two functions should be written in C and should perform the processing described below. The last function you will write is the write_leds functions, which should be written in assembly. This function will be used by the handle_dipsw and handle_pb functions and it used to illuminate certain LEDs.

Project Directions

  1. Create a system-on-chipi design using the BSB wizard
    Your system-on-chipi design needs to include a MicroBlazei soft-processori and RS-232 Serial port as is standard for the designs in this class. Additionally, for this project you should include the LEDi, DIPSW, and Push Button GPIOs. When enabling these devices make sure to select the "Use Interrupt" option. Otherwise your system will not include the necessary programmable interrupt controller (PIC).
  2. Write your high-level C functions
    Your high-level C function will comprise most of the software for this project. Any functionality you need for this project, except the functionality explicitly mentioned in the low-level assembly functions, can be code in C. You will most likely need to read the GPIOi and interrupt controller reference manuals to figure out exactly how to enable interrupts on the system. These manuals can be found in the reference materials. At a minimum you will need to do the following:
    1. Write your main function
      • Register your assembly level interrupt handler using the Xilinxi libraries
      • Enable interrupts on all of the GPIOi devices
      • Enable interrupts on the programmable interrupt controller
      • Enable interrupts on the MicroBlazei soft-processori.
    2. Write the handle_dipsw function
      • If the left-most switch is active then light the left-most LEDi
      • If the second-to-left switch is active then light the second-to-left LEDi
      • If the second-to-right switch is active then light the second-to-right LEDi
      • If the right-most switch is active then light the right-most LEDi
    3. Write the handle_pb function
      • If the up or right button is pressed then shift the LEDs to the right
      • If the down or left button is pressed then shift the LEDs to the left
      • If the middle button is pressed then restore the LEDs to the state of the DIPSWs
    4. Write the main_loop function
      • Prompt the user to enter two numbers using the serial port
      • Add the two number together
      • Print out all of the prime numbers less than the addition result
  3. Write your low-level assembly functions
    For this project you will be writing two assembly level functions. The first function will be your low-level interrupt handler. This function should be called intr_handler and it should be a function with no parameters and no return value. The function itself will need to examine the programmable interrupt controller and determine which interrupt occurred. If the interrupt was from the DIPSW peripheral then you will need to call the C function handle_dipsw. If the interrupt was from the push button peripheral then you will need to call the C function handle_pb. If the interrupt was from neither of these two sources then your system has not been properly configured as you should be masking out any unimportant interrupts.

    The second function that you will write in assembly will be a function called write_leds. This function should be a function of two parameters. The first parameter should be the base address of the LEDi GPIOi and the second parameter should be an unsigned integer value which indicates which light on the LEDi to illuminate. This function must be called by your handle_dipsw and handle_pb C functions.

  4. Synthesize your system-on-chipi design, compile your software, and combine them into a bitstream.
  5. Download your bitstream onto the XUPi development board, execute it, and demonstrate your working design to your TA.

Project Questions

  1. How do you call a C function from assembly language?
  2. How do you call an assembly function from C?
  3. How do you register an interrupt handler using the Xilinxi libraries?
  4. What does the programmable interrupt controller (PIC) do? What registers are exposed to the software?
  5. When a hardware device generated an interrupt what happens in the rest of the system? Describe what happens in the PIC, what happens in the CPU, and what the software does.
‹ Laboratory 4 up Laboratory 6 ›
  • Printer-friendly version

Navigation

  • Home
  • EECS 388
  • FPGA Tutorials
  • MicroBlaze Tutorials
  • Frequently Asked Questions
  • Glossary
  • Search

Book navigation

  • EECS 388 Laboratory
    • Syllabus
    • Deliverables
    • Report Format
    • Reference Materials
    • Project Submission
    • Laboratory 1
    • Laboratory 2
    • Laboratory 3
    • Laboratory 4
    • Laboratory 5
    • Laboratory 6
  • Tutorials

(C) 2008 Wesley Peck
All Rights Reserved