IP Library Granted Patent US 12,360,748
Granted Patent B1
US 12,360,748 · App. 18/075,855 · Granted Jul 15, 2025

Systems and methods for performing worst-case execution time analysis of simulation models

Inventors: Yuchen Zhang (Dover, MA); Partha Biswas (Wayland, MA); Xiaocang Lin (Sherborn, MA); Dixin Zhou (Ashland, MA); Mario Bambagini (Histon, GB); William F. Potter (Waddell, AZ); Chirag Gupta (Bangalore, IN)
Assignee: The MathWorks, Inc.
G06F8/35
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 12,360,748
App. No.
18/075,855
Granted
Jul 15, 2025
Kind
B1
Abstract

Systems and methods determine tight Worst Case Execution Time (WCET) for a simulation model or code generated for a model. Composite code blocks may be constructed from basic code blocks of an in-memory representation of the model. Information on the model and its elements may be obtained and utilized to construct the composite code blocks. The composite code blocks may be instrumented and execution times may be measured for the composite code blocks. The execution times for the composite code blocks along paths through the model may be summed and the highest total execution time may be presented as the WCET for the model and/or the code generated for the model.

Claims (51)

1. A computer-implemented method comprising:

accessing an executable simulation model, the executable simulation model constructed according to a syntax and semantics of a modeling environment, the executable simulation model including a plurality of model blocks arranged on data paths;

generating, by one or more processors, an in-memory, intermediate representation (IR) of the executable simulation model, the in-memory IR including nodes representing basic code blocks;

subsequent to the generating, querying, by a worst case execution time (WCET) analysis engine in connection with one or more of the basic code blocks of the in-memory IR, the executable simulation environment for semantic information regarding at least one of the executable simulation model or one or more of the plurality of model blocks of the executable simulation model, wherein the semantic information being sought relates to the one or more of the basic code blocks of the in-memory IR;

obtaining, at the WCET analysis engine in response to the querying, the semantic information related to the one or more of the basic code blocks;

utilizing, by the one or more processors, the semantic information obtained by the WCET analysis engine from the simulation environment in connection with the one or more basic code blocks to modify the in-memory IR, wherein the modifying includes aggregating groups of the basic code blocks of the in-memory IR into composite code blocks based on the semantic information obtained by the WCET analysis engine from the modeling environment;

instrumenting the composite code blocks and one or more basic code blocks of the basic code blocks that were not aggregated into the composite code blocks;

collecting, by the one or more processors, execution time data for the composite code blocks and the one or more basic code blocks that were not aggregated into the composite code blocks, the execution time data including worst case execution times (WCETs) for the composite code blocks and the one or more basic code blocks that were not aggregated into the composite code blocks;

determining, by the one or more processors, from the data paths a given data path for which a sum of the WCETs collected for the composite code blocks and the one or more basic code blocks that were not aggregated into the composite code blocks that are along the given data path is a maximum; and

presenting the sum of the WCETs collected for the composite code blocks and the one or more basic code blocks that were not aggregated into the composite code blocks that are along the given data path as a WCET for the executable simulation model.

2. The computer-implemented method of claim 1 wherein the information identifies at least one of a loop bound, a switch element or a trigger condition leading to conditional execution contexts, or a bounded search of a lookup table.

3. The computer-implemented method of claim 1 wherein the semantic execution time data is collected during execution of at least a portion of the executable simulation model in a target environment.

4. The computer-implemented method of claim 3 wherein the target environment includes a processor and the method further comprises:

automatically generating code, by the one or more processors, for the at least a portion of the executable simulation model; and

executing the generated code by the processor of the target environment.

5. The computer-implemented method of claim 3 wherein the target environment includes at least one thread for running the at least a portion of the executable simulation model in Software-in-the-Loop (SIL) testing separate from the modeling environment.

6. The computer-implemented method of claim 1 wherein the presenting includes using one or more graphical affordances to identify the given data path on a visual depiction of the executable simulation model.

