{"id":22241,"date":"2025-12-02T16:22:25","date_gmt":"2025-12-02T14:22:25","guid":{"rendered":"https:\/\/www.btc-embedded.com\/?p=22241"},"modified":"2025-12-02T16:36:17","modified_gmt":"2025-12-02T14:36:17","slug":"developing-algorithms-for-sdvs","status":"publish","type":"post","link":"https:\/\/www.btc-embedded.com\/zh-hans\/developing-algorithms-for-sdvs\/","title":{"rendered":"Developing Algorithms for SDVs: Models or Handwritten Code?"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"22241\" class=\"elementor elementor-22241\" data-elementor-post-type=\"post\">\n\t\t\t\t<div class=\"elementor-element elementor-element-df435c1 e-flex e-con-boxed e-con e-parent\" data-id=\"df435c1\" data-element_type=\"container\">\n\t\t\t\t\t<div class=\"e-con-inner\">\n\t\t\t\t<div class=\"elementor-element elementor-element-629313f elementor-widget elementor-widget-text-editor\" data-id=\"629313f\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>The rise of Software Defined Vehicles (SDVs) is a massive transformation in automotive industry. Unlike traditional vehicles, SDVs rely on software to deliver advanced features such as over-the-air updated, connectivity, autonomous driving etc. Two dominant approaches stand out: MBD and Handwritten <a href=\"https:\/\/www.btc-embedded.com\/test_environments\/c-code\/\">C-code<\/a>. So, which approach is the best for SDVs? In this article, we\u2019ll explore history, pros and cons of both approaches.<\/p><p>Software-Defined Vehicles (SDVs) trends are rising in the automotive industry. With features like ADAS, autonomous driving and over-the-air updates, software complexity is increasing day-by-day. Once critical question a developer might ask: What is the best approach to develop such a complex algorithm for SDV? Using Model-Based Development (MBD) or Handwritten C code.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-44b57b4 elementor-widget elementor-widget-heading\" data-id=\"44b57b4\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">A Brief History: From Machine Code to MBD<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-28cc40b elementor-widget elementor-widget-text-editor\" data-id=\"28cc40b\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>The question of using MBD or C-Code often comes up in SDV discussions. The answer is in the level of abstraction.<\/p>\n<p>In early days, engineer wrote raw machine code in strings of 1s and 0s, executed directly by the CPU to control simple hardware like 8-bit microcontrollers. This was however extremely difficult and required deep technical expertise.<\/p>\n<p>Assembly language was the next level of abstraction, first appeared in the 1950s and 60s. In this way, human-readable mnemonics took the place of binary instructions. For example, early washing machine controller used assembly language to manage timers and valves.<\/p>\n<p>As systems became more complex day by day, the next level of abstraction is this handwritten C code. It appeared in the 1980s and 90s giving the engineers the feasibility to create structured C-code using variables and functions. Compilers are used to convert or translate the sea code into assembly language. Automotive Engineers use C code for ABS controllers to ensure real-time performance.<\/p>\n<p>Finally, the 2000s brought Model-Based Development, where engineers could design algorithms graphically and simulate behavior. Auto-code generators are used to translate the Model into C-Code.<\/p>\n<p>With each high level of abstraction, specialized programming knowledge becomes less crucial, and Engineers gain flexibility to focus on system behavior and design quality rather than syntax and low-level details.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-0d941d3 elementor-widget elementor-widget-image\" data-id=\"0d941d3\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img fetchpriority=\"high\" decoding=\"async\" width=\"800\" height=\"651\" src=\"https:\/\/www.btc-embedded.com\/wp-content\/uploads\/2025\/12\/Abstractions-e1764683259857.webp\" class=\"attachment-large size-large wp-image-22250\" alt=\"SDV\" \/>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-50c9889 elementor-widget elementor-widget-heading\" data-id=\"50c9889\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Why Model-Based Development in SDV?<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-49279e9 elementor-widget elementor-widget-text-editor\" data-id=\"49279e9\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>Model-Based Development uses graphical models to design and simulate algorithms before generation production code automatically. This approach is ideal for high level logic and complex algorithms.<\/p><p>\u00a0<\/p><ul><li><strong>Rapid Prototyping:<\/strong> Developers can design, simulate and validate algorithms virtually before hardware is available<\/li><li><strong>Early Validation and Scalability:<\/strong> Systems involving multiple high-powered ECUs and millions of lines of code, MBD simplifies in managing complexity by providing hierarchical models and modular design. Which makes the large scale systems easy to maintain.<\/li><li><strong>Cross Domain Collaboration:<\/strong> Mechanical, Electrical, and software teams can work together using a common visual language.<\/li><\/ul><p>\u00a0<\/p><p><strong>Examples:<\/strong> Simulation of lane-keeping and adaptive cruise control algorithms in SDVs can be virtually validated before the deployment on ECUs. Sensor fusion and path planning can be developed in MBD for autonomous driving algorithms. Battery Management Systems in EV vehicles can be easily visualized due to its cross-domain collaborations.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-bc5740e elementor-widget elementor-widget-heading\" data-id=\"bc5740e\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Why Handwritten C-Code in SDV?<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-2717ce1 elementor-widget elementor-widget-text-editor\" data-id=\"2717ce1\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\tHandwritten code offers maximum control and optimization, making it essential for low-level drivers and performance critical components\n<ul><p><p>\n \t<li><strong>Fine Optimizations:<\/strong> Developers can tune memory usage and execution speed for real time performance<\/li>\n \t<li>Every line of code is visible briefly and can be customizable<\/li>\n \t<li><strong>Hardware specific control:<\/strong> Ideal for communication stacks, sensor drivers and real time scheduling.<\/li>\n<\/ul><p><p>\n<strong>Example:<\/strong> Implementation of CAN bus drivers and real time operation system integration for SDV platforms can be developed with C-code ensuring deterministic behavior.\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-2dd22d5 elementor-widget elementor-widget-image\" data-id=\"2dd22d5\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img decoding=\"async\" width=\"800\" height=\"704\" src=\"https:\/\/www.btc-embedded.com\/wp-content\/uploads\/2025\/12\/Approaches-in-SDV-e1764683292177.webp\" class=\"attachment-large size-large wp-image-22247\" alt=\"SDV\" \/>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-20bb2fd elementor-widget elementor-widget-heading\" data-id=\"20bb2fd\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Best Practice for SDV: The Hybrid Approach<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-6afb090 elementor-widget elementor-widget-text-editor\" data-id=\"6afb090\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>In SDV development, there is no single winner between Model-Based Development (MBD) and handwritten C-Code. The complexity demands a development strategy that balances speed, safety and performance. The most effective strategy is a hybrid approach that combines the advantages of both approached.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-1378bbd elementor-widget elementor-widget-heading\" data-id=\"1378bbd\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">How to Implement a Hybrid Approach?<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-0d3c99d elementor-widget elementor-widget-text-editor\" data-id=\"0d3c99d\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>A hybrid workflow leverages MBD for high level algorithms, such as Adaptive cruise control, energy management, sensor fusion because these areas benefit from simulation, rapid prototyping and virtualization.<\/p><p>Handwritten C-Code remains important for low-level drivers, communication stacks and performance critical routines. As C-Code helps to fine grain optimization and allows hardware specific modifications easily.<\/p><p>The key for a hybrid approach is to design clear interfaces between auto-generated code and manual code to ensure easy integration and maintainability.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-3093d38 elementor-widget elementor-widget-heading\" data-id=\"3093d38\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Why is it helpful to select a tool that is both qualified and able to do both?<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-b5dd0fb elementor-widget elementor-widget-text-editor\" data-id=\"b5dd0fb\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>Selecting a single integrated testing tool that supports both modeling and manual coding simplifies workflows, reduce tool effort and improves traceability. For safety-critical systems, tool qualification becomes mandatory under <a href=\"https:\/\/www.iso.org\/standard\/43464.html\" target=\"_blank\" rel=\"noopener\">ISO 26262<\/a>. Compliance is achieved through a verification process such as back-to-back testing between model and generated code to confirm functional equivalence.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-fc7a088 elementor-widget elementor-widget-heading\" data-id=\"fc7a088\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Conclusion<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-b441c89 elementor-widget elementor-widget-text-editor\" data-id=\"b441c89\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>In the current trend of Software Defined Vehicles, algorithms development is no longer a question of Model-Based Development and Handwritten C-Code. It\u2019s about finding a right balance between them. MBD allows faster design and enables early validation. While handwritten C-Code ensures optimization, performance and hardware specific control. The most effective strategy is hybrid approach: Where models are used for complex and high-level algorithms and C-Code is is used for low-level, real-time components. Selecting an integrated toolchain that supports both workflows, qualifying tools for ISO26262, and performing back-to-back test between models and generated code are essential steps for scalable SDV software.\u00a0<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>The rise of Software Defined Vehicles (SDVs) is a massi [&hellip;]<\/p>\n","protected":false},"author":16,"featured_media":22262,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"elementor_theme","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[1],"tags":[52,55,81,62,53,123,248,224,61,48,122,225,121],"product":[],"use_cases":[],"class_list":["post-22241","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized","tag-autosar","tag-ci-cd","tag-code-coverage","tag-handcode","tag-iso-26262","tag-matlab","tag-mbd","tag-rbt","tag-requirements-engineering","tag-simulink","tag-standard-tools","tag-tdd","tag-testing"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.btc-embedded.com\/zh-hans\/wp-json\/wp\/v2\/posts\/22241","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.btc-embedded.com\/zh-hans\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.btc-embedded.com\/zh-hans\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.btc-embedded.com\/zh-hans\/wp-json\/wp\/v2\/users\/16"}],"replies":[{"embeddable":true,"href":"https:\/\/www.btc-embedded.com\/zh-hans\/wp-json\/wp\/v2\/comments?post=22241"}],"version-history":[{"count":21,"href":"https:\/\/www.btc-embedded.com\/zh-hans\/wp-json\/wp\/v2\/posts\/22241\/revisions"}],"predecessor-version":[{"id":22272,"href":"https:\/\/www.btc-embedded.com\/zh-hans\/wp-json\/wp\/v2\/posts\/22241\/revisions\/22272"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.btc-embedded.com\/zh-hans\/wp-json\/wp\/v2\/media\/22262"}],"wp:attachment":[{"href":"https:\/\/www.btc-embedded.com\/zh-hans\/wp-json\/wp\/v2\/media?parent=22241"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.btc-embedded.com\/zh-hans\/wp-json\/wp\/v2\/categories?post=22241"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.btc-embedded.com\/zh-hans\/wp-json\/wp\/v2\/tags?post=22241"},{"taxonomy":"product","embeddable":true,"href":"https:\/\/www.btc-embedded.com\/zh-hans\/wp-json\/wp\/v2\/product?post=22241"},{"taxonomy":"use_cases","embeddable":true,"href":"https:\/\/www.btc-embedded.com\/zh-hans\/wp-json\/wp\/v2\/use_cases?post=22241"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}