Scene depicting method for embedded system time sequence simulation analysis
Technical Field
The invention belongs to the technical field of embedded systems, and particularly relates to a scene depicting method for simulation analysis.
Background
Embedded systems (Embedded systems) are becoming more and more closely related to people, and 95% of microprocessors in the world are used for Embedded systems. The application field of the embedded system is very wide, in some fields with higher requirements on real-time performance, whether the time sequence characteristics of the embedded system meet the design requirements or not can generate key influence on the operation of the real-time system, and the abnormal time sequence can cause the task execution failure and even cause destructive influence on the system. Therefore, ensuring the embedded software timing design and the correctness of implementation is an important task for embedded software development. With the increasing scale and complexity of embedded systems, time sequence analysis of embedded systems by using modeling and simulation methods is becoming a reasonable choice. In the modeling and simulation processes, because the operation process of the embedded system is complex, a prototype of the system in a real-time system is difficult to accurately restore through simulation by simply modeling the aspects of interruption, tasks, scheduling algorithms and the like, and unpredictable changes can be caused to the simulation process when the model is modified.
In order to solve the problems, the simulation process can accurately correspond to a real system, and the result obtained by the simulation process is meaningful, the simulation process is accurately controlled by adopting a scene depiction method, and the execution of interruption and the switch are accurately controlled so as to deal with the situation which possibly occurs in the real system. And the partial order relation of the tasks and the state machine in the tasks are finely set, and the debugging can be carried out by adopting an external constraint method on the basis of not modifying the original model, so that the operation of related personnel is simplified, the fineness of the model is improved, the simulation result is more reasonable, more accurate reference is provided for program designers, and the certainty of the embedded system is improved.
Disclosure of Invention
In order to overcome the defects of the prior art, the invention provides a scene depicting method for embedded system time sequence simulation analysis, which can be used for more finely controlling an abstracted system. The method provides the arrival time of the interrupt, the activation time of the periodic interrupt can be specified, the arrival time, the arrival times, the average time of multiple arrival, the arrival time interval, whether the interrupt is executed after each time of the interrupt arrival can be set for the non-periodic interrupt, and the switching time of the interrupt is also provided to allow the interrupt to carry out certain operation on the interrupt after the execution of a certain task is finished. And providing the partial order relation setting of the tasks and the circulation and migration control of the state under the state machine for the tasks. The simulation process is refined in an external control mode, a larger design space is provided for program designers, the model can approach a real system more, and the certainty of the system can be improved better by the obtained simulation result.
The technical scheme adopted by the invention for solving the technical problem comprises the following steps:
step 1: establishing an overall model of scene portrayal of embedded system time sequence simulation analysis;
firstly, a scene is integrally depicted, wherein the overall depiction comprises interruption arrival time, a task execution partial sequence relation, cycle control of a state machine, transition control between states and interruption switch time control; the model is as follows:
Scene={InterruptArrive,TaskSequence,CycleControl,TransControl,InterruptSwitch}
wherein, interrupt array represents the arrival time of interruption, task sequence represents task partial sequence relation control, CycleControl represents cyclic migration control and migration control between TransControl states, and interrupt switch represents interruption switch timing control;
step 2: establishing an arrival time control model of periodic interruption and non-periodic interruption;
the arrival time model for a periodic interruption is represented as:
ISRArrTimep=<IDp,ISRTypep,StartTimep>
wherein the IDpUnique identifier, ISRType, representing a periodic interruptpIndicates the type of interrupt, StartTimepRepresents the start time of the periodic interruption; in the simulation process, the cycle interrupt arrives at the specified arrival time, not immediately at the beginning of the simulation, and the arrival time refers to the interruption from the beginning of the simulation to the cycle interruptTime interval to start execution or to start response;
the arrival time of the aperiodic interrupt is expressed as:
InterruptArrTimeT=<IDT,ISRTypeT,StartTimeT,ExeOrNotT>
wherein InterruptArrTimeTRepresenting the arrival time, ID, of an aperiodic interruptTUnique identifier representing an aperiodic interrupt, ISRTypeTType of interrupt, StartTimeTRepresenting the arrival time of an aperiodic interrupt, ExeOrnotTRepresents whether each arrival is performed;
wherein the arrival time StartTime of the aperiodic interruptTMultiple values can be set, representing the case of multiple arrivals of an interrupt, as follows:
StartTimeT={Time1,Time2,...,Timen}
wherein Time1,Time2,…TimenRepresenting the arrival time of each aperiodic interrupt, and a plurality of arrival times represent that the aperiodic interrupt arrives a plurality of times, but each interrupt arrival can be followed by setting ExeOrNotTWhether the interrupt is executed or not is operated, which is expressed as follows:
ExeOrNotT={Exe1,Exe2,...,Exen}
wherein Exe1,Exe2,…,ExenNumber of parameters and StartTime representing whether the interrupt is executed each time after reaching multiple timesTThe consistency is achieved;
and step 3: establishing a model of task partial order relation;
the set of tasks executed in the system is Task ═ T1,T2,...,TnN is larger than or equal to 2, and the tasks in the set have a partial order relationship:
TaskSequence={Tn,...,Tm},Tn,...,Tm∈Task
partial order relationship, i.e. the execution order of the pre-designed tasks, where Tn,...,TmRepresenting a set of partial tasks to be performed in the system, in terms of setsThe sequence of the task arrangement in the combination represents the partial sequence relation between the tasks;
and 4, step 4: establishing a cyclic migration control model
CycleControl={ID,StartTask,StartStatus,EndStatus,CycleCount}
Wherein ID represents a unique identifier of the loop migration control variable, StartTask represents a task identifier where the loop is executed, StartStatus represents a state identifier of the start of the loop, EndStatus represents a state of the end of the state loop, StartStatus and EndStatus are arbitrary states of the state machine in StartTask, and CycleCount represents the number of state loops CycleCount ∈ {1, 2...., n };
and 5: establishing a state transition control execution model:
TransControl={ID1,InitialVal,TransTask,StartStatus1,VarVal,ToStatus,NewVal}
where ID1 represents the unique identifier of the state transition control variable, InitialVal represents the initial value of the variable, InitialVal ∈ {1, 2.. n }, TransTask represents the task identifier of the state transition, StartStatus1 represents the initial state of the state transition, and VarVal represents the value before the global variable of the state transition transitions, VarVal represents the value before the global variable of the state transition transitionsiE {1, 2.. n }, ToStatus represents a migrated state, and NewVal represents a variable value NewVal after state migration, which belongs to {1, 2.. n };
step 6: modeling the center-to-center disconnection switch:
InterruptSwitch={ID2,SwitchTask,SwitchStart,Release,ControlType,ISRID}
wherein ID2 is a unique identifier of an interrupt switch control variable, SwitchTask represents an identifier of a task to be executed, SwitchStart represents an operation to be executed by the task, and Release represents a task or job generated after the task is executed; the ControlType represents the operation quantity ControlType epsilon { On, Off } for the interrupt, namely, the On operation or the Off operation of the interrupt is defined; ISRID represents an interrupt identifier that is operated on;
and 7: the scene of embedded system time sequence simulation analysis is depicted;
step 7-1: checking the real system interrupt of the embedded system, and setting the interrupt arrival time of the embedded system simulation system according to the interrupt arrival time of the real system; if the interruption of the real system is periodic interruption, setting the activation time of the periodic interruption of the simulation system; if the interruption of the real system is non-periodic interruption and the interruption only reaches once, setting the arrival time of the interruption in the simulation system; if the interrupt of the real system arrives for a plurality of times, setting the average arrival time, the arrival times and the time interval of each arrival of the interrupt which arrives for a plurality of times in the simulation system, and setting whether to operate the interrupt after each interrupt arrival;
step 7-2: analyzing the task execution in the real system, abstracting according to a task set with a partial order relation in the real system, and setting a task execution sequence in the simulation system; if the simulation process violates the set partial order relationship, prompting the user to modify the design;
and 7-3: analyzing a state machine in a real system, if the condition that a plurality of state cycles under the state machine are executed for a plurality of times and then are cut off exists, setting a simulation system state cycle control module, and restricting the execution times of a cycle body and controlling the cycle to jump out in the simulation process;
and 7-4: if the state machine in the real system has different state transition results under different conditions, setting state transition control for simulation: firstly, setting an initial value InitialValue of a state transition control model, setting a condition value for transition to different states and a change value NewValue of a model value after execution, judging execution state transition operation by detecting whether the model value is the same as the set condition value, and assigning the model value as the set change value NewValue;
and 7-5: acquiring a precondition of a real system interrupt switch; the time for setting the interrupt switch in the simulation system: setting to perform switch interruption before the execution of the specified task or perform switch interruption after the execution of the specified task or generate another task to perform switch interruption by the specified task;
in the simulation process, a control variable of an interrupt switch is set, a task switch task of switch interrupt is set according to requirements, or an operation switch start under the task is set, or a released task Release is used as a mark, the target interrupt ISRID is switched, and the switching operation or the switching operation is controlled by setting a controlType.
The invention has the beneficial effects that: the scene depicting method for embedded system time sequence simulation analysis provided by the invention can control the simulation process more finely by the scene depicting method, so that the designed simulation system can approach to a real system more, interrupt, task and state machine can be controlled finely by the scene depicting method, the simulation process is more transparent, the modeling work of simulation is simplified, the true degree of the model is improved, the universality and accuracy of the simulation system are improved, the accuracy of embedded system design is indirectly improved, and the certainty of the embedded system is improved.
Drawings
FIG. 1 is a frame diagram of an embedded system timing simulation analysis scenario depiction in accordance with the present invention.
Detailed Description
The invention is further illustrated with reference to the following figures and examples.
The invention provides an operation scene model for real-time system simulation, which is used for restraining the simulation process of a system, improving the accuracy of a real-time system simulation model and enabling the model to be closer to a real system. Because the embedded system is limited by many factors in the actual operation process, the execution process is complex, the operation process of the real system is difficult to accurately restore only according to the basic configuration information of the general interrupt module and the task module, and the practicability of the simulation result is reduced, an external control method is needed for fine adjustment of the simulation process. All components in the system are unified to be used as a part of simulation operation, and the execution action of each component is carefully designed, so that each component can perform specific action at specific time, the whole simulation process is consistent with the operation mode of an actual system, the accuracy of modeling simulation analysis of the embedded system is improved, and the design of the embedded system is facilitated.
As shown in fig. 1, the present invention provides a scene depicting method for embedded system time sequence simulation analysis, which comprises the following steps:
step 1: establishing an overall model of scene portrayal of embedded system time sequence simulation analysis;
firstly, a scene is integrally depicted, wherein the overall depiction comprises interruption arrival time, a task execution partial sequence relation, cycle control of a state machine, transition control between states and interruption switch time control; the model is as follows:
Scene={InterruptArrive,TaskSequence,CycleControl,TransControl,InterruptSwitch}
wherein, interrupt array represents the arrival time of interruption, task sequence represents task partial sequence relation control, CycleControl represents cyclic migration control and migration control between TransControl states, and interrupt switch represents interruption switch timing control;
step 2: establishing an arrival time control model of periodic interruption and non-periodic interruption;
the arrival time model for a periodic interruption is represented as:
ISRArrTimep=<IDp,ISRTypep,StartTimep>
wherein the IDpUnique identifier, ISRType, representing a periodic interruptpIndicates the type of interrupt, StartTimepRepresents the start time of the periodic interruption; in the simulation process, the cycle interrupt arrives at a specified arrival time, rather than immediately arriving at the beginning of the simulation, wherein the arrival time refers to the time interval from the beginning of the simulation to the beginning of the execution or the beginning of the response of the cycle interrupt;
the arrival time of the aperiodic interrupt is expressed as:
InterruptArrTimeT=<IDT,ISRTypeT,StartTimeT,ExeOrNotT>
wherein InterruptArrTimeTRepresenting the arrival time, ID, of an aperiodic interruptTUnique identifier representing an aperiodic interrupt, ISRTypeTType of interrupt, StartTimeTRepresenting the arrival time of an aperiodic interrupt, ExeOrnotTRepresenting each arrival asOtherwise, executing;
wherein the arrival time StartTime of the aperiodic interruptTMultiple values can be set, representing the case of multiple arrivals of an interrupt, as follows:
StartTimeT={Time1,Time2,...,Timen}
wherein Time1,Time2,…TimenRepresenting the arrival time of each aperiodic interrupt, and a plurality of arrival times represent that the aperiodic interrupt arrives a plurality of times, but each interrupt arrival can be followed by setting ExeOrNotTWhether the interrupt is executed or not is operated, which is expressed as follows:
ExeOrNotT={Exe1,Exe2,...,Exen}
wherein Exe1,Exe2,…,ExenNumber of parameters and StartTime representing whether the interrupt is executed each time after reaching multiple timesTThe consistency is achieved;
and step 3: establishing a model of task partial order relation;
the set of tasks executed in the system is Task ═ T1,T2,...,TnN is larger than or equal to 2, and the tasks in the set have a partial order relationship:
TaskSequence={Tn,...,Tm},Tn,...,Tm∈Task
partial order relationship, i.e. the execution order of the pre-designed tasks, where Tn,...,TmRepresenting a part of task sets executed in the system, and representing the partial order relation among the tasks according to the sequence of the task arrangement in the sets;
and 4, step 4: establishing a cyclic migration control model
CycleControl={ID,StartTask,StartStatus,EndStatus,CycleCount}
Wherein ID represents a unique identifier of the loop migration control variable, StartTask represents a task identifier where the loop is executed, StartStatus represents a state identifier of the start of the loop, EndStatus represents a state of the end of the state loop, StartStatus and EndStatus are arbitrary states of the state machine in StartTask, and CycleCount represents the number of state loops CycleCount ∈ {1, 2...., n };
and 5: establishing a state transition control execution model:
TransControl={ID1,InitialVal,TransTask,StartStatus1,VarVal,ToStatus,NewVal}
where ID1 represents the unique identifier of the state transition control variable, InitialVal represents the initial value of the variable, InitialVal ∈ {1, 2.. n }, TransTask represents the task identifier of the state transition, StartStatus1 represents the initial state of the state transition, and VarVal represents the value before the global variable of the state transition transitions, VarVal represents the value before the global variable of the state transition transitionsiE {1, 2.. n }, ToStatus represents a migrated state, and NewVal represents a variable value NewVal after state migration, which belongs to {1, 2.. n };
step 6: modeling the center-to-center disconnection switch:
InterruptSwitch={ID2,SwitchTask,SwitchStart,Release,ControlType,ISRID}
wherein ID2 is a unique identifier of an interrupt switch control variable, SwitchTask represents an identifier of a task to be executed, SwitchStart represents an operation to be executed by the task, and Release represents a task or job generated after the task is executed; the ControlType represents the operation quantity ControlType epsilon { On, Off } for the interrupt, namely, the On operation or the Off operation of the interrupt is defined; ISRID represents an interrupt identifier that is operated on;
and 7: the scene of embedded system time sequence simulation analysis is depicted;
step 7-1: checking the real system interrupt of the embedded system, and setting the interrupt arrival time of the embedded system simulation system according to the interrupt arrival time of the real system; if the interruption of the real system is periodic interruption, setting the activation time of the periodic interruption of the simulation system; if the interruption of the real system is non-periodic interruption and the interruption only reaches once, setting the arrival time of the interruption in the simulation system; if the interrupt of the real system arrives for a plurality of times, setting the average arrival time, the arrival times and the time interval of each arrival of the interrupt which arrives for a plurality of times in the simulation system, and setting whether to operate the interrupt after each interrupt arrival;
step 7-2: analyzing the task execution in the real system, abstracting according to a task set with a partial order relation in the real system, and setting a task execution sequence in the simulation system; if the simulation process violates the set partial order relationship, prompting the user to modify the design;
and 7-3: analyzing a state machine in a real system, if the condition that a plurality of state cycles under the state machine are executed for a plurality of times and then are cut off exists, setting a simulation system state cycle control module, and restricting the execution times of a cycle body and controlling the cycle to jump out in the simulation process;
and 7-4: if the state machine in the real system has different state transition results under different conditions, setting state transition control for simulation: firstly, setting an initial value InitialValue of a state transition control model, setting a condition value for transition to different states and a change value NewValue of a model value after execution, judging execution state transition operation by detecting whether the model value is the same as the set condition value, and assigning the model value as the set change value NewValue;
and 7-5: acquiring a precondition of a real system interrupt switch; when the time for setting the interrupt switch in the simulation system is found, a situation that a certain interrupt needs to be turned on or turned off after a certain task (or job) is executed usually occurs in a real system, or a situation that another task needs to be turned on or turned off after a certain task (or job) is executed occurs. In the simulation process, a control variable of an interrupt switch is set, a task switch task interrupted by the switch is set according to requirements, or a certain operation switch start under the task is set, or a certain task Release is issued as a mark, the target interrupt ISRID is switched, and the specific operation can be controlled to be on or off by setting a controlType.