1 #include "BlockParameterPort.h"
\r
2 #include "ArithmeticEvaluator.h"
\r
3 #include "FunctionalBlock.h"
\r
4 #include "FunctionalInterface.h"
\r
6 BlockParameterPort::BlockParameterPort() : BlockParameter() {
\r
10 BlockParameterPort::BlockParameterPort(AbstractBlock* _owner, const QString &_name, const QString &_value, const QString &_ifaceName) : BlockParameter(_owner, _name, "expression", _value) {
\r
11 ifaceName = _ifaceName;
\r
14 bool BlockParameterPort::isPortParameter() {
\r
18 BlockParameter* BlockParameterPort::clone() {
\r
19 BlockParameter* block = new BlockParameterPort(owner,name,defaultValue.toString(),ifaceName);
\r
23 QString BlockParameterPort::toVHDL(int context, int flags) {
\r
26 ArithmeticEvaluator evaluator;
\r
28 if (!defaultValue.isNull()) {
\r
29 expr = defaultValue.toString();
\r
31 evaluator.setVariableMarkers("$");
\r
32 evaluator.setExpression(expr);
\r
34 double ifaceNb = 0.0;
\r
35 double ifaceWidth = 0.0;
\r
36 FunctionalInterface* iface = (FunctionalInterface*)(owner->getIfaceFromName(ifaceName));
\r
37 if (iface == NULL) return "INVALID_INTERFACE_NAME";
\r
39 // must get the number of instance of
\r
40 ifaceNb = iface->getInterfaceMultiplicity();
\r
43 evaluator.setVariableValue("$if_width",ifaceWidth);
\r
44 evaluator.setVariableValue("$if_nb",ifaceNb);
\r
45 result = (int)(evaluator.evaluate());
\r
49 cerr << "invalid expression in port parameter " << qPrintable(name) << " at character " << e << endl;
\r
56 void BlockParameterPort::setIfaceName(const QString& _ifaceName) {
\r
57 ifaceName = _ifaceName;
\r