7. The computer-implemented method of claim 1 further comprising:

presenting one or more of the WCETs on a visual depiction of the executable simulation model.

8. The computer-implemented method of claim 1 further comprising:

automatically generating source code, by the one or more processors, for at least a portion of the executable simulation model; and

presenting at least one of the sum of the WCETs or one or more of the WCETs on a visual depiction of the automatically generated source code.

9. The computer-implemented method of claim 3 wherein the in-memory representation includes at least one of a graph or a Program Structure Tree.

10. The computer-implemented method of claim 1 further comprising:

utilizing static path analysis to identify one or more of the data paths.

11. The computer-implemented method of claim 1 further comprising:

comparing the execution time data for at least one of the composite code blocks to a probability distribution;

identifying the at least one of the composite code blocks as having poor timing predictability or input data sensitivity, if the execution time data fails to match the probability distribution within a tolerance.

12. One or more non-transitory computer-readable media containing program instructions for execution by one or more processors, the program instructions comprising instructions to:

access an executable simulation model, the executable simulation model constructed according to a syntax and semantics of a modeling environment, the executable simulation model including a plurality of model blocks arranged on data paths;

generate an in-memory, intermediate representation (IR) of the executable simulation model, the in-memory IR including nodes representing basic code blocks;

subsequent to the generating, query, by a worst case execution time (WCET) analysis engine in connection with one or more of the basic code blocks of the in-memory IR, the executable simulation environment for semantic information regarding at least one of the executable simulation model or one or more of the plurality of model blocks of the executable simulation model, wherein the semantic information being sought relates to the one or more of the basic code blocks of the in-memory IR;

obtain, at the WCET analysis engine in response to the querying, the semantic information related to the one or more of the basic code blocks;

utilize the semantic information obtained by the WCET analysis engine from the simulation environment in connection with the one or more basic code blocks to modify the in-memory IR, wherein the modifying includes aggregating groups of the basic code blocks of the in-memory IR into composite code blocks based on the semantic information obtained by the WCET analysis engine from the modeling environment;

instrument the composite code blocks and one or more basic code blocks of the basic code blocks that were not aggregated into the composite code blocks;

collect execution time data for the composite code blocks and the one or more basic code blocks that were not aggregated into the composite code blocks, the execution time data including worst case execution times (WCETs) for the composite code blocks and the one or more basic code blocks that were not aggregated into the composite code blocks;

determine from the data paths a given data path for which a sum of the WCETs collected for the composite code blocks and the one or more basic code blocks that were not aggregated into the composite code blocks that are along the given data path is a maximum; and

present the sum of the WCETs collected for the composite code blocks and the one or more basic code blocks that were not aggregated into the composite code blocks that are along the given data path as a WCET for the executable simulation model.

13. The one or more computer-readable media of claim 12 wherein the semantic information identifies at least one of a loop bound, a switch element or a trigger condition leading to conditional execution contexts, or a bounded search of a lookup table.

14. An apparatus comprising:

one or more memories storing an executable simulation model, the executable simulation model constructed according to a syntax and semantics of a modeling environment, the executable simulation model including a plurality of model blocks arranged on data paths; and

one or more processors coupled to the one or more memories, the one or more processors configured to:

generate an in-memory, intermediate representation (IR) of the executable simulation model, the in-memory IR including nodes representing basic code blocks;

subsequent to the generating, query, by a worst case execution time (WCET) analysis engine in connection with one or more of the basic code blocks of the in-memory IR, the executable simulation environment for semantic information regarding at least one of the executable simulation model or one or more of the plurality of model blocks of the executable simulation model, wherein the semantic information being sought relates to the one or more of the basic code blocks of the in-memory IR;

obtain, at the WCET analysis engine in response to the querying, the semantic information related to the one or more of the basic code blocks;

