Home Learning Paths ECU Lab Assessments Interview Preparation Arena Pricing Log In Sign Up

Back-to-Back Testing Overview

V&V Test Levels
  MiL (Model-in-the-Loop)
  - Test the Simulink model directly
  - Double precision; no code involved
  - Purpose: verify algorithm correctness

  SiL (Software-in-the-Loop)
  - Compile generated C code; run on host PC
  - Production data types; production code
  - Purpose: verify code is numerically equivalent to model
  - Compares output to MiL reference

  PiL (Processor-in-the-Loop)
  - Run generated code on target MCU (cross-compiled)
  - Tests execution time and MCU-specific behaviour
  - Purpose: verify timing and MCU integer arithmetic

  HiL (Hardware-in-the-Loop)
  - Full ECU with plant model on HIL bench
  - Purpose: system-level integration test

  Back-to-back: compare MiL vs SiL output numerically.
  ISO 26262 Part 6 Cl. 9: MiL/SiL equivalence required.

SiL Mode Configuration

MATLABsil_config.m
% Configure model for SiL simulation
% Two methods:

% Method 1: Top Model SiL
% Simulation > Mode > Software-in-the-Loop (SIL)
% This compiles the top model and runs generated code
set_param(model, "SimulationMode", "software-in-the-loop (sil)");

% Method 2: Model Reference SiL (recommended for component testing)
% The referenced model runs as compiled code;
% the test harness runs as Simulink simulation
% In Model block properties: "Simulation mode" = "SIL"
set_param("TestHarness/SpeedController_Ref", ...
    "SimulationMode", "Software-in-the-loop (SIL)");

% Run SiL simulation (same test cases as MiL)
sil_result = sim("TestHarness", 20.0);

% SiL automatically creates code coverage data
% View in Coverage Analysis Report after SiL run

Back-to-Back Comparison Script

MATLABb2b_comparison.m
% Back-to-back MiL vs SiL comparison
model = "SpeedController";

% Step 1: Run MiL (reference)
set_param(model, "SimulationMode", "normal");
mil_out = sim(model, 20.0);
mil_speed = mil_out.VehicleSpeed.Data;
mil_pedal = mil_out.PedalRequest.Data;

% Step 2: Run SiL (generated code)
set_param(model, "SimulationMode", "software-in-the-loop (sil)");
sil_out = sim(model, 20.0);
sil_speed = sil_out.VehicleSpeed.Data;
sil_pedal = sil_out.PedalRequest.Data;

% Step 3: Compare
% Tolerance: quantisation from single vs double
% Expected: < 1e-5 for single-precision differences
speed_diff = max(abs(mil_speed - sil_speed));
pedal_diff = max(abs(mil_pedal - sil_pedal));

assert(speed_diff < 1e-4, "SiL/MiL speed mismatch: %g", speed_diff);
assert(pedal_diff < 1e-4, "SiL/MiL pedal mismatch: %g", pedal_diff);

fprintf("MiL/SiL back-to-back: PASS (max diff: %g)\n", ...
    max(speed_diff, pedal_diff));

Summary

Back-to-back MiL vs SiL testing is the fundamental quality gate between model verification and code verification in the V-model. ISO 26262 Part 6 requires demonstrating equivalence between the model and the generated code, and back-to-back comparison is the standard method. A difference larger than quantisation error (typically < 1e-4 for single-precision) indicates the generated code does not faithfully implement the model - caused by type conversion issues, fixed-point overflow, or incorrect hardware implementation settings. Finding this difference at SiL stage (on the PC) is vastly cheaper than finding it at HiL or vehicle level. The comparison script must cover all operating modes and boundary conditions, not just a single step response.

🔬 Deep Dive — Core Concepts Expanded

This section builds on the foundational concepts covered above with additional technical depth, edge cases, and configuration nuances that separate competent engineers from experts. When working on production ECU projects, the details covered here are the ones most commonly responsible for integration delays and late-phase defects.

Key principles to reinforce:

  • Configuration over coding: In AUTOSAR and automotive middleware environments, correctness is largely determined by ARXML configuration, not application code. A correctly implemented algorithm can produce wrong results due to a single misconfigured parameter.
  • Traceability as a first-class concern: Every configuration decision should be traceable to a requirement, safety goal, or architecture decision. Undocumented configuration choices are a common source of regression defects when ECUs are updated.
  • Cross-module dependencies: In tightly integrated automotive software stacks, changing one module's configuration often requires corresponding updates in dependent modules. Always perform a dependency impact analysis before submitting configuration changes.

🏭 How This Topic Appears in Production Projects

  • Project integration phase: The concepts covered in this lesson are most commonly encountered during ECU integration testing — when multiple software components from different teams are combined for the first time. Issues that were invisible in unit tests frequently surface at this stage.
  • Supplier/OEM interface: This is a topic that frequently appears in technical discussions between Tier-1 ECU suppliers and OEM system integrators. Engineers who can speak fluently about these details earn credibility and are often brought into critical design review meetings.
  • Automotive tool ecosystem: Vector CANoe/CANalyzer, dSPACE tools, and ETAS INCA are the standard tools used to validate and measure the correct behaviour of the systems described in this lesson. Familiarity with these tools alongside the conceptual knowledge dramatically accelerates debugging in real projects.

⚠️ Common Mistakes and How to Avoid Them

  1. Assuming default configuration is correct: Automotive software tools ship with default configurations that are designed to compile and link, not to meet project-specific requirements. Every configuration parameter needs to be consciously set. 'It compiled' is not the same as 'it is correctly configured'.
  2. Skipping documentation of configuration rationale: In a 3-year ECU project with team turnover, undocumented configuration choices become tribal knowledge that disappears when engineers leave. Document why a parameter is set to a specific value, not just what it is set to.
  3. Testing only the happy path: Automotive ECUs must behave correctly under fault conditions, voltage variations, and communication errors. Always test the error handling paths as rigorously as the nominal operation. Many production escapes originate in untested error branches.
  4. Version mismatches between teams: In a multi-team project, the BSW team, SWC team, and system integration team may use different versions of the same ARXML file. Version management of all ARXML files in a shared repository is mandatory, not optional.

📊 Industry Note

Engineers who master both the theoretical concepts and the practical toolchain skills covered in this course are among the most sought-after professionals in the automotive software industry. The combination of AUTOSAR standards knowledge, safety engineering understanding, and hands-on configuration experience commands premium salaries at OEMs and Tier-1 suppliers globally.

← PreviousDesign Verifier for Property ProvingNext →Coverage Analysis and Gap Closure