VisualSim can be used to construct stochastic models using SystemResource blocks; where priority and preemption can be factored into the shared resource. Stochastic models are in contrast to detailed cycle-accurate models. If stochastic models are constructed, then they can use time estimates for first order of approximation; or a specific number of cycles with the SystemResource specifying the SystemResource speed in MHz for a second order approximation. VisualSim can also estimate a third order approximation for a specific task or thread by using an array of probabilities, paired with an array of cycles to better estimate a complex flow. One needs to randomly select the array index with a random, or stochastic selection of the cycles employed by the SystemResource. Specific RegEx functions to select an array of probabilities based on a random number that the SysRes block can process:
>> P0 = 0.1
0.1
>> P1 = 0.2
0.2
>> P2 = 0.3
0.3
>> P3 = 0.4
0.4
>> Probability_Array = {P0,P1,P2,P3}
{0.1, 0.2, 0.3, 0.4}
>> Prob_Test_Total = Probability_Array.sum() // confirm total probability = 1.0
1.0
>> Cumulative_Prob_Array = {P0,P0+P1,P0+P1+P2,P0+P1+P2+P3} // might be a loop
{0.1, 0.3, 0.6, 1.0}
>> Probability_Cycle_Array = {1,2,3,4}
{1, 2, 3, 4}
>> Prob_Estimate = rand (0.0, 1.0) // random selection
0.413398390174
>> Cum_Prob_Array_minus_Prob_Estimate = Cumulative_Prob_Array – Prob_Estimate
{-0.313398390174, -0.113398390174, 0.186601609826, 0.586601609826}
>> Cum_Prob_Array_minus_Prob_Estimate_Idx_Array = Cum_Prob_Array_minus_Prob_Estimate.isGreaterThan(0.0)
{2, 3} // always one index?
>> Stochastic_Index = Cum_Prob_Array_minus_Prob_Estimate_Idx_Array(0) // first one only
2
>> Cycles = Probability_Cycle_Array (Stochastic_Index)
3
>> SysRes_MHz = 1000.0
1000.0
>> SysRes_Cycle_Time = 1.0 / (SysRes_MHz * 1.0e6)
1.0E-9
>> Stocastic_Time_Estimate = Cycles * SysRes_Cycle_Time
3.0E-9
The last expression can be replaced by the number of Cycles to simplify the flow. What does this mean, SysRes block can model more complex behavior simply by applying a Probability_Array to the actual time estimate, as shown above.
Further, this means a shared stochastic process (SystemResource) can be either over/under relative to detailed processing time of same; such that the stochastic model can confirm a user’s understanding of the detailed processing; Processor or Hardware Accelerator. If the mean result with either the detailed processor, or hardware accelerator is statistically close to the stochastic representation; then the stochastic sub-model should be sufficient? A sub-model might have a Stochastic_Mode parameter to select between the two levels of model abstraction, such that a user could run with either level of model detail. This basic processing methodology can be applied to sub-systems, such that if the detailed general purpose processor or hardware accelerator match the stochastic sub-system; then the stochastic version can replace the detailed processing?