In my last few columns, I've taken an existing command-line tutorial and brought it up in the Xilinx ISE development environment. That's an important first step, but now it's time to start doing something of my own. I'll begin simply, borrowing heavily from the example we just completed. Basically, I'm going to edit the counter back to four light-emitting diodes (LEDs) -- the way it was before we modified it -- and then add in some logic to "Start" and "Stop" the count sequence being displayed on the LEDs.
Today, we are going to:
- Create a new project called "led_input"
- Use most of the code from our prior example
- Change a few names to better fit what we're doing
- Take the two extra LEDs out of the register and turn them into independent outputs
- Add two switch inputs
- See what happens next...
You will need:
- Your Spartan-6 LX9 development board plugged into your computer
- The two LEDs with pigtail wires that we created in our earlier columns
- Two switches with pigtail wires soldered to them so they can be plugged into the header block on the FPGA board
- The old code from "ledflash_ISE_ver" (or the "led_input.v" file from this blog) opened in a text editor
To start, we need to follow the steps I outlined in an earlier column. (See: Discovering FPGAs: Bringing Up the IDE.) Start up ISE and create your empty project (Steps 1 through 4 in that prior column). The only difference so far is that this one will be named "led_input." Next, when you open the New Source Wizard, we'll start to see some differences. Define your ports as shown in the following image:
"CLK_66MHZ" and "USER_RESET" are the same as in our last project. The inputs "START_COUNT" and "STOP_COUNT" will be our new switch inputs. I changed the name of the port from plain "LED" to "COUNTING_LEDS" because non-descriptive names kind of drive me nuts. This is especially true in the case of something like "LED" when I also have to reference the physical light emitting diodes. "COUNTING_LEDS" is still marked as a bus, but the MSB is now 3 instead of 5.
"LED_STARTED" and "LED_STOPPED" will be the extra LEDs (you see -- now I can just say "LEDs," instead of spelling out the acronym, and not get confused) that we stuck into the header J5 in an earlier column. This time, however, they aren't assigned to be part of the main port; instead, they will be used as visual indicators displaying the status of the two switches we are going to add.
Next page >