Device Testing Scripts

The XJDeveloper test system follows a 'device-centric' philosophy. This means that the tests for non-JTAG devices are written in such a way that they only make reference to the device itself, and they do not make any reference to how the device is connected in the circuit.

This device-centric focus allows you to reuse a device file

  1. when the corresponding device is used multiple times in a circuit, or
  2. when it is used again in other circuits.

Although the way the device is connected will be specific to each instance, the device itself is the same and therefore the same XJEase device file can be used.

Tests for non-JTAG devices have to utilise the connections between these devices and the JTAG device(s) in the circuit. In this project setup, XJTAG can directly control only the JTAG device(s), so non-JTAG devices can only be tested by setting and/or reading the values of the nets that connect them to a JTAG device. The first XJEase code you are going to review has been extracted from the XJTAG Library and relates to the push-button, SW1.

Pushbutton.xje

  • Click Test Device Files under Setup.
  • Double-click Pushbutton.xje (in the Navigator section) to open it.

The ReadSwitch function uses the connection between the push-button and the devices in the JTAG chain, as described in the netlist, to read the value of the push-button's output pin. This is done using the SET statement.

The Test function uses the ReadSwitch function to get the current value of the net connected to the push-button. The output displayed by the Test function tells the operator what to do at each stage, and by using the built-in function UNIQUE_DEVICE_REF this output always prints the specific device reference for whichever device is being tested (in this case, SW1).

The net connected to the push-button's output pin will transition from low to high when the button is pressed, and will then revert to low when the button is released. The test uses the result variable to return RESULT_PASS if the function sees the expected transitions on the net (because the operator has interacted with the push-button when prompted), or RESULT_FAIL if the operator presses a key on the keyboard.

The constants RESULT_PASS and RESULT_FAIL are globally defined in the Globals.xje file, which is added to every new project from the XJTAG library and can be viewed on the Circuit Code Files screen.

As with the other device tests, this test must be enabled in the XJRunner Test List before it can be run.

Running the test

  • Click Run Tests under Run and Deploy.
  • Click Presets at the bottom of the Test List, and select None.
  • Double-click SW1.Test under the Push Button Tests test group to re-enable the push-button test.
  • Click Run to run the push-button test. This will pass if you press the button as instructed, or fail if you press a key on the keyboard.

LED (pin 2).xje

The push-button test uses the net between SW1 and the JTAG device to read the value being driven by the push-button. In contrast, the LED test uses the connection to drive pins on the LED in order to toggle the LED on and off.

  • Return to the Test Device Files screen. This time double-click LED (pin 2).xje (in the Navigator section) to open it.

The only text in this file is a comment, as shown in the code editor. There are also two busses (corresponding to the two pins of the LED) and three configuration variables defined in the file, shown in the tabs below the code editor. The actual test code is not visible here because it is in an additional code file called LED Test.xje which is a common file shared between various LED definitions.

  • Click the + to the left of LED (pin 2).xje in the Navigator panel.
  • Double-click the LED Test.xje sub-item underneath LED (pin 2).xje in order to review the code for the LED tests.

The XJEase code in the SetLED function switches the LED on and off using a SET statement. The Test function uses SetLED to continuously toggle the LED on and off, and triggers a pop-up dialog to ask the operator whether the LED is flashing. Then if the operator clicks Yes to indicate they have seen the toggling light, the result variable will return RESULT_PASS, whereas if they click No it will return RESULT_FAIL.

At the end of testing, the LED is turned off to the value OFF_STATE, using another SET statement. OFF_STATE is a configuration variable which can be set when categorising the device as a Test Device on the Categorise Devices screen.

All of the LEDs on the XJDemo board have been categorised using the same XJEase device file, meaning that they will all be tested individually in the same way.

Alternatively, the eight LEDs on the XJDemo board could be tested by writing a new function in a circuit code file that tests all of the LEDs in sequence and returns an overall result.