Table Of Contents

Adapting a Testbench for Fixed-Point Conversion

Last Modified: September 20, 2016

When converting a floating-point design to fixed-point, you can adapt an existing testbench, such as the testbench used to test the original floating-point design, to test the output of the converted fixed-point design and make sure it sufficiently represents the output of the original floating-point design.

If you do not have the testbench used to test the original design or your existing testbench does not provide the right kind of input data, create a new testbench. Refer to Creating a Testbench to Test a Floating-Point Design for help creating a new testbench.

What to Use

What to Do

The following diagram provides a model for adapting an existing testbench for use during the floating-point to fixed-point conversion process.

spd-note-note
Note  

The design of your testbench depends on the purpose and requirements of your application. Therefore, the nodes, inputs, outputs, and structure in your diagram may differ from the those in the following diagram.

Customize the gray sections for your unique programming goals.

Create code to generate input data that accurately represents the real data you expect the design to process. Testing with realistic input data increases the probability that your design will work properly with the real data you acquire from your hardware once you deploy to the target. Consider the following guidelines when configuring input data:

  • Create input values that span the full range of the real values that you expect to process. Otherwise, you might underestimate the necessary range of the fixed-point data types in your converted design.
  • Create input values that vary enough to test all operations within the design and accurately represent the type of data you expect to process. For example, in digital signal processing (DSP), a digital filter might require an input signal with broad spectral content to determine its frequency response, while a linear algebra algorithm might require an input matrix with a sufficient condition number.
  • For DSP, use Signal Generation nodes to generate and configure input signals for your design.

Select the node you plan to convert to fixed-point and click Edit»Duplicate Hierarchy from Selection. When you click Duplicate and Place VI on Cursor, LabVIEW creates a copy of the node and any source code documents called from within it and stores the copies in a new folder in your project directory. Creating a copy of the original node ensures that you retain a reference copy of the original floating-point design that you can use to compare to the fixed-point design or save as a backup of your original design.

spd-note-note
Note  

If you know how the fixed-point output should look and do not need to display both the floating-point and fixed-point outputs on the panel to determine whether the fixed-point output is sufficient, you can generate only the fixed-point output. To generate only the fixed-point output, remove the original node from the diagram and wire the copied node the same way that the original node was wired.

To process the output of the copied node, copy the code you use to process the output of the original floating-point design. This ensures that you process the outputs of both the original and copied nodes in the same way.

spd-note-note
Note  

If you know how the fixed-point output should look and do not need to display both the floating-point and fixed-point outputs on the panel to determine whether the fixed-point output is sufficient, you can process only the fixed-point output. To process only the fixed-point output, remove the original node from the diagram, and use the existing code to process the output of the copied node.

(Optional) Use Build Array to compare the outputs of both the original and copied designs on the same graph.

Display the output of your testbench in a manner that best displays the output data. For example, if you are processing digital signals, consider displaying the output of your testbench using one or more graphs to identify trends in the output data more easily.

Troubleshooting

If your testbench experiences performance issues, consider the following strategies to improve performance:

  • Limit the number of input data samples for your design. When you begin to convert your design, you must profile the design as part of the conversion process. Profiling can slow performance, so limiting the number of input samples can keep your testbench running efficiently. However, make sure that you provide enough input data to adequately represent the full range and variety of the real data you expect to process.
  • If your testbench compares the output of the copied node to the output of the original, consider capturing a snapshot of your original output using the Capture Data button . After you capture the floating-point output, remove the floating-point branch from the diagram, and process and display only the output of the node you plan to convert. Using this approach, you cannot directly compare the converted fixed-point output to the floating-point output on the panel. However, you can refer to the captured floating-point data to compare to the fixed-point output.

Examples

Search LabVIEW for the following installed lessons:

  • Converting Floating-Point Data Types to Fixed-Point
  • Fixed-Point Conversion

Recently Viewed Topics