Main Content

Code Replacement Tool

Create, modify, and validate content of code replacement libraries

Description

The Code Replacement Tool is a graphical interface that you can use to create and manage custom code replacement libraries. You can create, import, manipulate, and validate the code replacement tables in a library. The tool also generates the customization file to register a code replacement library with the code generator. If you specify a table name when you open the tool, the tool displays only the contents of that table.

The tool display consists of three panes that show table and table entry information:

  • Left pane lists code replacement tables.

  • Middle pane lists available tables or, if you select a table in the left pane, the table entries that are in that table.

  • Right pane lists table or table entry details. If you select a table, the right pane shows table properties: the table name, which you can modify, the table version, and the total number of entries in the table. If select a table entry, the right pane shows mapping and build information for that entry.

Open the Code Replacement Tool

At the command prompt, type crtool.

Examples

expand all

This example shows how to open a code replacement table, my_lookup_replacement_table, in the Code Replacement Tool. This table is used in Generate Code by Using Lookup Table Code Replacement Library.

crtool('my_lookup_replacement_table')

Code replacement tool showing table my_lookup_replacement_table.

Related Examples

Parameters

expand all

Entry Summary Information (Center Pane)

Conceptual name of the function or operation being replaced. Can name a math operation, function, BLAS operation, CBLAS operation, net slope fixed-point operation, semaphore or mutex entry, or customization entry.

Name of the implementation (replacement) function.

Number of input arguments.

Data type of a conceptual input argument.

Data type of a conceptual output argument.

The entry match priority, relative to other entries of the same name and to the conceptual argument list within the selected code replacement library. The priority can range from 0 to 100, with 0 being the highest priority. The default is 100. If the library provides two implementations for a function or operator, the implementation with the higher priority shadows the one with the lower priority.

Entry Mapping Information (Right Pane)

Conceptual name of the function or operation being replaced. Can name a math operation, function, BLAS operation, CBLAS operation, net slope fixed-point operation, semaphore or mutex entry, or customization entry.

Computation or approximation algorithm configured for a function or operation being replaced. For example, you can configure:

  • The Reciprocal Sqrt block to use the Newton-Raphson computation method.

  • The Trigonometric Function block, with Function set to sin, cos, sincos, or atan2, to use the approximation method CORDIC or Lookup.

  • An addition or subtraction operation, to use the cast-before-operation or cast-after-operation algorithm.

Names of input and output arguments of function or operation being replaced. Conceptual arguments observe naming conventions (y1, u1, u2, ...) and data types familiar to the code generator.

Data type of a selected input or output argument of the function or operation being replaced. Conceptual arguments observe data types familiar to the code generator.

Whether the selected input or output argument of the function or operation being replaced is real or complex.

Whether the selected input or output argument of the function or operation being replaced is a scalar value or a matrix. If you select Matrix, parameters for specifying range dimensions, and for replacement of MATLAB code, array layout appear.

Vector that specifies the lower range of the matrix dimensions.

Vector that specifies the upper range of the matrix dimensions.

Order in which array elements are stored in memory. Row-major layout can improve performance for certain algorithms and ease integration with external code or data that uses the row-major layout.

Whether you want the data types for your implementation arguments to be the same as the conceptual argument types. For example, most ANSI-C functions operate on and return double data. Clear the check box if want to map the conceptual representation of a function or operation to an implementation representation that specifies an argument and return value. For example, clear the check box to map the conceptual representation of the function sin to an implementation representation that specifies an argument and return value of type single (single sin(single)).

Name of the replacement function.

Namespace of the replacement function.

Whether your implementation function returns void.

Names of input and output arguments of your replacement function.

Data type of a selected input or output argument of your replacement function.

Whether a selected argument of your replacement function is an input or output argument.

Whether to apply the const type qualifier to a selected argument of your replacement function.

Whether a selected argument of your replacement function is a pointer.

Whether the selected input or output argument of the replacement function is real or complex.

Saturation mode supported by the replacement function.

Rounding modes supported by the replacement function.

Whether your replacement function accepts expression inputs. If you select the parameter, the code generator integrates an expression input into the generated code rather than inserting a temporary variable in place of the expression input.

Whether your replacement function modifies variables representing internal or global state.

Entry Build Information (Right Pane)

Header file for the replacement function (for example, my_rep_func.h).

Source file for the replacement function (for example, my_rep_func.c).

Names and paths of additional header files to include for the replacement function (for example, support_files.h and matlab\customization\mylib\include).

Names and paths of additional source files to include for the replacement function (for example, support_files.c and matlab\customization\mylib\src).

Names and paths of link object files to use for the replacement function (for example, support_files.o and matlab\customization\mylib\bin).

Link flags to use for the replacement function (for example, -MD -Gy).

Compile flags to use for the replacement function (for example, -Zi -Wall).

Whether the code generator copies files from external folders to the build folder before starting the build process.

Programmatic Use

expand all

crtool(table) opens the Code Replacement Tool and displays the contents of table, where table is a character vector that names a MATLAB file that defines code replacement tables. The file must be in the current folder or on the MATLAB path.

Version History

Introduced in R2014b