QString AbstractInterface::toVHDL(int context, int flags) throw(Exception) {
+
if (isReferenceInterface()) throw(Exception(IFACE_INVALID_TYPE));
QString msb = width;
QString ret="";
bool ok;
+ cout << "iface " << qPrintable(name) << " must be evaluated to vhdl :" << qPrintable(msb) << " with type = " << qPrintable(getTypeString()) << endl;
+
if ((context == BlockParameter::Entity) || (context == BlockParameter::Component)) {
QString formatBool = "%1 : %2 std_logic";
- QString formatVector = "%1 : %2 std_logic_vector(%3 downto %4)";
+ QString formatVector = "";
+ if (endianess == LittleEndian) formatVector = "%1 : %2 std_logic_vector(%3 downto %4)";
+ else formatVector = "%1 : %2 std_logic_vector(%4 to %3)";
+
if ((flags & BlockParameter::NoComma) == 0) {
formatBool.append(";");
formatVector.append(";");
orientation = "inout";
}
if (type == Boolean) {
- ret = formatVector.arg(name).arg(orientation);
+ ret = formatBool.arg(name).arg(orientation);
}
else if (type == Natural) {
int w = width.toInt(&ok);
}
}
else if (type == Expression) {
+
+
/* must check the following conditions :
- if it contains user/port parameters : must evaluate their numeric value
- if it contains generic parameters : just remove the $ -> the expression is not arithmetically evaluated.
QList<BlockParameter*> listPorts = owner->getPortParameters();
foreach(BlockParameter* p, listUsers) {
QString var = "$";
- var.append(p->getName());
+ var += p->getName();
if (width.contains(var)) {
int w = p->getValue().toInt(&ok);
if (!ok) throw(Exception(INVALID_VALUE));
}
foreach(BlockParameter* p, listPorts) {
QString var = "$";
- var.append(p->getName());
+ var += p->getName();
+ if (width.contains(var)) {
+ msb.replace(var,p->toVHDL(0,0));
+ }
+ }
+ foreach(BlockParameter* p, listGenerics) {
+ QString var = "$";
+ var += p->getName();
if (width.contains(var)) {
- BlockParameterPort* pp = (BlockParameterPort*)p;
- AbstractInterface* iface = owner->getIfaceFromName(pp->getIfaceName());
-
- int w = p->getValue().toInt(&ok);
- if (!ok) throw(Exception(INVALID_VALUE));
- msb.replace(var,p->getValue().toString());
+ msb.replace(var,p->getName());
}
}
-
- ret = formatVector.arg(name).arg(orientation).arg("toto").arg("0");
+ msb += "-1";
+ cout << "iface size :" << qPrintable(msb) << endl;
+ ret = formatVector.arg(name).arg(orientation).arg(msb).arg("0");
}
}
return ret;