Using Booleans and Strings

Parent Previous Next

VisualSim                                                                                                                               

Using Booleans and Strings

Create a Custom_C block that calls C functions that return a Boolean and output a String

Construction Steps
  1. Open VisualSim IDE and drag the Custom_C block from Full Library > System_Language > C_and_CPP to the Block Diagram Editor.

 

Configuring the Custom_C block

Figure 1: Configuring the Custom_C block

  1. Right click the Custom_C block and select Configure Arguments and add the following arguments:

C/C++ Arguments Configuration for YearInfo

Figure 2: C\C++ Arguments Configuration for YearInfo

Note: Specify the array size except for the char type while using Arrays as C\C++ Arguments.

  1. Click the VisualSim menu Interface > Generate Wrapper for interface generation and compilation of source files. Refer Figure 6.
  2. A new folder named “YearInfo” is automatically created under VS_C_Library directory if it does not exist. In case if the files in the respective folder already exist, then it is replaced with the new files.
  3. Successful compilation of the sources files creates a Jni<libraryname>I<return argument name>.dll file under the blocks directory. The file extension “. Dll” indicates that the file is a dynamic link library (dll).

Note: Open the “vsout.txt” file under the libraryDirectory to check for errors caused by a unsuccessful compilation process. These could help in correcting any mistakes in the interface C code.

  1. The blocks directory is provided under VS_C_Library directory to hold “. dll” files, which are in the PATH.
  2. Drag the MoniterValue result block from Result > Text. Similarly the Const input block from Full Library > Math Operations > Math and Trig. Control-click to create the relation.
  3. Connect all the blocks as shown in the Figure 3.
  4. Add an Untimed Digital Simulator (located under Full Library -> Model->Simulator). Double-click the Untimed Digital simulator and change the number of iterations from 0 to 1.
  5. To run YearInfo model, click the run button or Press Ctrl+R. The expected result looks similar to the one shown below.

 

Result of??YearInfo Model

Figure 3. Result of YearInfo Model