Skip to content
Merged
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "OM"
uuid = "2f925a0b-2436-437b-858e-49aee461894b"
version = "0.6.0"
version = "0.6.1"
authors = ["John Tinnerholm <john.tinnerholm@liu.se>"]

[deps]
Expand Down Expand Up @@ -52,7 +52,7 @@ DoubleEnded = "0.2.3"
ImmutableList = "0.4.2"
ListUtil = "0.4.1"
MetaModelica = "0.4.2"
OMBackend = "0.6.0"
OMBackend = "0.7.0"
OMFrontend = "1.7.4"
OMParser = "0.2.2"
OMRuntimeExternalC = "0.3.5"
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,8 @@ OM.jl is composed of several submodules, each in its own directory:
| **SCode.jl** | Simplified code representation (intermediate form between Absyn and the frontend) |
| **OMParser.jl** | Modelica parser that produces Absyn |
| **OMFrontend.jl** | The new frontend (NF) that performs instantiation, typing, flattening, and simplification |
| **OMBackend.jl** | Backend that performs matching, sorting, index reduction, code generation, and simulation via ModelingToolkit.jl |
| **DAE.jl** | Data structures for the DAE (Differential-Algebraic Equation) intermediate representation |
| **OMBackend.jl** | Backend that lowers the flat model to its own IR (OMJLIR), runs its passes, matches and sorts it into the simulation code, and generates and simulates the system via ModelingToolkit.jl |
| **DAE.jl** | Data structures of the frontend's DAE form (`OMFrontend.instantiateSCodeToDAE`); the backend does not use it |
| **MetaModelica.jl** | Julia implementation of MetaModelica language constructs (uniontypes, pattern matching, immutable lists) |
| **ImmutableList.jl** | Immutable cons-list implementation used throughout the compiler |
| **ArrayUtil.jl** | Array utility functions (fold, map, etc.) |
Expand Down
5 changes: 3 additions & 2 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ six-axis `RobotR3` system.
|
v
+---------------------------- BACKEND ---------------------------+
| FlatModel -> BDAE -> matching / index reduction / optimization |
| -> SimCode -> Julia / ModelingToolkit codegen |
| FlatModel -> OMJLIR -> passes (records, clocks, derivatives) |
| -> SimCode -> passes (aliases, constants, folds) |
| -> Julia / ModelingToolkit codegen |
+------------------------------+---------------------------------+
|
v
Expand Down
38 changes: 17 additions & 21 deletions src/OM.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ include("MosScripting/mosScripting.jl")
"""
EliminationOptions

Re-export of `OMBackend.SimulationCode.EliminationOptions`. Pass an instance to
Re-export of `OMBackend.SimCode.EliminationOptions`. Pass an instance to
the `eliminateNonDynamic` keyword of `translate` / `simulate` for fine-grained
control over which non-dynamic variables are removed before MTK code generation.

See `OMBackend.SimulationCode.EliminationOptions` for the available fields.
See `OMBackend.SimCode.EliminationOptions` for the available fields.
"""
const EliminationOptions = OMBackend.SimulationCode.EliminationOptions
const EliminationOptions = OMBackend.SimCode.EliminationOptions

function printWelcomeMessage()
printstyled("Open", bold=true, color=:light_blue)
Expand Down Expand Up @@ -784,26 +784,22 @@ function translate(modelName::String,
checkSimCode::Bool = true,
scalarize::Bool = SCALARIZE[])
return withDirectRHS(directRHS) do
#= MTK_MODE and DEMode both consume the FlatModel-derived SIM_CODE. Only the
deprecated DAE_MODE wants the legacy :DAE representation. =#
repr = (mode == OMBackend.MTK_MODE || mode == OMBackend.IMTK_MODE || mode == OMBackend.DEMode) ? :FM : :DAE
#= Arrays kept (the default mode): the array-preserving translation, else the
scalarizing flatten. An explicit MTK or DE mode gets that backend. =#
local keep = !scalarize && repr == :FM && mode == OMBackend.IMTK_MODE
(dae, cache) = flatten(modelName, modelFile;
repr = repr,
MSL = MSL, MSL_Version = MSL_Version,
libraries = libraries,
scalarize = !keep)
local keep = !scalarize && mode == OMBackend.IMTK_MODE
(fm, cache) = flatten(modelName, modelFile;
MSL = MSL, MSL_Version = MSL_Version,
libraries = libraries,
scalarize = !keep)
SCALARIZED_AT_TRANSLATE[OMBackend.canonicalName(modelName)] = scalarize
if keep
local arrays = OMBackend.translateArrays(dae; functionList = OMFrontend.cacheToFunctionList(cache))
local arrays = OMBackend.translateArrays(fm; functionList = OMFrontend.cacheToFunctionList(cache))
arrays === nothing || return arrays
(dae, cache) = flatten(modelName, modelFile; repr = repr, MSL = MSL, MSL_Version = MSL_Version,
libraries = libraries, scalarize = true)
(fm, cache) = flatten(modelName, modelFile; MSL = MSL, MSL_Version = MSL_Version,
libraries = libraries, scalarize = true)
end
functionList = OMFrontend.cacheToFunctionList(cache)
OMBackend.translate(dae;
OMBackend.translate(fm;
functionList = functionList,
BackendMode = mode,
warnMissingStartValues = warnMissingStartValues,
Expand Down Expand Up @@ -860,16 +856,16 @@ function translate(modelName::String;
#= Arrays kept (the default mode): the array-preserving translation, else the
scalarizing flatten. An explicit MTK or DE mode gets that backend. =#
local keep = !scalarize && mode == OMBackend.IMTK_MODE
(dae, cache) = flatten(modelName; MSL_Version = MSL_Version, libraries = libraries,
scalarize = !keep)
(fm, cache) = flatten(modelName; MSL_Version = MSL_Version, libraries = libraries,
scalarize = !keep)
SCALARIZED_AT_TRANSLATE[OMBackend.canonicalName(modelName)] = scalarize
if keep
local arrays = OMBackend.translateArrays(dae; functionList = OMFrontend.cacheToFunctionList(cache))
local arrays = OMBackend.translateArrays(fm; functionList = OMFrontend.cacheToFunctionList(cache))
arrays === nothing || return arrays
(dae, cache) = flatten(modelName; MSL_Version = MSL_Version, libraries = libraries, scalarize = true)
(fm, cache) = flatten(modelName; MSL_Version = MSL_Version, libraries = libraries, scalarize = true)
end
functionList = OMFrontend.cacheToFunctionList(cache)
OMBackend.translate(dae;
OMBackend.translate(fm;
functionList = functionList,
BackendMode = mode,
warnMissingStartValues = warnMissingStartValues,
Expand Down
Loading
Loading