Now that you have created the AmaniBlink project and have successfully compiled it, you are almost ready to load your design onto the Amani 64. However you must first assign the inputs and outputs of your design to physical pins on CPLD device. Once you have assigned the I/O pins, you will recompile the project and load the design onto your Amani. You will need some kind of JTAG in-system programmer such as the USBoomer JTAG development board, an Altera USB-Blaster, Byte-Blaster, or an equivalent. You also by now should have installed the appropriate drivers for your JTAG programmer.
Let’s begin by defining your I/O pins.
Step 1: With the AmaniBlink project open, having been previously successfully compiled, open the Pin Planner by the menu progression, Assignments: Pins. The Pin Planner tool will appear in a new window.
There are three methods of assigning pins: clicking on individual pins on the CPLD package window and assigning the node, entering pin values into the all pins list, or via text editor.
We will use the package editor to assign the clk_32 node to its appropriate pin. The 32MHz oscillator on the Amani 64 is connected to a fixed input pin; the Global Clock pin 43. Get used to this assignment.
Double click pin 43 on the package pin editor and select clk_32 in the Node name: drop menu.
Make your selection (clk_32) and press OK. You’ll notice the change for clk_32 in the All Pins List.
Next we will assign signal LED an output pin. Inspect your Amani 64. The usable I/O ports on the Amani are the Arduino connectors PB, PD; and Module Docks A – D. Arduino connector PC is not used by the Amani. You’ll notice white numbers corresponding to individual connections on each port. These numbers correspond to the CPLD pin the port is connected to.
For example, Arduino PD7 corresponds with CPLD Pin 39. PB3 = 44. PB5 = 2.
Notice that Pins 27 and 28 correspond to both PB0 and PB1 as well as PD0 and PD1. The selection jumpers JP5 and JP6 select which connector, PB or PD, pins 27 and 28 will connect to. This allows PD0 and PD1 to be freed for serial communications when connected to the Arduino.
Pins 44 and 2, PB3 and PB5, can only be assigned as inputs. These are dedicated function pins, Global Enable and Global Clock 2, that can also function as input pins. You cannot drive these as outputs.
Also available for standard I/O operations are Docks A-D. For example Dock D0 connects to pin 26, Dock C3 to pin 16, C5 to Vcc, C4 to GND.
In this example I will use DOCK C0 (Pin 20) to drive our LED. Using the All Pins List editor this time I assign LED to pin_20 by clicking in the corresponding box in the Location Column. You can either enter the number “20″ or use the drop down menu.
Notice: Do not assign TCK, TDI, TDO, and TMS to any pin values. Likewise do not assign Pins 7, 13, 32, and 38 to any other signals than TCK, TDI, TDO, and TMS. While Quartus II will attempt to warn you about such misassignments, it’s better that you understand why you should not. These four pins/signals are the JTAG programming controls. With these reassigned you will not be able to program your CPLD.
Now that you have assigned signals LED and clk_32 to pins 20 and 43, you may now close the Pin Planner (you do not have to save this file, it does so automatically).
Step 2: Recompile your design. While you have not made any design changes to your Verilog, you need the compile process to take your pin assignments into consideration. Recompile the project as you did in Module B.
Programming the CPLD
Now we get to the fun part, loading our design onto the CPLD and affecting change in the real world.
Step 1: Connect your LED and 1K resistor (or other appropriate value for your LED) in series on a bread board.
Step 2: Wire the cathode of the LED to GND. You can use DOCK C4. Wire the loose end of the resistor to DOCK C0 (Pin 20).
Step 3: Connect your USBoomer, USB-Blaster, or equivalent Altera-compatible JTAG programmer into the ISP Connector, J7, on your Amani. You should have already installed the appropriate drivers to run your JTAG programmer.
Plug your JTAG Programmer into your USB port.
Plug your Amani 64 into a power supply of choice. If you are using power connector J6, you do not need any Power Jumpers, JP1 – JP3, connected. If you are going to use your Arduino to power the Amani, use JP2. The 5V connection on JPower will be regulated to 3.3V on the Amani.
If you are using the USBoomerJTAG development board, you should see the PTGT LED lit, indicating the target device, here the Amani, is powered. PUSB should also be lit, indicating your USBoomer is powered by the USB port. TCK and TDI may be lit depending on the state of the programmer.
Step 2: Open the Programmer either by clicking the Programmer button on the menu bar or by menu Tools: Programmer.
Before beginning the programming process, you should note the following. AmaniBlink.pof should be listed under File, EPM3064AL44 under Device. USB-Blaster [USB-0] should be displayed in the dialogue box next to Hardware Setup.
If the USB-Blaster is not displayed in the dialogue box next to Hardware Setup, you need to force Quartus II to use your programmer. Press Hardware Setup and be sure there is a USB-Blaster or equivalent device in the “Available Hardware Items” window. Select your device in the “Currently Selected Hardware” drop down menu. You should get used to this process as sometimes Quartus fails to automatically load the device. If your device is not an available hardware item, check your connections and drivers.
Take a minute to use the “Auto Detect” feature of the Programmer. Highlight the AmaniBlink.pof line in the programmer window and press “Delete.” This does not delete your programmer file, just removes it from the programming cue. Push the “Auto Detect” button and your CPLD will be JTAG scanned and displayed. This is a valuable troubleshooting tool. Once satisfied highlight this line, delete, and load your AmaniBlink.pof file by selecting it via the “Add File” button.
Once you are ready to program the AmaniBlink.pof file onto your CPLD, be sure to place a check in the Program/Configure Box in the main programmer window. Press Start. Depending on your version of Quartus, the programmer window may disappear to the background. You can observe the programming progress in the Message Window of the Quartus main environment. You may also bring the programmer window to the foreground and watch the Progress Bar.
Observe the TDI/TCK LED action on your USBoomer. You will know the programming process is complete by the progress bar reaching 100%, the message window displaying “Info: Successfully performed operations(s)”, the TDI/TCK LED’s no longer toggle, and the LED connected to DOCK C0 begins to blink!
Congratulations on successfully completing your first Amani 64/Quartus II project! Take time to experiment with the Quartus interfaces, Verilog code, Pin Planner, and the JTAG programmer. Hopefully you will find experimenting with these devices as fun as I do!