#include "BlockParameterPort.h"
#include "AbstractBlock.h"
#include "Parameters.h"
+#include "Graph.h"
AbstractInterface::AbstractInterface(AbstractBlock* _owner) {
- owner = _owner;
+ owner = _owner;
name = "";
width = "1";
direction = Input;
type = Boolean;
endianess = LittleEndian;
associatedIface = NULL;
+ clkIfaceName = "";
+ clkIfaceType = NoName;
}
type = typeFromString(_type);
endianess = _endianess;
associatedIface = NULL;
+ clkIfaceName = "";
+ clkIfaceType = NoName;
}
AbstractInterface::AbstractInterface(AbstractInterface* other) {
purpose = other->purpose;
endianess = LittleEndian;
associatedIface = NULL;
+ clkIfaceName = other->clkIfaceName;
+ clkIfaceType = other->clkIfaceType;
}
void AbstractInterface::setName(const QString& _name) {
return str;
}
-double AbstractInterface::getDoubleWidth() throw(QException) {
-
- static QString fctName = "AbstractInterface::getDoubleWidth()";
- #ifdef DEBUG_FCTNAME
- cout << "call to " << qPrintable(fctName) << endl;
- #endif
-
- /*
- cout << "start AbstractInterface::getDoubleWidth()" << endl;
- bool ok;
- double width = getWidth().toDouble(&ok);
-
- if(!ok){
- ArithmeticEvaluator *evaluator = new ArithmeticEvaluator;
- cout << "evaluator created!" << endl;
- evaluator->setExpression(getWidth());
- cout << "expression defined!" << endl;
- foreach(BlockParameter *param, getOwner()->getParameters()){
- evaluator->setVariableValue(param->getName(), param->getIntValue());
- cout << "param : " << param->getName().toStdString() << " evaluated!" << endl;
- }
- width = evaluator->evaluate();
- cout << "expression evaluated succefully!" << endl;
- }
- cout << "real width : " << width << endl;
- return width;
- */
-
- return 1.0;
-}
void AbstractInterface::setPurpose(int _purpose) {
if ((_purpose>=Data) && (_purpose <= Wishbone)) {
return true;
}
+AbstractInterface* AbstractInterface::getClockIface() {
+ if (clkIfaceType == ClockName) {
+ return owner->getIfaceFromName(clkIfaceName);
+ }
+ return NULL;
+}
+
+
+double AbstractInterface::getClockFrequency() throw(Exception) {
+
+ int idClock = -1;
+
+ if (clkIfaceType == ParameterName) {
+ BlockParameter* param = owner->getParameterFromName(clkIfaceName);
+ if (!param->isUserParameter()) throw(Exception(IFACE_INVALID_CLKFREQ,this));
+ bool ok;
+ double freq = param->getDoubleValue(&ok);
+ if (!ok) throw(Exception(IFACE_INVALID_CLKFREQ,this));
+ return freq;
+ }
+ else {
+ try {
+ idClock = getClockDomain();
+ }
+ catch(Exception e) {
+ throw(e);
+ }
+ return owner->getGraph()->getClock(idClock);
+ }
+ return 0.0;
+}
+
+
int AbstractInterface::getIntDirection(QString str) {
if(str == "input") return Input;
return ret;
}
-QString AbstractInterface::toVHDL(int context, int flags) throw(Exception) {
+QString AbstractInterface::toVHDL(IfaceVHDLContext context, int flags) throw(Exception) {
if (isReferenceInterface()) throw(Exception(IFACE_INVALID_TYPE));
QString ret="";
bool ok;
- cout << "iface " << qPrintable(name) << " must be evaluated to vhdl :" << qPrintable(width) << " with type = " << qPrintable(getTypeString()) << endl;
+ //cout << "iface " << qPrintable(name) << " must be evaluated to vhdl :" << qPrintable(width) << " with type = " << qPrintable(getTypeString()) << endl;
+
+ if (context == Instance) {
+ if (direction == Input) {
+ ret = owner->getName()+"_"+name;
+ }
+ else if (direction == Output) {
+ ret = "from_"+owner->getName()+"_"+name;
+ }
+ else if (direction == InOut) {
+ ret = "fromto_"+owner->getName()+"_"+name;
+ }
+ return ret;
+ }
// create the width part
QString widthStr = "";
ret += widthStr;
}
else if (context == Signal) {
- ret = widthStr;
- }
- else if (context == Architecture) {
-
+ if (direction == Output) {
+ ret = "from_"+owner->getName()+"_"+name+" : "+widthStr;
+ }
+ else if (direction == InOut) {
+ ret = "fromto_"+owner->getName()+"_"+name+" : "+widthStr;
+ }
+ else if (direction == Input) {
+ ret = owner->getName()+"_"+name+" : "+widthStr;
+ }
}
return ret;