From 33ce614ffee38caacd93210d9953259274b347c7 Mon Sep 17 00:00:00 2001 From: "joaquin.f.fernandez" Date: Wed, 2 Nov 2022 11:24:00 -0300 Subject: [PATCH] Generate q macro for QSS handler access. --- src/mmoc/generator/macros.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/mmoc/generator/macros.cpp b/src/mmoc/generator/macros.cpp index 4ae136e9..7a5ff31b 100644 --- a/src/mmoc/generator/macros.cpp +++ b/src/mmoc/generator/macros.cpp @@ -123,7 +123,7 @@ string Macros::engineIndex() const void Macros::initialize() { - stringstream index, def, state_index, state_def, init_code; + stringstream index, def, state_index, state_def, init_code, quantized_def; int dim = _variable.dimensions(); bool idx = !_variable.isParameter() || dim; const bool IS_STATE = _variable.isState(); @@ -139,8 +139,9 @@ void Macros::initialize() } if (!_variable.isEqType() && !_variable.isOutput()) { _macros << "#define " << _variable << params << " "; - if (_variable.isState()) { + if (IS_STATE) { _macros << "x"; + quantized_def << "#define _q" << _variable << params << " q"; init_code << "#define _init" << _variable << params << " x"; } if (_variable.isAlgebraic()) { @@ -168,9 +169,13 @@ void Macros::initialize() state_def << " * COEFF_MULTIPLIER(coeff)"; } _macros << state_def.str() << endl; - if (_variable.isState()) { + if (IS_STATE) { init_code << def.str() << endl; _macros << init_code.str(); + quantized_def << state_def.str() << endl; + if (_is_qss) { + _macros << quantized_def.str(); + } } }