1 #include "BlockParameterGeneric.h"
\r
2 #include "GroupBlock.h"
\r
3 #include "FunctionalBlock.h"
\r
5 BlockParameterGeneric::BlockParameterGeneric() : BlockParameter() {
\r
6 userValue = defaultValue;
\r
9 BlockParameterGeneric::BlockParameterGeneric(AbstractBlock* _owner, const QString &_name, const QString &_type, const QString &_value) : BlockParameter(_owner, _name, _type, _value) {
\r
10 userValue = defaultValue;
\r
13 QVariant BlockParameterGeneric::getValue() {
\r
17 return defaultValue;
\r
20 bool BlockParameterGeneric::isGenericParameter() {
\r
24 void BlockParameterGeneric::setValue(const QString& _value) {
\r
25 userValue = QVariant(_value);
\r
29 bool BlockParameterGeneric::isValueSet() {
\r
30 if (userValue.isNull()) return false;
\r
34 bool BlockParameterGeneric::isDefaultValue() {
\r
35 if (userValue == defaultValue) return true;
\r
39 BlockParameter* BlockParameterGeneric::clone() {
\r
41 BlockParameter* block = new BlockParameterGeneric(owner,name,getTypeString(),defaultValue.toString());
\r
45 QString BlockParameterGeneric::toVHDL(int context, int flags) {
\r
50 if ((context == BlockParameter::Entity) || (context == BlockParameter::Component)) {
\r
52 QString formatValue = "%1 : %2 := %3";
\r
53 QString formatNoValue = "%1 : %2";
\r
54 if ((flags & BlockParameter::NoComma) == 0) {
\r
55 formatValue.append(";");
\r
56 formatNoValue.append(";");
\r
59 if (!userValue.isNull()) {
\r
60 ret = formatValue.arg(name).arg(type).arg(userValue.toString());
\r
62 else if (!defaultValue.isNull()) {
\r
63 ret = formatValue.arg(name).arg(type).arg(defaultValue.toString());
\r
66 ret = formatNoValue.arg(name).arg(type);
\r
69 else if (context == BlockParameter::Architecture) {
\r
70 QString format = "%1 => %2";
\r
71 if ((flags & BlockParameter::NoComma) == 0) {
\r
74 AbstractBlock* parent = owner->getParent();
\r
75 BlockParameter* p = parent->getParameterFromName(name);
\r
77 /* the parent group has a generic parameter with the same
\r
80 ret = format.arg(name).arg(name);
\r
83 if (!userValue.isNull()) {
\r
84 ret = format.arg(name).arg(userValue.toString());
\r
86 else if (!defaultValue.isNull()) {
\r
87 ret = format.arg(name).arg(defaultValue.toString());
\r
91 ret = format.arg(name).arg("INVALID_VALUE");
\r