X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/blast.git/blobdiff_plain/abbc64cf04a35ab3549d5c516f44c7c5921baa63..60c13e8b4c7ea3d595969c1e7c0a28b068a17ca6:/BlockParameterGeneric.cpp diff --git a/BlockParameterGeneric.cpp b/BlockParameterGeneric.cpp index 5b15eb9..14b8c59 100644 --- a/BlockParameterGeneric.cpp +++ b/BlockParameterGeneric.cpp @@ -7,6 +7,9 @@ BlockParameterGeneric::BlockParameterGeneric() : BlockParameter() { } BlockParameterGeneric::BlockParameterGeneric(AbstractBlock* _owner, const QString &_name, const QString &_type, const QString &_value) : BlockParameter(_owner, _name, _type, _value) { + /* CAUTION: no check done on the type parameter ! + * It must never be "expression" but something that is numeric/boolean + */ userValue = defaultValue; } @@ -56,23 +59,45 @@ QString BlockParameterGeneric::toVHDL(int context, int flags) { formatNoValue.append(";"); } - if (!userValue.isNull()) { - ret = formatValue.arg(name).arg(type).arg(userValue.toString()); - } - else if (!defaultValue.isNull()) { - ret = formatValue.arg(name).arg(type).arg(defaultValue.toString()); + QString typeStr = ""; + QString valueStr = ""; + if ((type == Boolean)||(type == Bit)) { + typeStr = "std_logic"; + if (!userValue.isNull()) { + valueStr = "'"+userValue.toString()+"'"; + ret = formatValue.arg(name).arg(typeStr).arg(valueStr); + } + else if (!defaultValue.isNull()) { + valueStr = "'"+defaultValue.toString()+"'"; + ret = formatValue.arg(name).arg(typeStr).arg(valueStr); + } + else { + ret = formatNoValue.arg(name).arg(typeStr); + } } else { - ret = formatNoValue.arg(name).arg(type); + typeStr = getTypeString(); + if (!userValue.isNull()) { + ret = formatValue.arg(name).arg(typeStr).arg(userValue.toString()); + } + else if (!defaultValue.isNull()) { + ret = formatValue.arg(name).arg(typeStr).arg(defaultValue.toString()); + } + else { + ret = formatNoValue.arg(name).arg(typeStr); + } } } - else if (context == BlockParameter::Architecture) { + else if (context == BlockParameter::Instance) { QString format = "%1 => %2"; if ((flags & BlockParameter::NoComma) == 0) { format.append(";"); } AbstractBlock* parent = owner->getParent(); - BlockParameter* p = parent->getParameterFromName(name); + BlockParameter* p = NULL; + if (parent != NULL) { + p = parent->getParameterFromName(name); + } if (p != NULL) { /* the parent group has a generic parameter with the same name @@ -81,10 +106,20 @@ QString BlockParameterGeneric::toVHDL(int context, int flags) { } else { if (!userValue.isNull()) { - ret = format.arg(name).arg(userValue.toString()); + if ((type == Boolean)||(type == Bit)) { + ret = format.arg(name).arg("'"+userValue.toString()+"'"); + } + else { + ret = format.arg(name).arg(userValue.toString()); + } } else if (!defaultValue.isNull()) { - ret = format.arg(name).arg(defaultValue.toString()); + if ((type == Boolean)||(type == Bit)) { + ret = format.arg(name).arg("'"+defaultValue.toString()+"'"); + } + else { + ret = format.arg(name).arg(defaultValue.toString()); + } } else { // abnormal case