Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 3

VHDL/FPGA Microprocessor Design 525.

442 Assignment 6: Embedded Picoblaze Microprocessor Introduction: As discussed in the lecture, including a small microprocessor in your FPGA design can be a very convenient tool. With a combined hardware/software system, the designer can partition tasks based on the requirements algorithmically complex tasks can be handled in software, while computationally intensive ones can be handled in hardware. Furthermore, the flexibility inherent in software is obviously invaluable at times. This lab will serve as an introduction to the practice of using embedded soft-core microprocessors as part of a larger FPGA design.

Part I: Picoblaze Tutorial For this exercise, the soft-core micro that we will use is the Xilinx Picoblaze. The small size of this processor means that it is essentially free in our FPGA, with practically no resource usage. To get started, visit www.echelonembedded.com/fpgaresources and download the picoblaze sample design and corresponding tutorial for the NEXYS2 board. This includes an entire picoblaze based project, which has interfaces to a serial port, switches, buttons, LEDs, etc. The tutorial will lead you through the entire construction of the project, as well as changing the application software. Follow through the entire process, and make sure that you can replicate the behavior on your own machine. Note: This design uses the JTAG loader method of changing software. This allows you to change application code, recompile, reload, and re-run the application on the FPGA in a matter of a couple seconds.

Part II: A simple Microcontroller calculator This lab will help familiarize the student with programming in assembly language for the Picoblaze processor. It is intended that all of this functionality be created without any hardware changes to the Picoblaze sample design that was provided to the student. In other words, this section of the lab is software only. The functionality of this design will be a very simple calculator. The calculator will take a 4-bit input value and either add or subtract it from a running total stored within the microcontroller. In addition, the stored value in the microcontroller can be shifted either right or left as well. The microcontroller will also display the value that it has stored on the two rightmost 7-segment LED displays. This 8 bit value can be driven out through PortOut0. An input port (PortIn0) from the slider switches will be implemented on the PicoBlaze. The port will be 8 bits wide, corresponding to sliderswitches 7 to 0. For this port, the lower nibble (bits 3 0) is the 4-bit input operand. The upper nibble (bits 7 4) is the operation control. The pushbuttons are on the lower 4 bits of a second port (PortIn1). An operation occurs when pushbutton 0 is pressed, according to the following rules:

Sliderswitch(4)=1 Sliderswitch(5)=1 Sliderswitch(6)=1 Sliderswitch(7)=1

Add Port0 value to total Subtract Port0 from total Shift total left by Port0[3:0] bits Shift total right by Port0[3:0] bits

Note that if more than one sliderswitch is active, the lowest active bit has priority, i.e. subtract takes priority over shift left. The total is reset when pushbutton 3 is pressed. Pushbuttons 1 and 2 have no effect. Tasks:


Notes:

Create a top-level architecture that will hold your microcontroller implementation along with any other logic required (this is done for you by the sample project) Create an assembly language program which polls the pushbuttons for input and then acts accordingly. Remember that you want only one action per press of pushbutton 0! Assemble the code and test using the SVF download feature described in the tutorial

The value displayed on the LEDs should be in hexadecimal. You do not have to convert to a decimal representation.

Part III: A Simple Picoblaze Peripheral In this section of the lab, we will design a simple pulse-width modulator peripheral for the picoblaze processor, and demonstrate its control from software. For this section of the lab, you will add a new component to the sample project. For an introduction to Pulse Width Modulation: http://en.wikipedia.org/wiki/Pulsewidth_modulation Create a new component named PWM_controller. entity PWM_controller generic (numbits : natural range 1 to 16 := 12) port ( clk : in std_logic; rst : in std_logic; dutycycle : in std_logic_vector(numbits-1 downto 0); pwm_out : out std_logic; reload : out std_logic ); The pulse width modulator operation is best described by example. If the dutycycle is programmed to 0, pwm_out is always 0. If it is programmed to 23, then for each 4096 clocks (for the 12 bit PWM), the pwm_out signal is high for 23 clocks, and low for the

remaining ones. The reload signal is an indicator to the outside world that on the next clock, the PWM peripheral will load its internal copy of the dutycycle register with the value on its input port. This will allow the PWM controller to operate through a complete cycle without being disturbed by changes on the dutycycle input. Furthermore, it will allow the microcontroller to keep track of when changes to the duty cycle should be loaded. After the PWM_controller has been designed and simulated, modify the top level project to hook the picoblaze processor to its new peripheral. Make sure that the picoblaze has the ability to write to the duty cycle. Also, provide some means by which the picoblaze processor can be interrupted by the PWM_controller reload signal. By this means, the picoblaze can respond to the PWM needing new data, and provide it via an ISR. Also, hook the PWM_out signal to one of the LEDs (you will have to disconnect one of them from the other part of the design). Now, test the operation of your PWM controller using the picoblaze software to write a variety of values to the duty cycle. You should be able to set the intensity of the LED by varying the duty cycle. Finally, modify your calculator application for the picoblaze such that while the calculator is operating, the picoblaze slowly varies the intensity of the LED. This procedure should happen at interrupt time. In other words, when the PWM controller says that it has taken a new duty cycle, it causes an interrupt, which the picoblaze responds to by writing a different value to the duty_cycle port. The LED should go from dark to bright and back to dark again with a continuous variation in intensity over the course of a few seconds (between 2 and 5).

Grading : Submit the zipped project online via the website. Demonstrate the calculator/led application in the lab to the instructors. 10 pts: One Operation per Button Press of BTN0 10 pts: Add operation works correctly 10 pts: Subtract operation works correctly 10 pts: Shift Left operation works correctly 10 pts: Shift Right operation works correctly 10 pts: BTN3 resets the running total 10 pts: LED varies continuously as prescribed 10 pts: PWM controller VHDL 10 pts: correct Handling of interrupt at hardware and software level 10 pts: reasonable picoblaze assembly code

You might also like