Creation of New Model Types

A model defines a complete program or application. Instead of having a "main" function as required in most programming languages, NSL applications require the existence of a model where execution begins. This model is unique to every NSL application. Its definition is somewhat similar to module definitions except in the use of the nslModel keyword (instead of nslModule) as shown in code segment 6.16. Note that NSLM does not allow any instantiation parameters nor a inheritiance specification for models.10

Code Segment 6.15

nslModel Definition Template.

The template section that appears outside the curly brackets corresponds to the model header, consisting of the following model-name is the name identifying the model. This name is internally used by NSLM to implicitly instantiate the complete model.

The template section that appears inside the curly brackets defines the actual structure and functionality of the model:

model-attribute-spec defines the structure of the model in terms of primitive, object and module type variables. With the exception of not having any port instantiations, this section is similar to that in modules.

model-method-spec defines the behavior of the model in terms of local functions or methods definitions, including simulation methods.


model-name ()







nslModel Definition Template.

For example, the ExtendedModel instantiates the ExtendedModule module as shown in code segment 6.17.

Code Segment 6.16

nslModel example.

ExtendedModel is implicitly instantiated by NSL in order to execute the model. 6.7 Summary

In this chapter we have presented the key concepts and constructs needed to build a NSL model. Since NSLM is built on top of C++ and Java, we discussed the parts of the NSLM language that is shared with these two native languages. We also discussed the basic NSLM types and how to build NSLM modules and models. Finally, we presented a section on how to build your own NSLM classes and what restrictions one might encounter when doing this. Although this chapter described the NSL modeling language in more detail than that presented in chapter 3, to fully grasp the language we recommend that Appendix I, The NSLM Methods be reviewed.

Was this article helpful?

0 0

Post a comment