Some time ago, I purchased a Papilio Arduino from the Gadget Factory. This is an open-source FPGA board that's based on a Xilinx Spartan 3E. The Papilio comes with a bit stream that turns the FPGA into an Arduino microcontroller, but it also works great as a generic FPGA development board. Not long after I'd purchased this board, I won an add-on -- called the B/LED Wing -- in a contest on the Gadget Factory site. This add-on has four push button switches and four LEDs. Although this may not seem like much, they will make fiddling with this board a lot more convenient.
Of course, I still like my Spartan 6 LX9 board and I'm far from done playing with it. In fact, I have an Avnet WiFi Pmod and a set of 15 Maxim Pmods covering a whole slew of applications to work with and write about. But the Spartan 6 board won't have enough input/outputs (I/Os) for my robot avatar project. I'm thinking that the Papilio's 48 I/Os will get me a lot further than the Spartan 6 LX9's 16 accessible pins.
Today, I'm going to:
- Dig up the documentation for my Papilo
- Start a new project
- Map the I/O for my Button / LED Wing
- Synchronize the switch inputs
- Attempt to de-bounce those inputs
- Pass the de-bounced value out to the LEDs
Papilio FPGA development board with B-LED Wing daughter card.
I'll start by creating a new ISE project and calling it "PaIO." In the New Project Wizard, I need to select "Spartan 3E" as the family, "XC3S250E" as the device, and "VQ100" as the package. The Papilio Wiki at the Gadget Factory has a "Xilinx UCF File" that I can draw from, but I'll have to create the Verilog file from scratch. This is really back to the basics, which is a nice change from killing myself with clocks last week.
I plugged the Wing into section "BH" on the Papilio, which connects up to the Spartan pins P58, P54, P41, P36, P34, P32, P25, and P22. The Wing has the pins clearly labeled as seen in the image below, so it will be easy to properly set the UCF. (I like clear labeling.)
Still in the ISE New Source Wizard, on the Define Module screen, I named my ports "WingLED" and "WingSW," both being busses with an MSB (most-significant bit) of 3 and an LSB (least-significant bit) of 0. The supplied UCF defines those pins on lines 43 through 50. Once I stripped all of the non-used lines out, except the clock, which I'll need later, this ended up as shown below (click here to see a larger, more detailed version of this image):
A simple "assign WingLED[3:0] = WingSW[3:0];" could end this exercise, but someday I'll need those switches to be de-bounced. What I'm thinking is:
- I'll hold the current state of the switch
- Send the switch inputs through a synchronizer
- If the state changes, I'll start a timer
- When the timer stops, I'll have a stable switch value
to see a larger, more detailed version of the above image. And click here
to download a ZIP file containing my Verilog source code to see if it makes sense. It's late at night as I pen these words, so please be kind. This code does pass the switch value on to the LED. The only problem is that I can't use ChipScope on this board to verify that it's doing what it's supposed to be doing. This means I'll have to put my code on the Spartan 6 LX9 board and ChipScope it out.