dSPACE SIC(Simulink Implementation Container)
說明與 BSC 整合
SIC 檔將 Simulink 行為模型的模型碼與介面封裝為容器,讓模型碼產生與建置流程分離。本頁說明 SIC 的內容、產生方式,以及在 Bus Manager 中如何將 SIC 與 BSC(Bus Simulation Container)整合。
Model Interface Package for Simulink 讓您為 Simulink 行為模型產生 SIC 檔(Simulink Implementation Container)——一個包含模型碼的容器檔。SIC 可加入 ConfigurationDesk 應用或匯入 VEOS;在 Bus Manager 工作流程中,SIC 更是「含行為模型」時產生 BSC(Bus Simulation Container)的必要元件。本頁內容整理自 dSPACE 原廠手冊(RLS2024-B)。
1. SIC 是什麼
SIC 檔是「Simulink 行為模型模型碼」的容器檔。若模型碼需要 Simulink Coder 未知的相依檔案,可透過 API 指令加入 SIC。SIC 可用於 ConfigurationDesk 或 VEOS,其核心價值在於將模型碼產生(code generation)與建置流程(build)分離。
不需 MATLAB 建置
僅「產生 SIC」需要 MATLAB;在 ConfigurationDesk 或 VEOS 使用 SIC 不需安裝 MATLAB。
向後相容
ConfigurationDesk 與 VEOS 支援以相同 Release 或前 7 個主要 Release 產生的 SIC。
可預編譯 / IP 保護
在 ConfigurationDesk 可預編譯 SIC 以節省建置時間;亦可產生無可讀原始碼的預編譯 SIC 以保護 IP。
2. SIC 檔的內容
一個 SIC 檔包含下列元素:
- 模型碼與外部相依檔行為模型產生的程式碼,以及透過 API 加入的外部相依檔。
- 必要靜態碼來自產生 SIC 時所用之 MATLAB/Simulink 安裝的必要靜態程式碼。
- 模型介面描述描述模型的輸入/輸出訊號與 runnable functions(即 model port blocks 對外的介面)。
- 變數描述產生 SIC 時一併產生,可為 TRT 檔(平台無關的中介檔,建置時由 ConfigurationDesk/VEOS 寫入平台位址成為 TRC)或 A2L 檔(可選啟用,供 VEOS 使用)。
外部檔案處理:透過 dsrt_addfiles() 加入的檔案依類型處理——二進位/程式庫會複製進 SIC 並加入 makefile 連結;原始碼(.c/.cpp)會複製並編譯連結;標頭檔會加入 include 路徑;DLL/共享物件會下載到目標平台或供 VEOS 模擬時存取。
3. Model Interface Blockset 與 Model Port Blocks
行為模型與外部 I/O 功能之間的介面,由 Model Interface Blockset 提供的 model port blocks 實作。這正是 SIC 對外暴露、之後在 Bus Manager 中要與 Bus Configuration 對應的介面。
Data Inport
資料輸入埠,實作 ConfigurationDesk/VEOS 送入模型的資料交換。
Data Outport
資料輸出埠,實作模型輸出至 ConfigurationDesk/VEOS 的資料交換。
Runnable Function
模型提供、須於 task 中呼叫以運算結果的函式;模型分析後可指派至週期或非同步 task。
- 兩種建立來源Model port blocks 可在 Simulink 模型中建立(匯入 ConfigurationDesk 的 model topology),或在 ConfigurationDesk 建立後匯出/直接產生到行為模型。
- 唯一 IDData port block 具唯一 ID;跨模型沿用同一介面時須用 Paste and Keep IDs 保留 ID。Runnable Function blocks 在模型中須有唯一函式名稱。
- 在 VEOS 的呈現SIC 匯入 VEOS 時,每個 model port block 會建立一個 VPU port;在 ConfigurationDesk 則建立對應的 model port block。
4. Target Architecture 與平台對應(關鍵)
產生 SIC 時於 Configuration Parameters → dSPACE Target DSRT 指定的 Target architecture,會決定該 SIC ——以及由它產生的 BSC ——可用的目標平台:
| Target Architecture | 目標平台 |
|---|---|
| Default | 由 dsmpb_pref() 的 DefaultTargetArchitecture 決定;建議使用,變更目標架構時模型設定得以保留。 |
| 32-bit | MicroAutoBox III、VEOS on Windows 32/64-bit、VEOS on Linux 32-bit |
| 64-bit | SCALEXIO Linux 64-bit、MicroLabBox II、VEOS on Linux 64-bit |
對 BSC 的影響:若 application process 含 SIC,該 SIC 的 target architecture 決定所產生 BSC 的可用平台。例如以 64-bit 建置的 SIC,其 BSC 僅能用於 Linux 64-bit 的 SCALEXIO、MicroLabBox II 與 VEOS。SIC 檔名可選擇加上架構後綴(如 demo_64-bit.sic)。
5. 如何產生 SIC
產生 SIC 需要 Simulink Coder 授權;兩種方法都必須以 dSPACE Run-Time Target(dsrt.tlc)作為 system target file。
方法一:Build 指令(Ctrl + B)
- 建立行為模型
- Configuration Parameters(Ctrl + E)→ Code Generation
- System target file 選擇
dsrt.tlc - dSPACE Target DSRT 頁選擇 Target architecture
- 按 Ctrl + B 產生 SIC
方法二:dsrt_build() API
於 MATLAB Command Window 執行,可指定混淆原始碼、架構與檔名後綴:
dsrt_build('System','myModel',
'ObfuscateCode',true,
'TargetArchitecture','64-bit',
'TargetArchInSICFilename',true)
SIC 以模型命名;經 Simulink Coder 產生時輸出至 MATLAB 工作目錄,經 dsrt_build() 且指定路徑時輸出至指定位置。可基於 Simulink 起始頁的 DSRT 範本建立預先配置好 dsrt.tlc 的新模型。
6. SIC 與 BSC 的關係
在 Bus Manager 工作流程中,SIC 與 BSC 的關係可歸納如下:SIC 提供「行為模型」,Bus Configuration 提供「匯流排通訊」,兩者透過 function ports ↔ model ports 的對應結合,最終由每個 application process 各產生一個 BSC。
SIC 的角色
提供行為模型的模型碼與 model ports(Data Inport/Outport、Runnable Function),供動態計算訊號值。
BSC 的角色
封裝已設定好的匯流排通訊;產生 BSC 時,每個 application process 只能含 0 或 1 個行為模型,若有則必須為 SIC。
一個 process 一個 SIC:若一個 application process 被指派多個模型,須先在 Build Configuration 表刪除該 process,再於 Model Browser 對各模型「Create Preconfigured Application Process」,讓每個模型各自獨立成 process,方能產生 BSC。
7. 整合步驟(在 Bus Manager 中將 SIC 與 BSC 結合)
啟用 Model Access
對要與模型交換資料的 function ports 啟用 model access(並視需要啟用 test automation support)。
加入 SIC
將 SIC 檔加入 ConfigurationDesk 應用(若尚無 SIC,可由 model interface 於 Simulink 產生後再加入)。
對應 Ports
把 SIC 的 model ports map 到 Bus Configuration 的 function ports(表格或圖形化視圖);對應後 Bus Configuration 會自動指派到該模型的 process。
建模 Tasks
若加入 SIC 時建立了 preconfigured application process,多數情況可沿用預設 task 設定。
解決衝突
於 Conflicts Viewer 確認無「No Valid Application Process Assigned」等阻擋性衝突;若又手動指派過 process 會造成「兩個 process」衝突,須清除手動指派。
產生 BSC
Buses 視圖集 → Home → Generate Bus Simulation Containers;每個合格 process 各產生一個 .bsc。
8. Port Interface 規則
BSC 匯入 VEOS/ConfigurationDesk 後,會依下列規則產生對外的 port interface:
- 納入條件model ports 屬於指派給該 process 的 SIC 且未對應到 Bus Configuration ports;或 function ports 已啟用 model access 但未對應到 model ports。
- Event ports 不納入event ports 不會出現在 port interface。
- VEOS 的限制data inports/outports/function ports 以 signals 呈現;runnable function ports 在 VEOS 不可用(匯入會出現警告)。ConfigurationDesk 則提供 Data port blocks 與 Runnable Function blocks。
- 效能建議只對「真的要與模型交換資料」的 function ports 啟用 model access,並盡量在產生 BSC 前先完成 map。
9. 部署到 VEOS / ConfigurationDesk
| 目標 | 步驟摘要 |
|---|---|
| VEOS(離線 / SIL) | 匯入 BSC → bus access requests 以 communication controllers 呈現並連接 communication clusters → 把 port interface signals 連到 plant model → 建置離線模擬應用。 |
| ConfigurationDesk(即時) | BSC 當 model implementation 加入 → Configuration Port blocks 對應 CAN/LIN bus function blocks 並指派硬體 → 把 BSC 的 Data port / Runnable Function blocks 接入訊號鏈 → 建置即時應用(程式碼已在 BSC/SIC 內,建置更快)。 |
變數描述路徑在離線與即時應用中相同,可共用同一份 ControlDesk Layout。
10. SIC 的限制
- 含匯流排 MultiMessage 區塊無法產生 SIC若行為模型含 dSPACE RTI CAN MultiMessage、RTI LIN MultiMessage 或 FlexRay Configuration Blockset 區塊,無法產生 SIC;但可將該模型直接加入 ConfigurationDesk 應用使用。
- 平台專屬 custom code 無法偵測若為某平台加入平台專屬 custom code,SIC 可能無法在其他平台建置,且工具不會發出警告。
- C++ 支援限制產生 SIC 時勿啟用 Simulink Coder 的 C++ 程式碼產生(可將 C++ 整合進 S-function);變數名稱須符合 C 符號語法。
- Code Generation Folder用於 SIC 產生的模型,Code Generation Folder Structure 僅支援預設的
Model Specific。 - VEOS 與 MM 區塊VEOS 不支援由含 RTI CAN/LIN MultiMessage Blockset 區塊之模型所產生的 SIC。
11. 整合前檢查清單
- SIC 以
dsrt.tlc為 system target file 產生,且 Target architecture 符合目標平台 - 行為模型不含 RTI CAN/LIN MultiMessage 或 FlexRay 區塊(否則無法產生 SIC)
- 要交換資料的 function ports 已啟用 model access
- SIC 的 model ports 已 map 到 Bus Configuration 的 function ports
- 每個 application process 只含 1 個 SIC,且無多餘的手動 process 指派
- Conflicts Viewer 無阻擋性衝突
- 執行 Generate Bus Simulation Containers,並於 Message Viewer 確認每個 process 各產生一個 .bsc
原始文件出處(dSPACE RLS2024-B)
| 文件 | 檔名 |
|---|---|
| Model Interface Package for Simulink – Modeling Guide | ModelInterfacePackageForSimulinkGuide.pdf |
| Model Interface Package for Simulink – API Reference | ModelInterfacePackageForSimulinkAPIReference.pdf |
| Bus Manager (Stand-Alone) Implementation Guide | BusManagerImplementationGuide.pdf |
| ConfigurationDesk Real-Time Implementation Guide | ConfigurationDeskImplementationGuide.pdf |
路徑前綴:C:\Users\Public\Acolada\Cobrili\HelpSetStorage\dSPACEPDF\RLS2024-B\en\ · 圖片擷取自對應手冊頁面。