loader image

Blog

Developing Algorithms for SDVs: Models or Handwritten Code?

Yatish Chitluri

Oldenburg, Germany

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 C-code. So, which approach is the best for SDVs? In this article, we’ll explore history, pros and cons of both approaches.

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.

A Brief History: From Machine Code to MBD

The question of using MBD or C-Code often comes up in SDV discussions. The answer is in the level of abstraction.

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.

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.

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.

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.

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.

SDV

Why Model-Based Development in SDV?

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.

 

  • Rapid Prototyping: Developers can design, simulate and validate algorithms virtually before hardware is available
  • Early Validation and Scalability: 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.
  • Cross Domain Collaboration: Mechanical, Electrical, and software teams can work together using a common visual language.

 

Examples: 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.

Why Handwritten C-Code in SDV?

Handwritten code offers maximum control and optimization, making it essential for low-level drivers and performance critical components

  • Fine Optimizations: Developers can tune memory usage and execution speed for real time performance
  • Every line of code is visible briefly and can be customizable
  • Hardware specific control: Ideal for communication stacks, sensor drivers and real time scheduling.

Example: Implementation of CAN bus drivers and real time operation system integration for SDV platforms can be developed with C-code ensuring deterministic behavior.

SDV

Best Practice for SDV: The Hybrid Approach

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.

How to Implement a Hybrid Approach?

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.

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.

The key for a hybrid approach is to design clear interfaces between auto-generated code and manual code to ensure easy integration and maintainability.

Why is it helpful to select a tool that is both qualified and able to do both?

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 ISO 26262. Compliance is achieved through a verification process such as back-to-back testing between model and generated code to confirm functional equivalence.

Conclusion

In the current trend of Software Defined Vehicles, algorithms development is no longer a question of Model-Based Development and Handwritten C-Code. It’s 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. 

Yatish Chitluri

Oldenburg, Germany

Application Engineer

Yatish Chitluri received his Master of Science in Mechatronics at the FH Aachen. He worked for 2.5 years at Fraunhofer ILT in Aachen, Germany as a research assistant in the field of Model-based Development methods. In October 2021, Yatish Chitluri joined BTC Embedded Systems AG as an Application Engineer in Oldenburg, Germany, where he supports our worldwide customers with their Model-based Development and Testing toolchains and processes.

Connect on LinkedIn

Popular Videos

Request Evaluation License

If you would like to try out our tools, we will gladly provide an evaluation license free of chargeEvaluations include a free launch workshop and also provide an opportunity for you to meet one-on-one with our support and engineering teams.

Schedule a Meeting

Do you have any questions or want to see our tools in action? If so, please use the link below to schedule a meeting, where a member of our engineering team will be happy to show you the features and use cases and directly answer any questions you might have.

Events

Join upcoming Webinar

Melden Sie sich für unseren Newsletter an!

Für den Newsletterversand wird Ihre Email Adresse vom DSGVO zertifizierten Dienstleister CleverReach verarbeitet. Weitere Informationen finden Sie in unserer Datenschutzerklärung.

Videos

Discover some of the main features of our products in these short videos.