Procedure superblocks, Generating reusable procedures, Linking procedures with the systembuild simulator – National Instruments AutoCode NI MATRIX User Manual

Page 37: Procedure superblocks -20

Advertising
background image

Chapter 2

C Language Reference

AutoCode Reference

2-20

ni.com

Linking a Variable Interface UCB with the Simulator

Unlike the fixed interface which provides an automatic method for linking
with the Simulator, the variable interface is too complicated for that
method. As a result, you are required to create a “wrapper” function that
interfaces between the Simulator and your code. For information on how to
create the wrapper for the Simulator, refer to the SystemBuild User Guide.

Procedure SuperBlocks

This section describes how to generate and link Procedure SuperBlocks.

Generating Reusable Procedures

Generate a reusable procedure from your Procedure SuperBlock as
described in Chapter 3,

Ada Language Reference

. Refer to callout 1

of Figure 2-4. Along with the algorithmic procedure (refer to callout 2),
AutoCode also generates the respective hook procedure or wrapper
(refer to callout 3) for automatic linking with the SystemBuild simulator.

Refer to Chapter 5,

Generated Code Architecture

, and Chapter 9,

Global

Scope Signals and Parameterless Procedures

, for more information about

generating procedures.

Linking Procedures with the SystemBuild Simulator

Replace the procedure SuperBlock with a UserCode Block (UCB), refer
to callout 4 of Figure 2-4 and place the appropriate file name and function
name in the UCB dialog box entries. The function name should be that of
the Procedure SuperBlock with

_ucbhook

appended to it.

When simulating the model, the SystemBuild simulator automatically
compiles and links the generated code, and executes the simulation with the
new code library created at this point.

If more than one Procedure SuperBlock resides in the top-level discrete
SuperBlock from which the procedures are generated, AutoCode will only
generate a UCB wrapper for the first Procedure SuperBlock it encounters.
If you want to generate wrappers for the other Procedure SuperBlocks,
place each Procedure SuperBlock in a separate Discrete SuperBlock and
generate code. You can also modify the template file to generate wrappers
for all procedures in your model by invoking the TPL function

proc_ucb_hook

on all Procedure SuperBlocks. Notice how default

template file

c_sim.tpl

invokes

proc_ucb_hook

for one Procedure

SuperBlock, modify it to loop on all Procedure SuperBlocks, and invoke

Advertising