Tu0116 Getting Started With Fpga Design
Tu0116 Getting Started With Fpga Design
Tu0116 Getting Started With Fpga Design
Summary
Tutorial TU0116 (v2.0) May 17, 2008
This tutorial introduces you to the basics of FPGA design using Altium's Innovation Station. It covers FPGA project creation within Altium Designer, targeting of a design to a physical FPGA device on a daughter board plugged into the Desktop NanoBoard, and processing of the design ultimately programming the FPGA. Use of design hierarchy and virtual instrumentation is also briefly explored.
The Altium Innovation Station the powerful combination of Altium Designer software and Desktop NanoBoard reconfigurable hardware platform provides all of the tools and technology needed to capture, implement, test and debug your FPGA designs, in real-time. With Altium's Innovation Station the low level detail is managed for you, leaving you free to focus on device intelligence and functionality the source of true and sustainable product differentiation. Before embarking into the world of processors and embedded software intelligence however, it is beneficial to receive a solid grasp of the fundamentals of designing within this innovative environment how to implement the most basic of designs and get it running on a physical FPGA device plugged into the Desktop NanoBoard. This tutorial implements a simple counter-based design (non-processor) which, when programmed into the target daughter board FPGA, will cause the User LEDs on the Desktop NanoBoard to light sequentially from left to right, or from right to left. During the course of this tutorial, you will gain knowledge of the basics of FPGA design, introducing you to: FPGA project creation within Altium Designer and how to implement a schematic-based design, including sourcing and placing parts and wiring them on a schematic sheet. Targeting of a design to a daughter board FPGA using the auto-configuration feature. Processing of a design compiling, synthesizing and building the design to obtain the programming file which is used to program the target device. Use of design hierarchy within an FPGA project, including simple custom logic (HDL). Virtual instrumentation.
The example design featured in this tutorial is a simple twisted-ring counter (Figure 1). This is a synchronous counter where the inverted output of the last stage is connected to the input of the first stage. Rather than individual flip-flops, we will use a shift register component, readily supplied with Altium Designer. The base design schematic and additional files can be found in the \Examples\Tutorials\Getting Started with FPGA Design folder of your Altium Designer installation. Refer to this example at any time to get further insight or to skip some of the steps.
Figure 1. Simple, non-processor-based design a twisted-ring counter. TU0116 (v2.0) May 17, 2008
Getting Started with FPGA Design The synchronizing clock signal for the logic components in our circuit is provided courtesy of the reference clock on the Desktop NanoBoard. The counter output is displayed on the NanoBoard's User LEDs. Additional logic in the design, coupled with use of resources found on the NanoBoard, allow for the following controls: Direction control the count will proceed from left to right or from right to left, dependent on the setting of an associated switch on the NanoBoard (part of the DIP-switch). Stop control the count can be stopped or resumed, dependent on the setting of an associated switch on the NanoBoard (part of the DIP-switch). Clear control the counter output can be cleared (all LEDs turned OFF), by pressing the 'DAUGHTER BD TEST/RESET' button on the NanoBoard. For detailed information on the Desktop NanoBoard, refer to the document TR0143 Technical Reference Manual for Altium's Desktop NanoBoard NB2DSK01. For information on the range of supported daughter boards available for the Desktop NanoBoard, and additional documentation specific to each, go to www.altium.com/nanoboard/resources.
Placing Components
Now we have our 'blank schematic canvas' it's time to add-in the required components those that depict the functionality of the design circuitry, and those that provide the interface with resources found on the Desktop NanoBoard NB2DSK01. Table 1 identifies the components required in defining the twisted-ring counter circuit. All of these components can be found in the FPGA Generic integrated library (FPGA Generic.IntLib), located in the \Library\Fpga folder of the installation.
Table 1. Design components required in the twisted-ring counter schematic.
Symbol
Quantity Required 2
INV
Inverter
J8B_8S
OR2N2S
2-input OR gate with active Low A and B inputs, (single pin version) 8-bit loadable serial/parallel-in parallel-out bidirectional shift register with clock enable and asynchronous clear (bus version)
SR8CLED
Table 2 identifies the design interface components required for our design. These components, commonly referred to as port components (or port-plugins), automatically establish connectivity between the relevant resources on the Desktop NanoBoard and the physical IO pins of the daughter board FPGA device to which our design is targeted. From the design perspective, they depict the extents of the design the physical pins of the target device to which the signals from the design connect. These port components can be found in the FPGA NB2DSK01 Port-Plugin integrated library (FPGA NB2DSK01 Port-Plugin.IntLib), also located in the \Library\Fpga folder of the installation.
Table 2. Port components required in the twisted-ring counter schematic.
Symbol
Description This component interfaces to the fixed 20MHz system clock signal on the Desktop NanoBoard. We will use this signal to provide the synchronous clock signal to our flip-flop and shift register logic. This component interfaces to the DIP-switch on the Desktop NanoBoard. We will use three of these switches to control direction of the counter (Left or Right) and also to stop the counter. This component interfaces to the user LEDs on the Desktop NanoBoard. We will use the LEDs to visually display the output of our counter. This component interfaces to the 'DAUGHTER BD TEST/RESET' button (push button switch SW7) on the Desktop NanoBoard. We will use this signal (inverted) as a control input to the Load Enable pin of the shift register. As we will tie the D inputs of this register to GND, pressing this button will load '0' into the register's data outputs.
DIPSWITCH
LED
TEST_BUTTON
Go ahead and place all of these components on the schematic sheet, as shown in Figure 3. Both of the integrated libraries are installed and available from the Libraries panel by default, so there is no need to add any libraries for this tutorial. Simply make the relevant library active in the panel, select the component entry in the list and either click the Place button at the top-right of the panel, or click and drag the component directly onto the sheet. Schematic placement controls, such as flipping and rotating, allow for fine tuning as needed.
Getting Started with FPGA Design Once placed, finalize the designation of each component using the Tools Annotate Schematics Quietly command.
2. From the Wiring toolbar, click the button to place a GND Power Port. While the port is still floating on the cursor, press the Tab key. From the Power Port dialog that appears, change the Style property to Bar. Now place the port so that it connects to the bottom-left of the wire connecting the CLR pins of the two flip-flops. 3. Now place another GND Power Port again using the Bar style so that it connects to the CLR pin of the shift register. button to place a GND 4. From the Wiring toolbar, click the Bus Power Port. Again, change the port's Style property to Bar. Now place the port so that it connects to the D[7..0] pin of the shift register. Press Spacebar to rotate the port as required.
Figure 5. Tying flip-flop CLR signals to GND.
Getting Started with FPGA Design 5. We now need to add bus entries for 'tapping off' individual signals from the output bus of the shift register. These entries need to connect to the individual wires that feed, via respective inverters, into the SLI and SRI inputs of the shift register. From the Wiring toolbar, click the button and place the two bus entries as shown in Figure 7.
6. To tidy up the design and also minimize compilation warnings, we can also place No ERC markers on each of the unused outputs of the Bus Joiner component (U4). From the Wiring toolbar, click the button to enter No ERC marker placement mode. Then position and place a marker on each of the unused pins, O3 to O7, as illustrated in Figure 8.
Figure 8. Mopping up loose ends with No ERC markers.
To complete the wiring of our design, we will add labels to key nets in the circuit. This will make the design both easier to understand and also enable any problems to be tracked down with greater efficiency when checking the design at the compilation stage. 7. Go ahead and add net labels to the design, as illustrated in Figure 9, using the Place Net Label command (or clicking the button on the Wiring toolbar). The net labels shown in Figure 9 are an example. You could use different names for the net labels, as long as they are unique.
8. Save the schematic and its parent project (File Save All). Congratulations! You have now fully captured the design on the schematic. We can now go on to verify the design and then target and download it to the physical FPGA device.
Figure 11. With the design wired correctly, these are the only messages that should appear after compilation.
If you have any different error messages, you will need to resolve them and recompile the design project. For detailed information on the various compiler errors, how they can occur and possible methods by which to resolve them, refer to the document TR0142 Project Compiler Error Reference. 4. Save the schematic and its parent project.
Although an FPGA design project targeting the Desktop NanoBoard can be configured manually by adding a configuration, assigning the required board constraint files and creating a mapping constraint file by hand the process is greatly simplified through use of an auto-configuration feature. Using this feature, a target configuration for the FPGA design project is automatically created. The required board-level constraint files are then automatically determined and added to this configuration, based on the hardware (motherboard, daughter board and peripheral boards) detected in your system. An additional mapping constraint file is also generated and added to the configuration, which handles connection of the satellite boards detected in the system (daughter board and any peripheral boards), to the main motherboard.
Note: Although older, 2-connector Altium daughter boards can be used with the Desktop NanoBoard NB2DSK01, they do not possess the memory device required for auto-configuration. For more information on the concept of configurations and constraints, and their role in design portability, refer to the article AR0124 Design Portability, Configurations and Constraints. For more detailed information on the Desktop NanoBoard NB2DSK01 constraint system, including auto-configuration, refer to the application note AP0154 Understanding the Desktop NanoBoard NB2DSK01 Constraint System. Let's go ahead and configure our FPGA project. 1. Prior to using the auto-configuration feature, ensure the following: The 3-connector daughter board carrying the FPGA device to which the design will be targeted is plugged into the NB2DSK01 motherboard. Our simple counter design does not use any resources resident on plug-in peripheral boards. These boards can be left attached to the motherboard, or removed, as required. The NB2DSK01 is connected to the PC via USB (or parallel) connection and is powered-on.
2. Open the Devices view (View Devices View). Enable the Live option and ensure that the Connected indicator is Green. 3. The auto-configuration feature can be accessed and run in two ways. For the purposes of this introductory tutorial, it is worth taking a look at both of these methods. For this step, pick only one of the following methods to run the autoconfiguration process: Method 1: Right-click on the icon for the Desktop NanoBoard in the NanoBoard chain of the view and from the menu that appears choose Configure Fpga Project Simple_Counter.PrjFpg (Figure 12).
Method 2: Double-click on the icon for the Desktop NanoBoard to access its corresponding instrumentation in the Instrument Rack NanoBoard Controllers panel. Then click on the Board View button to access the NanoBoard Configuration dialog. Use the Auto Configure FPGA Project drop-down at the bottom-left of the dialog and choose Simple_Counter.PrjFpg (Figure 13). By using the dialog, you are presented with a visual (and dynamic) summary of your current Desktop NanoBoard NB2DSK01 system. The image in the dialog displays the specific peripheral board(s) and daughter board that are physically plugged in to the NB2DSK01 motherboard.
The auto-configuration process will proceed, which involves the following: A configuration is created and added to the Simple_Counter project. The name for the configuration will depend on the version of your Desktop NanoBoard and the particular daughter board being used. The generic format for the name is: motherboard code_revision_daughter board code_revision For example, with a Desktop NanoBoard NB2DSK01 (revision 8), and a Xilinx Spartan-3 daughter board DB30 (revision 6), the configuration will be named NB2DSK01_08_DB30_06. Constraint files will then be added to the configuration for each of the detected boards in the system (motherboard, daughter board and peripheral board(s)). These are sourced from the \Library\Fpga\NB2 Constraint Files folder of the installation. In each case, the file used will be determined by the type and version of board. For example, if you are using a Xilinx Spartan-3 daughter board DB30 (revision 6), then the constraint file retrieved and added to the configuration will be DB30.06.Constraint. The constraint file that defines the mapping of daughter board and peripheral board(s) to the motherboard is also created, on-the-fly, and added to the configuration. The name of this file will simply be that of the configuration itself, with the additional suffix '_BoardMapping' (e.g. NB2DSK01_08_DB30_06_BoardMapping.Constraint). The file will be saved to the same location as the project file (Simple_Counter.PrjFpg) itself.
4. The configuration and assigned constraint files will appear listed in the Configuration Manager dialog, as shown in Figure 14.
Figure 14. Resulting configuration and constituent constraint files for the Simple_Counter project.
Click OK. A sub-folder named Settings will be added to the project and appear listed in the Projects panel. The constraint files themselves will be listed in the sub-folder Constraint Files. 5. Save the project file. We have now finished configuring the design. It is targeted to the daughter board FPGA device and is now ready to be processed and ultimately programmed into that device.
Figure 16. Associated Process Flow for the physical FPGA device.
This Process Flow will only be presented providing the following additional conditions are met: The relevant vendor tools, for the FPGA device fitted to the daughter board you are using, are installed. The drop-down field below the icon for the device in the chain shows a valid Project / Configuration pairing. A valid pairing exists when a project has an associated configuration that contains a constraint file targeting the design to the detected physical device. Having run the auto-configuration feature, a valid configuration already exists for our example project, containing a constraint file that targets the daughter board device. The Project / Configuration entry therefore appears as Simple_Counter / ConfigurationName (e.g. Simple_Counter / NB2DSK01_08_DB30_06 in Figure 15).
10
Getting Started with FPGA Design The Process Flow itself consists of four distinct stages, with the output of each stage required as input to You can run all stages of the next. Although the entire Process Flow can be run by clicking directly on the Program FPGA button the flow up to and the last stage in the flow it is worth considering and using each stage in turn. including the current 3. Click on the Compile button. This stage is used to perform a compile of the source documents in the associated FPGA project. If our project included processor cores, the associated embedded software projects would also be compiled during this stage. For our simple, non-processor design, this stage will simply use the Design Compiler to verify that the design is free from electrical and drafting errors. As we have previously compiled the project, we will be fine for this stage!
stage by clicking on the arrow icon located on the left side of the stage button .
Feedback on the Compile process can be viewed in the Messages panel. Once any stage has completed successfully, its associated indicator will turn Green. 4. Click on the Synthesize button. During synthesis, source documents are translated into intermediate VHDL files which are then synthesized into a top-level EDIF netlist, suitable for vendor Place & Route tools. For the particular FPGA device being targeted, synthesized model files associated with components in the design will be searched for and copied into the relevant synthesis output folder. If the synthesis is completed successfully, a folder called Generated [ConfigurationName] is created which holds the generated EDIF (Simple_Counter.edf), VHDL (Simple_Counter.vhd) and synthesis log (Simple_Counter_Synth.log) files. Feedback on the Synthesis process can be viewed in the Messages panel. 5. Click on the Build button. In this stage, Altium Designer calls and runs the vendor Place & Route tools, to process the design for the target physical FPGA device.
Figure 17. Generated files from the Synthesis stage of the flow.
Figure 18. Reaching the Place and Route stage of the overall Build process.
Each of the following five sub-stages will run in turn: Translate Design: uses the top-level EDIF netlist and related synthesized model files, obtained from the Sythesis stage of the Process Flow, to create a file in Native Generic Database (NGD) format. Map Design To FPGA: maps the design to FPGA primitives. Place and Route: takes the low-level description of the design (from the mapping stage) and works out how to place the required logic inside the FPGA. Once arranged, the required interconnections are routed. Timing Analysis: performs a timing analysis of the design, in accordance with any timing constraints that have been defined. If there are no specified constraints we don't have any for our simple design default enumeration will be used. Make Bit File: generates the programming file that is required for downloading the design to the physical device.
Feedback on the build progress can be obtained by viewing the Messages panel. More detailed vendor-related feedback can be obtained from the Output panel (accessed from the menu associated to the System button at the bottom of the main design window). Once the stage has completed successfully, the Results Summary dialog will appear. This dialog provides summary information with respect to resource usage within the target device, as well as any timing information. Close this dialog.
11
Figure 19. Accessing build process information and obtaining a final report of the build results.
6. Click on the Program FPGA button. The programming file obtained from the Build stage is downloaded to the physical FPGA device on the daughter board. Download occurs over the PC's JTAG link to the Desktop NanoBoard, with progress displayed in Altium Designer's Status Bar. Once the design has been downloaded, the text underneath the physical device's icon in the Devices view will change from Reset to Programmed. On the hardware side, the 'Program' LED on the daughter board will be lit (Green), confirming that the design has been loaded into the physical device.
For more information on the Process Flow and the Devices view, refer to the document AP0103 Processing the Captured FPGA Design. 7. Use switches on the NanoBoard's DIP-switch as follows: Switch 8: switch ON to start the counter if previously stopped and/or display the LEDs shifting in from the left Switch 7: switch ON to start the counter if previously stopped and/or display the LEDs shifting in from the right Switch 6: switch ON to stop the counter. Count will be stopped provided Switches 7 and 8 are OFF.
8. Press the 'DAUGHTER BD TEST/RESET' button on the NanoBoard to clear the LEDs. 9. Save the project. You will notice that the User LEDs on the Desktop NanoBoard look to be all on at the same time, which really defeats the purpose of having a twisted-ring counter! This is because the reference clock on the NanoBoard is 20MHz. We need to slow down the clock by a factor of one million to see the LEDs displaying sequentially. In the next section of this tutorial, we will look at adding some clock division to achieve this and, in doing so, also explore the use of hierarchy in an FPGA design.
12
A schematic sub-sheet can also include sheet symbols referencing lower design files. Using this approach a design hierarchy of any depth or complexity can be created. Hierarchical net and bus connectivity between documents obeys the standard hierarchical project connection behavior, where ports on the sub-document connect to sheet entries of the same name in the sheet symbol that represents that document, as shown for schematic and VHDL sub-documents in Figure 21.
Figure 21. Hierarchical net connectivity is from the sheet entries to matching ports on the document below.
In the base design for our simple counter example, we saw that the synchronous clock signal sourced from the Desktop NanoBoard was too fast. To slow down the counter we will add clock division circuitry. Rather than adding this circuitry to the Simple_Counter schematic, we will capture it in a sub-file (first in a schematic and then in a VHDL file), to demonstrate how hierarchical designs can be used when programming an FPGA.
4. Add a single sheet entry (Place Add Sheet Entry) to the left and right of the sheet symbol. Set the following properties: Left-hand sheet entry: Name: CLK_REF, I/O Type: Input Right-hand sheet entry: Name: CLK_OUT, I/O Type: Output
5. Wire the sheet symbol into the main circuit and next to the CLK_REF port component, as shown in Figure 23.
13
Figure 23. Simple_Counter schematic with sheet symbol for Clock_Divider.SchDoc sub-sheet placed and wired.
Now we have our parent sheet symbol, we must create the actual sub-sheet that it references and the required circuitry thereon. Note: The subsequent steps 6-9 take you through the process of defining the schematic sub-sheet and its content from scratch. To skip this sequence of steps, right-click on the Simple_Counter.PrjFpg entry in the Projects panel and choose Add Existing to Project. In the Choose Documents to Add to Project dialog that appears, navigate to and open the file Clock_Divider.SchDoc, located in the \Examples\Tutorials\Getting Started with FPGA Design folder of the installation. Then save the project and schematic top-sheet and proceed with step 10. 6. Right-click on the sheet symbol and choose Sheet Symbol Actions Create Sheet From Symbol. The new schematic document, Clock_Divider.SchDoc, is created and opened as the active document in the main design window. Initially, this document contains two ports CLK_REF and CLK_OUT which correspond (and connect upwards to) the respective sheet entries in the parent sheet symbol. 7. Access the Libraries panel and place six clock divider components (CDIV10DC50 divide by 10 with 50% duty cycle output) from the FPGA Generic integrated library (FPGA Generic.IntLib) onto this new sheet. Connect the components in series and between the two ports as shown in Figure 24.
8. Annotate the components using the Tools Annotate Schematics Quietly. 9. Use File Save All to save both schematics and the parent project. Accept the default location (i.e. same folder as top-level schematic) when saving Clock_Divider.SchDoc. 10. Compile the project to check for any errors. If there are, resolve, save and recompile. 11. After compiling, you can check the sheet hierarchy of the project in the Projects panel. The project will now recognize the sub-sheet (Clock_Divider.SchDoc) as a child of the Simple_Counter schematic. Now we have finished adding the clock division circuitry, let's test it out.
12. Open the Devices view, ensuring that the Live option is still enabled and the Connection indicator is still Green. 13. The physical FPGA device is still programmed and the Process Flow still shows all stages as successfully completed (Green). How so, when we have modified the design's source documents? The answer is in the Ignore FPGA source option, which is enabled by default. We need to disable this option so that the modified source documents are taken into account when assessing the status of the Process Flow. Go ahead and disable the Ignore FPGA source option each stage of the Process Flow will turn Yellow, indicating that it is out of date and must be run again.
Figure 26. Disable the Ignore FPGA source option to take into account modified source when assessing the Process Flow.
14
Getting Started with FPGA Design 14. Reprogram the daughter board's FPGA device. The simplest way to do this is to click directly on the Program FPGA stage in the Process Flow. All prior stages will be run automatically in sequence, because they are now marked as out of date. After the synthesis stage, a corresponding intermediate VHDL file for our new schematic subsheet will appear in the generated VHDL files for the project. Once programmed, start the counter (set either switch 7 or switch 8 of the DIP-switch to ON) and observe the output on the NanoBoard's User LEDs has slowed down and we can now see the sequence more clearly. Use the DIP-switch to play with the direction now that it has meaning!
Figure 27. Additional VHDL file for the sub-sheet, generated on synthesis.
entity Clock_Divider is port ( CLK_REF : in std_logic; CLK_OUT : out std_logic ); end entity;
architecture RTL of Clock_Divider is begin process(CLK_REF) variable i : integer range 0 to 999999; begin
15
Getting Started with FPGA Design if rising_edge(CLK_REF) then if i = 0 then CLK_OUT <= '1'; i := 999999; else CLK_OUT <= '0'; i := i - 1; end if; end if; end process; end architecture; 3. Save the document Now we have our VHDL source file, we can create a sheet symbol directly from it. Before we do though, let's remove the existing sheet symbol from the top-level schematic and also its referenced schematic sub-sheet. 4. Remove the schematic sub-sheet Clock_Divider.SchDoc from the FPGA project by right-clicking on its name in the Projects panel and choosing Remove from Project from the menu 5. Open the Simple_Counter schematic (Simple_Counter.SchDoc). Click on the existing sheet symbol and press the Delete key. 6. From the main menus, choose Design Create Sheet Symbol From Sheet Or HDL. In the Choose Document to Place dialog that appears, select the Clock_Divider.vhd entry and click OK. 7. Place and wire the new sheet symbol into the circuit as shown in Figure 28. Notice that the Designator and Filename have been automatically set to U_clock_divider and Clock_Divider.vhd respectively. The VHDLENTITY parameter has also been added, with value = clock_divider (the name of the entity in our VHDL sub-file).
Figure 28. Simple_Counter schematic with sheet symbol for Clock_Divider.vhd sub-file placed and wired.
8. Save the schematic and project. 9. Compile the project to check for any errors. If there are, resolve them, save and recompile. 10. After compiling, you can check the hierarchy of the project in the Projects panel. The project will now recognize the VHDL sub-file (Clock_Divider.vhd) as a child of the Simple_Counter schematic. Now we have finished adding the VHDL version of the clock division circuitry, let's test it out. 11. Open the Devices view and reprogram the daughter board's FPGA device by clicking the Program FPGA stage of the Process Flow. 12. Once programmed, start the counter (set either switch 7 or switch 8 of the DIP-switch to ON). You should be able to clearly see the slowed-down counter output on the NanoBoard's User LEDs and control the output via the DIP-switch as before.
Figure 29. Hierarchy with a VHDL sub-file.
16
2. Click the JTAG Viewer Panel button to access the JTAG Device Viewer panel. Ensure that both Live Update and Hide Unassigned I/O Pin options are enabled (Figure 31).
3. You are now viewing the pins of the physical FPGA device, while the circuit is in operation. Note how the LED icons light up next to the LEDS() ports as the circuit operates and reflect the distinctive output of the twisted-ring counter. You can also see the corresponding pins on the component symbol and footprint light up, as each pin is made active. 4. Change the direction of the count sequence using the NanoBoard's DIP-switch and see the change reflected in the panel.
17
Figure 32. Frequency counter instrument placed and wired into the simple counter design.
18
4. As we are not generating any outputs, we can simply remove the default entry. Click to select the AOUT[7..0] signal and click the associated Remove button for the section. 5. The default input signal is the right width for our purposes, so let's keep the signal, but give it a more meaningful name. Let's call it Count_Output[7..0]. We will keep the Style setting as LEDs, but change the Color setting to Green (just to mimic the color of the LEDs on the NanoBoard!). 6. To monitor the associated DIP-switch signals, let's now add a further three input signals to our configuration. Define these signals as: Signal 1 Name: Shift_Left, Style: LEDs, Color: Green. Signal 2 Name: Shift_Right, Style: LEDs, Color: Green. Signal 3 Name: STOP, Style: LEDs, Color: Red.
The Input Signals region of the dialog should now appear as shown in Figure 34.
7. Wire up the instrument as shown in Figure 35. Notice that we avoid messy wiring by using net labels to tap off the signals we wish to monitor (S04, SO3, SO2). These net labels already exist for the points we wish to interrogate, so it becomes a simple matter of copy and paste. Notice that we are monitoring the signals after they have passed through their respective inverters. This is because the switches associated with the DIP-switch are active Low, so it would be better to see a light come on when they are set to the ON position, rather than go off.
19
Figure 35. Digital IO instrument placed and wired into the simple counter design.
This component 'brings' the Soft JTAG chain into the design. In order to wire all relevant Nexus-enabled devices (in our case the two virtual instruments) into this chain, you need to also place a NEXUS_JTAG_PORT component (Figure 37), and connect this directly to the NEXUS_JTAG_CONNECTOR. This component can be found in the FPGA Generic integrated library (\Library\Fpga\FPGA Generic.IntLib). The presence of the NEXUS_JTAG_PORT component instructs the software to wire all components that possess the parameter NEXUS_JTAG_DEVICE=True into the Soft JTAG chain. For information on the JTAG communications, refer to the document AR0130 PC to NanoBoard Communications. 1. Place the NEXUS_JATAG_CONNECTOR and NEXUS_JTAG_PORT components onto the Simple_Counter schematic, connecting them together. 2. Place and connect a VCC Power Port to the TRST input of the NEXUS_JTAG_PORT component. Our design is now fully wired to include our two virtual instruments and should appear as shown in Figure 39.
Figure 38. Connecting JTAG devices into the Soft JTAG chain. Figure 37. Nexus JTAG Port.
20
Figure 39. Final design, complete with the two virtual instruments.
3. Save the schematic and the parent project. 4. Recompile the project. This time you should see no messages in the Messages panel. This is because all SQ outputs are being used by the Digital IO instrument and so all now have a load!
Figure 40. Virtual instruments are presented in the Soft Devices chain, once the FPGA is programmed.
21
Getting Started with FPGA Design 3. Start the counter (if not already) by toggling either switch 7 or switch 8 of the NanoBoard's DIP-switch. 4. Double-click on the icons for both instruments, to display their associated instrument panels in the Instrument Rack Soft Devices panel (Figure 41). These panels provide the necessary controls and displays for interacting with the instruments in real-time.
Figure 41. Respective instrument control panels for the frequency counter and digital IO module.
Looking at the panels we can see a couple of oddities. First, the frequency counter displays a frequency of 50Hz. Remember that our reference frequency from the NanoBoard is 20MHz and our clock divider provides divide-by-one million. The expected result of 20Hz is not there! Secondly, the LED display for the output of the counter, on the digital IO instrument's panel, is rather jittery the LEDs are certainly not shifting in a smooth fashion as they are on the NanoBoard itself. To remedy both of these situations, we need to further configure options relating to each instrument, from within their respective instrument panels. 5. From the instrument panel for the frequency counter, click on the Counter Options button. In the Counter Module Options dialog that appears, change the Counter Time Base entry from the default 50.000MHz to 20.000MHz (to be the same frequency as the signal we have wired to the instrument's TIMEBASE input). Close the dialog and notice, reassuringly, that the displayed freuqncy is now 20Hz. 6. From the instrument panel for the digital IO module, click on the Options button. In the Digital I/O Module Options dialog that appears, change the Update Display From Core Every entry from the default 250ms down to the minimum 100ms. Close the dialog. With this faster update, notice that the LEDs display more smoothly.
Figure 42. Change the counter time base for the instrument to be same as the frequency physically wired to the instrument's TIMEBASE input.
7. Have a play with the design toggling the count direction and stopping it and observe that the digital IO module updates live and in accordance with your changes.
22
Where to Now?
That concludes this introductory tutorial into the basics of FPGA design using the Altium Innovation Station. Armed with a solid grounding of the base concepts covered during the implementation of our simple counter, you can now embark on your own FPGA designs. The development environment provided by Altium Designer and the Desktop NanoBoard offers a far more extensive set of tools and features than those seen during the course of this tutorial. 32-bit processing, hardware acceleration and cutom logic are just a few catchphrases to tempt the taste buds not to mention a fully customizable virtual instrument where you even get to layout your own panel interface! For a high-level introduction to FPGA design and the Altium Innovation Station, refer to the document GU0123 An Introduction to Embedded Intelligence. For further, more advanced tutorials, covering more of the tools and features on offer, refer to the following documents: TU0122 Getting Started with Embedded Software TU0123 Creating a Core Component TU0126 Checking Signal Integrity on an FPGA Design TU0128 Implementing a 32-bit Processor-based Design in an FPGA TU0129 Converting an Existing FPGA Design to the OpenBus System TU0130 Getting Started with the C-to-Hardware Compiler TU0131 Capturing Video the Easy Way TU0133 Designing Custom FPGA Logic using C TU0135 Adding Custom Instrumentation to an FPGA Design
Revision History
Date 16-Jan-2004 23-Sep-2004 18-Jan-2005 13-Apr-2005 22-Aug-2005 28-Nov-2005 12-Apr-2007 17-May-2008 Version No. 1.0 1.1 1.2 1.3 1.4 1.5 1.6 2.0 Revision Initial release Clock divider components updated Components in Johnson_Counter.SchDoc updated Updated for Altium Designer Verilog references included Updated for Altium Designer 6 Updated for Altium Designer 6.7 Updated for Altium Designer Summer 08. Project and schematic documents renamed to Simple_Counter.PrjFpg and Simple_Counter.SchDoc respectively. Tutorial content enhanced throughout. Section on virtual instrumentation added. Software, hardware, documentation and related materials: Copyright 2008 Altium Limited. All Rights Reserved. The material provided with this notice is subject to various forms of national and international intellectual property protection, including but not limited to copyright protection. You have been granted a non-exclusive license to use such material for the purposes stated in the end-user license agreement governing its use. In no event shall you reverse engineer, decompile, duplicate, distribute, create derivative works from or in any way exploit the material licensed to you except as expressly permitted by the governing agreement. Failure to abide by such restrictions may result in severe civil and criminal penalties, including but not limited to fines and imprisonment. Provided, however, that you are permitted to make one archival copy of said materials for back up purposes only, which archival copy may be accessed and used only in the event that the original copy of the materials is inoperable. Altium, Altium Designer, Board Insight, DXP, Innovation Station, LiveDesign, NanoBoard, NanoTalk, OpenBus, P-CAD, SimCode, Situs, TASKING, and Topological Autorouting and their respective logos are trademarks or registered trademarks of Altium Limited or its subsidiaries. All other registered or unregistered trademarks referenced herein are the property of their respective owners and no trademark rights to the same are claimed. v8.0 31/3/08.
23