作者: Darren H. Chen
方向: 汽车芯片功能安全分析与故障注入实践
Demo: D10_failure_mode_library
标签: 汽车芯片 功能安全 Failure Mode FMEDA 失效模式库 Safety Mechanism
Demo 说明
D10_failure_mode_library 的目标是建立一个可维护、可检查、可复用的 Failure Mode Library。
对应的通用工具名称为:
text
safeic-fmlib
这个 Demo 的作用是把系统级安全目标逐步落到模块级、子模块级和结构级对象:
text
Safety Goal
-> Functional Failure
-> Module Failure Mode
-> Sub-part Failure Mode
-> Endpoint / Safety Mechanism Mapping
如果没有 failure mode library,FMEDA 很容易变成临时表格;如果建立了库,功能安全分析就可以形成可复用的方法资产。
1. Failure Mode 是什么
Failure Mode 可以理解为:
某个功能、模块或结构对象以什么方式失效。
它不是具体某个 bit 翻转,也不是某个 fault injection case。
它描述的是故障造成的功能后果。
例如:
text
输出数据错误
控制状态错误
传输过早或过晚
未请求时发生传输
请求后没有响应
计数器停止或跳变
错误中断上报
安全报警未触发
随机硬件故障是原因,Failure Mode 是后果。
可以这样理解:
text
Fault -> Error -> Failure Mode -> Safety Goal Violation
2. 为什么需要 Failure Mode Library
在实际项目中,failure mode 经常分散在不同文档里:
text
安全计划
系统 FMEA
IP safety manual
模块规格书
设计评审记录
验证计划
FMEDA 表格
如果没有统一库,会出现几个问题:
text
不同模块使用不同命名
同一个 failure mode 被重复定义
安全机制映射不一致
报告难以汇总
后续复用困难
Failure Mode Library 的作用是统一语言。
它应该回答:
text
这个 failure mode 叫什么?
它描述什么失效后果?
适用于哪些模块或接口?
它和哪些 safety mechanism 相关?
它是否 safety-related?
它是否影响 SPFM/LFM/PMHF?
3. 系统级到模块级的映射
功能安全分析不能只停留在系统级。
例如系统级安全目标:
text
制动控制输出不能产生危险错误值
落到芯片内部,可能对应多个模块 failure mode:
| 层级 | 示例 |
|---|---|
| 系统级 | wrong actuator output |
| 芯片级 | wrong output from control IC |
| 模块级 | CPU generated wrong control command |
| 子模块级 | ALU computation result wrong |
| 结构级 | register input captured wrong value |
这个过程不是简单翻译,而是从系统安全目标向硬件结构逐步分解。
Failure Mode Library 应该支持这种分层。
4. 常见 Failure Mode 分类
在汽车芯片实践中,可以先建立几类通用 failure mode。
4.1 数据类
text
wrong_data
stale_data
out_of_range_data
corrupted_message
wrong_address
wrong_id
适用模块:
text
ALU
DMA
Bus
Memory
Sensor Interface
Communication Controller
4.2 控制类
text
wrong_control_state
illegal_state
unexpected_transition
missing_transition
wrong_enable
wrong_grant
适用模块:
text
FSM
Bus Arbiter
Timer
Interrupt Controller
Power Controller
4.3 时序类
text
too_early
too_late
timeout_missing
unexpected_timeout
wrong_sequence
适用模块:
text
Timer
Protocol Controller
Communication Interface
Watchdog
4.4 传输类
text
message_not_sent
message_sent_when_not_requested
message_duplicated
message_lost
wrong_response
适用模块:
text
CAN/LIN/Ethernet Controller
Bus Fabric
DMA
Peripheral Bridge
4.5 安全机制类
text
alarm_not_triggered
false_alarm
checker_disabled
diagnostic_timeout
latent_fault_not_detected
适用对象:
text
Safety Mechanism
Error Handler
Alarm Aggregator
Safety Monitor
5. Failure Mode Library 的数据结构
推荐用 YAML 或 CSV。YAML 更适合表达层级和描述。
示例 failure_modes.yaml:
yaml
failure_modes:
WRONG_DATA:
description: Data value is different from the intended correct value.
category: data
safety_related: true
typical_modules:
- alu
- bus
- memory
candidate_safety_mechanisms:
- parity
- ecc
- duplication
- range_check
WRONG_CONTROL_STATE:
description: Control FSM enters an incorrect or illegal state.
category: control
safety_related: true
typical_modules:
- fsm
- bus_arbiter
- interrupt_controller
candidate_safety_mechanisms:
- state_parity
- illegal_state_checker
- control_flow_monitor
TOO_LATE:
description: Required action or message is generated later than allowed.
category: timing
safety_related: true
typical_modules:
- timer
- communication_controller
candidate_safety_mechanisms:
- watchdog
- timeout_monitor
这样一个库不仅供文章 Demo 使用,也可以作为后续 FMEDA、SM selection 和报告生成的输入。
6. Failure Mode 与 Safety Mechanism 的关系
Failure Mode 描述"会错成什么样"。
Safety Mechanism 描述"如何发现或缓解这种错误"。
两者之间不是一对一关系。
例如:
| Failure Mode | 可能安全机制 |
|---|---|
| wrong_data | parity、ECC、duplication、range check |
| wrong_control_state | state parity、illegal state checker、lockstep |
| too_late | watchdog、timeout monitor |
| wrong_sequence | protocol checker、sequence monitor |
| alarm_not_triggered | alarm self-test、diagnostic monitor |
同一个 safety mechanism 也可能覆盖多个 failure mode:
text
ECC 可以覆盖 wrong_data、corrupted_memory_data
watchdog 可以覆盖 too_late、missing_response
protocol checker 可以覆盖 wrong_sequence、unexpected_message
因此,Failure Mode Library 和 Safety Mechanism Library 应该独立维护,再通过 map 连接。
7. 工具架构设计
safeic-fmlib 的核心职责是管理和检查 failure mode library。
工具流程:
Read Failure Mode Library
Schema Check
Duplicate Name Check
Category Check
Safety Related Check
Link to Candidate SM
Generate Normalized Library
Generate Report
主要检查项:
text
failure mode ID 是否唯一
description 是否为空
category 是否属于允许范围
是否标注 safety_related
candidate safety mechanisms 是否存在于 SM library
是否有未使用的 failure mode
是否有模块引用了不存在的 failure mode
8. 输出文件设计
fmlib_check.rpt 示例:
text
[PASS] Failure mode ID uniqueness check
[PASS] Required fields check
[PASS] Category check
[WARN] Failure mode ALARM_FALSE has no candidate safety mechanism
[ERROR] Failure mode WRONG_BUS_RESP referenced by module bus_fabric but not defined
normalized_fmlib.json 示例:
json
{
"failure_modes": [
{
"id": "WRONG_DATA",
"category": "data",
"safety_related": true,
"candidate_safety_mechanisms": ["parity", "ecc", "duplication", "range_check"]
}
]
}
failure_mode_matrix.csv 示例:
csv
failure_mode,category,safety_related,candidate_sm_count,typical_module_count
WRONG_DATA,data,true,4,3
WRONG_CONTROL_STATE,control,true,3,3
TOO_LATE,timing,true,2,2
9. 与 FMEDA 的关系
FMEDA 需要把以下对象连接起来:
text
Part / Sub-part
Instance
Failure Mode
Safety Mechanism
Diagnostic Coverage
Failure Rate
Residual Fault
Failure Mode Library 是其中的中间层。
一个典型映射关系是:
text
Part: CPU
Sub-part: Control FSM
Instance: top.u_cpu.u_ctrl
Failure Mode: WRONG_CONTROL_STATE
Safety Mechanism: STATE_PARITY
Diagnostic Coverage: 90%
如果 failure mode 没有统一库,FMEDA 表格很难长期维护。
如果有统一库,就可以做到:
text
同类模块复用同一 failure mode
同类 failure mode 推荐相似 safety mechanism
报告中统一分类统计
跨项目复用安全分析经验
10. D10 Demo 的目录建议
text
D10_failure_mode_library/
README.md
run_demo.csh
run_demo.sh
inputs/
failure_modes.yaml
sm_library.yaml
module_failure_map.csv
outputs/
fmlib_check.rpt
normalized_fmlib.json
failure_mode_matrix.csv
failure_mode_report.md
scripts/
safeic_fmlib.py
运行命令示例:
bash
python3 scripts/safeic_fmlib.py \
--failure-modes inputs/failure_modes.yaml \
--sm-lib inputs/sm_library.yaml \
--module-map inputs/module_failure_map.csv \
--out outputs
csh 版本:
csh
python3 scripts/safeic_fmlib.py \
--failure-modes inputs/failure_modes.yaml \
--sm-lib inputs/sm_library.yaml \
--module-map inputs/module_failure_map.csv \
--out outputs
11. 方法论总结
Failure Mode Library 的价值是统一语言。
它把系统级安全目标、模块级失效后果、安全机制选择和 FMEDA 表格连接起来:
text
Safety Goal
-> Failure Mode
-> Safety Mechanism
-> DC Calculation
-> Fault Campaign
-> Final Metric
D10_failure_mode_library 的目标不是做复杂 GUI,而是先把 failure mode 变成可检查、可复用、可映射的数据资产。
有了这个库,后续 EP-to-Safety Mechanism Map、FMEDA Part/Sub-part 建模、DCE roll-up 和 fault campaign report 都会更容易组织。