Methods

Parent Previous Next

VisualSim                                                                                                                               

Methods

Virtual Machine comprises functions to facilitate delays, send to specific ports, and block defined queues. The following table contains functions specific to the Virtual Machine block. In addition, the entire RegEx language can be used in the code.

 

Functions

Format

WAIT (used for blocking delay)

WAIT(Double value or field_name or memory_name or Event_name)

SEND (This method can send to a port, virtual connection, another Virtual_Machine or to a LABEL.)

SEND (<port name>, <token expression>)

 

QUEUE (This stores (put) and removes (pop) the token in the Queue in a FIFO method. There can be only one.)

QUEUE(<queue name>, <token>, <priority>,<operation>)

 

TIMEQ (Queue is reordered based on the priority of the incoming token.)

TIMEQ (<queue name>, <token>, <priority>, <queue operation>, <delay expression>)  

 

 

Important Virtual_Machine RegEx Functions

Port

Explanation

Create a new Token from the VisualSim/data folder

MyToken = newToken("Processor_DS")

MyArray = newToken("{100:0}")

Create a new Memory or Field

 

port_token.A_New_Field   = Field_Value

newMemory("MyNewMemory", Memory_Value)

(Field_Value or Memory_Value can be a parameter or block level memory.)

Check if Data Structure contains field

port_token.containsRecordTokenLabel("A_Command")

Read a Memory or Field and insert into a field of port_token:

 

port_token.MyField  = readField(port_token, Channel_Field_Name)

port_token.MyField  = readMemory("MyMemory", Memory_Field_Name)

(where Channel_Field_Name or Memory_Field_Name can be a parameter or block level memory.)

Throw a model exception, stop the simulation.

throwMyException (Block_Name + " has a Channel value that is inconsistent.")

Send statement to the Command Line (debug is block memory flag) and do not stop the simulation.

debug ? sendToCommandLine (Block_Name + " next Cache Prefetch (" + C_Prefetch.ID + ") \t@ " + formatTime(TNow)) : Tnow

 

Coding Functions

Following are the coding functions:

Functions

Codes

LABEL (An identifier to denote a specific address in the code)

LABEL:Name and is used as GTO("Name")

If, else-if, else (This is a traditional if condition)

if (<conditional statement>)

{

   <true statements>

}

else if (<conditional statement>)

{

   <true statements>

}

else

{

    <false statements>

}

Transitional if-else (This is a single line if-statement)

<conditional statement> ? <true statement> : <false statement>

SWITCH-CASE (This is similar to C format with some differences)

SWITCH (port_token.ID) { /* Decodes ID integer field of Transaction */

  CASE: 0

   <RegEx statements>      

GTO (END)     /* Exit from script  */

CASE: DEFAULT /* Last CASE, unlike C code, must be DEFAULT */

   <RegEx statements>

GTO (END)    /* Exit from script  */

 }

While (This operates in a loop and terminates when a condition is reached)

while (true)/* Loop */

{

Remain_Bytes  = readField(port_token, Bytes_Remaining_Field) /* Down Counter */

WAIT (Time_Between_Fragments) /* Delay */

}

CALL (This function is used to call a common piece of code)

GTO(END)

 

Hidden Parameters

Parameter

Explanation

Max_Queue_Length (64)

This applies to each QUEUE, TIMEQ, and Input_Queue and must be a binary value, 128, and 256.

Number_of_Queues (256)

This applies to number of individual QUEUE and TIMEQ.

Add_Scheduler_Times_to_DS (false)

Used to add fields to incoming data structure: TIME_ACTIVATION, TIME_RELEASE, TIME_FINISH, TIME_RESPONSE, TIME_IN_SYSTEM. Refer to Scheduler documentation for more details on these field values.

Maximum_Loops (1000000)

This applies to a while loop without a WAIT or TIMEQ function being encountered.

Read_File

This is a file name that contains the code when it needs to be read from a file.  This approach is preferred when the code needs to be modified between simulation runs. The code is not in the block but is written in a separate text file.  If the Path parameter is available, then the block searches in the directory, else in $VS directory.  This is file name with a .txt extension.

Save_Files

This is a boolean used to save the compiled file in a location specified by the Path parameter of this block or the $VS directory. This parameter used to speed up the compile time. This is used when there are 100s of instances of the Virtual Machine or Smart_Controller. If this value is true, then the file is saved. The first time the code is compiled, it is written to a file. The next time around, the delta is compared and if there is no change, the code is not recompiled.

Path

This applies to the Read_File and Save_File option.  This path is used to save the compiled files and for reading a code file.    

Profile_File

Name of the file.  If there is a PATH setting, this will be relative to the path.  If the PATH does not exist, then enter the complete path here. This generates the profile for the code in this file. 

 

Math functions

Function

Description

Example

++

Can be applied to a memory, field
of a data structure or a array location.
This increase the value by 1.  Can be
applied to integer, double and long only.

++MyVar
++MyDS.ID
++MyArr(index)

--

Can be applied to a memory, field
of a data structure or an array location.
This decrease the value by 1.  Can be
applied to integer, double, and long only.

--MyVar
--MyDS.ID
--MyArr(index)

Name Operator= Value

Can be applied to a memory, field
of a data structure or an array location.
This increase the amount by the Value.  
Can be applied to integer, double and
long only.

Supports add (+), subtract (-), multiply (*), divide(/) and modulo (%).

MyVar += 5
MyDS.ID -= 1
MyArr(index) %= 4

 

Created with the Personal Edition of HelpNDoc: Produce online help for Qt applications