Full Library / Resource / Event Queue / Queue_Priority
Code File Location: VisualSim/actor/lib/Queue_One_Priority
Note: If you have purchased the Smart_Resource package, use the Smart_Resource block and not this one.
o Define Ingress or Egress ports.
o Create a FIFO or LIFO.
o This block differs from the Queue in that the queue is reordered based on the priority of the transactions.
o Define a temporary memory location to store requests or transactions.
o Create rudimentary cache with equal sized data access (Read or Write).
The following is a block diagram that illustrates the operation of the Queue block.
This block contains a single queue which orders the incoming data structures in the order from highest to the lowest priority. It requires the priority value to arrive along with the transaction to be placed in the queue. The Queue_Priority block queues the incoming data structure or token in a FIFO or LIFO order. When it receives a general value on the pop_input port, it sends the head of the Queue on the output port. If it receives an integer on the pop_input port, it sends the data structure in the specific numbered location of the queue on the output port. Higher the number signifies higher priority.
If the queue is full, then the incoming Data Structure or token is sent to the reject_output port (Queue_Reject_Mechanism->Incoming Token) or the lowest priority among the incoming token + the queued tokens (Queue_Reject_Mechanism->Lower Priority). If there are multiple tokens with the same priority, the last arriving is discarded.
Refer the following Demo Models.
Statistics Output
Statistic Name |
Value |
Explanation |
Mathematical Equation |
Type |
Number_Entered |
100 |
Number of transactions entering the queue. |
- |
int |
Number_Exited |
25 |
Number of transactions that left the queue. |
- |
int |
Number_Rejected |
10 |
Number of transactions rejected and output to reject port. |
- |
int |
Queue_Number |
1 |
Queue Number. Queue number start at 1. |
- |
int |
Occupancy_Min |
4.0 |
Minimum queue size during the simulation. |
If (Xn < Xn – 1) Xmin = Xn |
double |
Occupancy_Mean |
8.0 |
Mean/Average queue size during the simulation. |
Xµ = (1 / n) * (X1 + X2 + … + Xn) |
double |
Occupancy_StDev |
3.0 |
Standard Deviation from the Mean queue size during the simulation. |
Xσ = Math.sqrt ((1 / n) * ((X1 - Xµ)2 + (X2 - Xµ)2 + … + (Xn - Xµ)2)) STDEV_90_PCT = 1.6448530004790 |
double |
Occupancy_Max |
25.0 |
Maximum queue size consumed during the simulation. |
If (Xn > Xn – 1) Xmax = Xn |
double |
Total_Delay_Min |
1.3 |
In seconds. Least time through the queue among all transactions. |
If (Xn < Xn – 1) Xmin = Xn |
double |
Total_Delay_Mean |
1.3 |
In seconds. Mean/Average time through the queue among all transactions. |
Xµ = (1 / n) * (X1 + X2 + … + Xn) |
double |
Total_Delay_StDev |
1.3 |
In seconds. Standard Deviation from the Mean time through the queue among all transactions. |
Xσ = Math.sqrt ((1 / n) * ((X1 - Xµ)2 + (X2 - Xµ)2 + … + (Xn - Xµ)2)) STDEV_90_PCT = 1.6448530004790 |
double |
Total_Delay_Max |
1.3 |
In seconds. Maximum time through the queue among all transactions. |
If (Xn > Xn – 1) Xmax = Xn |
double |
Utilization_Pct_Mean |
10.0 |
Not Used for Queues. Will default to 0.0. |
Where n is the number of samples and X is occupancy or delay.
Parameter |
Explanation |
Type |
Example |
Max_Queue_Length |
This is the maximum number of tokens or data structures that can be in the queue at any instance of time. All items above this limit will be send to the reject_output port. |
Integer |
30 (Default Value) |
Initial_Queue_State |
Queue initial state attribute. This setting is used whenever the queue is empty and the first token arrives. If 'First_Token_Flow_Through' is selected, then the first data structure will flow through the queue without a pop whenever the queue is empty. If 'First_Token_Enqueue' is selected, a 'pop_queue_input' is required to obtain the first data token or data structure. |
- |
'First_Token_Flow_Through' 'First_Token_Enqueue' The default is 'First_Token_Flow_Through'. |
Queue_Reject_Mechanism |
Queue reject attribute, either 'Incoming_Token_Rejected' (default), or 'Lowest_Priority_Token_Rejected'. If 'Incoming_Token_Rejected' is selected and the designated queue is full, then the incoming data structure is sent to the 'reject_queue_output' port. If 'Lowest_Priority_Token_Rejected' is selected, and the designated queue is full, then the lowest priority queue element among all the queue transactions and incoming token will be sent to the 'reject_queue_output'. |
- |
'Incoming_Token_Rejected' 'Lowest_Priority_Token_Rejected' |
Queue_Type | Queue Type can be either First In First Out or Last In Last Out |
FIFO , LIFO |
Port |
Explanation |
queue_input |
Input port for data tokens (numerical values) or data structures entering the queue. This token must arrive with a priority_input to queue the incoming token or data structure. |
priority_input |
This is the priority of the incoming data tokens (numerical values) or data structures. This port must receive an integer. Every time a data structure enters the queue, the queue will be reordered based on the priority of the new data structure. If the queue is full, the Queue_Reject_Mechanism will determine the data structure to be rejected. |
pop_queue_input |
This port initiates the queue to send an item out of the queue. This input can either be an integer or any data type. If it is a non-integer data type then the head of the queue is sent to the pop_queue_output port. If the value is an integer, then the input number is the token location to be sent out. A '0' on the 'pop_queue_input' will send the head (front) of the FIFO queue to the 'pop_queue_output'. If the input on the 'pop_queue_input' is '1', then the second element of the queue will be sent to the 'pop_queue_output'. |
copy_queue_n_input |
This input specifies the index location of a token in the queue that must be placed on the 'Copy_queue_n_output" port. The items in the queue are not disturbed, thereby preserving the queue order. This is used to trigger an algorithm like a arbiter to act on the incoming request. This copied data structure can be a request for service or access. |
stats_input |
This port is triggered to output accumulated statistics for this block. To clear the statistics for the queue, send "-1"To output the statistics, send '1' on 'stats_input'. The statistics for the queue will be placed on the stats_output port as a Data Structure. |
pop_queue_output |
The pop data structure or token is placed on this port and the token is removed from the queue. |
reject_queue_output |
The incoming token is sent to this output if the if the queue is full. The type is based on the input token type |
copy_queue_n_output |
This outputs the current token or Data Structure in the index location specified by the integer on the 'copy_queue_n_input' port. The data structure is not removed from the queue. |
queue_length_output |
This provides the length of the queue each time a token is received on the input_queue, pop_queue_input or copy_queue_n_input ports. |
stats_output |
Output port receiving queue statistics as a data structure. See top for details on the fields of this Data Structure. Note: When the statistics reset, the Number_in_Queue is equal to the current queue length. |
Created with the Personal Edition of HelpNDoc: Free CHM Help documentation generator