In this week’s article we’ll be using the DIP switches located between the FPGA and the USB connector on the Microboard. This guide should be pretty short as I won’t be going into nearly as much detail about setting up the project, creating files, and so on.
As always, start a new project in Project Navigator. I called my project ‘switchy’, but you’re free to pick any name you wish. Hopefully the new project wizard remembered what FPGA you’re using, so creating the project once you’ve entered the name should just be a matter of clicking next a few times. Create a new Verilog file, calling it ‘adder.v’
For all your two-bit adding needs
This adder module adds the binary value of the two left switches to the binary value of the two right switches. Simple enough, right? The reason for the inversion (the ~) is because we want the switch in the down position to represent a zero, not a one. The reason for not having the switches on the sensitivity list (only the clock edge) stems back to a horrendous issue I encountered in my very first hardware design class. That case was slightly different, however, as it involved switch inputs on the sensitivity list of a Mealey state machine, but I digress.
1 2 3 4 5 6 7 8 9 10 11 12
What to do with the constraints file should be straightforward by now. The use of the “PULLDOWN” flag is specified in the Microboard user’s guide
1 2 3 4 5 6 7 8 9
Much the same as last time, go ahead and run “Generate Programming File”, wait a few minutes, and upload the programming file to your Microboard. Play around with the switches (when the USB connector is on the left, down = 0, up = 1) and watch the sum be displayed on the LEDs. Cool, huh?
Now that you’ve mastered the basics (I hope?), it’s time for a fun project. Implementing SPI communication sounds like fun, yeah?