Atom Tab for Basic Block

Define the Atom tab of the Block Builder for a basic block.

For a basic block, the Atom tab provides a list of simulation functions. Typically, a block has more than one simulation function, especially when it supports various data types. For each simulation function, you need to specify the shared library and its corresponding entry point. To define a basic block, you must create up to three OML functions, and the partial code for these functions is included in the Atom tab.

The first function, SetParameters, creates the structure of the block based on block parameters and port properties. The other two functions, SetIO and Reset, come into play when modifications to this structure are necessary.

Set Parameters

The OML code that must be provided to define the function assumes that the following are available:

  • The blocks name, defined in the variable _label.
  • The block parameter values under the corresponding parameter names.
  • The diagram where the block is to be placed, defined in the variable _diagram.
For a basic block, the block added to the diagram is of type "block." The OML code consistently includes the following lines:
_block = vssAddNewObject (’Block’, _diagram);
vssSetBlockName (_block, _label);

The structure represented by _block is then supplemented using provided APIs. The code applied here varies significantly based on the attributes of the new block. Rather than providing an exhaustive list of APIs and their usage, it is recommended that you review the code associated with existing blocks, especially those resembling the properties of the new block. This approach simplifies the process of creating new code, reducing it to modifying a few lines in existing code.

The SetParameters function is automatically generated based on the OML code provided by you. It includes systematic tests to generate error messages. This function is called in the model evaluation phase, which constructs the model structure used for compilation and simulation.

The other two functions are used to set values that are not set by the SetParameters function. These values relate to undefined sizes and data types for block input and output ports. Although the SetParameters function generally specifies all block structure properties, it might leave some properties undetermined for the compiler.

The size of an input may be left unknown by setting the size vector to negative values, such as [-1, -2]. Negative values indicate arbitrary sizes. If another input or output size is also set to [-1, -2], then both have arbitrary sizes, and they are equal. An input size of [-1, -1] implies a square matrix of arbitrary size. Negative values signify unknown sizes, and identical negative values indicate identical sizes. This approach allows for constraints on block port sizes to be applied to many common blocks. For example, a matrix transpose block might have an input size of [-1, -2] and an output size of [-2, -1], encapsulating the constraints imposed on its input and output.

The compiler determines the actual port sizes by considering these constraints and how the blocks are interconnected. Similarly, block port data types may be set to arbitrary values, with the compiler deducing the actual types.

Set Inputs/Outputs

Note: Most user defined blocks do not require the SetIO and Reset functions, so the associated code in Atom should be left empty.
The SetIO function is defined when constraints on port data types and sizes cannot be imposed using negative numbers. For example, a block might have an arbitrary input size and an output size one unit larger than the input. These unique constraints cannot be handled using negative size values. In such cases, the block can provide a SetIO function that operates on the block structure, previously constructed by SetParameters. This function, based on the current status of port sizes and types, can replace negative port sizes and types with positive values. It can be called multiple times during compilation. In the case where the output is one size larger than the input, the function can fully define the port sizes if either the input or output size is known when the SetIO function is called.

Reset Parameters

After the compiler computes block input/output data sizes and types, the block's Reset OML function is called with the block structure, including the actual port data sizes and types. This function can then adjust other block properties as needed. In most cases, the Reset function selects the appropriate simulation function based on port data types, and it is defined in Atom based on user-supplied code.