Getting Started Tutorial - Adding Virtual Instrumentation to the Mix

Frozen Content

To test the state of internal nodes in the design you can 'wire in' virtual instruments. The 'hardware' portion of the instrument is placed and wired on the schematic like other components, and then synthesized into the FPGA. The interface to each instrument is accessed from within the Devices view.

Virtual instruments are placed from the \Library\Fpga\FPGA Instruments.IntLib library.

Let's add a couple of instruments into our design:

  • A frequency counter (FRQCNT2) – which we will use to display the output frequency from our clock division circuit.
  • A digital IO module (DIGITAL_IO) – which we will use to display the output of the counter and also the current state of the three switches associated to the NanoBoard's DIP-switch.

At this point, the current incarnation of the project has clock division supplied by an underlying VHDL sub-file. For this part of the tutorial we will leave this as is – there is no need to revert back to the schematic implementation of the clock division (although you could if you prefer it!).

Add the Frequency Counter

Let's start off by placing and wiring the frequency counter instrument into our simple counter design.

  • Open the Simple_Counter schematic (Simple_Counter.SchDoc).
  • Access the Libraries panel and place the FRQCNT2 component from the FPGA Instruments integrated library (FPGA Instruments.IntLib), to the bottom-right of the sheet symbol used to reference the VHDL sub-file.
  • Annotate using the Tools » Annotate Schematics Quietly command.

The signal we want to monitor is the output of the clock divider (CLK_OUT). We'll connect this to the FREQA input of the instrument. The TIMEBASE signal should be the original frequency from the NanoBoard (CLK_REF).

  • Go ahead and wire up the instrument as shown in Figure 1. Place a GND power port, connected direct to the instrument's FREQB pin, as we are not using this channel.
     

    Figure 1. Frequency counter instrument placed and wired into the simple counter design.

Add the Digital IO Module

Now let's add the digital IO instrument.

  • Access the Libraries panel and place the DIGITAL_IO component, centrally and above the main circuitry in the design.
  • Annotate using the Tools » Annotate Schematics Quietly command.

Before we consider the wiring, let's configure the instrument with the signals we wish to monitor.

  • Right-click on the instrument and choose Configure U13 (DIGITAL_IO) from the menu to access the Digital I/O Configuration dialog. (Figure 2). Notice that by default, the instrument is configured to have a single 8-bit input bus (AIN[7..0]) and a single 8-bit output bus (AOUT[7..0]).
     

    Figure 2. Access to controls for configuring the Digital IO instrument.
  • 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.
  • 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!).
  • 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 3.
 

Figure 3. Fully configured Digital IO instrument.

  • Wire up the instrument as shown in Figure 4. 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.
     

    Figure 4. Digital IO instrument placed and wired into the simple counter design.

Enabling the Soft Devices JTAG Chain

Communications from the Altium Designer software environment to embedded processors and virtual instruments in an FPGA design, is carried out over a JTAG communications link. This is referred to on the Desktop NanoBoard as the Soft JTAG (or Nexus) chain.

The Soft JTAG chain signals (NEXUS_TMS, NEXUS_TCK, NEXUS_TDI and NEXUS_TDO) are derived in the Desktop NanoBoard's NanoTalk Controller (Xilinx Spartan-3). As part of the communications chain, these signals are wired to four pins of the daughter board FPGA. To interface to these pins, you need to place the NEXUS_JTAG_CONNECTOR design interface component (Figure 5). This can be found in the FPGA NB2DSK01 Port-Plugin integrated library (\Library\Fpga\FPGA NB2DSK01 Port-Plugin.IntLib).

Figure 5. Nexus JTAG Connector.

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 6), 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).

Figure 6. Nexus Port.

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.

  • Place the NEXUS_JATAG_CONNECTOR and NEXUS_JTAG_PORT components onto the Simple_Counter schematic, connecting them together.
  • Place and connect a VCC Power Port to the TRST input of the NEXUS_JTAG_PORT component.
     

    Figure 7. Connecting JTAG devices into the Soft JTAG chain.

Our design is now fully wired to include our two virtual instruments and should appear as shown in Figure 8.

Figure 8. Final design, complete with the two virtual instruments.

  • Save the schematic and the parent project.
  • 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!

Accessing Instrument Controls

In the previous section, we looked at the mechanics of adding the virtual instruments into the Soft JTAG chain. It is a good idea – before we reprogram the FPGA and actually access the instruments – to consider access to these instruments is made possible within Altium Designer.

The host computer is connected to the target instruments using the IEEE 1149.1 (JTAG) standard interface. This is the physical interface, providing connection to physical pins of the FPGA device in which the instruments are to be embedded.

The Nexus 5001 standard is used as the protocol for communications between the host and all devices that are debug-enabled with respect to this protocol. This includes the digital I/O and frequency counter, as well as other Nexus-compliant devices such as debug-enabled processors, frequency generators, logic analyzers and cross-point switches.

All such devices are connected in a chain – the Soft Devices chain – which is determined when the design has been implemented within the target FPGA device and presents within the Devices view. It is not a physical chain, in the sense that you can see no external wiring – the connections required between the Nexus-enabled devices are made internal to the FPGA itself.

  • Open the Devices view and reprogram the daughter board FPGA device.
  • Once programmed, the Soft Devices chain will appear as the last chain in the view, containing icons for our two virtual instruments (Figure 9).
     

    Figure 9. Virtual instruments are presented in the Soft Devices chain, once the FPGA is programmed.
  • Start the counter (if not already) by toggling either switch 7 or switch 8 of the NanoBoard's DIP-switch.
  • Double-click on the icons for both instruments, to display their associated instrument panels in the Instrument Rack - Soft Devices panel (Figure 10). These panels provide the necessary controls and displays for interacting with the instruments in real-time.
     

    Figure 10. 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.

  • 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).
     

    Figure 11. Change the counter time base for the
    instrument to be the same as the frequency physically wired
    to the instrument's TIMEBASE input.
  • Close the dialog and notice, reassuringly, that the displayed frequency is now 20Hz.
  • 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.
     

    Figure 12. Increase the display update speed.
  • Close the dialog. With this faster update, notice that the LEDs display more smoothly.
  • 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.

See Also

Counter Module.
Digital IO Module.
PC to NanoBoard Communications.

You are reporting an issue with the following selected text and/or image within the active document: