Full Library / Defining_Flow / Basic Processing / While
Block Name: While
Code File Location: VisualSim/actor/lib/DS_While_K
This is a programming block to implement while, for loops, and Do loops. If the condition in the "While_Statement" equates to a true or 1, then the lines numbers listed in the "True_Execute" are executed. If the condition in the "While_Statement" equates to a false or 0, then the lines numbers listed in the "False_Execute" are executed. The modified incoming Data Structure is sent on the true port if the "While_Statement" is true/1 and is sent on the false port if the statement is false/0. There will always be one false output. The Loop_Delay_Value is the time between each outputs.
The Field_Statements of this block follow the format of the Data Structure Expression Language. As far as the "While Statement" is true, the block repeats the processing. The maximum number of loops is given by the "Maximum_Loop_Count". The "Max_Loop_Count" emulate a For or Do loop when the "While_Statement" is kept to be always true. Example of While block usage is for fragmenting Data Structures based on a data size or sending multiple instances of the same data structure.
The format for the While Statement is: (name1 operator name2 || name3 operator name4) or (name1 operator name2 && name3 operator name4).
If the statement is true, i.e., a 'While', then the lines numbers on the 'true_execute' line are executed. If the statement is false, i.e., an 'else', then the lines numbers on the 'false_execute' line are executed. The list of line numbers in the 'true_execute' and 'false_execute' need not be unique. If the while statement is true, then the incoming Data Structure is sent on the 'output_true' port and if the statement is false, then the incoming data structure is sent on the 'output_false' port. As long as the while is true, the original Data Structure is maintained and the while statement is repeated. The first delay is executed after the first output. The number of while executions for one incoming Data Structure can be restricted by the number in the 'Max_Loop_Count' parameter. When a false is computed or if the Max_Count is reached, the loop counter reverts back to zero.
The Use Model for this block is for packet fragmentation and repeat a set of instructions multiple times.
Expression Language Syntax: X Op Y, or X = Y Op Z
Where X can be a Memory or Field, OP os the Operator (See below), Y can be Memory, Field, Time, Parameter or Value and Z can be Memory, Parameter, Field, Time or Value.
TYPES
int, long, double, string, binary, boolean and data structure.
OPERATORS
For the format of X Op Y, Operators are: =, +=, -=, *=, /=, 1/=, %=, !, ^, sqrt, ~, &, |, xor
For the format of Y Op Z, Operators are: +, -, *, /, 1/, %, &, |, xor
Additional operators include binary functions for Y Op Z: & (AND), | (OR), ~ (NOT), ! and 'xor' (Exclusive OR).
Additional operators include binary functions for Y Op Z: '&=', '|=', '~=', 'xor='
Other operators are for Y Op Z: <<', '<<=', '>>', '>>='
Random: irand(lower, upper), rand(lower, upper), exp(mean), norm(mean, stdev)
This block can also be used to define a memory as: MyMemL local 0, MyMemG global 1.0
TIME
DSNow, TNow, TLast, TDelta, TReal, TRealLast, TRealDelta
NOTE
Binary and shift operators can be applied only on int, binary and binary strings.
The Use Model for the Data Structure Blocks is to modify user-defined data structures or memories to implement an architectural abstraction, or cycle accurate model. Data Structure Blocks provide for communication between model flows via memory elements (DS Blocks or Memory BLocks) and with composite Data Structures to quickly and efficiently implement a modeling abstraction. One can think of Data Structure Blocks as operating on Data Structures, similar to individual EXCEL spreadsheets with flow oriented operators (DS Blocks).
Refer While Demo Model.
Parameter |
Explanation |
Type |
Example |
While_Statement |
The format for the While Statement is: |
String |
"Name_X == Name_Y" |
True_Execute |
While True_Execute identifies the Field_Statement_n's to be executed, assuming the 'while' statement is true. |
String |
"1, 2" |
False_Execute |
While False_Execute identifies the Field_Statement_n's to be executed, assuming the 'while' statement is false. |
String |
"3, 4" |
Field_Statement_1 |
The field description 1 (op_x, assign, op_y, op, op_z) is a string that utilizes the DS Expression language. op_x represents the result of the asssignment (assign) operator, typically '='. The expression formats, operators, types and Time values listed in the summary section can be used here. The assignment operator can also be '+=', '-=', '*=', '/=', etc. similar to C/C++. The assign can also be 'local' or 'global' for declaring memories. op_x can be a memory (local, global), composite data structure field, or combination 'memory:field'. op_x cannot be a constant or numerical value, like C/C++. op_y, op_z can be a memory, composite data structure field, 'memory.field', constant, or numerical value. |
String |
Name_X Assign Name_Y OP Name_Z |
Field_Statement_2 |
The field description 2 (op_x, assign, op_y, op, op_z) is a string that utilizes the DS Expression language. op_x represents the result of the asssignment (assign) operator, typically '='. The expression formats, operators, types and Time values listed in the summary section can be used here. The assignment operator can also be '+=', '-=', '*=', '/=', etc. similar to C/C++. The assign can also be 'local' or 'global' for declaring memories. op_x can be a memory (local, global), composite data structure field, or combination 'memory:field'. op_x cannot be a constant or numerical value, like C/C++. op_y, op_z can be a memory, composite data structure field, 'memory.field', constant, or numerical value. |
String |
Name_X Assign Name_Y OP Name_Z |
Field_Statement_3 |
The field description 3 (op_x, assign, op_y, op, op_z) is a string that utilizes the DS Expression language. op_x represents the result of the asssignment (assign) operator, typically '='. The expression formats, operators, types and Time values listed in the summary section can be used here. The assignment operator can also be '+=', '-=', '*=', '/=', etc. similar to C/C++. The assign can also be 'local' or 'global' for declaring memories. op_x can be a memory (local, global), composite data structure field, or combination 'memory:field'. op_x cannot be a constant or numerical value, like C/C++. op_y, op_z can be a memory, composite data structure field, 'memory.field', constant, or numerical value. |
String |
Name_X Assign Name_Y OP Name_Z |
Field_Statement_4 |
The field description 4 (op_x, assign, op_y, op, op_z) is a string that utilizes the DS Expression language. op_x represents the result of the asssignment (assign) operator, typically '='. The expression formats, operators, types and Time values listed in the summary section can be used here. The assignment operator can also be '+=', '-=', '*=', '/=', etc. similar to C/C++. The assign can also be 'local' or 'global' for declaring memories. op_x can be a memory (local, global), composite data structure field, or combination 'memory:field'. op_x cannot be a constant or numerical value, like C/C++. op_y, op_z can be a memory, composite data structure field, 'memory.field', constant, or numerical value. |
String |
Name_X Assign Name_Y OP Name_Z |
Loop_Delay_Value |
This is the delay between the output of the data structure on the true port and the execution of the next while on the same Data Structure. The value can be a variable, field, parameter, or double number. The type is string or double. |
String |
"MemName_FldName_Param_Num" |
Max_Loop_Count |
This is the Maximum Number of while statements that are executed for a single incoming Data Structure before exiting. The while statement will continue to execute up to "Max_Loop_Count" times, if the while statement continues to evaluate as true. When this maximum count is reached, the Data Structure will simply loop out and, as such, acts as a default false exit. When a false is computed, the loop counter reverts back to zero. If the user does not enter anything, the default is 10000. |
String or Integer |
"MemName_FldName_Param_Num" |
Random_Seed |
Random Number Seed. |
String |
123457L |
Port |
Explanation |
Type |
input |
It is used to accept the incoming Data Structure. |
String |
output_true |
It is used to sent the modified Data Structure out if the expression evaluates to 'true'. |
String |
output_false |
It is used to sent the modified Data Structure out if the expression evaluates to 'true'. |
String |
Created with the Personal Edition of HelpNDoc: Full-featured EPub generator