utilize the semantic information obtained by the WCET analysis engine from the simulation environment in connection with the one or more basic code blocks to modify the in-memory IR, wherein the modifying includes aggregating groups of the basic code blocks of the in-memory IR into composite code blocks based on the semantic information obtained by the WCET analysis engine from the modeling environment;

instrument the composite code blocks and one or more basic code blocks of the basic code blocks that were not aggregated into the composite code blocks;

collect execution time data for the composite code blocks and the one or more basic code blocks that were not aggregated into the composite code blocks, the execution time data including worst case execution times (WCETs) for the composite code blocks and the one or more basic code blocks that were not aggregated into the composite code blocks;

determine from the data paths a given data path for which a sum of the WCETs collected for the composite code blocks and the one or more basic code blocks that were not aggregated into the composite code blocks that are along the given data path is a maximum; and

present the sum of the WCETs collected for the composite code blocks and the one or more basic code blocks that were not aggregated into the composite code blocks that are along the given data path as a WCET for the executable simulation model.

15. The apparatus of claim 14 wherein the semantic information identifies at least one of a loop bound, a switch element or a trigger condition leading to conditional execution contexts, or a bounded search of a lookup table.

Assignments (1)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Apr 21, 2023
From: ZHANG, YUCHEN; BISWAS, PARTHA; LIN, XIAOCANG; ZHOU, DIXIN; BAMBAGINI, MARIO; POTTER, WILLIAM F.; GUPTA, CHIRAG
To: THE MATHWORKS, INC.
Reel/Frame 063404/0105 →
Continuity (1)
Provisional Application 63413845 · Oct 6, 2022
References Cited (46)
US 5961599A · Kalavade · 1999 [cited by examiner]
US 7007270B2 · Martin · 2006 [cited by examiner]
US 7702499B1 · Lavagno · 2010 [cited by examiner]
US 8104017B2 · Lin et al. · 2012 [cited by applicant]
US 8316368B2 · Vestal · 2012 [cited by examiner]
US 8402449B1 · Biswas · 2013 [cited by examiner]
US 8762953B2 · French et al. · 2014 [cited by applicant]
US 8990783B1 · Yu et al. · 2015 [cited by applicant]
US 9311057B2 · Brunel et al. · 2016 [cited by applicant]
US 9471383B2 · Paul · 2016 [cited by examiner]
US 9582768B1 · Englehart et al. · 2017 [cited by applicant]
US 10108400B1 · Myren · 2018 [cited by examiner]
US 10409563B2 · Portes · 2019 [cited by examiner]
US 10466671B2 · Stattelmann · 2019 [cited by examiner]
US 11726831B2 · Ikegami · 2023 [cited by examiner]
US 11748530B2 · Cucu-Grosjean · 2023 [cited by examiner]
US 20080022288A1 · Bekooij · 2008 [cited by examiner]
US 20100199280A1 · Vestal · 2010 [cited by examiner]
US 20100325635A1 · Pree · 2010 [cited by examiner]
US 20110010160A1 · Pree · 2011 [cited by examiner]
US 20120310620A1 · Resmerita · 2012 [cited by examiner]
US 20150286203A1 · Stattelmann · 2015 [cited by examiner]
US 20160011908A1 · Paul · 2016 [cited by examiner]
US 20160247081A1 · Zaykov · 2016 [cited by examiner]
US 20180157571A1 · Lünstroth · 2018 [cited by examiner]
US 20200159974A1 · Cucu-Grosjean · 2020 [cited by examiner]
US 20220171660A1 · Ikegami · 2022 [cited by examiner]
Allabriga, Clément, and Hugues Casse. “Improving the WCET computation time by IPET using control flow graph partitioning.” 8th International Workshop on Worst-Case Execution Time WCET Analysis (WCET'08). Schloss Dagstuh… [cited by examiner]
Asavoae, Mihail, et al., “Program Semantics in Model-Based WCET Analysis: A State of the Art Perspective,” Claire Maiza, editor, 13th International Workshop on Worst-Case Execution Time Analysis, WCET 2013, Jul. 9, 2013… [cited by applicant]
“Automating WCET Analysis for DO-178B/C,” Rapita Systems Inc., Rapita Systems, White Paper, Jan. 2018, pp. 1-14. [cited by applicant]
Barkah, Dani, et al., “Evaluation of Automatic Flow Analysis for WCET Calculation on Industrial Real-time System Code,” IEEE, Proceedings—2008 Euromicro Conference on Real-Time systems, Prague, Czech Republic , Jul. 2-4… [cited by applicant]
Falk, Heiko, et al., “A Compiler Framework for the Reduction of Worst-Case Execution Times,” Springer Link, Springer, Real-Time Systems, vol. 46, Issue 2, Jul. 22, 2010, pp. 251-298. [cited by applicant]
Gliwa, Peter, “Why We Need a New Worst Case Timing Approach for Automotive,” T1, EMCC2022, Oct. 11, 2022, pp. 1-27. [cited by applicant]
Hansen, Jeffery, et al., “Statistical-Based WCET Estimation and Validation,” ECRTS 2009, 9 [cited by applicant]
Heckmann, Reinhold, et al., “Worst-Case Execution Time Prediction by Static Program Analysis,” AbsInt Angewandte Informatik GmBH, AbsInt, Apr. 2004, pp. 1-12. [cited by applicant]
Johnson, Richard, et al., “The Program Structure Tree: Computing Control Regions in Linear Time,” ACM Sigplan, in Notices, Proceedings of the ACM Sigplan 1994 conference on Programming language design and implementation… [cited by applicant]
Kirner, Raimund, et al., “Fully Automatic Worst-Case Execution Time Analysis for Matlab/Simulink Models,” IEEE, Proceedings 14th Euromicro Conference on Real-Time Systems. Euromicro RTS 2002, Vienna, Austria, Jun. 19-21… [cited by applicant]
Lokuciejewski, Paul, “Superblock-Based Source Code Optimizations for WCET Reduction,” Jun. 2010, pp. 1-8. [cited by applicant]
“Measuring WCET from Matlab® Simulink® Models with RapiTime,” Rapita Systems Ltd., Rapita Systems, Document ID: MC-TN-006 Matlab WCET with RapiTime v5, INDT-v8, date first accessed May 11, 2023, pp. 1-2. [cited by applicant]
Merriam, Dr. Nicholas, “A New Worst-Case Timing Approach for Automotive: Worst is Not Always Best,” T1, ESE, ESE (Embedded Software Engineering Congress) 2022 in Sindelfingen, Dec. 5-9, 2022, pp. 1-34. [cited by applicant]
“Program Execution Time”, Elsevier B.V., Elsevier, ScienceDirect, 2014, pp. 1-46. [cited by applicant]
“Simulink User's Guide,” Matlab®&Simulink®, The MathWorks, Inc., R2022a, Mar. 2022, pp. 1-4122. [cited by applicant]
Wilhelm, Reinhard, et al., “The Worst-Case Execution-Time Problem-Overview of Models and Survey of Tools,” ACM, ACM Transactions on Embedded Computing Systems, vol. 7, No. 3, Article 36, Apr. 2008, pp. 1-53. [cited by applicant]
Lokuciejewski, P., “A WCET-Aware Compiler: Design, Concepts and Realization,” Av Akademikerverlag, May 2012, pp. I-VII, 1-21, and 96-107. [cited by applicant]
“Measuring WCET from Matlab Simulink® Models with RapiTime,” Rapita Systems Ltd., Rapita Systems, Document ID: MC-TN-006 Matlab WCET with RapiTime v5, INDT-v8, Feb. 2022, pp. 1-2. [cited by applicant]
“Embedded Coder® User's Guide”, Matlab® & Simulink®, R2022a, The MathWorks, Inc., Mar. 2022, pp. 1-3942. [cited by applicant]