X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/blast.git/blobdiff_plain/4cf57e6db08da791233d75237f62e74bc88dd427..4327c2b8817b627249d98d889835726217c81a4e:/AbstractBlock.cpp?ds=inline diff --git a/AbstractBlock.cpp b/AbstractBlock.cpp index f551b30..218ea61 100644 --- a/AbstractBlock.cpp +++ b/AbstractBlock.cpp @@ -3,16 +3,24 @@ #include #include "AbstractInterface.h" #include "BlockParameter.h" +#include "Parameters.h" +#include "GroupBlock.h" +#include "ConnectedInterface.h" -AbstractBlock::AbstractBlock() { + +AbstractBlock::AbstractBlock(Graph *_graph) { name = ""; parent = NULL; + specialType = NotSpecial; + graph = _graph; } +/* AbstractBlock::AbstractBlock(const QString& _name) { - name = _name; + name = Parameters::normalizeName(_name); parent = NULL; } +*/ AbstractBlock::~AbstractBlock() { @@ -25,7 +33,16 @@ AbstractBlock::~AbstractBlock() { } void AbstractBlock::setName(const QString& str) { - name = str; + name = Parameters::normalizeName(str); +} + +void AbstractBlock::setSpecialType(int type) { + if ((type >= NotSpecial) && (type <= ClkConvert)) { + specialType = type; + } + else { + specialType = NotSpecial; + } } void AbstractBlock::setParent(AbstractBlock* _parent) { @@ -40,6 +57,10 @@ bool AbstractBlock::isFunctionalBlock() { return false; } +bool AbstractBlock::isSpecialBlock() { + return false; +} + bool AbstractBlock::isGroupBlock() { return false; } @@ -48,18 +69,40 @@ bool AbstractBlock::isTopGroupBlock() { return false; } -bool AbstractBlock::isSourceBlock() { +bool AbstractBlock::isStimuliBlock() { return false; } -/* NB: a generator is a block that has no data inputs +/* NB: a source is a block that has no data inputs * and has at least one data output. + * By the way, blocks that have no data input/output + * (like clkrstgen) are not sources ! */ -bool AbstractBlock::isGeneratorBlock() { +bool AbstractBlock::isSourceBlock() { if (getDataInputs().size() > 0) return false; - + if (getDataOutputs().size() == 0) return false; return true; } +/* NB: a sink is a block without outputs of any type */ +bool AbstractBlock::isSinkBlock() { + if (getOutputs().size() == 0) return true; + return false; +} + +int AbstractBlock::getSpecialTypeFromString(QString str) { + if (str == "source") { + return Source; + } + else if (str == "sink") { + return Sink; + } + else if (str == "clkconvert") { + return ClkConvert; + } + return NotSpecial; +} + + void AbstractBlock::addParameter(BlockParameter *param) { params.append(param); } @@ -235,3 +278,28 @@ QList AbstractBlock::getWishboneParameters() { return lst; } +void AbstractBlock::generateEntity(QTextStream& out, bool hasController) throw(Exception) { + + out << "entity " << name << " is" << endl; + try { + generateEntityOrComponentBody(out, 0, hasController); + } + catch(Exception e) { + throw(e); + } + out << "end entity " << name << ";" << endl << endl; +} + +void AbstractBlock::generateComponent(QTextStream& out, bool hasController) throw(Exception) { + + out << " component " << name << " is" << endl; + try { + generateEntityOrComponentBody(out, 2, hasController); + } + catch(Exception e) { + throw(e); + } + out << " end component; " << endl << endl; +} + +