CASP Tutorial-9 Project
This tutorial project demonstrates how to create a custom block with user code and use it in CASP. This tutorial has two parts
1. Create a custom primary block:: CASP primary block creation typically consists of following
a. Configuring block parameters such as block name, version and other parameters related to block’s behavior
b. Configuring user parameters that user may select when using the block instance during CASP modeling.
c. Creating block ports and configuring port parameters such as port data type, data dimension and size.
d. Generate template code and modifying the code.
2. Use the created block in CASP model, perform simulation and validate the results.
Pre-Requisites
· Tutorial-2 should be completed.
· View the tutorial video on how to Create Custom Block from the link given in /tutorials/video_tutorials.txt.
Documentation Reference
User may need to refer following topics in CASP documentation when creating a block
· CASP Documentation > Blocks > Primary Blocks > Creating Primary Blocks
· CASP Documentation > Blocks > Block Editor
Block Creation
· Invoke Block Editor from CASP main tool bar Tools > Block Tools > Block Editor
· For the purpose of demonstration we will create a simple block that performs basic arithmetic operations such as Add, Subtract, Multiply and Divide. The block has two input ports and one output port.
· Create the block as shown in the video tutorial mentioned under Pre-Requisites. Save the block in /blocks directory of current project.
· Creating block images with Image Editor is not mandatory. However, block images gives more representation to the block.
· Source code to be modified for the block logic is shown below. Rest of the code that is not shown here may be left unchanged.
Model
· Create the model as shown below.
Simulation
Setup relevant simulation settings and run the simulation. The resultant simulation panel is shown below