This is part 2 of my Building a Processor series, where I try to build a processor on an FPGA board. This post is about getting all the tools working, and getting a very basic circuit programmed onto the FPGA.
Previous: getting started.
At this point, I have a Nexys 3 board, and have Xilinx ISE installed on my PC. The Nexys 3 comes with some test programs pre-loaded onto it, so the first thing I did was plug in the programming cable to get them running. I didn’t need to install or configure anything; it just needed the cable for power. The Nexys 3 comes with two memory chips that can both hold FPGA configuration data, and the choice of which one to load is controlled by “J8”, the jumper towards the top-right of the board; one of the preloaded programs is a memory test, and the other is a simple demo.
Now that the board has checked out, it’s time to start configuring it myself. ISE, while I’m sure is very full-featured, is a horribly complex agglomeration of different components. My guess is that they all existed separately at some point, and then Xilinx post-hoc decided that they should be a single software suite instead. It took me a while to even figure out that the one I wanted to start with is ISE Design Studio, which took me to the Project Navigator, where I could get started.
I had to set up a new project; ISE comes pre-shipped with part values for their dev boards, but since the Nexys 3 wasn’t in their list, I had to configure it myself. (I had to pick “None Specified”, “All”, “Spartan6”, “XC6SLX16”, “CSG324”, and “-3”.)
So far so good, but I still need to get the fpga to “do” anything. I started with a very simple circuit: simply connecting the switches to the leds above them. This can be achieved with this simple code snippet:
module fpga( input wire [7:0] switch, output wire [7:0] led ); assign led = switch; endmodule
(Code highlighting done with tohtml.com)
ISE comes with a tool for programming fpgas, but in my experience it’s been pretty bad, at least on the Nexys 3. I’ve found it to be much easier to use the Digilent-provided Adept software, which also has some other functionality specifically for the Nexys 3 board. I forget the exact steps that I had to take to get Adept to work, but I think it’s roughly this: launch Adept, go to Settings and click Device Manager, click the Enumerate button and make sure the Nexys3 shows up. Click the Nexys3 list entry, enter an alias for it in the Alias: field (can just be “nexys3”), and hit “Add Dvc”, and go ahead and close the Device Manager. While we’re on the Settings page, make sure the Auto Initialize SC checkbox is checked. Switch to the Config tab, and select Nexys3 from the Connect dropdown, and find the fpga entry. Hit Browse, navigate to the project folder, and find and open the fpga.bit file. Finally, after all that, I hit Program, and voila! My fpga is now programmed with my simple circuit.
As I turned to the board to test it, my excitement was palpable, but totally deflated when nothing happened when I flipped the switches. This is a common issue that I’ve run into multiple times, which is that not only do you have to specify the internals of the fpga circuitry, you have to tell ISE how that circuitry connects to the pins on the FPGA (I don’t know why they don’t give you an error if you don’t). This is done in a “user constraints file”, of the form *.ucf. Luckily, Digilent distributes a Nexys 3 ucf file that I downloaded from here. So I added it to the project, and uncommented the “sw” and “led” lines, resynthesized, reprogrammed, and this time it worked!
Next up: getting the seven-segment display to work.