Variables, Parameters and Timed Resources
Tutorial Goals
The following is a summary of the concepts and tasks you will learn in this session.
- Update DS fields using Expression List block.
- Provide input to the Timed_Resource block.
- Generate resource statistics
- Extract the statistics fields and provide multiple formats of the output - textual and graphical.
Target
The purpose of this session is
- to build a system model,
- generate traffic that feeds into a system
resource that can represent a hardware or software device,
- and collect
statistics.
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_Lab2.xml
Figure 2. Gen_Lab2 Model
Model Objectives
- Create parameters and memories.
- Initialize the memory using the VariableList block.
- Instantiate parameters and customize its name and value.
- Store values in memory and perform operations based on parameters the values from memory.
- Use the ExpressionList block to modify memory values.
- Add ports to the 'ExpressionList' block to extract data from specific transaction fields.
- Add resources to perform processing
- Instantiate the 'Timed_Queue_N_Priority' block.
- Provide values and connect all input ports to the 'Timed_Queue_Priority' block.
4. Obtain statistics from the resource blocks and view the output in either textual or graphical form.
- How does one use the 'stat_input' trigger.
- Use the
'ExpressionList' block to obtain the required 'Total_Delay_Max' field from
the incoming transaction and input this into a 'xTime_yData_Plotter'
block.
Blocks Used
Sl No
|
Library Block
|
Description
|
1
|
Digital Simulator
Model > Simulator >Digital
|
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
|
Traffic
Traffic > Traffic
|
Transaction_Source
or Traffic outputs a new Data Structure (DS) at time intervals
specified by the "Time_Distribution" setting. A Data Structure is a
transaction containing a list of Field Names + Values.
|
3
|
Expression List
Behavior > Expression List
|
The
Decision/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.
|
4
|
TimedQueue_N_Priority
Full Library > Resource > Timed Queue > TimedQueue_N_Priority
|
This
TimedQueue (First-Come, First-Server) block contains multiple sets of
Queue + Server Resource. The Queue to use for a data structure is
identified by an integer number in the dimension_input port. The
Queue is ordered based on the priority of the data structure.
|
5
|
Parameter
Model > Parameter > Parameter
|
Parameter is a variable containing a constant that can be any VisualSim data type, function and/or a RegEx expression.
|
6
|
Variable List
ModelSetup > Variable List
|
The
block is used to define local/global variables that can be used
in Expression, Decision/Expression List, Basic Processing
(Statement etc.), Smart_Machine, and Virtual_Machine blocks.
|
7
|
Text Display
Result > Text_Display
|
Display
the values arriving in the input port in a text display dialog. This
block buffers the display data and updates the screen after the buffer
is full.
|
8
|
TimeDataPlotter
Result > TimeDataPlotter
|
This
block plots the incoming data on the Y-Axis against the current
simulation time on the X-axis. Every wire connected to this block input
is considered a separate dataset and plotted separately.
|
Building the Model
- Instantiate the 'VariableList' block and specify values for its parameters.
- How does one initialize the memory?
Hint: FirstMem local 1;
- Modify the
'Expression List' blocks to use the
variables, 'transitional-if', adding new ports, block variable, and
parameter.
- Populate the following fields
with the values: Probability_num (integer random number between 1 and
100) and FirstMem (integer random number between 10 and15)
- Where did the 'DELTA' field come from?
Hint: DS Header fields
- How do you use the value of 'Probability_num' to set the 'Priority' fields?
Hint: Use the same expression that was used for creating the boolean to control the flow.
- After instantiating the 'ExpressionList' block, consider the following:
- How does one create new
ports? How does one extract values from the 'Result_A' and
'Priority' fields and place them on the appropriately named output
ports? Is the naming order of the ports important?.
- define DELTA
(double random number between FirstNum and 50.0). FirstNum is the
variable defined in the variableList. So this variable can be accessed
from multiple blocks within the same Block Diagram Editor window.
- What is 'Result_A'?
Hint: Temporary or local Variable
- Using the 'Text_Display'
block, check the outputs of the 'ExpressionList' block to confirm that the
correct values are being received.
- After instantiating the 'TimedQueue_N_Priority' block, consider the following:
- How does one connect input ports and provide correct values for the parameters?
- Check the input port types of
the 'TimedQueue_N_Priority' block. Are they set properly? If not, how
does one set the port types of the 'Processing' block?
- Re-implement the same model using the Results->Server block and using Results->ResourceStatistics to generate the reports.
- After instantiating the 'ExpressionList' and the 'TimeDataPlotter' blocks, consider the following:
- Which field of the statistics data structure should be plotted?
Hint: 'Total_Delay_Max'
- Check the output port types of the 'ExpressionList' block.
- How do you trigger the 'stats_in' port and generate results either during the simulation or at its end?
Hint: Feed a trigger input to the stats_in port, set the time to trigger the stats and provide a value.
- What is the significance of
the 'Const' block with value set to 2 (that is input to the stats_in
port)? How do you get the statistics for all of the ports?
Hint: The value at the stats_in port must be 'Number of Resources'.
Running the Model
- What should be the input to the 'TimedQueue_N_Priority' block?
- What are the required fields and their data types?
- Why do you need to do to change the port types?
- Re-implement using the Resource->Server block
- How does one generate plots?
- At what point in the simulation should you generate statistics?
- What is the value of viewing a single statistic (Plot or Text) vs. viewing all of the statistics together?
- If one generated statistics
for all of the queues, what would the output data type resemble?
Is this different from generating statistics from a
single queue?
- How do I use the multi-queue statistics to extract a single field?
Hint: First extract the data structure from an array index and then extract the field.
- Data Structure field usage?
- What is the advantage of
dynamically creating fields? Is this approach preferable to
adding the field in the DS template (remember that we created a DS
template file in Part 1 of the 'Getting Started' tutorial).
- What would be the common fields you would create for your model?
Modeling Considerations
- How will the blocks of this tutorial be utilized in a real model?
- What will the role of the 'Timed_Queue' block be in a real system?
Congrats
You now understand how to associated flows with hardware/software resources in VisualSim!!!