Traffic, Attributes, and Decisions
Tutorial Goals
This section is an introduction
to using the VisualSim library. You can also construct models using
standard operations. The following is a summary of the concepts and
tasks you will learn in this session.
- Define statements using the Expression List block.
- Instantiate the data structure fields with randomly generated values.
- Make block decisions using the content of the data structure fields.
Target
The purpose of this session is
to build a system model to generate traffic and to define the
attributes of the transactions through the fields of the data
structures. The block diagram of this system is shown in Figure 1.
Figure 1: Block Diagram of the system design
VisualSim Tutorial Model Location
Open this model in VisualSim from the following location:
File->Open File $VS/doc/Training_Material/Tutorial/WebHelp/Tutorial/General_Applications/Gen_Lab1.xml
Figure 2: Model
Model Objectives
- Construct a simple traffic generator, using the default 'Header' data structure.
- Dynamically add a new field to the transaction using the VisualSim ExpressionList block.
- Make If-Else decisions based on a specific field of a transaction.
- Debug models.
Blocks Used
Sl No
|
Library Block
|
Description
|
1
|
Digital Simulator
|
This
Simulator is used to model protocols, hardware, and mapping of behavior
to architecture. This simulator is used when the model is being
triggered as an event or based on time. The Digital Simulator
implements the discrete-event Model of Computation (MoC). This
Simulator maintains a notion of current time, and processes events
chronologically in this time.
|
2
|
ExpressionList
|
The
Expression List blocks executes a sequence of expressions
in order. The default block contains one input and one output. The user
can add multiple input and output ports.
|
3
|
Text Display
|
Display
the values arriving on the input port in a text display dialog. This
block buffers the display data and updates the screen after the buffer
is full.
|
Building the Model
For instatiating a particular block you can search for that block
name on the search bar and drag and drop that block to the modelling
window.
After instantiating the 'Traffic' block in the block diagram, consider the following questions:
- Where should the data structure name be entered?
- How can one generate a "Fixed" transaction every 1.0 seconds?
- How can one test that the transaction is being generated?
Hint: Display or Listen-to-Port
After instantiating the 'Decision or Expression List' block into the block diagram, consider the following questions.
- How should one connect the 'Traffic' and 'Behavior/Expression List' blocks?
- How does one enter a field name?
- How does one create a new field "Probability_Num" and generate field values from 1 to 100?
Hint: 'input.Probability_Num = irand(min, max)'. If the field does not exist, the Processing block will create it.
- How would you use the 'Behavior/Expression List' block to control the flow?
- How does one create a transitional if statement and use the result for routing the transaction.
3. If the transaction
field Probability_Num has a value of 1 to 5, or 95 to 100, then this
transaction should exit through the output port, or else it should exit
through the out_of_range port.
Hint: 'Probability_Num <= X || Probability_Num >= Y' or refer to the block documentation
4. Notice that the
decision can be assigned to a local memory variable in the block. This
can be used as the output_condition. An alternate way is to put the
condition directly in the output_condition field. Try to create the
model using both modes.
Running the Model
Add 'Text_Display' blocks for observing transactions leaving the 'ExpressionList' block.
- Are the transactions being created correctly? Do they leave through the proper ports?
- How long should the simulation run to properly test the decisions?
What happens if "Listen-to-Port"
is used to monitor transactions leaving the 'Expression List'
block instead of the 'Text_Display' block?
- Are the outputs the same?
- If not, then what are the differences?
What is the "Listen-to-Block" capability and what output does it provide?
- Can one observe the If-Else decisions as they are processed?
- What is the value of the "Listen-to-Block" capability and when might it be used?
Can we use animation to test the model?
- How does one set the pause period of the animation?
Hint: Use Debug->Animate Execution
- Is the animation capability useful for demonstration and illustration purposes?
Modeling Considerations
- How might the 'Behavior/Expression List' blocks be utilized in a real model?
- How would you relate to the Behavior/Expression List block in real-life?
- How would you test if the model is operating correctly?
Congrats
You now understand how to create flows and use the debugging features in VisualSim!!!