OpenASIP  2.0
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
HDB::HDBManager Class Referenceabstract

#include <HDBManager.hh>

Inheritance diagram for HDB::HDBManager:
Inheritance graph
Collaboration diagram for HDB::HDBManager:
Collaboration graph

Classes

struct  PipelineElementUsage
 

Public Types

typedef std::list< DataObjectDataObjectList
 

Public Member Functions

virtual ~HDBManager ()
 
std::string fileName () const
 
RowID addCostFunctionPlugin (const CostFunctionPlugin &plugin) const
 
virtual void removeCostFunctionPlugin (RowID pluginID) const
 
RowID addFUArchitecture (const FUArchitecture &architecture) const
 
bool canRemoveFUArchitecture (RowID archID) const
 
virtual void removeFUArchitecture (RowID archID) const
 
RowID addFUEntry () const
 
virtual void removeFUEntry (RowID id) const
 
RowID addFUImplementation (const FUEntry &entry) const
 
virtual void removeFUImplementation (RowID implementationID) const
 
void setArchitectureForFU (RowID fuID, RowID archID) const
 
void unsetArchitectureForFU (RowID fuID) const
 
RowID addRFArchitecture (const RFArchitecture &architecture) const
 
bool canRemoveRFArchitecture (RowID archID) const
 
virtual void removeRFArchitecture (RowID archID) const
 
RowID addRFEntry () const
 
virtual void removeRFEntry (RowID id) const
 
RowID addRFImplementation (const RFImplementation &implementation, RowID rfEntryID)
 
virtual void removeRFImplementation (RowID implID) const
 
void setArchitectureForRF (RowID rfID, RowID archID) const
 
void unsetArchitectureForRF (RowID rfID) const
 
void setCostFunctionPluginForFU (RowID fuID, RowID pluginID) const
 
void unsetCostFunctionPluginForFU (RowID fuID) const
 
void setCostFunctionPluginForRF (RowID rfID, RowID pluginID) const
 
void unsetCostFunctionPluginForRF (RowID rfID) const
 
std::set< RowIDfuEntryIDs () const
 
std::set< RowIDrfEntryIDs () const
 
std::set< RowIDbusEntryIDs () const
 
std::set< RowIDsocketEntryIDs () const
 
std::set< RowIDOperationImplementationIDs () const
 
std::set< RowIDOperationImplementationResourceIDs () const
 
OperationImplementation OperationImplementationByID (RowID id) const
 
OperationImplementationResource OperationImplementationResourceByID (RowID id) const
 
void addOperationImplementationResource (const OperationImplementationResource &resource)
 
void addOperationImplementation (const OperationImplementation &operation)
 
void removeOperationImplementation (RowID id)
 
void removeOperationImplementationResource (RowID id)
 
std::set< RowIDfuArchitectureIDs () const
 
std::set< RowIDfuArchitectureIDsByOperationSet (const std::set< std::string > &operationNames) const
 
std::set< RowIDrfArchitectureIDs () const
 
RowID fuEntryIDOfImplementation (RowID implID) const
 
RowID rfEntryIDOfImplementation (RowID implID) const
 
FUEntryfuByEntryID (RowID id) const
 
RFEntryrfByEntryID (RowID id) const
 
virtual FUArchitecturefuArchitectureByID (RowID id) const
 
virtual RFArchitecturerfArchitectureByID (RowID id) const
 
std::set< RowIDfuEntriesByArchitecture (const TTAMachine::FunctionUnit &fu) const
 
std::set< RowIDrfEntriesByArchitecture (int readPorts, int writePorts, int bidirPorts, int maxReads, int maxWrites, int latency, bool guardSupport, int guardLatency=0, int width=0, int size=0, bool zeroRegister=false) const
 
virtual DataObject costEstimationDataValue (const std::string &valueName, const std::string &pluginName) const
 
DataObject costEstimationDataValue (RowID entryId) const
 
RowID addFUCostEstimationData (RowID fuID, const std::string &valueName, const std::string &value, RowID pluginID) const
 
RowID addRFCostEstimationData (RowID rfID, const std::string &valueName, const std::string &value, RowID pluginID) const
 
DataObject fuCostEstimationData (const std::string &valueName, RowID implementationId, const std::string &pluginName) const
 
DataObject rfCostEstimationData (const std::string &valueName, RowID implementationId, const std::string &pluginName) const
 
RowID addBusEntry () const
 
virtual void removeBusEntry (RowID id) const
 
RowID addBusCostEstimationData (RowID busID, const std::string &valueName, const std::string &value, RowID pluginID) const
 
DataObject busCostEstimationData (const std::string &valueName, RowID busID, const std::string &pluginName) const
 
DataObjectListbusCostEstimationDataList (const std::string &valueName, RowID implementationId, const std::string &pluginName) const
 
RowID addSocketEntry () const
 
virtual void removeSocketEntry (RowID id) const
 
RowID addSocketCostEstimationData (RowID socketID, const std::string &valueName, const std::string &value, RowID pluginID) const
 
DataObject socketCostEstimationData (const std::string &valueName, RowID socketID, const std::string &pluginName) const
 
DataObjectListsocketCostEstimationDataList (const std::string &valueName, RowID implementationID, const std::string &pluginName) const
 
std::set< RowIDfuCostEstimationDataIDs (RowID fuImplID) const
 
std::set< RowIDrfCostEstimationDataIDs (RowID rfImplID) const
 
std::set< RowIDbusCostEstimationDataIDs (RowID busID) const
 
std::set< RowIDsocketCostEstimationDataIDs (RowID socketID) const
 
CostEstimationData costEstimationData (RowID id) const
 
std::set< RowIDcostFunctionPluginIDs () const
 
std::set< RowIDcostFunctionPluginDataIDs (RowID pluginID) const
 
CostFunctionPlugincostFunctionPluginByID (RowID pluginID) const
 
virtual std::set< RowIDcostEstimationDataIDs (const CostEstimationData &match, bool useCompiledQueries=false, RelationalDBQueryResult *compiledQuery=NULL) const
 
RowID addCostEstimationData (const CostEstimationData &data) const
 
virtual void removeCostEstimationData (RowID id) const
 
virtual void modifyCostEstimationData (RowID id, const CostEstimationData &data)
 
virtual void modifyCostFunctionPlugin (RowID id, const CostFunctionPlugin &plugin)
 
virtual void deleteCostEstimationDataIDsQueries () const =0
 
std::list< std::string > blockSourceFile ()
 

Static Public Member Functions

static void createNew (const std::string &file)
 
static std::string formatString (BlockImplementationFile::Format format)
 

Protected Member Functions

virtual RFImplementationcreateImplementationOfRF (RowID id) const
 
virtual FUImplementationcreateImplementationOfFU (FUArchitecture &architecture, RowID id) const
 
void createCostEstimatioDataIdsQuery (const CostEstimationData &match, std::string *query, RelationalDBQueryResult *compiledQuery=NULL, short int *queryHash=NULL, bool createBindableQuery=false) const
 
RelationalDBConnectiongetDBConnection () const
 
 HDBManager (const std::string &hdbFile)
 

Private Types

typedef std::vector< PipelineElementUsagePipelineElementUsageTable
 

Private Member Functions

bool hasFUEntry (RowID id) const
 
bool hasRFEntry (RowID id) const
 
bool hasBusEntry (RowID id) const
 
bool hasSocketEntry (RowID id) const
 
bool hasCostEstimationDataByID (RowID id) const
 
bool hasCostFunctionPluginByID (RowID id) const
 
bool fuEntryHasArchitecture (RowID id) const
 
bool rfEntryHasArchitecture (RowID id) const
 
bool containsOperation (const std::string &opName) const
 
bool containsImplementationFile (const std::string &pathToFile) const
 
bool containsFUArchitecture (RowID id) const
 
bool containsRFArchitecture (RowID id) const
 
RowID fuArchitectureID (RowID fuEntryID) const
 
RowID rfArchitectureID (RowID rfEntryID) const
 
bool hasColumn (const std::string &table, const std::string &columnName) const
 
int addBooleanColumn (const std::string &table, const std::string &newcolumn)
 
CostFunctionPlugincreateCostFunctionOfFU (RowID id) const
 
CostFunctionPlugincreateCostFunctionOfRF (RowID id) const
 
void addPortsAndBindingsToFUArchitecture (FUArchitecture &architecture, RowID id) const
 
void addOperationPipelinesToFUArchitecture (FUArchitecture &architecture, RowID id) const
 
std::string resolveArchitecturePort (const FUArchitecture &architecture, RowID entryID, const std::string &implementedPort) const
 
void addOpcodesToImplementation (FUImplementation &implementation, RowID entryID) const
 
void addDataPortsToImplementation (FUImplementation &implementation, FUArchitecture &architecture, RowID entryID) const
 
void addFUExternalPortsToImplementation (FUImplementation &implementation, RowID entryID) const
 
void addRFExternalPortsToImplementation (RFImplementation &implementation, RowID entryID) const
 
void addFUParametersToImplementation (FUImplementation &implementation, RowID entryID) const
 
void addRFParametersToImplementation (RFImplementation &implementation, RowID entryID) const
 
void addBlockImplementationFiles (FUImplementation &implementation, RowID entryID) const
 
void addDataPortsToImplementation (RFImplementation &implementation, RowID entryID) const
 
void addBlockImplementationFiles (RFImplementation &implementation, RowID entryID) const
 
void addBlockImplementationFileToHDB (const BlockImplementationFile &file) const
 
void createCostEstimatioDataIdsQuery (const CostEstimationData &match, std::string &query) const
 

Static Private Member Functions

static bool isMatchingArchitecture (const TTAMachine::FunctionUnit &fu, const FUArchitecture &arch)
 
static bool areCompatiblePipelines (const PipelineElementUsageTable &table)
 
static void insertFileFormats (RelationalDBConnection &connection)
 
static BlockImplementationFile::Format fileFormat (const std::string &formatString)
 
static std::string directionString (HDB::Direction direction)
 
static std::string fuEntryByIDQuery (RowID id)
 
static std::string rfEntryByIDQuery (RowID id)
 
static std::string busEntryByIDQuery (RowID id)
 
static std::string socketEntryByIDQuery (RowID id)
 
static std::string fuArchitectureByIDQuery (RowID id)
 
static std::string fuPortsAndBindingsByIDQuery (RowID id)
 
static std::string ioUsageDataByIDQuery (RowID id)
 
static std::string resourceUsageDataByIDQuery (RowID id)
 
static std::string fuImplementationByIDQuery (RowID id)
 
static std::string opcodesByIDQuery (RowID id)
 
static std::string fuImplementationDataPortsByIDQuery (RowID id)
 
static std::string fuExternalPortsByIDQuery (RowID id)
 
static std::string rfExternalPortsByIDQuery (RowID id)
 
static std::string fuPortBindingByNameQuery (RowID fuID, const std::string &portName)
 
static std::string fuImplementationParametersByIDQuery (RowID id)
 
static std::string rfImplementationParametersByIDQuery (RowID id)
 
static std::string fuSourceFilesByIDQuery (RowID id)
 
static std::string rfArchitectureByIDQuery (RowID id)
 
static std::string rfImplementationByIDQuery (RowID id)
 
static std::string rfImplementationByIDQuery2 (RowID id)
 
static std::string rfImplementationDataPortsByIDQuery (RowID id)
 
static std::string rfSourceFilesByIDQuery (RowID id)
 

Private Attributes

SQLitedb_
 Handle to the database. More...
 
RelationalDBConnectiondbConnection_
 Handle to the database connection. More...
 
std::string hdbFile_
 The HDB file to manager. More...
 

Static Private Attributes

static HDBManagerinstance_ = NULL
 Unique instance of the HDBManager. More...
 

Friends

class HDBManagerTest
 

Detailed Description

Class used to access hardware database (HDB).

Provides methods to create new HDB and to search, add, and remove blocks from/to HDB. There can exist only one HDBManager instance per database at the same time because HDBManager creates a connection to the database in its constructor and does not close the connection unless the HDBManager instance is deleted. And there cannot be several connections to the same database at the same time.

Definition at line 82 of file HDBManager.hh.

Member Typedef Documentation

◆ DataObjectList

Definition at line 86 of file HDBManager.hh.

◆ PipelineElementUsageTable

Definition at line 297 of file HDBManager.hh.

Constructor & Destructor Documentation

◆ ~HDBManager()

HDB::HDBManager::~HDBManager ( )
virtual

The destructor.

Definition at line 534 of file HDBManager.cc.

534  {
536  delete db_;
537 }

References SQLite::close(), db_, and dbConnection_.

Here is the call graph for this function:

◆ HDBManager()

HDB::HDBManager::HDBManager ( const std::string &  hdbFile)
protected

The constructor.

Parameters
hdbFileName of the HDB file to be managed by the manager.
Exceptions
IOExceptionIf connection to the DB cannot be established.

Definition at line 394 of file HDBManager.cc.

395  : db_(new SQLite()), dbConnection_(NULL), hdbFile_(hdbFile) {
396  if (!FileSystem::fileExists(hdbFile)) {
397  string errorMsg = "File '" + hdbFile + "' doesn't exist.";
398  throw FileNotFound(__FILE__, __LINE__, __func__, errorMsg);
399  }
400 
401  if (!FileSystem::fileIsReadable(hdbFile)) {
402  string errorMsg = "File '" + hdbFile + "' has no read rights.";
403  throw IOException(__FILE__, __LINE__, __func__, errorMsg);
404  }
405 
406  try {
407  dbConnection_ = &db_->connect(hdbFile);
408  } catch (const RelationalDBException& exception) {
409  throw IOException(
410  __FILE__, __LINE__, __func__, exception.errorMessage());
411  }
412 
413  // Update outdated HDB.
414  // Version 0 indicates db without version number also.
415  int dbVersion = dbConnection_->version();
416 
417  // Version 0 -> 1
418  if (dbVersion < 1) {
419  // Initial fu-gen tables and fugen stuff.
426  dbConnection_->updateQuery(std::string(
427  "INSERT INTO format(id,format) VALUES"
428  "(NULL,\"" + VHDL_SIM_FORMAT + "\");"));
429  dbConnection_->updateQuery(std::string(
430  "INSERT INTO format(id,format) VALUES"
431  "(NULL,\"" + VERILOG_SIM_FORMAT + "\");"));
433  }
434 
435  // Version 1 -> 2
436  if (dbVersion < 2) {
437  // Variables for operation snippets.
440  }
441 
442  // Version 2 -> 3
443  if (dbVersion < 3) {
444  // ipxact to resource table
445  dbConnection_->updateQuery(std::string(
446  "ALTER TABLE operation_implementation_resource ADD COLUMN "
447  "ipxact TEXT;"));
449  }
450 
451  // Version 3 -> 4
452  if (dbVersion < 4) {
453  // support for post-operation (for LOADs) and
454  // operation bus definitions for FUGen.
455  dbConnection_->updateQuery(std::string(
456  "ALTER TABLE operation_implementation ADD COLUMN "
457  "bus_definition TEXT;"));
458  dbConnection_->updateQuery(std::string(
459  "ALTER TABLE operation_implementation ADD COLUMN "
460  "post_op_vhdl TEXT;"));
461  dbConnection_->updateQuery(std::string(
462  "ALTER TABLE operation_implementation ADD COLUMN "
463  "post_op_verilog TEXT;"));
465  }
466 
467  // Version 4 -> 5
468  if (dbVersion < 5) {
469  dbConnection_->updateQuery(std::string(
470  "ALTER TABLE operation_implementation_resource ADD COLUMN "
471  "latency INTEGER;"));
472  dbConnection_->updateQuery(std::string(
473  "ALTER TABLE operation_implementation ADD COLUMN "
474  "default_verilog TEXT;"));
475  dbConnection_->updateQuery(std::string(
476  "ALTER TABLE operation_implementation ADD COLUMN "
477  "default_vhdl TEXT;"));
479  }
480 
481  // Version 5 -> 6
482  if (dbVersion < 6) {
483  try {
484  // rename default_vhdl and default_verilog to initial_*
485  // and add latency column
486  dbConnection_->updateQuery(std::string(
487  "ALTER TABLE operation_implementation RENAME TO "
488  "operation_implementation_old"));
489  dbConnection_->updateQuery(std::string(
490  "CREATE TABLE operation_implementation ( "
491  "id INTEGER PRIMARY KEY, "
492  "latency INTEGER, "
493  "name TEXT NOT NULL, "
494  "bus_definition TEXT, "
495  "post_op_vhdl TEXT, "
496  "post_op_verilog TEXT, "
497  "initial_vhdl TEXT, "
498  "initial_verilog TEXT)"));
499  dbConnection_->updateQuery(std::string(
500  "INSERT INTO operation_implementation "
501  "(id, name, bus_definition, post_op_vhdl, post_op_verilog, "
502  "initial_vhdl, initial_verilog) "
503  "SELECT id, name, bus_definition, post_op_vhdl, post_op_verilog, "
504  "default_vhdl, default_verilog "
505  "FROM operation_implementation_old"));
506  dbConnection_->updateQuery(std::string(
507  "DROP TABLE operation_implementation_old"));
508 
510  } catch (const RelationalDBException& exception) {
511  throw IOException(
512  __FILE__, __LINE__, __func__, exception.errorMessage());
513  }
515  }
516 
517  if (dbVersion < 7) {
518  try {
519  if (!hasColumn("rf_architecture", "zero_register")) {
520  addBooleanColumn("rf_architecture", "zero_register");
521  }
522  } catch (const RelationalDBException& exception) {
523  throw IOException(
524  __FILE__, __LINE__, __func__, exception.errorMessage());
525  }
527  }
528 
529 }

References __func__, addBooleanColumn(), SQLite::connect(), CQ_OPERATION_IMPLEMENTATION, CQ_OPERATION_IMPLEMENTATION_RESOURCE, CQ_OPERATION_IMPLEMENTATION_RESOURCE_SOURCE_FILE, CQ_OPERATION_IMPLEMENTATION_RESOURCES, CQ_OPERATION_IMPLEMENTATION_SOURCE_FILE, CQ_OPERATION_IMPLEMENTATION_VARIABLE, db_, dbConnection_, RelationalDBConnection::DDLQuery(), Exception::errorMessage(), FileSystem::fileExists(), FileSystem::fileIsReadable(), hasColumn(), RelationalDBConnection::updateQuery(), RelationalDBConnection::updateVersion(), VERILOG_SIM_FORMAT, RelationalDBConnection::version(), and VHDL_SIM_FORMAT.

Here is the call graph for this function:

Member Function Documentation

◆ addBlockImplementationFiles() [1/2]

void HDB::HDBManager::addBlockImplementationFiles ( FUImplementation implementation,
RowID  entryID 
) const
private

Adds the block implementation files to the given FU implementation which is the implementation of the FU entry that has the given ID.

Parameters
implementationThe implementation.
entryIDID of the FU entry.

Definition at line 5337 of file HDBManager.cc.

5339  {
5340 
5341  RelationalDBQueryResult* sourceFileData = NULL;
5342  try {
5343  sourceFileData = dbConnection_->query(
5344  fuSourceFilesByIDQuery(entryID));
5345  } catch (const Exception&) {
5346  assert(false);
5347  }
5348 
5349  int fileColumn = sourceFileData->column("block_source_file.file");
5350  int formatColumn = sourceFileData->column("format.format");
5351 
5352  while (sourceFileData->hasNext()) {
5353  sourceFileData->next();
5354  const DataObject& fileData = sourceFileData->data(fileColumn);
5355  const DataObject& formatData = sourceFileData->data(
5356  formatColumn);
5358  formatData.stringValue());
5359  BlockImplementationFile* file = new BlockImplementationFile(
5360  fileData.stringValue(), format);
5361  implementation.addImplementationFile(file);
5362  }
5363 
5364  delete sourceFileData;
5365  sourceFileData = NULL;
5366 }

References assert, RelationalDBQueryResult::column(), RelationalDBQueryResult::data(), dbConnection_, fileFormat(), fuSourceFilesByIDQuery(), RelationalDBQueryResult::hasNext(), implementation, RelationalDBQueryResult::next(), RelationalDBConnection::query(), and DataObject::stringValue().

Referenced by createImplementationOfFU(), and createImplementationOfRF().

Here is the call graph for this function:

◆ addBlockImplementationFiles() [2/2]

void HDB::HDBManager::addBlockImplementationFiles ( RFImplementation implementation,
RowID  entryID 
) const
private

Adds the block implementation files to the given RF implementation which is the implementation of the RF entry that has the given ID.

Parameters
implementationThe implementation.
entryIDID of the RF entry.

Definition at line 5443 of file HDBManager.cc.

5445  {
5446 
5447  RelationalDBQueryResult* result = NULL;
5448  try {
5449  result = dbConnection_->query(rfSourceFilesByIDQuery(entryID));
5450  } catch (const Exception&) {
5451  assert(false);
5452  }
5453 
5454  int fileColumn = result->column("block_source_file.file");
5455  int formatColumn = result->column("format.format");
5456 
5457  while (result->hasNext()) {
5458  result->next();
5459  const DataObject& fileData = result->data(fileColumn);
5460  const DataObject& formatData = result->data(formatColumn);
5462  formatData.stringValue());
5463  BlockImplementationFile* file = new BlockImplementationFile(
5464  fileData.stringValue(), format);
5465  implementation.addImplementationFile(file);
5466  }
5467 
5468  delete result;
5469  result = NULL;
5470 }

References assert, RelationalDBQueryResult::column(), RelationalDBQueryResult::data(), dbConnection_, fileFormat(), RelationalDBQueryResult::hasNext(), implementation, RelationalDBQueryResult::next(), RelationalDBConnection::query(), rfSourceFilesByIDQuery(), and DataObject::stringValue().

Here is the call graph for this function:

◆ addBlockImplementationFileToHDB()

void HDB::HDBManager::addBlockImplementationFileToHDB ( const BlockImplementationFile file) const
private

Adds the given block implementation file to the HDB.

Parameters
fileThe file to add.

Definition at line 5498 of file HDBManager.cc.

5499  {
5500  if (!containsImplementationFile(file.pathToFile())) {
5502  std::string(
5503  "INSERT INTO block_source_file(id,file,format) "
5504  "VALUES(NULL,\"" + file.pathToFile() +
5505  "\",(SELECT id FROM format WHERE format=\"" +
5506  formatString(file.format()) + "\"));"));
5507  }
5508 }

References containsImplementationFile(), dbConnection_, HDB::BlockImplementationFile::format(), formatString(), HDB::BlockImplementationFile::pathToFile(), and RelationalDBConnection::updateQuery().

Referenced by addFUImplementation(), and addRFImplementation().

Here is the call graph for this function:

◆ addBooleanColumn()

int HDB::HDBManager::addBooleanColumn ( const std::string &  table,
const std::string &  newcolumn 
)
private

Inserts a new boolean type column into existing table.

Parameters
tableThe name of the targeted table.
newColumnThe name of the new column.
Returns
Number of rows affected by the change.

Definition at line 4380 of file HDBManager.cc.

4381  {
4382  std::string add_column_query("ALTER TABLE ");
4383  add_column_query += table + " ADD COLUMN " + newcolumn;
4384  add_column_query += " INTEGER DEFAULT 0;";
4385 
4386  int result = 0;
4387 
4388  try {
4389  result = dbConnection_->updateQuery(add_column_query);
4390  } catch (const Exception& e) {
4391  debugLog(e.errorMessage());
4392  assert(false);
4393  }
4394 
4395  return result;
4396 }

References assert, dbConnection_, debugLog, Exception::errorMessage(), and RelationalDBConnection::updateQuery().

Referenced by addRFImplementation(), and HDBManager().

Here is the call graph for this function:

◆ addBusCostEstimationData()

RowID HDB::HDBManager::addBusCostEstimationData ( RowID  busID,
const std::string &  valueName,
const std::string &  value,
RowID  pluginID 
) const

Adds the given cost estimation data values to given Bus entry.

Parameters
busIDThe ID of the Bus entry the cost data will be added. @valueName The name of the cost value. @value The cost value. @pluginID The ID of the cost function plugin that owns this data.

Definition at line 3465 of file HDBManager.cc.

3469  {
3470 
3471 
3472  RowID dataID;
3473 
3474  // add the data
3475  try {
3477  std::string(
3478  "INSERT INTO cost_estimation_data (id,plugin_reference,"
3479  "bus_reference,name,value) VALUES (NULL," +
3480  Conversion::toString(pluginID) + "," +
3481  Conversion::toString(busID) + ",\"" + valueName + "\",\"" +
3482  value + "\");"));
3483  dataID = dbConnection_->lastInsertRowID();
3484  } catch (const Exception& e) {
3485  debugLog(e.errorMessage());
3486  assert(false);
3487  }
3488  return dataID;
3489 }

References assert, dbConnection_, debugLog, Exception::errorMessage(), RelationalDBConnection::lastInsertRowID(), Conversion::toString(), and RelationalDBConnection::updateQuery().

Here is the call graph for this function:

◆ addBusEntry()

RowID HDB::HDBManager::addBusEntry ( ) const

Adds an empty Bus entry to the database.

Parameters
entryThe Bus entry.
Returns
ID of the added Bus entry.

Definition at line 3393 of file HDBManager.cc.

3393  {
3394  try {
3396  std::string("INSERT INTO bus(id) VALUES(NULL);"));
3397  return dbConnection_->lastInsertRowID();
3398  } catch (const Exception& e) {
3399  debugLog(e.errorMessage());
3400  assert(false);
3401  }
3402 
3403  // dummy return to avoid compiler whining
3404  assert(false);
3405  return 0;
3406 }

References assert, dbConnection_, debugLog, Exception::errorMessage(), RelationalDBConnection::lastInsertRowID(), and RelationalDBConnection::updateQuery().

Referenced by AddBusEntryCmd::Do().

Here is the call graph for this function:

◆ addCostEstimationData()

RowID HDB::HDBManager::addCostEstimationData ( const CostEstimationData data) const

Adds cost estimation data to the HDB.

Parameters
dataCost estimation data to add.
Returns
Row ID of the added cost data.

Definition at line 6694 of file HDBManager.cc.

6694  {
6695  if (!data.hasName() || !data.hasValue() || !data.hasPluginID()) {
6696  throw InvalidData(__FILE__, __LINE__, __func__);
6697  }
6698 
6699  std::string query =
6700  std::string("INSERT INTO cost_estimation_data"
6701  " (id, name, value, plugin_reference, "
6702  " fu_reference, rf_reference, "
6703  " bus_reference, socket_reference) VALUES (") +
6704  "NULL, '" + data.name() + "', '" +
6705  data.value().stringValue() + "', " +
6706  Conversion::toString(data.pluginID()) + ", ";
6707 
6708  // FU Reference
6709  if (data.hasFUReference()) {
6710  if (!hasFUEntry(data.fuReference())) {
6711  throw KeyNotFound(__FILE__, __LINE__, __func__);
6712  }
6713  query += Conversion::toString(data.fuReference());
6714  query += ", ";
6715  } else {
6716  query += "NULL, ";
6717  }
6718 
6719  // RF Reference
6720  if (data.hasRFReference()) {
6721  if (!hasRFEntry(data.rfReference())) {
6722  throw KeyNotFound(__FILE__, __LINE__, __func__);
6723  }
6724  query += Conversion::toString(data.rfReference());
6725  query += ", ";
6726  } else {
6727  query += "NULL, ";
6728  }
6729 
6730  // Bus Reference
6731  if (data.hasBusReference()) {
6732  if (!hasBusEntry(data.busReference())) {
6733  throw KeyNotFound(__FILE__, __LINE__, __func__);
6734  }
6735  query += Conversion::toString(data.busReference());
6736  query += ", ";
6737  } else {
6738  query += "NULL, ";
6739  }
6740 
6741  // Socket Reference
6742  if (data.hasSocketReference()) {
6743  if (!hasSocketEntry(data.socketReference())) {
6744  throw KeyNotFound(__FILE__, __LINE__, __func__);
6745  }
6746  query += Conversion::toString(data.socketReference());
6747  query += ");";
6748  } else {
6749  query += "NULL);";
6750  }
6751 
6752  try {
6753  dbConnection_->updateQuery(query);
6754  return dbConnection_->lastInsertRowID();
6755  } catch (const Exception& e) {
6756  debugLog(e.errorMessage());
6757  assert(false);
6758  }
6759 
6760  // dummy return to avoid compiler whining
6761  assert(false);
6762  return 0;
6763 }

References __func__, assert, CostEstimationData::busReference(), dbConnection_, debugLog, Exception::errorMessage(), CostEstimationData::fuReference(), hasBusEntry(), CostEstimationData::hasBusReference(), hasFUEntry(), CostEstimationData::hasFUReference(), CostEstimationData::hasName(), CostEstimationData::hasPluginID(), hasRFEntry(), CostEstimationData::hasRFReference(), hasSocketEntry(), CostEstimationData::hasSocketReference(), CostEstimationData::hasValue(), RelationalDBConnection::lastInsertRowID(), CostEstimationData::name(), CostEstimationData::pluginID(), CostEstimationData::rfReference(), CostEstimationData::socketReference(), DataObject::stringValue(), Conversion::toString(), RelationalDBConnection::updateQuery(), and CostEstimationData::value().

Here is the call graph for this function:

◆ addCostFunctionPlugin()

RowID HDB::HDBManager::addCostFunctionPlugin ( const CostFunctionPlugin plugin) const

Add the given CostFunctionPlugin to the database.

Parameters
pluginThe CostFunctionPlugin to add.
Returns
ID of the plugin added.
Exceptions
ExceptionMay throw InvalidData if the CostFunctionPlugin type is unknown.

Definition at line 626 of file HDBManager.cc.

626  {
627  RowID pluginID;
628  try {
630 
631  // insert into cost_function_plugin table
632  string description = plugin.description();
633  string pluginFilePath = plugin.pluginFilePath();
634  string type = "";
635  switch (plugin.type()) {
637  type = COST_PLUGIN_TYPE_FU;
638  break;
640  type = COST_PLUGIN_TYPE_RF;
641  break;
644  break;
646  type = COST_PLUGIN_TYPE_ICDEC;
647  break;
648  default:
649  InvalidData ex(
650  __FILE__, __LINE__, __func__,
651  (boost::format("Illegal cost_function_plugin type %d.") %
652  type).str());
653  throw ex;
654  break;
655  }
656  string name = plugin.name();
657 
659  std::string(
660  "INSERT INTO cost_function_plugin(id,description,name,"
661  "plugin_file_path,type) VALUES"
662  "(NULL,\"" + description + "\",\"" + name + "\",\"" +
663  pluginFilePath + "\",\"" + type + "\");"));
664  pluginID = dbConnection_->lastInsertRowID();
666  } catch (const RelationalDBException& e) {
668  debugLog(e.errorMessage());
669  assert(false);
670  } catch (const Exception& e) {
672  debugLog(e.errorMessage());
673  assert(false);
674  }
675  return pluginID;
676 }

References __func__, assert, RelationalDBConnection::beginTransaction(), RelationalDBConnection::commit(), HDB::CostFunctionPlugin::COST_DECOMP, HDB::CostFunctionPlugin::COST_FU, HDB::CostFunctionPlugin::COST_ICDEC, COST_PLUGIN_TYPE_DECOMP, COST_PLUGIN_TYPE_FU, COST_PLUGIN_TYPE_ICDEC, COST_PLUGIN_TYPE_RF, HDB::CostFunctionPlugin::COST_RF, dbConnection_, debugLog, HDB::CostFunctionPlugin::description(), Exception::errorMessage(), RelationalDBConnection::lastInsertRowID(), HDB::CostFunctionPlugin::name(), HDB::CostFunctionPlugin::pluginFilePath(), RelationalDBConnection::rollback(), HDB::CostFunctionPlugin::type(), and RelationalDBConnection::updateQuery().

Referenced by AddCostFunctionPluginCmd::Do().

Here is the call graph for this function:

◆ addDataPortsToImplementation() [1/2]

void HDB::HDBManager::addDataPortsToImplementation ( FUImplementation implementation,
FUArchitecture architecture,
RowID  entryID 
) const
private

Adds data ports to the given FU implementation which is the implementation of the FU entry that has the given ID.

Parameters
implementationThe implementation.
architectureThe corresponding architecture.
entryIDID of the FU entry.

Definition at line 5006 of file HDBManager.cc.

5009  {
5010 
5011  RelationalDBQueryResult* portData = NULL;
5012  try {
5013  portData = dbConnection_->query(
5015  } catch (const Exception& e) {
5016  assert(false);
5017  }
5018  int portNameColumn = portData->column("fu_port_map.name");
5019  int widthFormulaColumn = portData->column("fu_port_map.width_formula");
5020  int loadPortColumn = portData->column("fu_port_map.load_port");
5021  int guardPortColumn = portData->column("fu_port_map.guard_port");
5022 
5023  while (portData->hasNext()) {
5024  portData->next();
5025  const DataObject& portNameData = portData->data(portNameColumn);
5026  const DataObject& widthFormulaData = portData->data(
5027  widthFormulaColumn);
5028  const DataObject& loadPortData = portData->data(loadPortColumn);
5029  const DataObject& guardPortData = portData->data(guardPortColumn);
5030 
5031  string portName = portNameData.stringValue();
5032  string widthFormula = widthFormulaData.stringValue();
5033  string loadPort = loadPortData.stringValue();
5034  string guardPort = guardPortData.stringValue();
5035  string architecturePort = resolveArchitecturePort(
5036  architecture, entryID, portName);
5037  new FUPortImplementation(
5038  portName, architecturePort, widthFormula, loadPort, guardPort,
5039  implementation);
5040  }
5041 
5042  delete portData;
5043  portData = NULL;
5044 }

References assert, RelationalDBQueryResult::column(), RelationalDBQueryResult::data(), dbConnection_, fuImplementationDataPortsByIDQuery(), RelationalDBQueryResult::hasNext(), implementation, RelationalDBQueryResult::next(), RelationalDBConnection::query(), resolveArchitecturePort(), and DataObject::stringValue().

Referenced by createImplementationOfFU(), and createImplementationOfRF().

Here is the call graph for this function:

◆ addDataPortsToImplementation() [2/2]

void HDB::HDBManager::addDataPortsToImplementation ( RFImplementation implementation,
RowID  entryID 
) const
private

Adds data ports to the given RF implementation which is the implementation of the RF entry that has the given ID.

Parameters
implementationThe implementation.
entryIDID of the RF entry.

Definition at line 5377 of file HDBManager.cc.

5379  {
5380 
5381  // obtain port data from HDB and add ports to RF implementation
5382  RelationalDBQueryResult* portData = NULL;
5383  try {
5384  portData = dbConnection_->query(
5386  } catch (const Exception& e) {
5387  debugLog(e.errorMessage());
5388  assert(false);
5389  }
5390 
5391  int portNameColumn = portData->column("name");
5392  int directionColumn = portData->column("direction");
5393  int loadPortColumn = portData->column("load_port");
5394  int opcodePortColumn = portData->column("opcode_port");
5395  int opcodePortFormulaColumn = portData->column(
5396  "opcode_port_width_formula");
5398  assert(directionColumn != RelationalDBQueryResult::UNKNOWN_INDEX);
5400  assert(opcodePortColumn != RelationalDBQueryResult::UNKNOWN_INDEX);
5401  assert(
5402  opcodePortFormulaColumn != RelationalDBQueryResult::UNKNOWN_INDEX);
5403 
5404  while (portData->hasNext()) {
5405  portData->next();
5406  const DataObject& portNameData = portData->data(portNameColumn);
5407  const DataObject& directionData = portData->data(
5408  directionColumn);
5409  const DataObject& loadPortData = portData->data(loadPortColumn);
5410  const DataObject& opcodePortData = portData->data(
5411  opcodePortColumn);
5412  const DataObject& opcodePortFormulaData = portData->data(
5413  opcodePortFormulaColumn);
5414  Direction direction;
5415  if (directionData.stringValue() == IN_DIRECTION) {
5416  direction = IN;
5417  } else if (directionData.stringValue() == OUT_DIRECTION) {
5418  direction = OUT;
5419  } else if (directionData.stringValue() == BIDIR_DIRECTION) {
5420  direction = BIDIR;
5421  } else {
5422  assert(false);
5423  }
5424  new RFPortImplementation(
5425  portNameData.stringValue(), direction,
5426  loadPortData.stringValue(), opcodePortData.stringValue(),
5427  opcodePortFormulaData.stringValue(), implementation);
5428  }
5429 
5430  delete portData;
5431  portData = NULL;
5432 }

References assert, HDB::BIDIR, BIDIR_DIRECTION, RelationalDBQueryResult::column(), RelationalDBQueryResult::data(), dbConnection_, debugLog, Exception::errorMessage(), RelationalDBQueryResult::hasNext(), implementation, HDB::IN, IN_DIRECTION, RelationalDBQueryResult::next(), HDB::OUT, OUT_DIRECTION, RelationalDBConnection::query(), rfImplementationDataPortsByIDQuery(), DataObject::stringValue(), and RelationalDBQueryResult::UNKNOWN_INDEX.

Here is the call graph for this function:

◆ addFUArchitecture()

RowID HDB::HDBManager::addFUArchitecture ( const FUArchitecture arch) const

Adds the given FU architecture to the database.

Parameters
archThe FU architecture to add.
Returns
ID of the architecture added.
Exceptions
InvalidDataIf the FU architecture is invalid.

Definition at line 717 of file HDBManager.cc.

717  {
718  // check the operand bindings of the FU
719  FunctionUnit& fu = arch.architecture();
720  MachineValidatorResults results;
721  FUValidator::checkOperations(fu, results);
723  if (results.errorCount() > 0) {
724  throw InvalidData(
725  __FILE__, __LINE__, __func__, results.error(0).second);
726  }
727 
728  RowID archID;
729  std::map<FUPort*, RowID> portIDMap;
730 
731  try {
733 
734  // insert into fu_architecture table
736  std::string("INSERT INTO fu_architecture(id) VALUES(NULL);"));
737  archID = dbConnection_->lastInsertRowID();
738 
739  // insert into fu_data_port table
740  for (int i = 0; i < fu.operationPortCount(); i++) {
741  FUPort* port = fu.operationPort(i);
742  string query(
743  "INSERT INTO fu_data_port(id,triggers,sets_opcode,"
744  "guard_support,width,fu_arch) "
745  "VALUES(NULL," +
746  Conversion::toString(port->isTriggering()) + "," +
747  Conversion::toString(port->isOpcodeSetting()) + "," +
748  Conversion::toString(arch.hasGuardSupport(port->name()))
749  + ",");
750  if (arch.hasParameterizedWidth(port->name())) {
751  query += "NULL,";
752  } else {
753  query += (Conversion::toString(port->width()) + ",");
754  }
755  query += (Conversion::toString(archID) + ");");
756  dbConnection_->updateQuery(query);
757  RowID portID = dbConnection_->lastInsertRowID();
758  portIDMap.insert(std::pair<FUPort*, RowID>(port, portID));
759  }
760 
761  // insert into operation table
762  for (int i = 0; i < fu.operationCount(); i++) {
763  HWOperation* operation = fu.operation(i);
764  if (!containsOperation(operation->name())) {
766  std::string(
767  "INSERT INTO operation(id,name) VALUES(NULL,\"" +
768  operation->name() + "\");"));
769  }
770  }
771 
772  // insert into io_binding table
773  for (int i = 0; i < fu.operationCount(); i++) {
774  HWOperation* operation = fu.operation(i);
775  for (int i = 0; i < fu.operationPortCount(); i++) {
776  FUPort* port = fu.operationPort(i);
777  if (operation->isBound(*port)) {
778  int io = operation->io(*port);
779  string query(
780  "INSERT INTO io_binding(id,io_number,port,operation)"
781  " VALUES(NULL," + Conversion::toString(io) + "," +
783  MapTools::valueForKey<RowID>(portIDMap, port)) +
784  ",(SELECT id FROM operation WHERE "
785  "lower(name)=\"" + operation->name() + "\"));");
786  dbConnection_->updateQuery(query);
787  }
788  }
789  }
790 
791  std::map<HWOperation*, RowID> pLineIDMap;
792 
793  // insert into operation pipeline table
794  for (int i = 0; i < fu.operationCount(); i++) {
795  HWOperation* operation = fu.operation(i);
797  std::string(
798  "INSERT INTO operation_pipeline(id,fu_arch,operation) "
799  "VALUES(NULL," + Conversion::toString(archID) +
800  ",(SELECT id FROM operation WHERE lower(name)=\"" +
801  operation->name() + "\"));"));
802  pLineIDMap.insert(
803  std::pair<HWOperation*, RowID>(
804  operation, dbConnection_->lastInsertRowID()));
805  }
806 
807  // insert into io_usage_table
808  for (int i = 0; i < fu.operationCount(); i++) {
809  HWOperation* operation = fu.operation(i);
810  ExecutionPipeline* pLine = operation->pipeline();
811  for (int cycle = 0; cycle < pLine->latency(); cycle++) {
812  ExecutionPipeline::OperandSet readOperands =
813  pLine->readOperands(cycle);
814  ExecutionPipeline::OperandSet writtenOperands =
815  pLine->writtenOperands(cycle);
816  for (ExecutionPipeline::OperandSet::const_iterator iter =
817  readOperands.begin();
818  iter != readOperands.end(); iter++) {
820  std::string(
821  "INSERT INTO io_usage(id,cycle,io_number,action,"
822  "pipeline) VALUES(NULL," +
823  Conversion::toString(cycle) + "," +
824  Conversion::toString(*iter) + "," +
827  MapTools::valueForKey<RowID>(
828  pLineIDMap, operation)) + ");"));
829  }
830  for (ExecutionPipeline::OperandSet::const_iterator iter =
831  writtenOperands.begin();
832  iter != writtenOperands.end(); iter++) {
834  std::string(
835  "INSERT INTO io_usage(id,cycle,io_number,action,"
836  "pipeline) VALUES(NULL," +
837  Conversion::toString(cycle) + "," +
838  Conversion::toString(*iter) + "," +
841  MapTools::valueForKey<RowID>(
842  pLineIDMap, operation)) + ");"));
843  }
844  }
845  }
846 
847  // insert into pipeline_resource table
848  std::map<PipelineElement*, RowID> pipelineElementMap;
849  for (int i = 0; i < fu.pipelineElementCount(); i++) {
850  PipelineElement* element = fu.pipelineElement(i);
852  std::string(
853  "INSERT INTO pipeline_resource(id,fu_arch) VALUES "
854  "(NULL," + Conversion::toString(archID) + ");"));
855  pipelineElementMap.insert(
856  std::pair<PipelineElement*, RowID>(
857  element, dbConnection_->lastInsertRowID()));
858  }
859 
860  // insert into pipeline_resource_usage table
861  for (int i = 0; i < fu.operationCount(); i++) {
862  HWOperation* operation = fu.operation(i);
863  ExecutionPipeline* pLine = operation->pipeline();
864  for (int i = 0; i < fu.pipelineElementCount(); i++) {
865  PipelineElement* element = fu.pipelineElement(i);
866  for (int cycle = 0; cycle < pLine->latency(); cycle++) {
867  if (pLine->isResourceUsed(element->name(), cycle)) {
868  string resID = Conversion::toString(
869  MapTools::valueForKey<RowID>(
870  pipelineElementMap, element));
871  string pLineID = Conversion::toString(
872  MapTools::valueForKey<RowID>(
873  pLineIDMap, operation));
875  std::string(
876  "INSERT INTO pipeline_resource_usage(id,"
877  "cycle,resource,pipeline) VALUES(NULL," +
878  Conversion::toString(cycle) + "," +
879  resID + "," + pLineID + ");"));
880  }
881  }
882  }
883  }
884 
886 
887  } catch (const Exception& e) {
889  debugLog(e.errorMessage());
890  assert(false);
891  }
892 
893  return archID;
894 }

References __func__, HDB::FUArchitecture::architecture(), assert, RelationalDBConnection::beginTransaction(), FUValidator::checkOperandBindings(), FUValidator::checkOperations(), RelationalDBConnection::commit(), containsOperation(), dbConnection_, debugLog, MachineValidatorResults::error(), MachineValidatorResults::errorCount(), Exception::errorMessage(), HDB::FUArchitecture::hasGuardSupport(), HDB::FUArchitecture::hasParameterizedWidth(), TTAMachine::HWOperation::io(), TTAMachine::HWOperation::isBound(), TTAMachine::FUPort::isOpcodeSetting(), TTAMachine::ExecutionPipeline::isResourceUsed(), TTAMachine::FUPort::isTriggering(), RelationalDBConnection::lastInsertRowID(), TTAMachine::ExecutionPipeline::latency(), TTAMachine::PipelineElement::name(), TTAMachine::HWOperation::name(), TTAMachine::Port::name(), TTAMachine::FunctionUnit::operation(), TTAMachine::FunctionUnit::operationCount(), TTAMachine::FunctionUnit::operationPort(), TTAMachine::FunctionUnit::operationPortCount(), TTAMachine::HWOperation::pipeline(), TTAMachine::FunctionUnit::pipelineElement(), TTAMachine::FunctionUnit::pipelineElementCount(), READ_ACTION, TTAMachine::ExecutionPipeline::readOperands(), RelationalDBConnection::rollback(), Conversion::toString(), RelationalDBConnection::updateQuery(), TTAMachine::BaseFUPort::width(), WRITE_ACTION, and TTAMachine::ExecutionPipeline::writtenOperands().

Referenced by AddFUArchFromADFCmd::Do().

Here is the call graph for this function:

◆ addFUCostEstimationData()

RowID HDB::HDBManager::addFUCostEstimationData ( RowID  fuID,
const std::string &  valueName,
const std::string &  value,
RowID  pluginID 
) const

Adds the given cost estimation data values to given FU entry.

Parameters
fuIDThe ID of the FU entry the cost data will be added. @valueName The name of the cost value. @value The cost value. @pluginID The ID of the cost function plugin that owns this data.

Definition at line 3210 of file HDBManager.cc.

3214  {
3215 
3216 
3217  RowID dataID;
3218 
3219  // add the data
3220  try {
3222  std::string(
3223  "INSERT INTO cost_estimation_data (id,plugin_reference,"
3224  "fu_reference,name,value) VALUES (NULL," +
3225  Conversion::toString(pluginID) + "," +
3226  Conversion::toString(fuID) + ",\"" + valueName + "\",\"" +
3227  value + "\");"));
3228  dataID = dbConnection_->lastInsertRowID();
3229  } catch (const Exception& e) {
3230  debugLog(e.errorMessage());
3231  assert(false);
3232  }
3233  return dataID;
3234 }

References assert, dbConnection_, debugLog, Exception::errorMessage(), RelationalDBConnection::lastInsertRowID(), Conversion::toString(), and RelationalDBConnection::updateQuery().

Here is the call graph for this function:

◆ addFUEntry()

RowID HDB::HDBManager::addFUEntry ( ) const

Adds an empty FU entry to the database.

Parameters
entryThe FU entry.
Returns
ID of the added FU entry.

Definition at line 1014 of file HDBManager.cc.

1014  {
1015  try {
1017  std::string("INSERT INTO fu(id) VALUES(NULL);"));
1018  return dbConnection_->lastInsertRowID();
1019  } catch (const Exception& e) {
1020  debugLog(e.errorMessage());
1021  assert(false);
1022  }
1023 
1024  // dummy return to avoid compiler whining
1025  assert(false);
1026  return 0;
1027 }

References assert, dbConnection_, debugLog, Exception::errorMessage(), RelationalDBConnection::lastInsertRowID(), and RelationalDBConnection::updateQuery().

Referenced by AddFUEntryCmd::Do(), and AddFUImplementationCmd::Do().

Here is the call graph for this function:

◆ addFUExternalPortsToImplementation()

void HDB::HDBManager::addFUExternalPortsToImplementation ( FUImplementation implementation,
RowID  entryID 
) const
private

Adds external ports to the given FU implementation which is the implementation of the FU entry that has the given ID.

Parameters
implementationThe implementation.
entryIDID of the FU entry.

Definition at line 5055 of file HDBManager.cc.

5057  {
5058 
5059  RelationalDBQueryResult* extPortData = NULL;
5060  try {
5061  extPortData = dbConnection_->query(fuExternalPortsByIDQuery(entryID));
5062  } catch (const Exception& e) {
5063  assert(false);
5064  }
5065 
5066  int extPortNameColumn = extPortData->column("fu_external_port.name");
5067  int directionColumn = extPortData->column(
5068  "fu_external_port.direction");
5069  int extPortWidthFormulaColumn = extPortData->column(
5070  "fu_external_port.width_formula");
5071  int descriptionColumn = extPortData->column(
5072  "fu_external_port.description");
5073 
5074  while (extPortData->hasNext()) {
5075  extPortData->next();
5076  const DataObject& nameData = extPortData->data(
5077  extPortNameColumn);
5078  const DataObject& directionData = extPortData->data(
5079  directionColumn);
5080  const DataObject& widthFormulaData = extPortData->data(
5081  extPortWidthFormulaColumn);
5082  const DataObject& descriptionData = extPortData->data(
5083  descriptionColumn);
5084 
5085  string name = nameData.stringValue();
5086  string widthFormula = widthFormulaData.stringValue();
5087  string description = descriptionData.stringValue();
5088 
5089  Direction direction;
5090  if (directionData.stringValue() == IN_DIRECTION) {
5091  direction = IN;
5092  } else if (directionData.stringValue() == OUT_DIRECTION) {
5093  direction = OUT;
5094  } else {
5095  assert(directionData.stringValue() == BIDIR_DIRECTION);
5096  direction = BIDIR;
5097  }
5098 
5099  new FUExternalPort(
5100  name, direction, widthFormula, description, implementation);
5101  }
5102 
5103  delete extPortData;
5104  extPortData = NULL;
5105 
5106  // add parameter dependencies
5107  for (int i = 0; i < implementation.externalPortCount(); i++) {
5108  FUExternalPort& port = implementation.externalPort(i);
5109  try {
5111  std::string(
5112  "SELECT fu_implementation_parameter.name FROM "
5113  "fu_implementation_parameter, fu_external_port, "
5114  "fu_ext_port_parameter_dependency, fu_implementation "
5115  "WHERE fu_implementation.fu=" +
5116  Conversion::toString(entryID) +
5117  " AND fu_external_port.fu_impl=fu_implementation.id AND "
5118  "fu_external_port.name=\"" + port.name() +
5119  "\" AND fu_ext_port_parameter_dependency.port="
5120  "fu_external_port.id AND fu_implementation_parameter.id="
5121  "fu_ext_port_parameter_dependency.parameter;"));
5122  while (result->hasNext()) {
5123  result->next();
5124  const DataObject& paramData = result->data(0);
5125  port.setParameterDependency(paramData.stringValue());
5126  }
5127  delete result;
5128  } catch (const Exception& e) {
5129  debugLog(e.errorMessage());
5130  assert(false);
5131  }
5132  }
5133 }

References assert, HDB::BIDIR, BIDIR_DIRECTION, RelationalDBQueryResult::column(), RelationalDBQueryResult::data(), dbConnection_, debugLog, Exception::errorMessage(), fuExternalPortsByIDQuery(), RelationalDBQueryResult::hasNext(), implementation, HDB::IN, IN_DIRECTION, HDB::ExternalPort::name(), RelationalDBQueryResult::next(), HDB::OUT, OUT_DIRECTION, RelationalDBConnection::query(), HDB::ExternalPort::setParameterDependency(), DataObject::stringValue(), and Conversion::toString().

Referenced by createImplementationOfFU().

Here is the call graph for this function:

◆ addFUImplementation()

RowID HDB::HDBManager::addFUImplementation ( const FUEntry entry) const

Adds the implementation of the given FU entry to the database.

In practice the implementation is added for the FU entry that has the same ID as the given FUEntry instance. The given FUEntry instance must also have an architecture similar to the architecture of the FU entry in the database. This is required in port mapping.

Parameters
entryThe FU entry containing the implementation to add.
Returns
ID of the implementation that was added.
Exceptions
InvalidDataIf the given FUEntry instance is invalid or if the FU entry does not have architecture in the database of if the FU entry has an implementation already.

Definition at line 1112 of file HDBManager.cc.

1112  {
1113  if (!entry.hasID() || !entry.hasImplementation() ||
1114  !entry.hasArchitecture() || !hasFUEntry(entry.id())) {
1115  throw InvalidData(__FILE__, __LINE__, __func__);
1116  }
1117 
1118  FUImplementation& impl = entry.implementation();
1119  FUArchitecture& arch = entry.architecture();
1120  FunctionUnit& fu = arch.architecture();
1121 
1122  FUEntry* existingEntry = fuByEntryID(entry.id());
1123  if (existingEntry->hasImplementation() ||
1124  !existingEntry->hasArchitecture()) {
1125  delete existingEntry;
1126  throw InvalidData(__FILE__, __LINE__, __func__);
1127  }
1128  delete existingEntry;
1129  existingEntry = NULL;
1130 
1131  RowID archID = fuArchitectureID(entry.id());
1132  RowID implID;
1133 
1134  try {
1136 
1137  // insert into fu_implementation table
1138  string module = impl.moduleName();
1139  string opcPort = impl.opcodePort();
1140  string clkPort = impl.clkPort();
1141  string rstPort = impl.rstPort();
1142  string glockPort = impl.glockPort();
1143  string glockReqPort = impl.glockReqPort();
1144 
1146  std::string(
1147  "INSERT INTO fu_implementation(id,name,opcode_port,"
1148  "clk_port,rst_port,glock_port,glock_req_port,fu) VALUES"
1149  "(NULL,\"" + module + "\",\"" + opcPort + "\",\"" +
1150  clkPort + "\",\"" + rstPort + "\",\"" + glockPort + "\",\""
1151  + glockReqPort + "\"," + Conversion::toString(entry.id())
1152  + ");"));
1153  implID = dbConnection_->lastInsertRowID();
1154 
1155  // insert into fu_port_map table
1156  for (int i = 0; i < impl.architecturePortCount(); i++) {
1157  FUPortImplementation& portImpl = impl.architecturePort(i);
1158  string name = portImpl.name();
1159  string widthFormula = portImpl.widthFormula();
1160  string loadPort = portImpl.loadPort();
1161  string guardPort = portImpl.guardPort();
1162  string archPortName = portImpl.architecturePort();
1163  if (!fu.hasOperationPort(archPortName)) {
1164  throw InvalidData(__FILE__, __LINE__, __func__);
1165  }
1166  FUPort* port = fu.operationPort(archPortName);
1167  bool portAdded = false;
1168  for (int j = 0; j < fu.operationCount(); j++) {
1169  HWOperation* operation = fu.operation(j);
1170  if (operation->isBound(*port)) {
1171  int io = operation->io(*port);
1172  // find the fu_data_port from DB
1174  std::string(
1175  "SELECT fu_data_port.id FROM fu_data_port,"
1176  "io_binding,operation WHERE "
1177  "fu_data_port.fu_arch=" +
1178  Conversion::toString(archID) +
1179  " AND io_binding.port=fu_data_port.id AND "
1180  "io_binding.io_number=" +
1181  Conversion::toString(io) +
1182  " AND lower(operation.name)=\"" +
1183  operation->name() +
1184  "\" AND io_binding.operation=operation.id;"));
1185  if (!result->hasNext()) {
1186  delete result;
1187  throw InvalidData(__FILE__, __LINE__, __func__);
1188  }
1189  result->next();
1190  string portID = result->data(0).stringValue();
1191  delete result;
1192 
1193  // update fu_port_map table
1195  std::string(
1196  "INSERT INTO fu_port_map(id,name,width_formula,"
1197  "load_port,guard_port,fu_impl,arch_port) VALUES"
1198  "(NULL,\"" + name + "\",\"" + widthFormula +
1199  "\",\"" + loadPort + "\",\"" + guardPort +
1200  "\"," + Conversion::toString(implID) + "," +
1201  portID + ");"));
1202  portAdded = true;
1203  break;
1204  }
1205  }
1206 
1207  if (!portAdded) {
1208  throw InvalidData(__FILE__, __LINE__, __func__);
1209  }
1210  }
1211 #ifdef ALLOW_OPCODE_EDITING
1212  // insert into opcode_map table
1213  for (int i = 0; i < fu.operationCount(); i++) {
1214  HWOperation* operation = fu.operation(i);
1215  if (!containsOperation(operation->name())) {
1216  format errorMsg(
1217  "FU implementation uses unknown operation %1%.");
1218  errorMsg % operation->name();
1219  throw InvalidData(
1220  __FILE__, __LINE__, __func__, errorMsg.str());
1221  }
1222  if (fu.operationCount() > 1 &&
1223  !impl.hasOpcode(operation->name())) {
1224  format errorMsg("Opcode not defined for operation %1%.");
1225  errorMsg % operation->name();
1226  throw InvalidData(
1227  __FILE__, __LINE__, __func__, errorMsg.str());
1228  }
1229  if (fu.operationCount() > 1) {
1230  int opcode = impl.opcode(operation->name());
1232  std::string(
1233  "INSERT INTO opcode_map(id,opcode,operation,fu_impl)"
1234  " VALUES(NULL," + Conversion::toString(opcode) +
1235  ",(SELECT id FROM operation WHERE lower(name)=\"" +
1236  operation->name() + "\")," +
1237  Conversion::toString(implID) + ");"));
1238  }
1239  }
1240 #endif
1241  // insert into fu_external_port table
1242  for (int i = 0; i < impl.externalPortCount(); i++) {
1243  FUExternalPort& port = impl.externalPort(i);
1244  string direction = directionString(port.direction());
1246  std::string(
1247  "INSERT INTO fu_external_port(id,name,direction,"
1248  "width_formula,description,fu_impl) VALUES(NULL,\"" +
1249  port.name() + "\",\"" + direction + "\",\"" +
1250  port.widthFormula() + "\",\"" + port.description() +
1251  "\"," + Conversion::toString(implID) + ");"));
1252  }
1253 
1254  // insert into fu_implementation_parameter table
1255  for (int i = 0; i < impl.parameterCount(); i++) {
1256  FUImplementation::Parameter param = impl.parameter(i);
1258  std::string(
1259  "INSERT INTO fu_implementation_parameter(id,name,type,"
1260  "value,fu_impl) VALUES(NULL,\"" + param.name +
1261  "\",\"" + param.type + "\",\"" + param.value +
1262  "\"," + Conversion::toString(implID) + ");"));
1263  }
1264 
1265  // insert into fu_ext_port_parameter_dependency table
1266  for (int i = 0; i < impl.externalPortCount(); i++) {
1267  FUExternalPort& port = impl.externalPort(i);
1268  for (int i = 0; i < port.parameterDependencyCount(); i++) {
1269  string param = port.parameterDependency(i);
1271  std::string(
1272  "INSERT INTO fu_ext_port_parameter_dependency(id,"
1273  "port,parameter) VALUES(NULL,(SELECT id FROM "
1274  "fu_external_port WHERE fu_impl=" +
1275  Conversion::toString(implID) + " AND name=\"" +
1276  port.name() + "\"),(SELECT id FROM "
1277  "fu_implementation_parameter WHERE fu_impl=" +
1278  Conversion::toString(implID) + " AND name=\"" +
1279  param + "\"));"));
1280  }
1281  }
1282 
1283  // insert into block_source_file table
1284  for (int i = 0; i < impl.implementationFileCount(); i++) {
1285  BlockImplementationFile& file = impl.file(i);
1287  }
1288 
1289  // insert into fu_source_file table
1290  for (int i = 0; i < impl.implementationFileCount(); i++) {
1291  BlockImplementationFile& file = impl.file(i);
1292  string path = file.pathToFile();
1294  std::string(
1295  "INSERT INTO fu_source_file(id,fu_impl,file) "
1296  "VALUES(NULL," + Conversion::toString(implID) +
1297  ",(SELECT id FROM block_source_file WHERE file=\"" +
1298  path + "\"));"));
1299  }
1300 
1301  dbConnection_->commit();
1302 
1303  } catch (const RelationalDBException& e) {
1305  debugLog(e.errorMessage());
1306  assert(false);
1307  } catch (const InvalidData& e) {
1309  throw;
1310  } catch (const Exception& e) {
1312  debugLog(e.errorMessage());
1313  assert(false);
1314  }
1315 
1316  return implID;
1317 }

References __func__, addBlockImplementationFileToHDB(), HDB::FUEntry::architecture(), HDB::FUArchitecture::architecture(), HDB::FUPortImplementation::architecturePort(), HDB::FUImplementation::architecturePort(), HDB::FUImplementation::architecturePortCount(), assert, RelationalDBConnection::beginTransaction(), HDB::HWBlockImplementation::clkPort(), RelationalDBConnection::commit(), containsOperation(), RelationalDBQueryResult::data(), dbConnection_, debugLog, HDB::ExternalPort::description(), HDB::ExternalPort::direction(), directionString(), Exception::errorMessage(), HDB::FUImplementation::externalPort(), HDB::FUImplementation::externalPortCount(), HDB::HWBlockImplementation::file(), fuArchitectureID(), fuByEntryID(), HDB::HWBlockImplementation::glockPort(), HDB::FUImplementation::glockReqPort(), HDB::FUPortImplementation::guardPort(), HDB::FUEntry::hasArchitecture(), hasFUEntry(), HDB::HDBEntry::hasID(), HDB::FUEntry::hasImplementation(), RelationalDBQueryResult::hasNext(), HDB::FUImplementation::hasOpcode(), TTAMachine::FunctionUnit::hasOperationPort(), HDB::HDBEntry::id(), HDB::FUEntry::implementation(), HDB::HWBlockImplementation::implementationFileCount(), TTAMachine::HWOperation::io(), TTAMachine::HWOperation::isBound(), RelationalDBConnection::lastInsertRowID(), HDB::PortImplementation::loadPort(), HDB::HWBlockImplementation::moduleName(), HDB::Parameter::name, HDB::PortImplementation::name(), TTAMachine::HWOperation::name(), HDB::ExternalPort::name(), RelationalDBQueryResult::next(), HDB::FUImplementation::opcode(), HDB::FUImplementation::opcodePort(), TTAMachine::FunctionUnit::operation(), TTAMachine::FunctionUnit::operationCount(), TTAMachine::FunctionUnit::operationPort(), HDB::FUImplementation::parameter(), HDB::FUImplementation::parameterCount(), HDB::ExternalPort::parameterDependency(), HDB::ExternalPort::parameterDependencyCount(), HDB::BlockImplementationFile::pathToFile(), RelationalDBConnection::query(), RelationalDBConnection::rollback(), HDB::HWBlockImplementation::rstPort(), DataObject::stringValue(), Conversion::toString(), HDB::Parameter::type, RelationalDBConnection::updateQuery(), HDB::Parameter::value, HDB::FUPortImplementation::widthFormula(), and HDB::ExternalPort::widthFormula().

Referenced by AddFUImplementationCmd::Do(), and HDBEditorModifyCmd::Do().

◆ addFUParametersToImplementation()

void HDB::HDBManager::addFUParametersToImplementation ( FUImplementation implementation,
RowID  entryID 
) const
private

Adds parameters to the given FU implementation which is the implementation of the FU entry that has the given ID.

Parameters
implementationThe implementation.
entryIDID of the FU entry.

Definition at line 5240 of file HDBManager.cc.

5242  {
5243 
5244  RelationalDBQueryResult* result = NULL;
5245  try {
5246  result = dbConnection_->query(
5248  } catch (const Exception&) {
5249  assert(false);
5250  }
5251 
5252  while (result->hasNext()) {
5253  result->next();
5254  const DataObject& nameData = result->data("name");
5255  const DataObject& typeData = result->data("type");
5256  const DataObject& valueData = result->data("value");
5257  string name = nameData.stringValue();
5258  string type = typeData.stringValue();
5259  string value = valueData.stringValue();
5260  implementation.addParameter(name, type, value);
5261  }
5262  delete result;
5263 }

References assert, RelationalDBQueryResult::data(), dbConnection_, fuImplementationParametersByIDQuery(), RelationalDBQueryResult::hasNext(), implementation, RelationalDBQueryResult::next(), RelationalDBConnection::query(), and DataObject::stringValue().

Referenced by createImplementationOfFU().

Here is the call graph for this function:

◆ addOpcodesToImplementation()

void HDB::HDBManager::addOpcodesToImplementation ( FUImplementation implementation,
RowID  entryID 
) const
private

Adds the operation codes to the given FU implementation which is the implementation of the FU entry that has the given ID.

Parameters
implementationThe FU implementation.
entryIDID of the FU entry.

Definition at line 4971 of file HDBManager.cc.

4973  {
4974 
4975  RelationalDBQueryResult* opcodeData = NULL;
4976  try {
4977  opcodeData = dbConnection_->query(opcodesByIDQuery(entryID));
4978  } catch (const Exception&) {
4979  assert(false);
4980  }
4981  int operationColumn = opcodeData->column("operation.name");
4982  int opcodeColumn = opcodeData->column("opcode_map.opcode");
4983  while (opcodeData->hasNext()) {
4984  opcodeData->next();
4985  const DataObject& operationData = opcodeData->data(
4986  operationColumn);
4987  const DataObject& opcodeDataObject = opcodeData->data(
4988  opcodeColumn);
4989  implementation.setOpcode(
4990  operationData.stringValue(), opcodeDataObject.integerValue());
4991  }
4992  delete opcodeData;
4993  opcodeData = NULL;
4994 }

References assert, RelationalDBQueryResult::column(), RelationalDBQueryResult::data(), dbConnection_, RelationalDBQueryResult::hasNext(), implementation, DataObject::integerValue(), RelationalDBQueryResult::next(), opcodesByIDQuery(), RelationalDBConnection::query(), and DataObject::stringValue().

Referenced by createImplementationOfFU().

Here is the call graph for this function:

◆ addOperationImplementation()

void HDB::HDBManager::addOperationImplementation ( const OperationImplementation operation)

Add addOperationImplementation to the DB.

Definition at line 2541 of file HDBManager.cc.

2542  {
2543 
2544 
2545  std::string i1 = "INSERT INTO operation_implementation(id,name,latency,"
2546  "post_op_vhdl,post_op_verilog,bus_definition,"
2547  "initial_vhdl,initial_verilog) "
2548  "VALUES (NULL,\"" + operation.name + "\","
2549  + std::to_string(operation.latency) + ","
2550  "\"" + operation.postOpImplFileVhdl + "\","
2551  "\"" + operation.postOpImplFileVerilog + "\","
2552  "\"" + operation.absBusDefFile + "\","
2553  "\"" + operation.initialImplFileVhdl + "\","
2554  "\"" + operation.initialImplFileVerilog +
2555  "\");";
2557  RowID newid = dbConnection_->lastInsertRowID();
2558 
2559  for (const auto r : operation.resources) {
2560  std::string i2 = "INSERT INTO operation_implementation_resources("
2561  "id, operation, resource, count) "
2562  "VALUES (NULL, " + std::to_string(newid)
2563  + ", " + std::to_string(r.id)
2564  + ", " + std::to_string(r.count)
2565  + ");";
2567  }
2568 
2569  for (const auto r : operation.vhdlVariables) {
2570  std::string i2 = "INSERT INTO operation_implementation_variable("
2571  "id, operation, name, width, type, language) "
2572  "VALUES (NULL, " + std::to_string(newid)
2573  + ", \"" + r.name + "\""
2574  + ", \"" + r.width + "\""
2575  + ", \"" + r.type + "\""
2576  + ", \"VHDL\");";
2578  }
2579 
2580  for (const auto r : operation.verilogVariables) {
2581  std::string i2 = "INSERT INTO operation_implementation_variable("
2582  "id, operation, name, width, type, language) "
2583  "VALUES (NULL, " + std::to_string(newid)
2584  + ", \"" + r.name + "\""
2585  + ", \"" + r.width + "\""
2586  + ", \"" + r.type + "\""
2587  + ", \"Verilog\");";
2589  }
2590 
2591  std::string i3 = "INSERT INTO block_source_file(id,file,format) "
2592  "VALUES (NULL,\"" + operation.implFileVhdl +
2593  "\", " + std::to_string(BlockImplementationFile::VHDL) + ");";
2596 
2597  std::string i4 = "INSERT INTO "
2598  "operation_implementation_source_file(id, operation, file) "
2599  "VALUES (NULL, " + std::to_string(newid) +
2600  ", " + std::to_string(vhdl) +
2601  ");";
2603 
2604  std::string i5 = "INSERT INTO block_source_file(id,file,format) "
2605  "VALUES (NULL,\"" + operation.implFileVerilog +
2606  "\", " + std::to_string(BlockImplementationFile::Verilog) + ");";
2608  RowID verilog = dbConnection_->lastInsertRowID();
2609 
2610  std::string i6 = "INSERT INTO "
2611  "operation_implementation_source_file(id, operation, file) "
2612  "VALUES (NULL, " + std::to_string(newid) +
2613  ", " + std::to_string(verilog) +
2614  ");";
2616 }

References HDB::OperationImplementation::absBusDefFile, dbConnection_, HDB::OperationImplementation::implFileVerilog, HDB::OperationImplementation::implFileVhdl, HDB::OperationImplementation::initialImplFileVerilog, HDB::OperationImplementation::initialImplFileVhdl, RelationalDBConnection::lastInsertRowID(), HDB::OperationImplementation::latency, HDB::OperationImplementation::name, HDB::OperationImplementation::postOpImplFileVerilog, HDB::OperationImplementation::postOpImplFileVhdl, HDB::OperationImplementation::resources, RelationalDBConnection::updateQuery(), HDB::BlockImplementationFile::Verilog, HDB::OperationImplementation::verilogVariables, HDB::BlockImplementationFile::VHDL, and HDB::OperationImplementation::vhdlVariables.

Referenced by OperationImplementationDialog::onOK().

Here is the call graph for this function:

◆ addOperationImplementationResource()

void HDB::HDBManager::addOperationImplementationResource ( const OperationImplementationResource resource)

Add addOperationImplementationResource to the DB.

Definition at line 2482 of file HDBManager.cc.

2483  {
2484 
2486  std::string(
2487  "INSERT INTO operation_implementation_resource(id,name,ipxact) "
2488  "VALUES (NULL, \"" +
2489  resource.name +"\", \"" + resource.ipxact+ "\");"));
2490  RowID resourceID = dbConnection_->lastInsertRowID();
2491 
2492  auto t = resource.simFormats.begin();
2493  auto f = resource.simFiles.begin();
2494  for (; f != resource.simFiles.end(); ++f, ++t) {
2495  int type = fileFormat(*t) + 1;
2496 
2498  std::string(
2499  "INSERT INTO block_source_file(id,file,format) "
2500  "VALUES (NULL, \"" + *f + "\","
2501  + std::to_string(type) +
2502  ");"));
2503  RowID fileID = dbConnection_->lastInsertRowID();
2504 
2506  std::string(
2507  "INSERT INTO operation_implementation_resource_source_file"
2508  "(id,resource,file) "
2509  "VALUES (NULL, " + std::to_string(resourceID) + ", "
2510  + std::to_string(fileID) +
2511  ");"));
2512  }
2513 
2514  auto st = resource.synFormats.begin();
2515  auto sf = resource.synFiles.begin();
2516  for (; sf != resource.synFiles.end(); ++sf, ++st) {
2517  int type = fileFormat(*st) + 1;
2518 
2520  std::string(
2521  "INSERT INTO block_source_file(id,file,format) "
2522  "VALUES (NULL, \"" + *sf + "\","
2523  + std::to_string(type) +
2524  ");"));
2525  RowID fileID = dbConnection_->lastInsertRowID();
2526 
2528  std::string(
2529  "INSERT INTO operation_implementation_resource_source_file"
2530  "(id,resource,file) "
2531  "VALUES (NULL, " + std::to_string(resourceID) + ", "
2532  + std::to_string(fileID) +
2533  ");"));
2534  }
2535 }

References dbConnection_, fileFormat(), HDB::OperationImplementationResource::ipxact, RelationalDBConnection::lastInsertRowID(), HDB::OperationImplementationResource::name, HDB::OperationImplementationResource::simFiles, HDB::OperationImplementationResource::simFormats, HDB::OperationImplementationResource::synFiles, HDB::OperationImplementationResource::synFormats, and RelationalDBConnection::updateQuery().

Referenced by OperationImplementationResourceDialog::onOK().

Here is the call graph for this function:

◆ addOperationPipelinesToFUArchitecture()

void HDB::HDBManager::addOperationPipelinesToFUArchitecture ( FUArchitecture architecture,
RowID  id 
) const
private

Obtains data from HDB and creates the operation pipelines to the given FU architecture.

Parameters
architectureThe FU architecture to which the operations are added.
idID the FU architecture in HDB.

Definition at line 4517 of file HDBManager.cc.

4519  {
4520 
4521  FunctionUnit& fu = architecture.architecture();
4522 
4523  // make the SQL query to obtain IO usage data
4524  RelationalDBQueryResult* ioUsageData = NULL;
4525  try {
4526  ioUsageData = dbConnection_->query(ioUsageDataByIDQuery(id));
4527  } catch (const Exception& e) {
4528  assert(false);
4529  }
4530  int operationColumn = ioUsageData->column("operation.name");
4531  int cycleColumn = ioUsageData->column("io_usage.cycle");
4532  int ioColumn = ioUsageData->column("io_usage.io_number");
4533  int actionColumn = ioUsageData->column("io_usage.action");
4534 
4535  while (ioUsageData->hasNext()) {
4536  ioUsageData->next();
4537  const DataObject& operationData = ioUsageData->data(operationColumn);
4538  const DataObject& cycleData = ioUsageData->data(cycleColumn);
4539  const DataObject& ioData = ioUsageData->data(ioColumn);
4540  const DataObject& actionData = ioUsageData->data(actionColumn);
4541 
4542  string operationName = operationData.stringValue();
4543  int cycle = cycleData.integerValue();
4544  int ioNumber = ioData.integerValue();
4545  int action = actionData.boolValue();
4546 
4547  assert(fu.hasOperation(operationName));
4548  HWOperation* operation = fu.operation(operationName);
4549  ExecutionPipeline* pipeline = operation->pipeline();
4550  if (action == READ_ACTION) {
4551  pipeline->addPortRead(ioNumber, cycle, 1);
4552  } else if (action == WRITE_ACTION) {
4553  pipeline->addPortWrite(ioNumber, cycle, 1);
4554  }
4555  }
4556 
4557  delete ioUsageData;
4558  ioUsageData = NULL;
4559 
4560  // add resource usages
4561  RelationalDBQueryResult* resUsageData = NULL;
4562  try {
4563  resUsageData = dbConnection_->query(resourceUsageDataByIDQuery(id));
4564  } catch (const Exception&) {
4565  assert(false);
4566  }
4567  operationColumn = resUsageData->column("operation.name");
4568  cycleColumn = resUsageData->column("pipeline_resource_usage.cycle");
4569  int resourceColumn = resUsageData->column("pipeline_resource.id");
4570 
4571  int resourceName(0);
4572  std::map<int, string> resourceMap;
4573 
4574  while (resUsageData->hasNext()) {
4575  resUsageData->next();
4576  const DataObject& operationData = resUsageData->data(
4577  operationColumn);
4578  const DataObject& cycleData = resUsageData->data(cycleColumn);
4579  const DataObject& resourceData = resUsageData->data(resourceColumn);
4580 
4581  string operationName = operationData.stringValue();
4582  int cycle = cycleData.integerValue();
4583  int resourceID = resourceData.integerValue();
4584 
4585  assert(fu.hasOperation(operationName));
4586  HWOperation* operation = fu.operation(operationName);
4587  ExecutionPipeline* pipeline = operation->pipeline();
4588  if (!MapTools::containsKey(resourceMap, resourceID)) {
4589  resourceMap.insert(
4590  std::pair<int, string>(
4591  resourceID, "res" + Conversion::toString(resourceName)));
4592  resourceName++;
4593  }
4594  pipeline->addResourceUse(
4595  MapTools::valueForKey<string>(
4596  resourceMap, resourceID), cycle, 1);
4597  }
4598 
4599  delete resUsageData;
4600  resUsageData = NULL;
4601 }

References TTAMachine::ExecutionPipeline::addPortRead(), TTAMachine::ExecutionPipeline::addPortWrite(), TTAMachine::ExecutionPipeline::addResourceUse(), HDB::FUArchitecture::architecture(), assert, DataObject::boolValue(), RelationalDBQueryResult::column(), MapTools::containsKey(), RelationalDBQueryResult::data(), dbConnection_, RelationalDBQueryResult::hasNext(), TTAMachine::FunctionUnit::hasOperation(), DataObject::integerValue(), ioUsageDataByIDQuery(), RelationalDBQueryResult::next(), TTAMachine::FunctionUnit::operation(), TTAMachine::HWOperation::pipeline(), RelationalDBConnection::query(), READ_ACTION, resourceUsageDataByIDQuery(), DataObject::stringValue(), Conversion::toString(), and WRITE_ACTION.

Referenced by fuArchitectureByID().

Here is the call graph for this function:

◆ addPortsAndBindingsToFUArchitecture()

void HDB::HDBManager::addPortsAndBindingsToFUArchitecture ( FUArchitecture architecture,
RowID  id 
) const
private

Obtains data from HDB and creates ports and operand bindings to the given FU architecture that has the given ID in HDB.

Parameters
architectureThe FU architecture to which the ports are added.
idID of the FU architecture in HDB.

Definition at line 4406 of file HDBManager.cc.

4408  {
4409 
4410  FunctionUnit& fu = architecture.architecture();
4411 
4412  // make the SQL query to obtain the ports
4413  RelationalDBQueryResult* fuPorts = NULL;
4414  try {
4416  } catch (const Exception& e) {
4418  }
4419  int portIDColumnIndex = fuPorts->column("fu_data_port.id");
4420  int triggersColumnIndex = fuPorts->column("fu_data_port.triggers");
4421  int setsOpcodeColumnIndex = fuPorts->column("fu_data_port.sets_opcode");
4422  int guardSupportColumnIndex = fuPorts->column(
4423  "fu_data_port.guard_support");
4424  int widthColumnIndex = fuPorts->column("fu_data_port.width");
4425  int operationColumnIndex = fuPorts->column("operation.name");
4426  int bindingColumnIndex = fuPorts->column("io_binding.io_number");
4427 
4428  // @fixme Do not assert() inside a library function in case of broken
4429  // user input data!!
4430  assert(portIDColumnIndex != RelationalDBQueryResult::UNKNOWN_INDEX);
4431  assert(triggersColumnIndex != RelationalDBQueryResult::UNKNOWN_INDEX);
4432  assert(setsOpcodeColumnIndex != RelationalDBQueryResult::UNKNOWN_INDEX);
4433  assert(
4434  guardSupportColumnIndex != RelationalDBQueryResult::UNKNOWN_INDEX);
4435  assert(widthColumnIndex != RelationalDBQueryResult::UNKNOWN_INDEX);
4436  assert(operationColumnIndex != RelationalDBQueryResult::UNKNOWN_INDEX);
4437  assert(bindingColumnIndex != RelationalDBQueryResult::UNKNOWN_INDEX);
4438 
4439  if (!fuPorts->hasNext()) {
4440  delete fuPorts;
4441  abortWithError("No row.");
4442  }
4443 
4444  std::map<int, std::string> portIDMap;
4445 
4446  // create ports, operations and bindings to the FU
4447  int name(1);
4448  while (fuPorts->hasNext()) {
4449  fuPorts->next();
4450 
4451  const DataObject& idData = fuPorts->data(portIDColumnIndex);
4452  const DataObject& triggersData = fuPorts->data(triggersColumnIndex);
4453  const DataObject& setsOpcodeData = fuPorts->data(
4454  setsOpcodeColumnIndex);
4455  const DataObject& guardData = fuPorts->data(guardSupportColumnIndex);
4456  const DataObject& widthData = fuPorts->data(widthColumnIndex);
4457  const DataObject& operationData = fuPorts->data(
4458  operationColumnIndex);
4459  const DataObject& bindingData = fuPorts->data(bindingColumnIndex);
4460 
4461  int portID = idData.integerValue();
4462 
4463  // create operation if it is not created yet
4464  string operationName = operationData.stringValue();
4465  if (!fu.hasOperation(operationName)) {
4466  new HWOperation(operationName, fu);
4467  }
4468 
4469  // create port if it is not created yet
4470  if (!MapTools::containsKey(portIDMap, portID)) {
4471  bool triggers = triggersData.boolValue();
4472  bool setsOpcode = setsOpcodeData.boolValue();
4473  string portName = "p" + Conversion::toString(name);
4474 
4475  int width = DEFAULT_PORT_WIDTH;
4476  if (widthData.isNull()) {
4477  architecture.setParameterizedWidth(portName);
4478  } else {
4479  width = widthData.integerValue();
4480  }
4481  new FUPort(portName, width, fu, triggers, setsOpcode);
4482  portIDMap.insert(
4483  std::pair<int, string>(idData.integerValue(), portName));
4484  if (setsOpcode && !triggers)
4485  debugLog(
4486  std::string("Created a suspicious port ") + portName +
4487  " which sets opcode but does not trigger");
4488 
4489  // set guard support
4490  if (guardData.boolValue()) {
4491  architecture.setGuardSupport(portName);
4492  }
4493 
4494  name++;
4495  }
4496 
4497  // create binding
4498  FUPort* portToBind = fu.operationPort(
4499  MapTools::valueForKey<string>(portIDMap, portID));
4500  HWOperation* operation = fu.operation(operationName);
4501  operation->bindPort(bindingData.integerValue(), *portToBind);
4502  }
4503 
4504  delete fuPorts;
4505  fuPorts = NULL;
4506 }

References abortWithError, HDB::FUArchitecture::architecture(), assert, TTAMachine::HWOperation::bindPort(), DataObject::boolValue(), RelationalDBQueryResult::column(), MapTools::containsKey(), RelationalDBQueryResult::data(), dbConnection_, debugLog, DEFAULT_PORT_WIDTH, Exception::errorMessage(), fuPortsAndBindingsByIDQuery(), RelationalDBQueryResult::hasNext(), TTAMachine::FunctionUnit::hasOperation(), DataObject::integerValue(), DataObject::isNull(), RelationalDBQueryResult::next(), TTAMachine::FunctionUnit::operation(), TTAMachine::FunctionUnit::operationPort(), RelationalDBConnection::query(), HDB::FUArchitecture::setGuardSupport(), HDB::FUArchitecture::setParameterizedWidth(), DataObject::stringValue(), Conversion::toString(), and RelationalDBQueryResult::UNKNOWN_INDEX.

Referenced by fuArchitectureByID().

Here is the call graph for this function:

◆ addRFArchitecture()

RowID HDB::HDBManager::addRFArchitecture ( const RFArchitecture architecture) const

Adds the given RF architecture to the HDB.

Parameters
architectureThe architecture to add.
Returns
ID of the architecture added.

Definition at line 1461 of file HDBManager.cc.

1461  {
1462 
1463  try {
1464  string query =
1465  "INSERT INTO rf_architecture(id,size,width,read_ports,"
1466  "write_ports,bidir_ports,latency,max_reads,max_writes,"
1467  "guard_support,guard_latency,zero_register) VALUES(NULL,";
1468  if (architecture.hasParameterizedSize()) {
1469  query += "NULL,";
1470  } else {
1471  query += (Conversion::toString(architecture.size()) + ",");
1472  }
1473  if (architecture.hasParameterizedWidth()) {
1474  query += "NULL,";
1475  } else {
1476  query += (Conversion::toString(architecture.width()) + ",");
1477  }
1478  query += (Conversion::toString(architecture.readPortCount()) + ",");
1479  query += (Conversion::toString(architecture.writePortCount()) + ",");
1480  query += (Conversion::toString(architecture.bidirPortCount()) + ",");
1481  query += (Conversion::toString(architecture.latency()) + ",");
1482  query += (Conversion::toString(architecture.maxReads()) + ",");
1483  query += (Conversion::toString(architecture.maxWrites()) + ",");
1484  query +=
1485  (Conversion::toString(architecture.hasGuardSupport()) + ",");
1486  query += (Conversion::toString(architecture.guardLatency()) + ",");
1487  query += (Conversion::toString(architecture.zeroRegister()));
1488  query += ");";
1489 
1490  dbConnection_->updateQuery(query);
1491  } catch (const Exception& e) {
1492  debugLog(e.errorMessage());
1493  assert(false);
1494  }
1495 
1496  return dbConnection_->lastInsertRowID();
1497 }

References assert, HDB::RFArchitecture::bidirPortCount(), dbConnection_, debugLog, Exception::errorMessage(), HDB::RFArchitecture::guardLatency(), HDB::RFArchitecture::hasGuardSupport(), HDB::RFArchitecture::hasParameterizedSize(), HDB::RFArchitecture::hasParameterizedWidth(), RelationalDBConnection::lastInsertRowID(), HDB::RFArchitecture::latency(), HDB::RFArchitecture::maxReads(), HDB::RFArchitecture::maxWrites(), HDB::RFArchitecture::readPortCount(), HDB::RFArchitecture::size(), Conversion::toString(), RelationalDBConnection::updateQuery(), HDB::RFArchitecture::width(), HDB::RFArchitecture::writePortCount(), and HDB::RFArchitecture::zeroRegister().

Referenced by AddRFArchitectureCmd::Do().

Here is the call graph for this function:

◆ addRFCostEstimationData()

RowID HDB::HDBManager::addRFCostEstimationData ( RowID  rfID,
const std::string &  valueName,
const std::string &  value,
RowID  pluginID 
) const

Adds the given cost estimation data values to given RF entry.

Parameters
rfIDThe ID of the RF entry the cost data will be added. @valueName The name of the cost value. @value The cost value. @pluginID The ID of the cost function plugin that owns this data.

Definition at line 3246 of file HDBManager.cc.

3250  {
3251 
3252  RowID dataID;
3253 
3254  // add the data
3255  try {
3257  std::string(
3258  "INSERT INTO cost_estimation_data (id,plugin_reference,"
3259  "rf_reference,name,value) VALUES (NULL," +
3260  Conversion::toString(pluginID) + "," +
3261  Conversion::toString(rfID) + ",\"" + valueName + "\",\"" +
3262  value + "\");"));
3263  dataID = dbConnection_->lastInsertRowID();
3264  } catch (const Exception& e) {
3265  debugLog(e.errorMessage());
3266  assert(false);
3267  }
3268  return dataID;
3269 }

References assert, dbConnection_, debugLog, Exception::errorMessage(), RelationalDBConnection::lastInsertRowID(), Conversion::toString(), and RelationalDBConnection::updateQuery().

Here is the call graph for this function:

◆ addRFEntry()

RowID HDB::HDBManager::addRFEntry ( ) const

Adds an empty RF entry to the database.

Returns
ID of the entry added.

Definition at line 1557 of file HDBManager.cc.

1557  {
1558  try {
1560  std::string(
1561  "INSERT INTO rf(id,architecture,cost_function) "
1562  "VALUES(NULL,NULL,NULL);"));
1563  return dbConnection_->lastInsertRowID();
1564  } catch (const Exception& e) {
1565  debugLog(e.errorMessage());
1566  assert(false);
1567  }
1568 
1569  // dummy return to avoid compiler whining
1570  assert(false);
1571  return 0;
1572 }

References assert, dbConnection_, debugLog, Exception::errorMessage(), RelationalDBConnection::lastInsertRowID(), and RelationalDBConnection::updateQuery().

Referenced by AddRFEntryCmd::Do(), and AddRFImplementationCmd::Do().

Here is the call graph for this function:

◆ addRFExternalPortsToImplementation()

void HDB::HDBManager::addRFExternalPortsToImplementation ( RFImplementation implementation,
RowID  entryID 
) const
private

Adds external ports to the given RF implementation which is the implementation of the RF entry that has the given ID.

Parameters
implementationThe implementation.
entryIDID of the RF implementation entry.

Definition at line 5143 of file HDBManager.cc.

5145  {
5146 
5147  if (!dbConnection_->tableExistsInDB("rf_external_port")) {
5148  return;
5149  }
5150 
5151  RelationalDBQueryResult* extPortData = NULL;
5152  try {
5153  extPortData = dbConnection_->query(rfExternalPortsByIDQuery(entryID));
5154  } catch (const Exception& e) {
5155  assert(false);
5156  }
5157 
5158  int extPortNameColumn = extPortData->column("rf_external_port.name");
5159  int directionColumn = extPortData->column(
5160  "rf_external_port.direction");
5161  int extPortWidthFormulaColumn = extPortData->column(
5162  "rf_external_port.width_formula");
5163  int descriptionColumn = extPortData->column(
5164  "rf_external_port.description");
5165 
5166  while (extPortData->hasNext()) {
5167  extPortData->next();
5168  const DataObject& nameData = extPortData->data(
5169  extPortNameColumn);
5170  const DataObject& directionData = extPortData->data(
5171  directionColumn);
5172  const DataObject& widthFormulaData = extPortData->data(
5173  extPortWidthFormulaColumn);
5174  const DataObject& descriptionData = extPortData->data(
5175  descriptionColumn);
5176 
5177  string name = nameData.stringValue();
5178  string widthFormula = widthFormulaData.stringValue();
5179  string description = descriptionData.stringValue();
5180 
5181  Direction direction;
5182  if (directionData.stringValue() == IN_DIRECTION) {
5183  direction = IN;
5184  } else if (directionData.stringValue() == OUT_DIRECTION) {
5185  direction = OUT;
5186  } else {
5187  assert(directionData.stringValue() == BIDIR_DIRECTION);
5188  direction = BIDIR;
5189  }
5190 
5191  new RFExternalPort(
5192  name, direction, widthFormula, description, implementation);
5193  }
5194 
5195  delete extPortData;
5196  extPortData = NULL;
5197 
5198  // add parameter dependencies
5199  if (!dbConnection_->tableExistsInDB("rf_ext_port_parameter_dependency")) {
5200  return;
5201  }
5202 
5203  for (int i = 0; i < implementation.externalPortCount(); i++) {
5204  RFExternalPort& port = implementation.externalPort(i);
5205  try {
5207  std::string(
5208  "SELECT rf_implementation_parameter.name FROM "
5209  "rf_implementation_parameter, rf_external_port, "
5210  "rf_ext_port_parameter_dependency, rf_implementation "
5211  "WHERE rf_implementation.rf=" +
5212  Conversion::toString(entryID) +
5213  " AND rf_external_port.rf_impl=rf_implementation.id AND "
5214  "rf_external_port.name=\"" + port.name() +
5215  "\" AND rf_ext_port_parameter_dependency.port="
5216  "rf_external_port.id AND rf_implementation_parameter.id="
5217  "rf_ext_port_parameter_dependency.parameter;"));
5218  while (result->hasNext()) {
5219  result->next();
5220  const DataObject& paramData = result->data(0);
5221  port.setParameterDependency(paramData.stringValue());
5222  }
5223  delete result;
5224  } catch (const Exception& e) {
5225  debugLog(e.errorMessage());
5226  assert(false);
5227  }
5228  }
5229 }

References assert, HDB::BIDIR, BIDIR_DIRECTION, RelationalDBQueryResult::column(), RelationalDBQueryResult::data(), dbConnection_, debugLog, Exception::errorMessage(), RelationalDBQueryResult::hasNext(), implementation, HDB::IN, IN_DIRECTION, HDB::ExternalPort::name(), RelationalDBQueryResult::next(), HDB::OUT, OUT_DIRECTION, RelationalDBConnection::query(), rfExternalPortsByIDQuery(), HDB::ExternalPort::setParameterDependency(), DataObject::stringValue(), RelationalDBConnection::tableExistsInDB(), and Conversion::toString().

Referenced by createImplementationOfRF().

Here is the call graph for this function:

◆ addRFImplementation()

RowID HDB::HDBManager::addRFImplementation ( const RFImplementation implementation,
RowID  rfEntryID 
)

Adds an implementation for the the given RF entry.

Parameters
implementationThe implementation to add.
rfEntryIDID of the RF entry.
Exceptions
InvalidDataIf the RF entry has an implementation already or if the database does not contain an RF entry with the given ID.

Definition at line 1640 of file HDBManager.cc.

1641  {
1642  if (!hasRFEntry(rfEntryID)) {
1643  throw InvalidData(__FILE__, __LINE__, __func__);
1644  }
1645 
1646  RFEntry* entry = rfByEntryID(rfEntryID);
1647  if (entry->hasImplementation()) {
1648  throw InvalidData(__FILE__, __LINE__, __func__);
1649  }
1650  delete entry;
1651  entry = NULL;
1652 
1653  if(!hasColumn("rf_implementation", "sac_param")) {
1654  addBooleanColumn("rf_implementation", "sac_param");
1655  }
1656 
1657  // Create tables for external ports, parameters and parameter dependecies
1658  // if needed.
1659  if (!dbConnection_->tableExistsInDB("rf_implementation_parameter")) {
1661  }
1662  if (!dbConnection_->tableExistsInDB("rf_external_port")) {
1664  }
1665  if (!dbConnection_->tableExistsInDB("rf_ext_port_parameter_dependency")) {
1667 
1668  }
1669 
1670  try {
1672 
1673  int sacFlagAsInt = implementation.separateAddressCycleParameter();
1674 
1675  // insert into rf_implementation table
1676  std::string insert_query(
1677  "INSERT INTO rf_implementation(id,name,size_param,"
1678  "width_param,clk_port,rst_port,glock_port,guard_port,sac_param,rf) "
1679  "VALUES(NULL,\"" + implementation.moduleName() + "\",\"" +
1680  implementation.sizeParameter() + "\",\"" +
1681  implementation.widthParameter() + "\",\"" +
1682  implementation.clkPort() + "\",\"" +
1683  implementation.rstPort() + "\",\"" +
1684  implementation.glockPort() + "\",\"" +
1685  implementation.guardPort() + "\"," +
1686  Conversion::toString(sacFlagAsInt) + "," +
1687  Conversion::toString(rfEntryID) + ");");
1688 
1689  dbConnection_->updateQuery(insert_query);
1690  RowID implID = dbConnection_->lastInsertRowID();
1691 
1692  // insert into rf_data_port table
1693  for (int i = 0; i < implementation.portCount(); i++) {
1694  RFPortImplementation& port = implementation.port(i);
1696  std::string(
1697  "INSERT INTO rf_data_port(id,name,direction,load_port,"
1698  "opcode_port,opcode_port_width_formula,rf_impl) "
1699  "VALUES(NULL,\"" + port.name() + "\",\"" +
1700  directionString(port.direction()) + "\",\"" +
1701  port.loadPort() + "\",\"" + port.opcodePort() + "\",\""
1702  + port.opcodePortWidthFormula() + "\"," +
1703  Conversion::toString(implID) + ");"));
1704  }
1705 
1706  // insert into block_source_file table
1707  for (int i = 0; i < implementation.implementationFileCount(); i++) {
1708  BlockImplementationFile& file = implementation.file(i);
1710  }
1711 
1712  // insert into rf_source_file table
1713  for (int i = 0; i < implementation.implementationFileCount(); i++) {
1714  BlockImplementationFile& file = implementation.file(i);
1715  string path = file.pathToFile();
1717  std::string(
1718  "INSERT INTO rf_source_file values(NULL, " +
1719  Conversion::toString(implID) +
1720  ", (SELECT id FROM block_source_file WHERE file=\"" +
1721  path + "\"));"));
1722  }
1723 
1724  // insert into rf_external_port table
1725  for (int i = 0; i < implementation.externalPortCount(); i++) {
1726  RFExternalPort& port = implementation.externalPort(i);
1727  string direction = directionString(port.direction());
1729  std::string(
1730  "INSERT INTO rf_external_port(id,name,direction,"
1731  "width_formula,description,rf_impl) VALUES(NULL,\"" +
1732  port.name() + "\",\"" + direction + "\",\"" +
1733  port.widthFormula() + "\",\"" + port.description() +
1734  "\"," + Conversion::toString(implID) + ");"));
1735  }
1736 
1737  // insert into rf_implementation_parameter table
1738  for (int i = 0; i < implementation.parameterCount(); i++) {
1739  RFImplementation::Parameter param = implementation.parameter(i);
1741  std::string(
1742  "INSERT INTO rf_implementation_parameter(id,name,type,"
1743  "value,rf_impl) VALUES(NULL,\"" + param.name +
1744  "\",\"" + param.type + "\",\"" + param.value +
1745  "\"," + Conversion::toString(implID) + ");"));
1746  }
1747 
1748  // Insert implicit parameters to rf_implementation_parameter table
1749  // (size and width parameter references if not empty and parameters
1750  // for them do not exists).
1751  string widthParam = implementation.widthParameter();
1752  if (!widthParam.empty() && !implementation.hasParameter(widthParam)) {
1754  std::string(
1755  "INSERT INTO rf_implementation_parameter(id,name,type,"
1756  "value,rf_impl) VALUES(NULL,\"" + widthParam +
1757  "\", \"integer\", \"\"," +
1758  Conversion::toString(implID) + ");"));
1759  }
1760  string sizeParam = implementation.sizeParameter();
1761  if (!sizeParam.empty() && !implementation.hasParameter(sizeParam)) {
1763  std::string(
1764  "INSERT INTO rf_implementation_parameter(id,name,type,"
1765  "value,rf_impl) VALUES(NULL,\"" + sizeParam +
1766  "\", \"integer\", \"\"," +
1767  Conversion::toString(implID) + ");"));
1768  }
1769 
1770  // insert into rf_ext_port_parameter_dependency table
1771  for (int i = 0; i < implementation.externalPortCount(); i++) {
1772  RFExternalPort& port = implementation.externalPort(i);
1773  for (int i = 0; i < port.parameterDependencyCount(); i++) {
1774  string param = port.parameterDependency(i);
1776  std::string(
1777  "INSERT INTO rf_ext_port_parameter_dependency(id,"
1778  "port,parameter) VALUES(NULL,(SELECT id FROM "
1779  "rf_external_port WHERE rf_impl=" +
1780  Conversion::toString(implID) + " AND name=\"" +
1781  port.name() + "\"),(SELECT id FROM "
1782  "rf_implementation_parameter WHERE rf_impl=" +
1783  Conversion::toString(implID) + " AND name=\"" +
1784  param + "\"));"));
1785  }
1786  }
1787 
1788  dbConnection_->commit();
1789  return implID;
1790 
1791  } catch (const Exception& e) {
1793  debugLog(e.errorMessage());
1794  assert(false);
1795  }
1796 
1797  // dummy return to avoid compiler whining
1798  assert(false);
1799  return 0;
1800 }

References __func__, addBlockImplementationFileToHDB(), addBooleanColumn(), assert, RelationalDBConnection::beginTransaction(), RelationalDBConnection::commit(), CQ_RF_EXT_PORT_PARAMETER_DEPENDENCY, CQ_RF_EXTERNAL_PORT, CQ_RF_IMPLEMENTATION_PARAMETER, dbConnection_, RelationalDBConnection::DDLQuery(), debugLog, HDB::ExternalPort::description(), HDB::RFPortImplementation::direction(), HDB::ExternalPort::direction(), directionString(), Exception::errorMessage(), hasColumn(), HDB::RFEntry::hasImplementation(), hasRFEntry(), implementation, RelationalDBConnection::lastInsertRowID(), HDB::PortImplementation::loadPort(), HDB::Parameter::name, HDB::PortImplementation::name(), HDB::ExternalPort::name(), HDB::RFPortImplementation::opcodePort(), HDB::RFPortImplementation::opcodePortWidthFormula(), HDB::ExternalPort::parameterDependency(), HDB::ExternalPort::parameterDependencyCount(), HDB::BlockImplementationFile::pathToFile(), rfByEntryID(), RelationalDBConnection::rollback(), RelationalDBConnection::tableExistsInDB(), Conversion::toString(), HDB::Parameter::type, RelationalDBConnection::updateQuery(), HDB::Parameter::value, and HDB::ExternalPort::widthFormula().

Referenced by AddRFImplementationCmd::Do(), and HDBEditorModifyCmd::Do().

Here is the call graph for this function:

◆ addRFParametersToImplementation()

void HDB::HDBManager::addRFParametersToImplementation ( RFImplementation implementation,
RowID  entryID 
) const
private

Adds parameters to the given RF implementation which is the implementation of the RF entry that has the given ID.

Parameters
implementationThe implementation.
entryIDID of the RF entry.

Definition at line 5274 of file HDBManager.cc.

5276  {
5277 
5278  if (!dbConnection_->tableExistsInDB("rf_implementation_parameter")) {
5279  // Add implicit parameters: size and width parameters if older
5280  // hdb is opened.
5281  if (implementation.widthParameter() != "") {
5282  implementation.addParameter(implementation.widthParameter(),
5283  "integer", "");
5284  }
5285  if (implementation.sizeParameter() != "") {
5286  implementation.addParameter(implementation.sizeParameter(),
5287  "integer", "");
5288  }
5289  return;
5290  }
5291 
5292  RelationalDBQueryResult* result = NULL;
5293  try {
5294  result = dbConnection_->query(
5296  } catch (const Exception&) {
5297  assert(false);
5298  }
5299 
5300  while (result->hasNext()) {
5301  result->next();
5302  const DataObject& nameData = result->data("name");
5303  const DataObject& typeData = result->data("type");
5304  const DataObject& valueData = result->data("value");
5305  string name = nameData.stringValue();
5306  string type = typeData.stringValue();
5307  string value = valueData.stringValue();
5308  implementation.addParameter(name, type, value);
5309  }
5310 
5311  // If RF implementation's size and width parameter dependencies do not have
5312  // parameter defined, add default parameters for them.
5313  if (implementation.widthParameter() != "" &&
5314  !implementation.hasParameter(implementation.widthParameter())) {
5315  implementation.addParameter(implementation.widthParameter(),
5316  "integer", "");
5317  implementation.addParameter(implementation.sizeParameter(),
5318  "integer", "");
5319  }
5320  if (implementation.sizeParameter() != "" &&
5321  !implementation.hasParameter(implementation.sizeParameter())) {
5322  implementation.addParameter(implementation.sizeParameter(),
5323  "integer", "");
5324  }
5325  delete result;
5326 }

References assert, RelationalDBQueryResult::data(), dbConnection_, RelationalDBQueryResult::hasNext(), implementation, RelationalDBQueryResult::next(), RelationalDBConnection::query(), rfImplementationParametersByIDQuery(), DataObject::stringValue(), and RelationalDBConnection::tableExistsInDB().

Referenced by createImplementationOfRF().

Here is the call graph for this function:

◆ addSocketCostEstimationData()

RowID HDB::HDBManager::addSocketCostEstimationData ( RowID  socketID,
const std::string &  valueName,
const std::string &  value,
RowID  pluginID 
) const

Adds the given cost estimation data values to given Socket entry.

Parameters
socketIDThe ID of the Socket entry the cost data will be added. @valueName The name of the cost value. @value The cost value. @pluginID The ID of the cost function plugin that owns this data.

Definition at line 3678 of file HDBManager.cc.

3682  {
3683 
3684 
3685  RowID dataID;
3686 
3687  // add the data
3688  try {
3690  std::string(
3691  "INSERT INTO cost_estimation_data (id,plugin_reference,"
3692  "socket_reference,name,value) VALUES (NULL," +
3693  Conversion::toString(pluginID) + "," +
3694  Conversion::toString(socketID) + ",\"" + valueName + "\",\"" +
3695  value + "\");"));
3696  dataID = dbConnection_->lastInsertRowID();
3697  } catch (const Exception& e) {
3698  debugLog(e.errorMessage());
3699  assert(false);
3700  }
3701  return dataID;
3702 }

References assert, dbConnection_, debugLog, Exception::errorMessage(), RelationalDBConnection::lastInsertRowID(), Conversion::toString(), and RelationalDBConnection::updateQuery().

Here is the call graph for this function:

◆ addSocketEntry()

RowID HDB::HDBManager::addSocketEntry ( ) const

Adds an empty Socket entry to the database.

Parameters
entryThe Socket entry.
Returns
ID of the added Socket entry.

Definition at line 3606 of file HDBManager.cc.

3606  {
3607  try {
3609  std::string("INSERT INTO socket(id) VALUES(NULL);"));
3610  return dbConnection_->lastInsertRowID();
3611  } catch (const Exception& e) {
3612  debugLog(e.errorMessage());
3613  assert(false);
3614  }
3615 
3616  // dummy return to avoid compiler whining
3617  assert(false);
3618  return 0;
3619 }

References assert, dbConnection_, debugLog, Exception::errorMessage(), RelationalDBConnection::lastInsertRowID(), and RelationalDBConnection::updateQuery().

Referenced by AddSocketEntryCmd::Do().

Here is the call graph for this function:

◆ areCompatiblePipelines()

bool HDB::HDBManager::areCompatiblePipelines ( const PipelineElementUsageTable table)
staticprivate

Checks whether the pipeline element usages of the given table are compatible.

They are compatible if the first pipeline is more restrictive or equal to the second pipeline.

Parameters
tableThe table that describes the pipeline usages.
Returns
True if the pipelines are compatible, otherwise false.

Definition at line 5634 of file HDBManager.cc.

5634  {
5635 
5636  for (size_t i = 0; i < table.size(); i++) {
5637  std::set<const PipelineElement*> usedResources1 = table[i].usage1;
5638  // create a set of vector indices which mean what stages cannot be
5639  // executed at the same time
5640  std::set<size_t> illegalStages1;
5641  for (size_t usageIndex = 0; usageIndex < table.size();
5642  usageIndex++) {
5643  if (usageIndex == i) {
5644  continue;
5645  }
5646  std::set<const PipelineElement*> resources =
5647  table[usageIndex].usage1;
5648  std::set<const PipelineElement*> intersect;
5649  SetTools::intersection(usedResources1, resources, intersect);
5650  if (!intersect.empty()) {
5651  illegalStages1.insert(usageIndex);
5652  }
5653  }
5654 
5655  // create a similar vector of the other pipeline
5656  std::set<const PipelineElement*> usedResources2 = table[i].usage2;
5657  std::set<size_t> illegalStages2;
5658  for (size_t usageIndex = 0; usageIndex < table.size();
5659  usageIndex++) {
5660  if (usageIndex == i) {
5661  continue;
5662  }
5663  std::set<const PipelineElement*> resources =
5664  table[usageIndex].usage2;
5665  std::set<const PipelineElement*> intersect;
5666  SetTools::intersection(usedResources2, resources, intersect);
5667  if (!intersect.empty()) {
5668  illegalStages2.insert(usageIndex);
5669  }
5670  }
5671 
5672  std::set<size_t> difference;
5673  AssocTools::difference(illegalStages2, illegalStages1, difference);
5674  if (!difference.empty()) {
5675  return false;
5676  }
5677  }
5678 
5679  return true;
5680 }

References AssocTools::difference(), and SetTools::intersection().

Referenced by isMatchingArchitecture().

Here is the call graph for this function:

◆ blockSourceFile()

std::list< std::string > HDB::HDBManager::blockSourceFile ( )

Returns block source file names

Returns
List of block source file names.

Definition at line 7138 of file HDBManager.cc.

7138  {
7139 
7140  RelationalDBQueryResult* queryResult;
7141  try {
7142  queryResult = dbConnection_->query(
7143  std::string("SELECT * FROM block_source_file"));
7144  } catch (const Exception& e) {
7145  debugLog(e.errorMessage());
7146  assert(false);
7147  }
7148 
7149  std::list<std::string> files;
7150  while (queryResult->hasNext()) {
7151  queryResult->next();
7152  files.push_back(queryResult->data(1).stringValue());
7153  }
7154 
7155  delete queryResult;
7156  return files;
7157 }

References assert, RelationalDBQueryResult::data(), dbConnection_, debugLog, Exception::errorMessage(), RelationalDBQueryResult::hasNext(), RelationalDBQueryResult::next(), RelationalDBConnection::query(), and DataObject::stringValue().

Here is the call graph for this function:

◆ busCostEstimationData()

DataObject HDB::HDBManager::busCostEstimationData ( const std::string &  valueName,
RowID  busID,
const std::string &  pluginName 
) const

Returns bus cost estimation data.

This version assumes that there's only one entry with given parameters.

Parameters
valueNameName of the value to fetch.
busIDThe ID of the bus entry.
pluginNameName of the cost estimation plugin that owns the data.
Returns
The data.
Exceptions
KeyNotFoundIf the HDB does not contain bus cost estimation data with the given arguments.

Definition at line 3506 of file HDBManager.cc.

3508  {
3509  RelationalDBQueryResult* queryResult = NULL;
3510  try {
3511  queryResult = dbConnection_->query(
3512  std::string(
3513  "SELECT value "
3514  "FROM cost_estimation_data, cost_function_plugin "
3515  "WHERE plugin_reference = cost_function_plugin.id AND "
3516  "cost_function_plugin.name LIKE('") +
3517  pluginName + "') " +
3518  " AND rf_reference IS NULL " +
3519  " AND socket_reference IS NULL AND " +
3520  " bus_reference = " + Conversion::toString(busID) +
3521  " AND cost_estimation_data.name LIKE('" + valueName + "');");
3522  } catch (const Exception& e) {
3523  // should not throw in any case
3524  debugLog(e.errorMessage());
3525  assert(false);
3526  }
3527 
3528  if (queryResult->hasNext()) {
3529  queryResult->next();
3530 
3531  DataObject value = queryResult->data("value");
3532 
3533  delete queryResult;
3534  queryResult = NULL;
3535 
3536  return value;
3537  } else {
3538  delete queryResult;
3539  throw KeyNotFound(__FILE__, __LINE__, __func__);
3540  }
3541  // silence compiler warning
3542  throw 1;
3543 }

References __func__, assert, RelationalDBQueryResult::data(), dbConnection_, debugLog, Exception::errorMessage(), RelationalDBQueryResult::hasNext(), RelationalDBQueryResult::next(), RelationalDBConnection::query(), and Conversion::toString().

Referenced by DefaultICDecoderEstimator::delayOfBus().

Here is the call graph for this function:

◆ busCostEstimationDataIDs()

std::set< RowID > HDB::HDBManager::busCostEstimationDataIDs ( RowID  busID) const

Returns a set of cost estimation data IDs which reference the given bus entry.

Parameters
busIDID of the bus entry.
Returns
Set of cost estimation data IDs.

Definition at line 6514 of file HDBManager.cc.

6514  {
6515 
6516  // make the SQL query to obtain IDs.
6517  RelationalDBQueryResult* queryResult = NULL;
6518  try {
6519  std::string theQuery =
6520  std::string(
6521  "SELECT id "
6522  "FROM cost_estimation_data "
6523  "WHERE bus_reference = ") +
6524  Conversion::toString(busID);
6525 
6526  queryResult = dbConnection_->query(theQuery);
6527 
6528  } catch (const Exception& e) {
6529  // should not throw in any case
6530  debugLog(e.errorMessage());
6531  assert(false);
6532  }
6533 
6534  std::set<RowID> ids;
6535 
6536  while (queryResult->hasNext()) {
6537  queryResult->next();
6538 
6539  ids.insert(queryResult->data("id").integerValue());
6540  }
6541 
6542  delete queryResult;
6543  queryResult = NULL;
6544  return ids;
6545 }

References assert, RelationalDBQueryResult::data(), dbConnection_, debugLog, Exception::errorMessage(), RelationalDBQueryResult::hasNext(), DataObject::integerValue(), RelationalDBQueryResult::next(), RelationalDBConnection::query(), and Conversion::toString().

Referenced by HDBToHtml::busEntryToHtml().

Here is the call graph for this function:

◆ busCostEstimationDataList()

HDBManager::DataObjectList * HDB::HDBManager::busCostEstimationDataList ( const std::string &  valueName,
RowID  busID,
const std::string &  pluginName 
) const

Returns a list of bus cost estimation data.

Parameters
valueNameName of the value to fetch.
busIDThe ID of the bus entry.
pluginNameName of the cost estimation plugin that owns the data.
Returns
The data. Becomes property of the caller.
Exceptions
KeyNotFoundIf the HDB does not contain bus cost estimation data with the given arguments.

Definition at line 3556 of file HDBManager.cc.

3558  {
3559  RelationalDBQueryResult* queryResult = NULL;
3560  try {
3561  queryResult = dbConnection_->query(
3562  std::string(
3563  "SELECT value "
3564  "FROM cost_estimation_data, cost_function_plugin "
3565  "WHERE plugin_reference = cost_function_plugin.id AND "
3566  "cost_function_plugin.name LIKE('") +
3567  pluginName + "') " +
3568  " AND rf_reference IS NULL " +
3569  " AND socket_reference IS NULL AND " +
3570  " bus_reference = " + Conversion::toString(busID) +
3571  " AND cost_estimation_data.name LIKE('" + valueName + "');");
3572  } catch (const Exception& e) {
3573  // should not throw in any case
3574  debugLog(e.errorMessage());
3575  assert(false);
3576  }
3577 
3578  if (queryResult->hasNext()) {
3579 
3580  DataObjectList* data = new DataObjectList;
3581 
3582  while (queryResult->hasNext()) {
3583  queryResult->next();
3584  DataObject value = queryResult->data("value");
3585  data->push_back(value);
3586  }
3587 
3588  delete queryResult;
3589  queryResult = NULL;
3590  return data;
3591  } else {
3592  delete queryResult;
3593  throw KeyNotFound(__FILE__, __LINE__, __func__);
3594  }
3595  // silence compiler warning
3596  throw 1;
3597 }

References __func__, assert, RelationalDBQueryResult::data(), dbConnection_, debugLog, Exception::errorMessage(), RelationalDBQueryResult::hasNext(), RelationalDBQueryResult::next(), RelationalDBConnection::query(), and Conversion::toString().

Here is the call graph for this function:

◆ busEntryByIDQuery()

std::string HDB::HDBManager::busEntryByIDQuery ( RowID  id)
staticprivate

Creates an SQL query for getting the Bus entry that has the given ID.

The result set has fields {id}.

Parameters
idID of the entry.
Returns
The SQL query.

Definition at line 5819 of file HDBManager.cc.

5819  {
5820  string idString = Conversion::toString(id);
5821  string query =
5822  "SELECT * "
5823  "FROM bus "
5824  "WHERE bus.id=" + idString + ";";
5825  return query;
5826 }

References Conversion::toString().

Referenced by hasBusEntry().

Here is the call graph for this function:

◆ busEntryIDs()

std::set< RowID > HDB::HDBManager::busEntryIDs ( ) const

Returns a set of Bus entry IDs in the database.

Returns
A set containing all the Bus entry IDs in the database.

Definition at line 2099 of file HDBManager.cc.

2099  {
2100 
2101  string query = "SELECT id AS 'bus.id' FROM bus;";
2102 
2103  // make the SQL query to obtain all the IDs
2104  RelationalDBQueryResult* queryResult = NULL;
2105  try {
2106  queryResult = dbConnection_->query(query);
2107  } catch (const Exception& e) {
2108  // should not throw in any case
2109  debugLog(e.errorMessage());
2110  assert(false);
2111  }
2112 
2113  std::set<RowID> idSet;
2114  while (queryResult->hasNext()) {
2115  queryResult->next();
2116  const DataObject& idData = queryResult->data("bus.id");
2117  idSet.insert(idData.integerValue());
2118  }
2119 
2120  delete queryResult;
2121  return idSet;
2122 }

References assert, RelationalDBQueryResult::data(), dbConnection_, debugLog, Exception::errorMessage(), RelationalDBQueryResult::hasNext(), DataObject::integerValue(), RelationalDBQueryResult::next(), and RelationalDBConnection::query().

Referenced by CostDatabase::buildBuses().

Here is the call graph for this function:

◆ canRemoveFUArchitecture()

bool HDB::HDBManager::canRemoveFUArchitecture ( RowID  archID) const

Tells whether the FU architecture that has the given ID can be removed from the database. It can be removed only if no FU entry uses it.

Parameters
archIDID of the FU architecture.
Returns
True if the architecture can be removed, otherwise false.

Definition at line 904 of file HDBManager.cc.

904  {
905 
906  // check whether the architecture is used by FU entries
907  try {
909  std::string(
910  "SELECT id FROM fu WHERE architecture=" +
911  Conversion::toString(archID) + ";"));
912  if (queryResult->hasNext()) {
913  // there is an FU entry using the architecture
914  delete queryResult;
915  return false;
916  } else {
917  delete queryResult;
918  return true;
919  }
920  } catch (const Exception& e) {
921  debugLog(e.errorMessage());
922  assert(false);
923  }
924 
925  // dummy return to avoid compiler whining
926  assert(false);
927  return false;
928 }

References assert, dbConnection_, debugLog, Exception::errorMessage(), RelationalDBQueryResult::hasNext(), RelationalDBConnection::query(), and Conversion::toString().

Referenced by HDBEditorDeleteCmd::Do(), and removeFUArchitecture().

Here is the call graph for this function:

◆ canRemoveRFArchitecture()

bool HDB::HDBManager::canRemoveRFArchitecture ( RowID  archID) const

Tells whether the given RF architecture can be removed.

The architecture can be removed if it is not used by any RF entry.

Parameters
archIDID of the RF architecture.

Definition at line 1508 of file HDBManager.cc.

1508  {
1509  try {
1511  std::string(
1512  "SELECT id FROM rf WHERE architecture=" +
1513  Conversion::toString(archID) + ";"));
1514  bool returnValue = !result->hasNext();
1515  delete result;
1516  return returnValue;
1517  } catch (const Exception& e) {
1518  debugLog(e.errorMessage());
1519  assert(false);
1520  }
1521 
1522  // dummy return to avoid compiler whining
1523  assert(false);
1524  return false;
1525 }

References assert, dbConnection_, debugLog, Exception::errorMessage(), RelationalDBQueryResult::hasNext(), RelationalDBConnection::query(), and Conversion::toString().

Referenced by HDBEditorDeleteCmd::Do(), and removeRFArchitecture().

Here is the call graph for this function:

◆ containsFUArchitecture()

bool HDB::HDBManager::containsFUArchitecture ( RowID  id) const
private

Tells whether the HDB contains a FU architecture that has the given ID.

Parameters
idThe ID.
Returns
True if the HDB contains the architecture, otherwise false.

Definition at line 4212 of file HDBManager.cc.

4212  {
4213 
4214  try {
4216  std::string(
4217  "SELECT id FROM fu_architecture WHERE id=" +
4218  Conversion::toString(id) + ";"));
4219  bool returnValue = result->hasNext();
4220  delete result;
4221  return returnValue;
4222  } catch (const Exception& e) {
4223  debugLog(e.errorMessage());
4224  assert(false);
4225  }
4226 
4227  // dummy return to avoid compiler whining
4228  assert(false);
4229  return false;
4230 }

References assert, dbConnection_, debugLog, Exception::errorMessage(), RelationalDBQueryResult::hasNext(), RelationalDBConnection::query(), and Conversion::toString().

Referenced by fuArchitectureByID(), and setArchitectureForFU().

Here is the call graph for this function:

◆ containsImplementationFile()

bool HDB::HDBManager::containsImplementationFile ( const std::string &  pathToFile) const
private

Tells whether the HDB contains the given block implementation file.

Parameters
pathToFileFull path to the file.

Definition at line 4185 of file HDBManager.cc.

4185  {
4186  try {
4188  std::string(
4189  "SELECT * FROM block_source_file WHERE file=\"" +
4190  pathToFile + "\";"));
4191  bool returnValue = result->hasNext();
4192  delete result;
4193  return returnValue;
4194  } catch (const Exception& e) {
4195  debugLog(e.errorMessage());
4196  assert(false);
4197  }
4198 
4199  // dummy return to avoid compiler whining
4200  assert(false);
4201  return false;
4202 }

References assert, dbConnection_, debugLog, Exception::errorMessage(), RelationalDBQueryResult::hasNext(), and RelationalDBConnection::query().

Referenced by addBlockImplementationFileToHDB().

Here is the call graph for this function:

◆ containsOperation()

bool HDB::HDBManager::containsOperation ( const std::string &  opName) const
private

Tells whether the HDB contains the given operation in operation table.

Parameters
opNameName of the operation.
Returns
True if HDB contains the operation, otherwise false.

Definition at line 4159 of file HDBManager.cc.

4159  {
4160  try {
4162  std::string(
4163  "SELECT * FROM operation WHERE lower(name)=lower(\"" + opName
4164  + "\");"));
4165  bool returnValue = result->hasNext();
4166  delete result;
4167  return returnValue;
4168  } catch (const Exception& e) {
4169  debugLog(e.errorMessage());
4170  assert(false);
4171  }
4172 
4173  // dummy return to avoid compiler whining
4174  assert(false);
4175  return false;
4176 }

References assert, dbConnection_, debugLog, Exception::errorMessage(), RelationalDBQueryResult::hasNext(), and RelationalDBConnection::query().

Referenced by addFUArchitecture(), and addFUImplementation().

Here is the call graph for this function:

◆ containsRFArchitecture()

bool HDB::HDBManager::containsRFArchitecture ( RowID  id) const
private

Tells whether the HDB contains a RF architecture with the given ID.

Parameters
idThe ID.
Returns
True if the HDB contains the architecture, otherwise false.

Definition at line 4240 of file HDBManager.cc.

4240  {
4241  try {
4243  std::string(
4244  "SELECT id FROM rf_architecture WHERE id=" +
4245  Conversion::toString(id) + ";"));
4246  bool returnValue = result->hasNext();
4247  delete result;
4248  return returnValue;
4249  } catch (const Exception& e) {
4250  debugLog(e.errorMessage());
4251  assert(false);
4252  }
4253 
4254  // dummy return to avoid compiler whining
4255  assert(false);
4256  return false;
4257 }

References assert, dbConnection_, debugLog, Exception::errorMessage(), RelationalDBQueryResult::hasNext(), RelationalDBConnection::query(), and Conversion::toString().

Referenced by rfArchitectureByID(), and setArchitectureForRF().

Here is the call graph for this function:

◆ costEstimationData()

CostEstimationData HDB::HDBManager::costEstimationData ( RowID  entryId) const

Returns cost estimation data with the given id.

Parameters
entryIdId of the cost estimation data entry.
Returns
The data.
Exceptions
KeyNotFoundIf the HDB does not contain cost estimation data with the given arguments.

Definition at line 6323 of file HDBManager.cc.

6323  {
6324  // make the SQL query to obtain implementation data
6325  RelationalDBQueryResult* queryResult = NULL;
6326  try {
6327  std::string theQuery =
6328  std::string(
6329  "SELECT value, cost_estimation_data.name AS data_name, "
6330  " cost_function_plugin.id AS plugin_id, "
6331  " fu_reference, rf_reference, bus_reference, "
6332  " socket_reference "
6333  "FROM cost_estimation_data, cost_function_plugin "
6334  "WHERE cost_estimation_data.plugin_reference="
6335  " cost_function_plugin.id AND "
6336  " cost_estimation_data.id = ") +
6337  Conversion::toString(entryId);
6338 
6339  queryResult = dbConnection_->query(theQuery);
6340 
6341  } catch (const Exception& e) {
6342  // should not throw in any case
6343  debugLog(e.errorMessage());
6344  assert(false);
6345  }
6346 
6347  if (queryResult->hasNext()) {
6348  queryResult->next();
6349 
6350  std::string name = queryResult->data("data_name").stringValue();
6351 
6352  CostEstimationData data;
6353  data.setName(name);
6354  data.setValue(queryResult->data("value"));
6355  data.setPluginID(queryResult->data("plugin_id").integerValue());
6356 
6357  if (!queryResult->data("fu_reference").isNull()) {
6358  data.setFUReference(queryResult->data("fu_reference").integerValue());
6359  }
6360  if (!queryResult->data("rf_reference").isNull()) {
6361  data.setRFReference(queryResult->data("rf_reference").integerValue());
6362  }
6363  if (!queryResult->data("bus_reference").isNull()) {
6364  data.setBusReference(queryResult->data("bus_reference").integerValue());
6365  }
6366  if (!queryResult->data("socket_reference").isNull()) {
6367  data.setSocketReference(
6368  queryResult->data("socket_reference").integerValue());
6369  }
6370 
6371  delete queryResult;
6372  queryResult = NULL;
6373 
6374  return data;
6375  } else {
6376  delete queryResult;
6377  throw KeyNotFound(__FILE__, __LINE__, __func__);
6378  }
6379  // silence compiler warning
6380  throw 1;
6381 }

References __func__, assert, RelationalDBQueryResult::data(), dbConnection_, debugLog, Exception::errorMessage(), RelationalDBQueryResult::hasNext(), DataObject::integerValue(), DataObject::isNull(), RelationalDBQueryResult::next(), RelationalDBConnection::query(), CostEstimationData::setBusReference(), CostEstimationData::setFUReference(), CostEstimationData::setName(), CostEstimationData::setPluginID(), CostEstimationData::setRFReference(), CostEstimationData::setSocketReference(), CostEstimationData::setValue(), DataObject::stringValue(), and Conversion::toString().

Referenced by CostDatabase::buildBuses(), CostDatabase::buildFunctionUnits(), CostDatabase::buildRegisterFiles(), CostDatabase::buildSockets(), HDBToHtml::busEntryToHtml(), HDBToHtml::costFunctionPluginToHtml(), HDBToHtml::fuEntryToHtml(), HDBToHtml::fuImplToHtml(), HDBToHtml::rfEntryToHtml(), HDBToHtml::rfImplToHtml(), and HDBToHtml::socketEntryToHtml().

Here is the call graph for this function:

◆ costEstimationDataIDs()

std::set< RowID > HDB::HDBManager::costEstimationDataIDs ( const CostEstimationData match,
bool  useCompiledQueries = false,
RelationalDBQueryResult compiledQuery = NULL 
) const
virtual

Function for querying cost estimation data from the HDB.

Returns set of cost estiamtion data Row IDs that match the given datas attributes that are set.

Parameters
matchCostEstimationData which is matched to the HDB data.
useCompiledQueriesif true use a compiled query instead of making a new one.
compiledQueryPointer to a prepared query to be used.
Returns
Set of cost estimation data row IDs that match the query.

Reimplemented in HDB::CachedHDBManager.

Definition at line 6778 of file HDBManager.cc.

6781  {
6782 
6783  std::string query = "";
6784  if (!compiledQuery) {
6785  createCostEstimatioDataIdsQuery(match, &query);
6786  } else {
6787  // only bind query variables
6788  createCostEstimatioDataIdsQuery(match, NULL, compiledQuery, NULL);
6789  }
6790 
6791  RelationalDBQueryResult* result = NULL;
6792 
6793  if (compiledQuery) {
6794  result = compiledQuery;
6795  } else {
6796  try {
6797  result = dbConnection_->query(query);
6798  } catch (const Exception& e) {
6799  debugLog(query);
6800  debugLog(e.errorMessage());
6801  assert(false);
6802  }
6803  }
6804 
6805  std::set<RowID> dataIDs;
6806  while (result->hasNext()) {
6807  result->next();
6808  dataIDs.insert(result->data(0).integerValue());
6809  }
6810 
6811  if (!compiledQuery) {
6812  delete result;
6813  } else {
6814  compiledQuery->reset();
6815  }
6816 
6817  return dataIDs;
6818 }

References assert, createCostEstimatioDataIdsQuery(), RelationalDBQueryResult::data(), dbConnection_, debugLog, Exception::errorMessage(), RelationalDBQueryResult::hasNext(), DataObject::integerValue(), RelationalDBQueryResult::next(), RelationalDBConnection::query(), and RelationalDBQueryResult::reset().

Referenced by CostDatabase::buildBuses(), CostDatabase::buildFunctionUnits(), CostDatabase::buildRegisterFiles(), CostDatabase::buildSockets(), and HDB::CachedHDBManager::costEstimationDataIDs().

Here is the call graph for this function:

◆ costEstimationDataValue() [1/2]

DataObject HDB::HDBManager::costEstimationDataValue ( const std::string &  valueName,
const std::string &  pluginName 
) const
virtual

Returns cost estimation data which is not connected to any machine implementation id.

This version assumes that there's only one entry with given parameters.

Todo:
Another version for fetching lists of data.
Parameters
valueNameName of the value to fetch.
pluginNameName of the cost estimation plugin that owns the data.
Returns
The data.
Exceptions
KeyNotFoundIf the HDB does not contain cost estimation data with the given arguments.

Reimplemented in HDB::CachedHDBManager.

Definition at line 3831 of file HDBManager.cc.

3832  {
3833  // make the SQL query to obtain implementation data
3834  RelationalDBQueryResult* queryResult = NULL;
3835  try {
3836  std::string theQuery =
3837  std::string(
3838  "SELECT value "
3839  "FROM cost_estimation_data, cost_function_plugin "
3840  "WHERE plugin_reference = cost_function_plugin.id AND "
3841  "cost_function_plugin.name LIKE('") +
3842  pluginName + "') " +
3843  " AND rf_reference IS NULL " +
3844  " AND fu_reference IS NULL " +
3845  " AND socket_reference IS NULL " +
3846  " AND bus_reference IS NULL " +
3847  " AND cost_estimation_data.name LIKE('" + valueName + "');";
3848  queryResult = dbConnection_->query(theQuery);
3849 
3850  } catch (const Exception& e) {
3851  // should not throw in any case
3852  debugLog(e.errorMessage());
3853  assert(false);
3854  }
3855 
3856  if (queryResult->hasNext()) {
3857  queryResult->next();
3858 
3859  DataObject value = queryResult->data("value");
3860 
3861  delete queryResult;
3862  queryResult = NULL;
3863 
3864  return value;
3865  } else {
3866  delete queryResult;
3867  throw KeyNotFound(__FILE__, __LINE__, __func__);
3868  }
3869  // silence compiler warning
3870  throw 1;
3871 }

References __func__, assert, RelationalDBQueryResult::data(), dbConnection_, debugLog, Exception::errorMessage(), RelationalDBQueryResult::hasNext(), RelationalDBQueryResult::next(), and RelationalDBConnection::query().

Referenced by HDB::CachedHDBManager::costEstimationDataValue(), DefaultICDecoderEstimator::delayOfBus(), DefaultICDecoderEstimator::delayOfSocket(), DefaultICDecoderEstimator::estimateICArea(), and DefaultICDecoderEstimator::estimateICEnergy().

Here is the call graph for this function:

◆ costEstimationDataValue() [2/2]

DataObject HDB::HDBManager::costEstimationDataValue ( RowID  entryId) const

Returns cost estimation data value with the given id.

Parameters
entryIdId of the cost estimation data entry.
Returns
The data.
Exceptions
KeyNotFoundIf the HDB does not contain cost estimation data with the given arguments.

Definition at line 3882 of file HDBManager.cc.

3882  {
3883  // make the SQL query to obtain implementation data
3884  RelationalDBQueryResult* queryResult = NULL;
3885  try {
3886  std::string theQuery =
3887  std::string(
3888  "SELECT value "
3889  "FROM cost_estimation_data "
3890  "WHERE cost_estimation_data.id = ") +
3891  Conversion::toString(entryId);
3892 
3893  queryResult = dbConnection_->query(theQuery);
3894 
3895  } catch (const Exception& e) {
3896  // should not throw in any case
3897  debugLog(e.errorMessage());
3898  assert(false);
3899  }
3900 
3901  if (queryResult->hasNext()) {
3902  queryResult->next();
3903 
3904  DataObject value = queryResult->data("value");
3905 
3906  delete queryResult;
3907  queryResult = NULL;
3908 
3909  return value;
3910  } else {
3911  delete queryResult;
3912  throw KeyNotFound(__FILE__, __LINE__, __func__);
3913  }
3914  // silence compiler warning
3915  throw 1;
3916 }

References __func__, assert, RelationalDBQueryResult::data(), dbConnection_, debugLog, Exception::errorMessage(), RelationalDBQueryResult::hasNext(), RelationalDBQueryResult::next(), RelationalDBConnection::query(), and Conversion::toString().

Here is the call graph for this function:

◆ costFunctionPluginByID()

CostFunctionPlugin * HDB::HDBManager::costFunctionPluginByID ( RowID  pluginID) const

Returns cost function plugin with the given ID.

Parameters
pluginIDID of the cost function plugin.
Returns
Cost function plugin with the given ID.
Exceptions
ExceptionThrows if pluginID not found (KeyNotFound) or illegal cost_function_plugin row found.

Definition at line 6631 of file HDBManager.cc.

6631  {
6632  RelationalDBQueryResult* pluginData;
6633 
6634  std::string pluginDataQuery =
6635  "SELECT id, description, name, plugin_file_path, type "
6636  " FROM cost_function_plugin WHERE id = ";
6637 
6638  pluginDataQuery += Conversion::toString(pluginID);
6639 
6640  try {
6641  pluginData = dbConnection_->query(pluginDataQuery);
6642  } catch (const Exception& e) {
6643  debugLog(e.errorMessage());
6644  assert(false);
6645  }
6646 
6647  if (pluginData->hasNext()) {
6648  pluginData->next();
6649 
6650  int id = pluginData->data("id").integerValue();
6651  std::string name = pluginData->data("name").stringValue();
6652  std::string desc = pluginData->data("description").stringValue();
6653  std::string path = pluginData->data("plugin_file_path").stringValue();
6654  std::string typeStr = pluginData->data("type").stringValue();
6655 
6658  if (typeStr == COST_PLUGIN_TYPE_FU) {
6660  } else if (typeStr == COST_PLUGIN_TYPE_RF) {
6662  } else if (typeStr == COST_PLUGIN_TYPE_DECOMP) {
6664  } else if (typeStr == COST_PLUGIN_TYPE_ICDEC) {
6666  } else {
6667  delete pluginData;
6668  InvalidData ex(
6669  __FILE__, __LINE__, __func__,
6670  (boost::format("Illegal cost_function_plugin type %d.") %
6671  type).str());
6672  throw ex;
6673  }
6674 
6675  delete pluginData;
6676  return new CostFunctionPlugin(id, desc, name, path, type);
6677 
6678  } else {
6679  delete pluginData;
6680  throw KeyNotFound(
6681  __FILE__, __LINE__, __func__,
6682  (boost::format("Cost function plugin with id %d not found.") %
6683  pluginID).str());
6684  }
6685 }

References __func__, assert, HDB::CostFunctionPlugin::COST_DECOMP, HDB::CostFunctionPlugin::COST_FU, HDB::CostFunctionPlugin::COST_ICDEC, COST_PLUGIN_TYPE_DECOMP, COST_PLUGIN_TYPE_FU, COST_PLUGIN_TYPE_ICDEC, COST_PLUGIN_TYPE_RF, HDB::CostFunctionPlugin::COST_RF, RelationalDBQueryResult::data(), dbConnection_, debugLog, Exception::errorMessage(), RelationalDBQueryResult::hasNext(), DataObject::integerValue(), RelationalDBQueryResult::next(), RelationalDBConnection::query(), DataObject::stringValue(), and Conversion::toString().

Referenced by CostDatabase::buildBuses(), CostDatabase::buildFunctionUnits(), CostDatabase::buildRegisterFiles(), CostDatabase::buildSockets(), HDBToHtml::costFunctionPluginToHtml(), and SetCostFunctionPluginCmd::Do().

Here is the call graph for this function:

◆ costFunctionPluginDataIDs()

std::set< RowID > HDB::HDBManager::costFunctionPluginDataIDs ( RowID  pluginID) const

Returns cost estimation data IDs related to the given cost function plugin.

Parameters
pluginIDID of the cost function plugin.
Returns
IDs of the cost function plugin estimation data.

Definition at line 6589 of file HDBManager.cc.

6589  {
6590 
6591  // make the SQL query to obtain IDs.
6592  RelationalDBQueryResult* queryResult = NULL;
6593  try {
6594  std::string theQuery =
6595  std::string(
6596  "SELECT id "
6597  "FROM cost_estimation_data "
6598  "WHERE plugin_reference = ") +
6599  Conversion::toString(pluginID);
6600 
6601  queryResult = dbConnection_->query(theQuery);
6602 
6603  } catch (const Exception& e) {
6604  // should not throw in any case
6605  debugLog(e.errorMessage());
6606  assert(false);
6607  }
6608 
6609  std::set<RowID> ids;
6610 
6611  while (queryResult->hasNext()) {
6612  queryResult->next();
6613 
6614  ids.insert(queryResult->data("id").integerValue());
6615  }
6616 
6617  delete queryResult;
6618  queryResult = NULL;
6619  return ids;
6620 }

References assert, RelationalDBQueryResult::data(), dbConnection_, debugLog, Exception::errorMessage(), RelationalDBQueryResult::hasNext(), DataObject::integerValue(), RelationalDBQueryResult::next(), RelationalDBConnection::query(), and Conversion::toString().

Referenced by HDBToHtml::costFunctionPluginToHtml().

Here is the call graph for this function:

◆ costFunctionPluginIDs()

std::set< RowID > HDB::HDBManager::costFunctionPluginIDs ( ) const

Returns RowIDs of cost fucntion plugins in the HDB.

Returns
All cost function plugin IDs.

Definition at line 6553 of file HDBManager.cc.

6553  {
6554 
6555  // make the SQL query to obtain IDs.
6556  RelationalDBQueryResult* queryResult = NULL;
6557  try {
6558  std::string theQuery =
6559  "SELECT id FROM cost_function_plugin";
6560 
6561  queryResult = dbConnection_->query(theQuery);
6562 
6563  } catch (const Exception& e) {
6564  // should not throw in any case
6565  debugLog(e.errorMessage());
6566  assert(false);
6567  }
6568 
6569  std::set<RowID> ids;
6570 
6571  while (queryResult->hasNext()) {
6572  queryResult->next();
6573 
6574  ids.insert(queryResult->data("id").integerValue());
6575  }
6576 
6577  delete queryResult;
6578  queryResult = NULL;
6579  return ids;
6580 }

References assert, RelationalDBQueryResult::data(), dbConnection_, debugLog, Exception::errorMessage(), RelationalDBQueryResult::hasNext(), DataObject::integerValue(), RelationalDBQueryResult::next(), and RelationalDBConnection::query().

Referenced by CostDatabase::buildBuses(), CostDatabase::buildFunctionUnits(), CostDatabase::buildRegisterFiles(), CostDatabase::buildSockets(), and SetCostFunctionPluginCmd::Do().

Here is the call graph for this function:

◆ createCostEstimatioDataIdsQuery() [1/2]

void HDB::HDBManager::createCostEstimatioDataIdsQuery ( const CostEstimationData match,
std::string &  query 
) const
private

◆ createCostEstimatioDataIdsQuery() [2/2]

void HDB::HDBManager::createCostEstimatioDataIdsQuery ( const CostEstimationData match,
std::string *  query,
RelationalDBQueryResult compiledQuery = NULL,
short int *  queryHash = NULL,
bool  createBindableQuery = false 
) const
protected

Creates or prepares the query for cost estimation data ids.

Parameters
matchCostEstimationData which is matched to the HDB data.
queryString variable where query is stored, null if no query is to be created.
compiledQueryPointer to a prepared query to be used, null if not to be used.
queryHashPointer to unique id variable to be created for the query, null if not to be created.
createBindableQueryIf true query of a kind where variables can be binded is created, if false normal query with values is created.

Definition at line 6835 of file HDBManager.cc.

6840  {
6841 
6842  if (queryHash) {
6843  *queryHash = 0;
6844  }
6845  bool firstMatch = true;
6846  unsigned int count = 0;
6847 
6848  if (query) {
6849  *query = "SELECT id FROM cost_estimation_data WHERE ";
6850  }
6851 
6852  if (match.hasName()) {
6853  if (queryHash) {
6854  *queryHash |= 1;
6855  }
6856 
6857  if (compiledQuery) {
6858  compiledQuery->bindString(++count, match.name());
6859  }
6860 
6861  if (query) {
6862  firstMatch = false;
6863  *query += "name='";
6864  *query += createBindableQuery ? "?" : match.name();
6865  *query += "'";
6866  }
6867  }
6868 
6869  if (match.hasValue()) {
6870  if (queryHash) {
6871  *queryHash |= 2;
6872  }
6873 
6874  if (compiledQuery) {
6875  compiledQuery->bindString(++count, match.name());
6876  }
6877 
6878  if (query) {
6879  if (!firstMatch) *query += " AND ";
6880  firstMatch = false;
6881  *query += "value='";
6882  *query += createBindableQuery ? "?" : match.name();
6883  *query += "'";
6884  }
6885  }
6886 
6887  if (match.hasPluginID()) {
6888  if (queryHash) {
6889  *queryHash |= 4;
6890  }
6891 
6892  if (compiledQuery) {
6893  compiledQuery->bindInt(++count, match.pluginID());
6894  }
6895 
6896  if (query) {
6897  if (!firstMatch) *query += " AND ";
6898  firstMatch = false;
6899  *query += "plugin_reference = ";
6900  *query += createBindableQuery ? "?" :
6901  Conversion::toString(match.pluginID());
6902  }
6903  }
6904 
6905  if (match.hasFUReference()) {
6906  if (queryHash) {
6907  *queryHash |= 8;
6908  }
6909 
6910  if (compiledQuery) {
6911  compiledQuery->bindInt(++count, match.fuReference());
6912  }
6913 
6914  if (query) {
6915  if (!firstMatch) *query += " AND ";
6916  firstMatch = false;
6917  *query += "fu_reference = ";
6918  *query += createBindableQuery ? "?" :
6920  }
6921  }
6922 
6923  if (match.hasRFReference()) {
6924  if (queryHash) {
6925  *queryHash |= 16;
6926  }
6927 
6928  if (compiledQuery) {
6929  compiledQuery->bindInt(++count, match.rfReference());
6930  }
6931 
6932  if (query) {
6933  if (!firstMatch) *query += " AND ";
6934  firstMatch = false;
6935  *query += "rf_reference = ";
6936  *query += createBindableQuery ? "?" :
6938  }
6939  }
6940 
6941  if (match.hasBusReference()) {
6942  if (queryHash) {
6943  *queryHash |= 32;
6944  }
6945 
6946  if (compiledQuery) {
6947  compiledQuery->bindInt(++count, match.rfReference());
6948  }
6949 
6950  if (query) {
6951  if (!firstMatch) *query += " AND ";
6952  firstMatch = false;
6953  *query += "bus_reference = ";
6954  *query += createBindableQuery ? "?" :
6956  }
6957  }
6958 
6959  if (match.hasSocketReference()) {
6960  if (queryHash) {
6961  *queryHash |= 64;
6962  }
6963 
6964  if (compiledQuery) {
6965  compiledQuery->bindInt(++count, match.rfReference());
6966  }
6967 
6968  if (query) {
6969  if (!firstMatch) *query += " AND ";
6970  firstMatch = false;
6971  *query += "socket_reference = ";
6972  *query += createBindableQuery ? "?" :
6974  }
6975  }
6976 
6977  if (query) {
6978  *query += ";";
6979  }
6980 }

References RelationalDBQueryResult::bindInt(), RelationalDBQueryResult::bindString(), CostEstimationData::busReference(), CostEstimationData::fuReference(), CostEstimationData::hasBusReference(), CostEstimationData::hasFUReference(), CostEstimationData::hasName(), CostEstimationData::hasPluginID(), CostEstimationData::hasRFReference(), CostEstimationData::hasSocketReference(), CostEstimationData::hasValue(), CostEstimationData::name(), CostEstimationData::pluginID(), CostEstimationData::rfReference(), CostEstimationData::socketReference(), and Conversion::toString().

Referenced by HDB::CachedHDBManager::costEstimationDataIDs(), and costEstimationDataIDs().

Here is the call graph for this function:

◆ createCostFunctionOfFU()

CostFunctionPlugin * HDB::HDBManager::createCostFunctionOfFU ( RowID  id) const
private

Obtains the cost function data of the FU that has the given ID and creates a CostFunctionPlugin instance of it.

Parameters
idID of the FU entry.
Returns
The newly created FUImplementation instance or NULL if the FU has no cost function.

Definition at line 4691 of file HDBManager.cc.

4691  {
4692 
4693  // make the SQL query to obtain implementation data
4694  RelationalDBQueryResult* queryResult = NULL;
4695  try {
4696  queryResult = dbConnection_->query(
4697  "SELECT cost_function_plugin.id AS id, "
4698  " cost_function_plugin.description AS description,"
4699  " cost_function_plugin.name AS name, "
4700  " cost_function_plugin.plugin_file_path AS plugin_file_path "
4701  "FROM cost_function_plugin, fu "
4702  "WHERE fu.id = " + Conversion::toString(id) +
4703  " AND cost_function_plugin.id = fu.cost_function;");
4704  } catch (const Exception& e) {
4705  delete queryResult;
4706  debugLog(e.errorMessage());
4707  return NULL;
4708  }
4709 
4710  CostFunctionPlugin* costFunction = NULL;
4711 
4712  if (queryResult->hasNext()) {
4713  queryResult->next();
4714 
4715  const DataObject& pluginIdData =
4716  queryResult->data("id");
4717  const DataObject& descriptionData =
4718  queryResult->data("description");
4719  const DataObject& nameData =
4720  queryResult->data("name");
4721  const DataObject& pluginFilePathData =
4722  queryResult->data("plugin_file_path");
4723 
4724  int pluginId = -1;
4725  string description = "";
4726  string name = "";
4727  string pluginFilePath = "";
4728  try {
4729  if (!pluginIdData.isNull()) {
4730  pluginId = pluginIdData.integerValue();
4731  }
4732  description = descriptionData.stringValue();
4733  name = nameData.stringValue();
4734  pluginFilePath = pluginFilePathData.stringValue();
4735  } catch (const Exception& e) {
4736  debugLog(
4737  std::string("Something wrong with conversion: ") +
4738  e.errorMessage());
4739  delete queryResult;
4740  queryResult = NULL;
4741  return NULL;
4742  }
4743 
4744  costFunction = new CostFunctionPlugin(
4745  pluginId, description, name, pluginFilePath,
4747  }
4748 
4749  delete queryResult;
4750  queryResult = NULL;
4751  return costFunction;
4752 }

References HDB::CostFunctionPlugin::COST_FU, RelationalDBQueryResult::data(), dbConnection_, debugLog, Exception::errorMessage(), RelationalDBQueryResult::hasNext(), DataObject::integerValue(), DataObject::isNull(), RelationalDBQueryResult::next(), RelationalDBConnection::query(), DataObject::stringValue(), and Conversion::toString().

Referenced by fuByEntryID().

Here is the call graph for this function:

◆ createCostFunctionOfRF()

CostFunctionPlugin * HDB::HDBManager::createCostFunctionOfRF ( RowID  id) const
private

Obtains the cost function data of the RF that has the given ID and creates a CostFunctionPlugin instance of it.

Parameters
idID of the RF entry.
Returns
The newly created FUImplementation instance or NULL if the RF has no cost function.

Definition at line 4763 of file HDBManager.cc.

4763  {
4764 
4765  // make the SQL query to obtain implementation data
4766  RelationalDBQueryResult* queryResult = NULL;
4767  try {
4768  queryResult = dbConnection_->query(
4769  "SELECT cost_function_plugin.id AS id, "
4770  " cost_function_plugin.description AS description,"
4771  " cost_function_plugin.name AS name, "
4772  " cost_function_plugin.plugin_file_path AS plugin_file_path "
4773  "FROM cost_function_plugin, rf "
4774  "WHERE rf.id = " + Conversion::toString(id) +
4775  " AND cost_function_plugin.id = rf.cost_function;");
4776  } catch (const Exception& e) {
4777  delete queryResult;
4778  debugLog(e.errorMessage());
4779  return NULL;
4780  }
4781 
4782  CostFunctionPlugin* costFunction = NULL;
4783 
4784  if (queryResult->hasNext()) {
4785  queryResult->next();
4786 
4787  const DataObject& pluginIdData =
4788  queryResult->data("id");
4789  const DataObject& descriptionData =
4790  queryResult->data("description");
4791  const DataObject& nameData =
4792  queryResult->data("name");
4793  const DataObject& pluginFilePathData =
4794  queryResult->data("plugin_file_path");
4795 
4796  int pluginId = -1;
4797  string description = "";
4798  string name = "";
4799  string pluginFilePath = "";
4800  try {
4801  if (!pluginIdData.isNull()) {
4802  pluginId = pluginIdData.integerValue();
4803  }
4804  description = descriptionData.stringValue();
4805  name = nameData.stringValue();
4806  pluginFilePath = pluginFilePathData.stringValue();
4807  } catch (const Exception& e) {
4808  debugLog(
4809  std::string("Something wrong with conversion: ") +
4810  e.errorMessage());
4811  delete queryResult;
4812  queryResult = NULL;
4813  return NULL;
4814  }
4815 
4816  costFunction = new CostFunctionPlugin(
4817  pluginId, description, name, pluginFilePath,
4819  }
4820 
4821  delete queryResult;
4822  queryResult = NULL;
4823  return costFunction;
4824 }

References HDB::CostFunctionPlugin::COST_RF, RelationalDBQueryResult::data(), dbConnection_, debugLog, Exception::errorMessage(), RelationalDBQueryResult::hasNext(), DataObject::integerValue(), DataObject::isNull(), RelationalDBQueryResult::next(), RelationalDBConnection::query(), DataObject::stringValue(), and Conversion::toString().

Referenced by rfByEntryID().

Here is the call graph for this function:

◆ createImplementationOfFU()

FUImplementation * HDB::HDBManager::createImplementationOfFU ( FUArchitecture architecture,
RowID  id 
) const
protectedvirtual

Obtains implementation data of the FU that has the given ID and creates an FUImplementation instance of it.

Parameters
architectureArchitecture of the FU (needed when matching the ports in the implementation).
idID of the FU entry.
Returns
The newly created FUImplementation instance or NULL if the FU has no implementation.

Reimplemented in HDB::CachedHDBManager.

Definition at line 4615 of file HDBManager.cc.

4617  {
4618 
4619  // make the SQL query to obtain implementation data
4620  RelationalDBQueryResult* implData = NULL;
4621  const std::string queryString = fuImplementationByIDQuery(id);
4622  try {
4623  implData = dbConnection_->query(queryString);
4624  } catch (const Exception& e) {
4625  delete implData;
4626  debugLog(
4627  std::string("query ") + queryString + " threw something: " +
4628  e.errorMessage());
4629  return NULL;
4630  }
4631 
4632  FUImplementation* implementation = NULL;
4633 
4634  if (implData->hasNext()) {
4635  implData->next();
4636  assert(!implData->hasNext());
4637 
4638  int idColumn = implData->column("fu_implementation.id");
4639  int nameColumn = implData->column("fu_implementation.name");
4640  int opcodePortColumn = implData->column(
4641  "fu_implementation.opcode_port");
4642  int clkPortColumn = implData->column("fu_implementation.clk_port");
4643  int rstPortColumn = implData->column("fu_implementation.rst_port");
4644  int glockPortColumn = implData->column(
4645  "fu_implementation.glock_port");
4646  int glockReqPortColumn = implData->column(
4647  "fu_implementation.glock_req_port");
4648 
4649  const DataObject& idData = implData->data(idColumn);
4650  const DataObject& nameData = implData->data(nameColumn);
4651  const DataObject& opcodePortData = implData->data(opcodePortColumn);
4652  const DataObject& clkPortData = implData->data(clkPortColumn);
4653  const DataObject& rstPortData = implData->data(rstPortColumn);
4654  const DataObject& glockPortData = implData->data(glockPortColumn);
4655  const DataObject& glockReqPortData = implData->data(
4656  glockReqPortColumn);
4657 
4658  RowID implID = idData.integerValue();
4659  string name = nameData.stringValue();
4660  string opcodePort = opcodePortData.stringValue();
4661  string clkPort = clkPortData.stringValue();
4662  string rstPort = rstPortData.stringValue();
4663  string glockPort = glockPortData.stringValue();
4664  string glockReqPort = glockReqPortData.stringValue();
4665 
4666  implementation = new FUImplementation(
4667  name, opcodePort, clkPort, rstPort, glockPort, glockReqPort);
4668  implementation->setID(implID);
4669 
4672  addDataPortsToImplementation(*implementation, architecture, id);
4675  }
4676 
4677  delete implData;
4678  implData = NULL;
4679  return implementation;
4680 }

References addBlockImplementationFiles(), addDataPortsToImplementation(), addFUExternalPortsToImplementation(), addFUParametersToImplementation(), addOpcodesToImplementation(), assert, RelationalDBQueryResult::column(), RelationalDBQueryResult::data(), dbConnection_, debugLog, Exception::errorMessage(), fuImplementationByIDQuery(), RelationalDBQueryResult::hasNext(), implementation, DataObject::integerValue(), RelationalDBQueryResult::next(), RelationalDBConnection::query(), and DataObject::stringValue().

Referenced by HDB::CachedHDBManager::createImplementationOfFU(), and fuByEntryID().

Here is the call graph for this function:

◆ createImplementationOfRF()

RFImplementation * HDB::HDBManager::createImplementationOfRF ( RowID  id) const
protectedvirtual

Obtains implementation data of the RF that has the given ID and creates an RFImplementation instance of it.

Parameters
idID of the RF entry.
Returns
The newly created RFImplementation instance or NULL if the RF has no implementation.

Reimplemented in HDB::CachedHDBManager.

Definition at line 4837 of file HDBManager.cc.

4837  {
4838 
4839  RelationalDBQueryResult* implementationData = NULL;
4840  try {
4841  if(hasColumn("rf_implementation", "sac_param")) {
4842  // Use new query.
4843  implementationData = dbConnection_->query(
4845  } else {
4846  // Use fallback query.
4847  implementationData = dbConnection_->query(
4849  }
4850  } catch (const Exception& e) {
4851  assert(false);
4852  }
4853 
4854  RFImplementation* implementation = NULL;
4855 
4856  if (implementationData->hasNext()) {
4857  implementationData->next();
4858  assert(!implementationData->hasNext());
4859  int idColumn = implementationData->column("id");
4860  int nameColumn = implementationData->column("name");
4861  int sizeParamColumn = implementationData->column("size_param");
4862  int widthParamColumn = implementationData->column("width_param");
4863  int sacParamColumn = implementationData->column("sac_param");
4864  int clkPortColumn = implementationData->column("clk_port");
4865  int rstPortColumn = implementationData->column("rst_port");
4866  int glockPortColumn = implementationData->column("glock_port");
4867  int guardPortColumn = implementationData->column("guard_port");
4868 
4869  const DataObject& idData = implementationData->data(idColumn);
4870  const DataObject& nameData = implementationData->data(nameColumn);
4871  const DataObject& sizeParamData = implementationData->data(
4872  sizeParamColumn);
4873  const DataObject& widthParamData = implementationData->data(
4874  widthParamColumn);
4875  const DataObject& clkPortData = implementationData->data(
4876  clkPortColumn);
4877  const DataObject& rstPortData = implementationData->data(
4878  rstPortColumn);
4879  const DataObject& glockPortData = implementationData->data(
4880  glockPortColumn);
4881  const DataObject& guardPortData = implementationData->data(
4882  guardPortColumn);
4883  const DataObject& sacParamData = implementationData->data(
4884  sacParamColumn);
4885 
4886  string sizeParam = sizeParamData.stringValue();
4887  string widthParam = widthParamData.stringValue();
4888  string guardPort = guardPortData.stringValue();
4889  bool sacParam =
4890  (sacParamColumn != RelationalDBQueryResult::UNKNOWN_INDEX) ?
4891  sacParamData.boolValue() :
4892  false;
4893 
4894  implementation = new RFImplementation(
4895  nameData.stringValue(), clkPortData.stringValue(),
4896  rstPortData.stringValue(), glockPortData.stringValue(),
4897  sizeParam, widthParam, guardPort, sacParam);
4898  implementation->setID(idData.integerValue());
4899 
4904  }
4905 
4906  delete implementationData;
4907  implementationData = NULL;
4908  return implementation;
4909 }

References addBlockImplementationFiles(), addDataPortsToImplementation(), addRFExternalPortsToImplementation(), addRFParametersToImplementation(), assert, DataObject::boolValue(), RelationalDBQueryResult::column(), RelationalDBQueryResult::data(), dbConnection_, hasColumn(), RelationalDBQueryResult::hasNext(), implementation, DataObject::integerValue(), RelationalDBQueryResult::next(), RelationalDBConnection::query(), rfImplementationByIDQuery(), rfImplementationByIDQuery2(), DataObject::stringValue(), and RelationalDBQueryResult::UNKNOWN_INDEX.

Referenced by HDB::CachedHDBManager::createImplementationOfRF(), and rfByEntryID().

Here is the call graph for this function:

◆ createNew()

void HDB::HDBManager::createNew ( const std::string &  file)
static

Creates a new HDB to the given file.

Parameters
fileThe database file to be created.
Exceptions
UnreachableStreamIf the given file exists already or cannot be created for another reason.

Definition at line 548 of file HDBManager.cc.

548  {
549  if (!FileSystem::fileIsCreatable(file)) {
550  const string procName = "HDBManager::createNew";
551  throw UnreachableStream(__FILE__, __LINE__, procName);
552  }
553 
554  try {
555  SQLite db;
556  RelationalDBConnection& connection = db.connect(file);
557 
558  // create tables to the database
559  connection.DDLQuery(CQ_FU);
560  connection.DDLQuery(CQ_FU_ARCHITECTURE);
561  connection.DDLQuery(CQ_PIPELINE_RESOURCE);
562  connection.DDLQuery(CQ_OPERATION_PIPELINE);
564  connection.DDLQuery(CQ_IO_USAGE);
565  connection.DDLQuery(CQ_OPERATION);
566  connection.DDLQuery(CQ_FU_DATA_PORT);
567  connection.DDLQuery(CQ_IO_BINDING);
568  connection.DDLQuery(CQ_FU_IMPLEMENTATION);
569  connection.DDLQuery(CQ_OPCODE_MAP);
570  connection.DDLQuery(CQ_FU_PORT_MAP);
571  connection.DDLQuery(CQ_FU_EXTERNAL_PORT);
574  connection.DDLQuery(CQ_RF);
575  connection.DDLQuery(CQ_RF_ARCHITECTURE);
576  connection.DDLQuery(CQ_RF_IMPLEMENTATION);
578  connection.DDLQuery(CQ_RF_EXTERNAL_PORT);
580  connection.DDLQuery(CQ_RF_DATA_PORT);
581  connection.DDLQuery(CQ_FORMAT);
582  connection.DDLQuery(CQ_BUS);
583  connection.DDLQuery(CQ_SOCKET);
584  connection.DDLQuery(CQ_COST_FUNCTION_PLUGIN);
585  connection.DDLQuery(CQ_COST_ESTIMATION_DATA);
586  connection.DDLQuery(CQ_BLOCK_SOURCE_FILE);
587  connection.DDLQuery(CQ_RF_SOURCE_FILE);
588  connection.DDLQuery(CQ_FU_SOURCE_FILE);
590  connection.DDLQuery(CQ_FU_IMPL_ENTRY_INDEX);
591  connection.DDLQuery(CQ_RF_IMPL_ENTRY_INDEX);
592 
593  // insert the contents to format table
594  insertFileFormats(connection);
595  db.close(connection);
596  } catch (const Exception& e) {
597  debugLog(
598  std::string("Initialization of HDB failed. ") +
599  e.errorMessage());
600  // this should not normally happen, but only if our table creation
601  // queries are broken, thus it's a program error and not input error
602  assert(false);
603  }
604 }

References assert, SQLite::close(), SQLite::connect(), CQ_BLOCK_SOURCE_FILE, CQ_BUS, CQ_COST_ESTIMATION_DATA, CQ_COST_FUNCTION_PLUGIN, CQ_FORMAT, CQ_FU, CQ_FU_ARCHITECTURE, CQ_FU_DATA_PORT, CQ_FU_EXT_PORT_PARAMETER_DEPENDENCY, CQ_FU_EXTERNAL_PORT, CQ_FU_IMPL_ENTRY_INDEX, CQ_FU_IMPLEMENTATION, CQ_FU_IMPLEMENTATION_PARAMETER, CQ_FU_PORT_MAP, CQ_FU_PORT_MAP_ARCH_INDEX, CQ_FU_SOURCE_FILE, CQ_IO_BINDING, CQ_IO_USAGE, CQ_OPCODE_MAP, CQ_OPERATION, CQ_OPERATION_PIPELINE, CQ_PIPELINE_RESOURCE, CQ_PIPELINE_RESOURCE_USAGE, CQ_RF, CQ_RF_ARCHITECTURE, CQ_RF_DATA_PORT, CQ_RF_EXT_PORT_PARAMETER_DEPENDENCY, CQ_RF_EXTERNAL_PORT, CQ_RF_IMPL_ENTRY_INDEX, CQ_RF_IMPLEMENTATION, CQ_RF_IMPLEMENTATION_PARAMETER, CQ_RF_SOURCE_FILE, CQ_SOCKET, RelationalDBConnection::DDLQuery(), debugLog, Exception::errorMessage(), FileSystem::fileIsCreatable(), and insertFileFormats().

Referenced by HDB::CachedHDBManager::createNew(), and main().

Here is the call graph for this function:

◆ deleteCostEstimationDataIDsQueries()

virtual void HDB::HDBManager::deleteCostEstimationDataIDsQueries ( ) const
pure virtual

◆ directionString()

std::string HDB::HDBManager::directionString ( HDB::Direction  direction)
staticprivate

Returns the string used to represent the given direction in HDB.

Parameters
directionThe direction.
Returns
The string.

Definition at line 5761 of file HDBManager.cc.

5761  {
5762  if (direction == HDB::IN) {
5763  return IN_DIRECTION;
5764  } else if (direction == HDB::OUT) {
5765  return OUT_DIRECTION;
5766  } else {
5767  return BIDIR_DIRECTION;
5768  }
5769 }

References BIDIR_DIRECTION, HDB::IN, IN_DIRECTION, HDB::OUT, and OUT_DIRECTION.

Referenced by addFUImplementation(), and addRFImplementation().

◆ fileFormat()

BlockImplementationFile::Format HDB::HDBManager::fileFormat ( const std::string &  formatString)
staticprivate

Returns the format corresponding to the given string which is stored in the database.

Parameters
formatStringThe format string stored in the database.
Returns
The format.

Definition at line 5714 of file HDBManager.cc.

5714  {
5715  if (formatString == VHDL_FORMAT) {
5717  } else if (formatString == VERILOG_FORMAT) {
5719  } else if (formatString == VHDL_SIM_FORMAT) {
5721  } else if (formatString == VERILOG_SIM_FORMAT) {
5723  }
5724  assert(false);
5725  // dummy return to avoid whining with some compilers
5727 }

References assert, formatString(), HDB::BlockImplementationFile::Verilog, VERILOG_FORMAT, VERILOG_SIM_FORMAT, HDB::BlockImplementationFile::Verilogsim, HDB::BlockImplementationFile::VHDL, VHDL_FORMAT, VHDL_SIM_FORMAT, and HDB::BlockImplementationFile::VHDLsim.

Referenced by addBlockImplementationFiles(), and addOperationImplementationResource().

Here is the call graph for this function:

◆ fileName()

std::string HDB::HDBManager::fileName ( ) const

◆ formatString()

std::string HDB::HDBManager::formatString ( BlockImplementationFile::Format  format)
static

Returns the string used to represent the given file format in HDB.

Parameters
formatThe format.
Returns
The string.

Definition at line 5737 of file HDBManager.cc.

5737  {
5738  if (format == BlockImplementationFile::VHDL) {
5739  return VHDL_FORMAT;
5740  } else if (format == BlockImplementationFile::Verilog) {
5741  return VERILOG_FORMAT;
5742  } else if (format == BlockImplementationFile::VHDLsim) {
5743  return VHDL_SIM_FORMAT;
5744  } else if (format == BlockImplementationFile::Verilogsim) {
5745  return VERILOG_SIM_FORMAT;
5746  }
5747 
5748  // dummy return to avoid compiler whining
5749  assert(false);
5750  return "";
5751 }

References assert, HDB::BlockImplementationFile::Verilog, VERILOG_FORMAT, VERILOG_SIM_FORMAT, HDB::BlockImplementationFile::Verilogsim, HDB::BlockImplementationFile::VHDL, VHDL_FORMAT, VHDL_SIM_FORMAT, and HDB::BlockImplementationFile::VHDLsim.

Referenced by addBlockImplementationFileToHDB(), fileFormat(), OperationImplementationResourceDialog::onAddVerilogSimFile(), OperationImplementationResourceDialog::onAddVerilogSynFile(), OperationImplementationResourceDialog::onAddVhdlSimFile(), OperationImplementationResourceDialog::onAddVhdlSynFile(), and OperationImplementationResourceDialog::onOK().

◆ fuArchitectureByID()

FUArchitecture * HDB::HDBManager::fuArchitectureByID ( RowID  id) const
virtual

Creates an FUArchitecture instance of the FU architecture that has the given ID.

Parameters
IDThe ID of the FU architecture.
Returns
The newly created FUArchitecture instance.
Exceptions
KeyNotFoundIf the HDB does not have a FU architecture with the given ID.

Reimplemented in HDB::CachedHDBManager.

Definition at line 2940 of file HDBManager.cc.

2940  {
2941  if (!containsFUArchitecture(id)) {
2942  throw KeyNotFound(__FILE__, __LINE__, __func__);
2943  }
2944 
2945  FunctionUnit* fu = new FunctionUnit("name");
2946  FUArchitecture* architecture = new FUArchitecture(fu);
2947  architecture->setID(id);
2948  addPortsAndBindingsToFUArchitecture(*architecture, id);
2949  addOperationPipelinesToFUArchitecture(*architecture, id);
2950  return architecture;
2951 }

References __func__, addOperationPipelinesToFUArchitecture(), addPortsAndBindingsToFUArchitecture(), containsFUArchitecture(), and HWBlockArchitecture::setID().

Referenced by HDB::CachedHDBManager::fuArchitectureByID(), HDB::CachedHDBManager::fuArchitectureByIDConst(), HDBToHtml::fuArchToHtml(), fuByEntryID(), fuEntriesByArchitecture(), and AddFUFromHDBDialog::loadHDB().

Here is the call graph for this function:

◆ fuArchitectureByIDQuery()

std::string HDB::HDBManager::fuArchitectureByIDQuery ( RowID  id)
staticprivate

Creates an SQL query for getting the architecture of the FU entry that has the given ID.

The result set has all the fields of fu_architecture.

Parameters
idID of the FU entry.

Definition at line 5857 of file HDBManager.cc.

5857  {
5858  string idString = Conversion::toString(id);
5859  string query =
5860  "SELECT * "
5861  "FROM fu, fu_architecture "
5862  "WHERE fu.id=" + idString + " AND"
5863  " fu_architecture.id = fu.architecture;";
5864  return query;
5865 }

References Conversion::toString().

Here is the call graph for this function:

◆ fuArchitectureID()

RowID HDB::HDBManager::fuArchitectureID ( RowID  fuEntryID) const
private

Returns the ID of the architecture of the given FU entry.

Parameters
fuEntryIDID of the FU entry.
Returns
ID of the FU architecture.
Exceptions
NotAvailableIf the FU entry does not have an architecture.

Definition at line 4268 of file HDBManager.cc.

4268  {
4269  RelationalDBQueryResult* result;
4270  try {
4271  result = dbConnection_->query(
4272  std::string(
4273  "SELECT architecture FROM fu WHERE id=" +
4274  Conversion::toString(fuEntryID) + ";"));
4275  } catch (const Exception& e) {
4276  debugLog(e.errorMessage());
4277  assert(false);
4278  }
4279 
4280  if (!result->hasNext()) {
4281  delete result;
4282  throw NotAvailable(__FILE__, __LINE__, __func__);
4283  }
4284 
4285  result->next();
4286  const DataObject& idData = result->data(0);
4287  if (idData.isNull()) {
4288  delete result;
4289  throw NotAvailable(__FILE__, __LINE__, __func__);
4290  } else {
4291  RowID retValue = idData.integerValue();
4292  delete result;
4293  return retValue;
4294  }
4295 }

References __func__, assert, RelationalDBQueryResult::data(), dbConnection_, debugLog, Exception::errorMessage(), RelationalDBQueryResult::hasNext(), DataObject::integerValue(), DataObject::isNull(), RelationalDBQueryResult::next(), RelationalDBConnection::query(), and Conversion::toString().

Referenced by addFUImplementation().

Here is the call graph for this function:

◆ fuArchitectureIDs()

std::set< RowID > HDB::HDBManager::fuArchitectureIDs ( ) const

Returns a set of FU architecture IDs in the database.

Returns
A set containing all the FU architecture IDs in the database.

Definition at line 2163 of file HDBManager.cc.

2163  {
2164 
2165  RelationalDBQueryResult* result = NULL;
2166  try {
2167  result = dbConnection_->query(
2168  std::string("SELECT id FROM fu_architecture;"));
2169  } catch (const Exception& e) {
2170  debugLog(e.errorMessage());
2171  assert(false);
2172  }
2173 
2174  std::set<RowID> idSet;
2175  while (result->hasNext()) {
2176  result->next();
2177  const DataObject& idData = result->data(0);
2178  idSet.insert(idData.integerValue());
2179  }
2180 
2181  delete result;
2182  return idSet;
2183 }

References assert, RelationalDBQueryResult::data(), dbConnection_, debugLog, Exception::errorMessage(), RelationalDBQueryResult::hasNext(), DataObject::integerValue(), RelationalDBQueryResult::next(), and RelationalDBConnection::query().

Referenced by SetFUArchitectureCmd::Do(), and AddFUFromHDBDialog::loadHDB().

Here is the call graph for this function:

◆ fuArchitectureIDsByOperationSet()

std::set< RowID > HDB::HDBManager::fuArchitectureIDsByOperationSet ( const std::set< std::string > &  operationNames) const

Definition at line 2684 of file HDBManager.cc.

2685  {
2686 
2687  RelationalDBQueryResult* result = NULL;
2688  try {
2689  std::string operationQuery = "(";
2690  std::set<string>::const_iterator iter = operationNames.begin();
2691  while (iter != operationNames.end()) {
2692  // LIKE makes case-insensitive match to operation names
2693  operationQuery +=
2694  "operation.name LIKE '" + *iter + "'";
2695  iter++;
2696  if (iter != operationNames.end()) {
2697  operationQuery += " OR ";
2698  }
2699  }
2700  operationQuery += ")";
2701  if (operationQuery == "()") {
2702  return std::set<RowID>();
2703  }
2704  result = dbConnection_->query(
2705  std::string("SELECT fu_architecture.id FROM operation_pipeline,"
2706  "operation, fu_architecture WHERE "
2707  "operation.id=operation_pipeline.operation AND "
2708  "operation_pipeline.fu_arch=fu_architecture.id AND "
2709  + operationQuery +
2710  "GROUP BY fu_architecture.id ORDER BY "
2711  "fu_architecture.id;"));
2712  } catch (const Exception& e) {
2713  std::string eMsg = ", HDB file where error occurred was: " + hdbFile_;
2714  debugLog(e.errorMessage() + eMsg);
2715  assert(false);
2716  }
2717 
2718  std::set<RowID> idSet;
2719  while (result->hasNext()) {
2720  result->next();
2721  const DataObject& idData = result->data(0);
2722  idSet.insert(idData.integerValue());
2723  }
2724 
2725  delete result;
2726  return idSet;
2727 }

References assert, RelationalDBQueryResult::data(), dbConnection_, debugLog, Exception::errorMessage(), RelationalDBQueryResult::hasNext(), hdbFile_, DataObject::integerValue(), RelationalDBQueryResult::next(), and RelationalDBConnection::query().

Referenced by ComponentImplementationSelector::fuArchsByOpSetWithMinLatency().

Here is the call graph for this function:

◆ fuByEntryID()

FUEntry * HDB::HDBManager::fuByEntryID ( RowID  id) const

Returns the FU entry that has the given ID.

Parameters
idThe ID of the FU entry.
Returns
The FU entry. @excpetion KeyNotFound If the HDB does not contain an FU entry with the given ID.

Definition at line 2828 of file HDBManager.cc.

2828  {
2829  std::string query = "SELECT architecture FROM fu WHERE id=";
2830  query += Conversion::toString(id) + ";";
2831 
2832  RelationalDBQueryResult* result = NULL;
2833  try {
2834  result = dbConnection_->query(query);
2835  } catch (const Exception& e) {
2836  debugLog(e.errorMessage());
2837  assert(false);
2838  }
2839 
2840  bool hasArch = false;
2841  RowID archID = -1;
2842  if (result->hasNext()) {
2843  result->next();
2844  DataObject data = result->data(0);
2845  if (!data.isNull()) {
2846  hasArch = true;
2847  archID = data.integerValue();
2848  }
2849  delete result;
2850  result = NULL;
2851  } else {
2852  delete result;
2853  std::ostringstream stream;
2854  stream << "FU entry with id " << id << " not found from hdb "
2855  << hdbFile_;
2856  throw KeyNotFound(__FILE__, __LINE__, __func__, stream.str());
2857  }
2858 
2859  FUEntry* entry = new FUEntry();
2860  entry->setID(id);
2861  if (hasArch) {
2862  FUArchitecture* architecture = fuArchitectureByID(archID);
2863  entry->setArchitecture(architecture);
2864  FUImplementation* implementation = createImplementationOfFU(
2865  *architecture, id);
2866  entry->setImplementation(implementation);
2867  }
2868 
2869  CostFunctionPlugin* costFunction = createCostFunctionOfFU(id);
2870  entry->setCostFunction(costFunction);
2871  entry->setHDBFile(hdbFile_);
2872  delete result;
2873  return entry;
2874 }

References __func__, assert, createCostFunctionOfFU(), createImplementationOfFU(), RelationalDBQueryResult::data(), dbConnection_, debugLog, Exception::errorMessage(), fuArchitectureByID(), RelationalDBQueryResult::hasNext(), hdbFile_, implementation, DataObject::integerValue(), DataObject::isNull(), RelationalDBQueryResult::next(), RelationalDBConnection::query(), HDB::FUEntry::setArchitecture(), HDB::HDBEntry::setCostFunction(), HDB::HDBEntry::setHDBFile(), HDB::HDBEntry::setID(), HDB::FUEntry::setImplementation(), and Conversion::toString().

Referenced by addFUImplementation(), ProGe::NetlistGenerator::addFUToNetlist(), CostDatabase::buildFunctionUnits(), ProGeTools::checkForSelectableFU(), Automagic::checkForSelectableFU(), ProGe::BlockSourceCopier::copyShared(), AddFUImplementationCmd::Do(), HDBEditorModifyCmd::Do(), CostEstimator::Estimator::fuCostFunctionPluginOfImplementation(), ImplementationTester::fuEntryFromHdb(), HDBToHtml::fuEntryToHtml(), HDBToHtml::fuImplToHtml(), ProGeTestBenchGenerator::generate(), ProGeScriptGenerator::getBlockOrder(), AddFUImplementationCmd::isEnabled(), PlatformIntegrator::loadFUExternalPorts(), BlockImplementationDialog::onHDBSelection(), setArchitectureForFU(), and unsetArchitectureForFU().

Here is the call graph for this function:

◆ fuCostEstimationData()

DataObject HDB::HDBManager::fuCostEstimationData ( const std::string &  valueName,
RowID  implementationId,
const std::string &  pluginName 
) const

Returns FU cost estimation data.

This version assumes that there's only one entry with given parameters.

Todo:

Another version for fetching lists of data.

Refactor most of the code in *costEstimationData() functions to a helper function

Parameters
valueNameName of the value to fetch.
implementationIdThe ID of the FU entry.
pluginNameName of the cost estimation plugin that owns the data.
Returns
The data.
Exceptions
KeyNotFoundIf the HDB does not contain FU cost estimation data with the given arguments.

Definition at line 3289 of file HDBManager.cc.

3291  {
3292  // make the SQL query to obtain implementation data
3293  RelationalDBQueryResult* queryResult = NULL;
3294  try {
3295  queryResult = dbConnection_->query(
3296  std::string(
3297  "SELECT value "
3298  "FROM cost_estimation_data, cost_function_plugin "
3299  "WHERE plugin_reference = cost_function_plugin.id AND "
3300  "cost_function_plugin.name LIKE('") +
3301  pluginName + "') " +
3302  " AND rf_reference IS NULL " +
3303  " AND bus_reference IS NULL " +
3304  " AND socket_reference IS NULL AND " +
3305  " fu_reference = " + Conversion::toString(implementationId) +
3306  " AND cost_estimation_data.name LIKE('" + valueName + "');");
3307  } catch (const Exception& e) {
3308  // should not throw in any case
3309  debugLog(e.errorMessage());
3310  assert(false);
3311  }
3312 
3313  if (queryResult->hasNext()) {
3314  queryResult->next();
3315 
3316  DataObject value = queryResult->data("value");
3317 
3318  delete queryResult;
3319  queryResult = NULL;
3320 
3321  return value;
3322  } else {
3323  delete queryResult;
3324  throw KeyNotFound(__FILE__, __LINE__, __func__);
3325  }
3326  // silence compiler warning
3327  throw 1;
3328 }

References __func__, assert, RelationalDBQueryResult::data(), dbConnection_, debugLog, Exception::errorMessage(), RelationalDBQueryResult::hasNext(), RelationalDBQueryResult::next(), RelationalDBConnection::query(), and Conversion::toString().

Referenced by StrictMatchFUEstimator::estimateArea(), StrictMatchFUEstimator::estimateEnergy(), StrictMatchFUEstimator::estimateMaximumComputationDelay(), StrictMatchFUEstimator::estimatePortReadDelay(), and StrictMatchFUEstimator::estimatePortWriteDelay().

Here is the call graph for this function:

◆ fuCostEstimationDataIDs()

std::set< RowID > HDB::HDBManager::fuCostEstimationDataIDs ( RowID  fuImplID) const

Returns a set of cost estimation data IDs which reference the give FU implementation.

Parameters
fuImplIDID of the FU implementation.
Returns
Set of cost estimation data IDs.

Definition at line 6391 of file HDBManager.cc.

6391  {
6392 
6393  // make the SQL query to obtain IDs.
6394  RelationalDBQueryResult* queryResult = NULL;
6395  try {
6396  std::string theQuery =
6397  std::string(
6398  "SELECT id "
6399  "FROM cost_estimation_data "
6400  "WHERE fu_reference = ") +
6401  Conversion::toString(fuImplID);
6402 
6403  queryResult = dbConnection_->query(theQuery);
6404 
6405  } catch (const Exception& e) {
6406  // should not throw in any case
6407  debugLog(e.errorMessage());
6408  assert(false);
6409  }
6410 
6411  std::set<RowID> ids;
6412 
6413  while (queryResult->hasNext()) {
6414  queryResult->next();
6415 
6416  ids.insert(queryResult->data("id").integerValue());
6417  }
6418 
6419  delete queryResult;
6420  queryResult = NULL;
6421  return ids;
6422 }

References assert, RelationalDBQueryResult::data(), dbConnection_, debugLog, Exception::errorMessage(), RelationalDBQueryResult::hasNext(), DataObject::integerValue(), RelationalDBQueryResult::next(), RelationalDBConnection::query(), and Conversion::toString().

Referenced by HDBToHtml::fuEntryToHtml(), and HDBToHtml::fuImplToHtml().

Here is the call graph for this function:

◆ fuEntriesByArchitecture()

std::set< RowID > HDB::HDBManager::fuEntriesByArchitecture ( const TTAMachine::FunctionUnit fu) const

Returns a set of FU entry IDs that have a corresponding architecture with the given one.

The set may contain FU entry IDs that have ports with parametrized width while the given one has fixed width.

Parameters
fuThe FU architecture.
Returns
Set of FU entry IDs.

Definition at line 3040 of file HDBManager.cc.

3041  {
3042 
3043  std::set<RowID> architectureIDs;
3044  std::set<RowID> entryIDs;
3045 
3046  try {
3047  // get FU architectures with required operation set
3048  string query = "";
3049  for (int i = 0; i < fu.operationCount(); i++) {
3050  query +=
3051  "SELECT fu_arch FROM operation_pipeline,operation "
3052  "WHERE operation.name=\"" + fu.operation(i)->name() +
3053  "\" AND operation_pipeline.operation=operation.id";
3054  if (i+1 < fu.operationCount()) {
3055  query += " INTERSECT ";
3056  } else {
3057  query += ";";
3058  }
3059  }
3060 
3061  RelationalDBQueryResult* queryResult = dbConnection_->query(query);
3062 
3063  // check the architectures are compeletely similar
3064  while (queryResult->hasNext()) {
3065  queryResult->next();
3066  const DataObject& archID = queryResult->data(0);
3067  FUArchitecture* arch = fuArchitectureByID(archID.integerValue());
3068  if (isMatchingArchitecture(fu, *arch)) {
3069  architectureIDs.insert(arch->id());
3070  }
3071  delete arch;
3072  }
3073 
3074  delete queryResult;
3075 
3076  if (!architectureIDs.empty()) {
3077  // find the FU entry IDs
3078  string fuEntryQuery = "SELECT id FROM fu WHERE ";
3079  for (std::set<RowID>::const_iterator iter =
3080  architectureIDs.begin();
3081  iter != architectureIDs.end(); iter++) {
3082  fuEntryQuery += "architecture=" +
3083  Conversion::toString(*iter);
3084  std::set<RowID>::const_iterator nextIter = iter;
3085  nextIter++;
3086  if (nextIter == architectureIDs.end()) {
3087  fuEntryQuery += ";";
3088  } else {
3089  fuEntryQuery += " OR ";
3090  }
3091  }
3092 
3093  RelationalDBQueryResult* fuEntryResult = dbConnection_->query(
3094  fuEntryQuery);
3095  while (fuEntryResult->hasNext()) {
3096  fuEntryResult->next();
3097  const DataObject& idData = fuEntryResult->data(0);
3098  entryIDs.insert(idData.integerValue());
3099  }
3100 
3101  delete fuEntryResult;
3102  }
3103 
3104  } catch (const Exception& e) {
3105  debugLog(e.errorMessage());
3106  ;
3107  }
3108 
3109  return entryIDs;
3110 }

References RelationalDBQueryResult::data(), dbConnection_, debugLog, Exception::errorMessage(), fuArchitectureByID(), RelationalDBQueryResult::hasNext(), HWBlockArchitecture::id(), DataObject::integerValue(), isMatchingArchitecture(), TTAMachine::HWOperation::name(), RelationalDBQueryResult::next(), TTAMachine::FunctionUnit::operation(), TTAMachine::FunctionUnit::operationCount(), RelationalDBConnection::query(), and Conversion::toString().

Referenced by ComponentImplementationSelector::fuImplementations(), and BlockImplementationDialog::onHDBSelection().

Here is the call graph for this function:

◆ fuEntryByIDQuery()

std::string HDB::HDBManager::fuEntryByIDQuery ( RowID  id)
staticprivate

Creates an SQL query for getting the FU entry that has the given ID.

The result set has fields {id, architecture, cost_function}.

Parameters
idID of the entry.
Returns
The SQL query.

Definition at line 5781 of file HDBManager.cc.

5781  {
5782  string idString = Conversion::toString(id);
5783  string query =
5784  "SELECT * "
5785  "FROM fu "
5786  "WHERE fu.id=" + idString + ";";
5787  return query;
5788 }

References Conversion::toString().

Referenced by hasFUEntry().

Here is the call graph for this function:

◆ fuEntryHasArchitecture()

bool HDB::HDBManager::fuEntryHasArchitecture ( RowID  id) const
private

Tells whether the FU entry that has the given ID has an architecture.

Parameters
idID of the FU entry.
Returns
True if it has an architecture, otherwise false.
Exceptions
KeyNotFoundIf the HDB does not contain a FU entry with the given ID.

Definition at line 4097 of file HDBManager.cc.

4097  {
4098  RelationalDBQueryResult* result;
4099  try {
4100  result = dbConnection_->query(
4101  std::string(
4102  "SELECT architecture FROM fu WHERE id=" +
4103  Conversion::toString(id) + ";"));
4104  } catch (const Exception& e) {
4105  debugLog(e.errorMessage());
4106  assert(false);
4107  }
4108 
4109  if (result->hasNext()) {
4110  result->next();
4111  const DataObject& data = result->data(0);
4112  delete result;
4113  return !data.isNull();
4114  } else {
4115  delete result;
4116  throw KeyNotFound(__FILE__, __LINE__, __func__);
4117  }
4118 }

References __func__, assert, RelationalDBQueryResult::data(), dbConnection_, debugLog, Exception::errorMessage(), RelationalDBQueryResult::hasNext(), DataObject::isNull(), RelationalDBQueryResult::next(), RelationalDBConnection::query(), and Conversion::toString().

Here is the call graph for this function:

◆ fuEntryIDOfImplementation()

RowID HDB::HDBManager::fuEntryIDOfImplementation ( RowID  implID) const

Returns the ID of the FU entry that has the given implementation ID.

Parameters
implIDThe implementation ID.
Returns
The FU entry ID.
Exceptions
KeyNotFoundIf there is no implementation by the given ID.

Definition at line 2765 of file HDBManager.cc.

2765  {
2766  RelationalDBQueryResult* result = NULL;
2767  try {
2768  result = dbConnection_->query(
2769  std::string(
2770  "SELECT fu from fu_implementation WHERE id=" +
2771  Conversion::toString(implID) + ";"));
2772  } catch (const Exception& e) {
2773  debugLog(e.errorMessage());
2774  assert(false);
2775  }
2776 
2777  if (result->hasNext()) {
2778  result->next();
2779  RowID id = result->data(0).integerValue();
2780  delete result;
2781  return id;
2782  } else {
2783  delete result;
2784  throw KeyNotFound(__FILE__, __LINE__, __func__);
2785  }
2786 }

References __func__, assert, RelationalDBQueryResult::data(), dbConnection_, debugLog, Exception::errorMessage(), RelationalDBQueryResult::hasNext(), DataObject::integerValue(), RelationalDBQueryResult::next(), RelationalDBConnection::query(), and Conversion::toString().

Referenced by HDBEditorDeleteCmd::Do(), HDBEditorModifyCmd::Do(), HDBToHtml::fuImplToHtml(), and HDB::CachedHDBManager::removeFUImplementation().

Here is the call graph for this function:

◆ fuEntryIDs()

std::set< RowID > HDB::HDBManager::fuEntryIDs ( ) const

Returns a set of FU entry IDs in the database.

Returns
A set containing all the FU entry IDs in the database.

Definition at line 2035 of file HDBManager.cc.

2035  {
2036 
2037  string query = "SELECT id AS 'fu.id' FROM fu;";
2038 
2039  // make the SQL query to obtain all the IDs
2040  RelationalDBQueryResult* queryResult = NULL;
2041  try {
2042  queryResult = dbConnection_->query(query);
2043  } catch (const Exception& e) {
2044  // should not throw in any case
2045  debugLog(e.errorMessage());
2046  assert(false);
2047  }
2048 
2049  std::set<RowID> idSet;
2050  while (queryResult->hasNext()) {
2051  queryResult->next();
2052  const DataObject& idData = queryResult->data("fu.id");
2053  idSet.insert(idData.integerValue());
2054  }
2055 
2056  delete queryResult;
2057  return idSet;
2058 }

References assert, RelationalDBQueryResult::data(), dbConnection_, debugLog, Exception::errorMessage(), RelationalDBQueryResult::hasNext(), DataObject::integerValue(), RelationalDBQueryResult::next(), and RelationalDBConnection::query().

Referenced by CostDatabase::buildFunctionUnits(), ProGeTools::checkForSelectableFU(), Automagic::checkForSelectableFU(), and ImplementationTester::fuEntryIDs().

Here is the call graph for this function:

◆ fuExternalPortsByIDQuery()

std::string HDB::HDBManager::fuExternalPortsByIDQuery ( RowID  id)
staticprivate

Creates an SQL query for getting external port data of implementation of the FU that has the given ID.

The result table has fields {fu_external_port.name, fu_external_port.direction, fu_external_port.width_formula, fu_external_port.description}.

Parameters
idID of the FU entry in HDB.
Returns
The SQL query.

Definition at line 6043 of file HDBManager.cc.

6043  {
6044  string idString = Conversion::toString(id);
6045  string query =
6046  "SELECT fu_external_port.name AS 'fu_external_port.name',"
6047  " fu_external_port.direction AS 'fu_external_port.direction',"
6048  " fu_external_port.width_formula AS "
6049  " 'fu_external_port.width_formula',"
6050  " fu_external_port.description AS "
6051  " 'fu_external_port.description' "
6052  "FROM fu, fu_implementation, fu_external_port "
6053  "WHERE fu.id=" + idString + " AND"
6054  " fu_implementation.fu=fu.id AND"
6055  " fu_external_port.fu_impl=fu_implementation.id;";
6056  return query;
6057 }

References Conversion::toString().

Referenced by addFUExternalPortsToImplementation().

Here is the call graph for this function:

◆ fuImplementationByIDQuery()

std::string HDB::HDBManager::fuImplementationByIDQuery ( RowID  id)
staticprivate

Creates an SQL query for getting FU implementation data of the FU that has the given ID.

The result table has fields {fu_implementation.id, fu_implementation.name, fu_implementation.opcode_port, fu_implementation.clk_port, fu_implementation.rst_port, fu_implementation.glock_port, fu_implementation.glock_req_port}.

Parameters
idID of the FU entry in HDB.

Definition at line 5962 of file HDBManager.cc.

5962  {
5963  string idString = Conversion::toString(id);
5964  string query =
5965  "SELECT fu_implementation.id AS 'fu_implementation.id',"
5966  " fu_implementation.name AS 'fu_implementation.name',"
5967  " fu_implementation.opcode_port AS "
5968  "'fu_implementation.opcode_port',"
5969  " fu_implementation.clk_port AS 'fu_implementation.clk_port',"
5970  " fu_implementation.rst_port AS 'fu_implementation.rst_port',"
5971  " fu_implementation.glock_port AS "
5972  " 'fu_implementation.glock_port',"
5973  " fu_implementation.glock_req_port AS "
5974  " 'fu_implementation.glock_req_port' "
5975  "FROM fu, fu_implementation "
5976  "WHERE fu.id=" + idString + " AND"
5977  " fu_implementation.fu=fu.id;";
5978  return query;
5979 }

References Conversion::toString().

Referenced by createImplementationOfFU().

Here is the call graph for this function:

◆ fuImplementationDataPortsByIDQuery()

std::string HDB::HDBManager::fuImplementationDataPortsByIDQuery ( RowID  id)
staticprivate

Creates an SQL qury for getting data port data of implementation of the FU that has the given ID.

The result table has fields {fu_port_map.name, fu_port_map.width_formula, fu_port_map.load_port, fu_port_map.guard_port}

Parameters
idID of the FU entry in HDB.

Definition at line 6016 of file HDBManager.cc.

6016  {
6017  string idString = Conversion::toString(id);
6018  string query =
6019  "SELECT fu_port_map.name AS 'fu_port_map.name',"
6020  " fu_port_map.width_formula AS 'fu_port_map.width_formula',"
6021  " fu_port_map.load_port AS 'fu_port_map.load_port',"
6022  " fu_port_map.guard_port AS 'fu_port_map.guard_port' "
6023  "FROM fu, fu_port_map, fu_implementation "
6024  "WHERE fu.id=" + idString + " AND"
6025  " fu_implementation.fu=fu.id AND"
6026  " fu_port_map.fu_impl=fu_implementation.id;";
6027  return query;
6028 }

References Conversion::toString().

Referenced by addDataPortsToImplementation().

Here is the call graph for this function:

◆ fuImplementationParametersByIDQuery()

std::string HDB::HDBManager::fuImplementationParametersByIDQuery ( RowID  id)
staticprivate

Creates an SQL query for getting the parameters of the implementation of the FU that has the given ID.

The result table has fields {name, type, value}.

Parameters
idID of the FU implementation entry.
Returns
The SQL query.

Definition at line 6099 of file HDBManager.cc.

6099  {
6100  string idString = Conversion::toString(id);
6101  string query =
6102  "SELECT fu_implementation_parameter.name AS 'name',"
6103  " fu_implementation_parameter.type AS 'type',"
6104  " fu_implementation_parameter.value AS 'value' "
6105  "FROM fu_implementation, fu_implementation_parameter "
6106  "WHERE fu_implementation.fu=" + idString + " AND"
6107  " fu_implementation_parameter.fu_impl=fu_implementation.id;";
6108  return query;
6109 }

References Conversion::toString().

Referenced by addFUParametersToImplementation().

Here is the call graph for this function:

◆ fuPortBindingByNameQuery()

std::string HDB::HDBManager::fuPortBindingByNameQuery ( RowID  fuID,
const std::string &  portName 
)
staticprivate

Creates an SQL query for getting io binding data of port that has the given name.

The result table has fields {operation.name, io_binding.io_number}.

Parameters
fuIDID of the FU entry.
portNameName of the implemented port.
Returns
The SQL query.

Definition at line 6146 of file HDBManager.cc.

6148  {
6149 
6150  string idString = Conversion::toString(fuID);
6151  string query =
6152  "SELECT operation.name AS 'operation.name',"
6153  " io_binding.io_number AS 'io_binding.io_number' "
6154  "FROM operation, io_binding, fu_port_map, fu_implementation "
6155  "WHERE fu_implementation.fu=" + idString + " AND"
6156  " fu_port_map.fu_impl=fu_implementation.id AND"
6157  " fu_port_map.name='" + portName + "' AND"
6158  " io_binding.port=fu_port_map.arch_port AND"
6159  " operation.id=io_binding.operation;";
6160  return query;
6161 }

References Conversion::toString().

Referenced by resolveArchitecturePort().

Here is the call graph for this function:

◆ fuPortsAndBindingsByIDQuery()

std::string HDB::HDBManager::fuPortsAndBindingsByIDQuery ( RowID  id)
staticprivate

Creates an SQL query for getting the architectural ports and their operand bindings of the FU architecture that has the given ID.

The result table has fields {fu_data_port.id, fu_data_port.triggers, fu_data_port.sets-opcode, fu_data_port.guard_support, fu_data_port.width, operation.name, io_binding.io_number}

Parameters
idThe ID of the FU architecture.

Definition at line 5880 of file HDBManager.cc.

5880  {
5881  string idString = Conversion::toString(id);
5882  string query =
5883  "SELECT fu_data_port.id AS 'fu_data_port.id',"
5884  " fu_data_port.triggers AS 'fu_data_port.triggers',"
5885  " fu_data_port.sets_opcode AS 'fu_data_port.sets_opcode',"
5886  " fu_data_port.guard_support AS 'fu_data_port.guard_support',"
5887  " fu_data_port.width AS 'fu_data_port.width',"
5888  " operation.name AS 'operation.name',"
5889  " io_binding.io_number AS 'io_binding.io_number' "
5890  "FROM fu_data_port, io_binding, operation "
5891  "WHERE fu_data_port.fu_arch=" + idString + " AND"
5892  " io_binding.port=fu_data_port.id AND"
5893  " io_binding.operation=operation.id;";
5894  return query;
5895 }

References Conversion::toString().

Referenced by addPortsAndBindingsToFUArchitecture().

Here is the call graph for this function:

◆ fuSourceFilesByIDQuery()

std::string HDB::HDBManager::fuSourceFilesByIDQuery ( RowID  id)
staticprivate

Creates an SQL query for getting the block source files of the FU entry that has the given ID.

The result table has fields {block_source_file.file, format.format}.

Parameters
idID of the FU entry.
Returns
The SQL query.

Definition at line 6174 of file HDBManager.cc.

6174  {
6175  string idString = Conversion::toString(id);
6176  string query =
6177  "SELECT block_source_file.file AS 'block_source_file.file',"
6178  " format.format AS 'format.format' "
6179  "FROM block_source_file, fu_source_file, fu_implementation, format "
6180  "WHERE fu_implementation.fu=" + idString + " AND"
6181  " fu_source_file.fu_impl=fu_implementation.id AND"
6182  " block_source_file.id=fu_source_file.file AND"
6183  " format.id=block_source_file.format;";
6184  return query;
6185 }

References Conversion::toString().

Referenced by addBlockImplementationFiles().

Here is the call graph for this function:

◆ getDBConnection()

RelationalDBConnection * HDB::HDBManager::getDBConnection ( ) const
protected

Returns used database connection.

Definition at line 6987 of file HDBManager.cc.

6987  {
6988  return dbConnection_;
6989 }

References dbConnection_.

Referenced by HDB::CachedHDBManager::costEstimationDataIDs().

◆ hasBusEntry()

bool HDB::HDBManager::hasBusEntry ( RowID  id) const
private

Tells whether the HDB has an Bus entry that has the given ID.

Returns
True if the HDB has the entry, otherwise false.

Definition at line 3980 of file HDBManager.cc.

3980  {
3981 
3982  RelationalDBQueryResult* result;
3983 
3984  try {
3985  result = dbConnection_->query(busEntryByIDQuery(id));
3986  } catch (const Exception&) {
3987  assert(false);
3988  }
3989 
3990  if (result->hasNext()) {
3991  result->next();
3992  assert(!result->hasNext());
3993  delete result;
3994  return true;
3995  } else {
3996  delete result;
3997  return false;
3998  }
3999 }

References assert, busEntryByIDQuery(), dbConnection_, RelationalDBQueryResult::hasNext(), RelationalDBQueryResult::next(), and RelationalDBConnection::query().

Referenced by addCostEstimationData(), modifyCostEstimationData(), and removeBusEntry().

Here is the call graph for this function:

◆ hasColumn()

bool HDB::HDBManager::hasColumn ( const std::string &  table,
const std::string &  columnName 
) const
private

Returns true if a table by name has a column by given name.

Parameters
tableThe table by name to search the column from.
columnNameThe name of the column to be searched.
Returns
True if the table has the named column.

Definition at line 4342 of file HDBManager.cc.

4343  {
4344 
4345  std::string table_info_query("PRAGMA table_info(");
4346  table_info_query += table;
4347  table_info_query += ");";
4348 
4349  RelationalDBQueryResult* result;
4350  try {
4351  result = dbConnection_->query(table_info_query);
4352  } catch (const Exception& e) {
4353  debugLog(e.errorMessage());
4354  assert(false);
4355  }
4356 
4357  while(result->hasNext()) {
4358  result->next();
4359  // Second column in result row is column name of the table.
4360  const DataObject& columnData = result->data(1);
4361  std::string columnNameFromTable = columnData.stringValue();
4362 
4363  assert(!columnNameFromTable.empty());
4364  if(columnNameFromTable == columnName) {
4365  return true;
4366  }
4367  }
4368 
4369  return false;
4370 }

References assert, RelationalDBQueryResult::data(), dbConnection_, debugLog, Exception::errorMessage(), RelationalDBQueryResult::hasNext(), RelationalDBQueryResult::next(), RelationalDBConnection::query(), and DataObject::stringValue().

Referenced by addRFImplementation(), createImplementationOfRF(), and HDBManager().

Here is the call graph for this function:

◆ hasCostEstimationDataByID()

bool HDB::HDBManager::hasCostEstimationDataByID ( RowID  id) const
private

Tells whether the HDB has cost estimation data that has the given ID.

Returns
True if the HDB has the data, otherwise false.

Definition at line 4035 of file HDBManager.cc.

4035  {
4036 
4037  RelationalDBQueryResult* result;
4038  std::string query = "SELECT id FROM cost_estimation_data WHERE id=";
4039  query += Conversion::toString(id) + ";";
4040 
4041  try {
4042  result = dbConnection_->query(query);
4043  } catch (const Exception&) {
4044  assert(false);
4045  }
4046 
4047  if (result->hasNext()) {
4048  result->next();
4049  assert(!result->hasNext());
4050  delete result;
4051  return true;
4052  } else {
4053  delete result;
4054  return false;
4055  }
4056 }

References assert, dbConnection_, RelationalDBQueryResult::hasNext(), RelationalDBQueryResult::next(), RelationalDBConnection::query(), and Conversion::toString().

Referenced by modifyCostEstimationData().

Here is the call graph for this function:

◆ hasCostFunctionPluginByID()

bool HDB::HDBManager::hasCostFunctionPluginByID ( RowID  id) const
private

Tells whether the HDB has cost function plugin that has the given ID.

Returns
True if the HDB has the plugin, otherwise false.

Definition at line 4064 of file HDBManager.cc.

4064  {
4065 
4066  RelationalDBQueryResult* result;
4067  std::string query = "SELECT id FROM cost_function_plugin WHERE id=";
4068  query += Conversion::toString(id) + ";";
4069 
4070  try {
4071  result = dbConnection_->query(query);
4072  } catch (const Exception&) {
4073  assert(false);
4074  }
4075 
4076  if (result->hasNext()) {
4077  result->next();
4078  assert(!result->hasNext());
4079  delete result;
4080  return true;
4081  } else {
4082  delete result;
4083  return false;
4084  }
4085 }

References assert, dbConnection_, RelationalDBQueryResult::hasNext(), RelationalDBQueryResult::next(), RelationalDBConnection::query(), and Conversion::toString().

Referenced by modifyCostFunctionPlugin().

Here is the call graph for this function:

◆ hasFUEntry()

bool HDB::HDBManager::hasFUEntry ( RowID  id) const
private

Tells whether the HDB has an FU entry that has the given ID.

Returns
True if the HDB has the entry, otherwise false.

Definition at line 3924 of file HDBManager.cc.

3924  {
3925 
3926  RelationalDBQueryResult* result;
3927 
3928  try {
3929  result = dbConnection_->query(fuEntryByIDQuery(id));
3930  } catch (const Exception&) {
3931  assert(false);
3932  }
3933 
3934  if (result->hasNext()) {
3935  result->next();
3936  assert(!result->hasNext());
3937  delete result;
3938  return true;
3939  } else {
3940  delete result;
3941  return false;
3942  }
3943 }

References assert, dbConnection_, fuEntryByIDQuery(), RelationalDBQueryResult::hasNext(), RelationalDBQueryResult::next(), and RelationalDBConnection::query().

Referenced by addCostEstimationData(), addFUImplementation(), modifyCostEstimationData(), removeFUEntry(), setArchitectureForFU(), and unsetArchitectureForFU().

Here is the call graph for this function:

◆ hasRFEntry()

bool HDB::HDBManager::hasRFEntry ( RowID  id) const
private

Tells whether the HDB has an RF entry that has the given ID.

Returns
True if the HDB has the entry, otherwise false.

Definition at line 3952 of file HDBManager.cc.

3952  {
3953 
3954  RelationalDBQueryResult* result;
3955 
3956  try {
3957  result = dbConnection_->query(rfEntryByIDQuery(id));
3958  } catch (const Exception&) {
3959  assert(false);
3960  }
3961 
3962  if (result->hasNext()) {
3963  result->next();
3964  assert(!result->hasNext());
3965  delete result;
3966  return true;
3967  } else {
3968  delete result;
3969  return false;
3970  }
3971 }

References assert, dbConnection_, RelationalDBQueryResult::hasNext(), RelationalDBQueryResult::next(), RelationalDBConnection::query(), and rfEntryByIDQuery().

Referenced by addCostEstimationData(), addRFImplementation(), modifyCostEstimationData(), removeRFEntry(), and setArchitectureForRF().

Here is the call graph for this function:

◆ hasSocketEntry()

bool HDB::HDBManager::hasSocketEntry ( RowID  id) const
private

Tells whether the HDB has an Socket entry that has the given ID.

Returns
True if the HDB has the entry, otherwise false.

Definition at line 4008 of file HDBManager.cc.

4008  {
4009 
4010  RelationalDBQueryResult* result;
4011 
4012  try {
4013  result = dbConnection_->query(socketEntryByIDQuery(id));
4014  } catch (const Exception&) {
4015  assert(false);
4016  }
4017 
4018  if (result->hasNext()) {
4019  result->next();
4020  assert(!result->hasNext());
4021  delete result;
4022  return true;
4023  } else {
4024  delete result;
4025  return false;
4026  }
4027 }

References assert, dbConnection_, RelationalDBQueryResult::hasNext(), RelationalDBQueryResult::next(), RelationalDBConnection::query(), and socketEntryByIDQuery().

Referenced by addCostEstimationData(), modifyCostEstimationData(), and removeSocketEntry().

Here is the call graph for this function:

◆ insertFileFormats()

void HDB::HDBManager::insertFileFormats ( RelationalDBConnection connection)
staticprivate

Inserts the supported formats to the format table.

Parameters
connectionThe connection used when inserting the formats.

Definition at line 5689 of file HDBManager.cc.

5689  {
5690  try {
5691  connection.updateQuery(
5692  std::string(
5693  "INSERT INTO format(id,format) VALUES(1,\"" +
5694  VHDL_FORMAT + "\");"));
5695  connection.updateQuery(
5696  std::string(
5697  "INSERT INTO format(id,format) VALUES(2,\"" +
5698  VERILOG_FORMAT + "\");"));
5699  } catch (const Exception& e) {
5700  debugLog(e.errorMessage());
5701  assert(false);
5702  }
5703 }

References assert, debugLog, Exception::errorMessage(), RelationalDBConnection::updateQuery(), VERILOG_FORMAT, and VHDL_FORMAT.

Referenced by createNew().

Here is the call graph for this function:

◆ ioUsageDataByIDQuery()

std::string HDB::HDBManager::ioUsageDataByIDQuery ( RowID  id)
staticprivate

Creates an SQL query for getting the IO usage data of pipelines of operations contained in the FU architecture that has the given ID.

The result table has fields {operation.name, io_usage.cycle, io_usage.io_number, io_usage.action}.

Parameters
idID of the FU architecture in HDB.

Definition at line 5908 of file HDBManager.cc.

5908  {
5909  string idString = Conversion::toString(id);
5910  string query =
5911  "SELECT operation.name AS 'operation.name',"
5912  " io_usage.cycle AS 'io_usage.cycle',"
5913  " io_usage.io_number AS 'io_usage.io_number',"
5914  " io_usage.action AS 'io_usage.action' "
5915  "FROM operation_pipeline, io_usage, operation "
5916  "WHERE operation_pipeline.fu_arch=" + idString + " AND"
5917  " io_usage.pipeline=operation_pipeline.id AND"
5918  " operation.id=operation_pipeline.operation;";
5919  return query;
5920 }

References Conversion::toString().

Referenced by addOperationPipelinesToFUArchitecture().

Here is the call graph for this function:

◆ isMatchingArchitecture()

bool HDB::HDBManager::isMatchingArchitecture ( const TTAMachine::FunctionUnit fu,
const FUArchitecture arch 
)
staticprivate

Checks whether the given FU has a mathing architecture with the given FU architecture instance.

Parameters
fuThe function unit.
archThe FU architecture.
Returns
True if the architectures match, otherwise false.

Definition at line 5519 of file HDBManager.cc.

5521  {
5522 
5523  if (fu.operationCount() != arch.architecture().operationCount()) {
5524  return false;
5525  }
5526 
5527  std::map<const FUPort*, const FUPort*> portMap;
5528  for (int i = 0; i < fu.operationPortCount(); i++) {
5529  portMap.insert(
5530  std::pair<const FUPort*, const FUPort*>(
5531  fu.operationPort(i), NULL));
5532  }
5533 
5534  PipelineElementUsageTable plineElementUsages;
5535 
5536  for (int i = 0; i < fu.operationCount(); i++) {
5537  HWOperation* operation = fu.operation(i);
5538  if (!arch.architecture().hasOperation(operation->name())) {
5539  return false;
5540  }
5541  HWOperation* archOp = arch.architecture().operation(
5542  operation->name());
5543  if (operation->latency() != archOp->latency()) {
5544  return false;
5545  }
5546 
5547  // check operand bindings
5548  for (int i = 0; i < fu.operationPortCount(); i++) {
5549  FUPort* port = fu.operationPort(i);
5550  if (operation->isBound(*port)) {
5551  int io = operation->io(*port);
5552  FUPort* samePort = archOp->port(io);
5553  if (samePort == NULL) {
5554  return false;
5555  }
5556  const FUPort* existingSamePort =
5557  MapTools::valueForKey<const FUPort*>(portMap, port);
5558  if (existingSamePort != NULL &&
5559  existingSamePort != samePort) {
5560  return false;
5561  }
5562 
5563  // check the width of the ports
5564  if (!arch.hasParameterizedWidth(samePort->name()) &&
5565  samePort->width() != port->width()) {
5566  return false;
5567  }
5568 
5569  if (port->isOpcodeSetting() != samePort->isOpcodeSetting() ||
5570  port->isTriggering() != samePort->isTriggering()) {
5571  return false;
5572  }
5573  portMap.erase(port);
5574  portMap.insert(
5575  std::pair<const FUPort*, const FUPort*>(port, samePort));
5576  }
5577  }
5578 
5579  // check operation pipeline
5580  ExecutionPipeline* opPipeline = operation->pipeline();
5581  ExecutionPipeline* archOpPipeline = archOp->pipeline();
5582  for (int cycle = 0; cycle < operation->latency(); cycle++) {
5583  ExecutionPipeline::OperandSet written1 =
5584  opPipeline->writtenOperands(cycle);
5585  ExecutionPipeline::OperandSet written2 =
5586  archOpPipeline->writtenOperands(cycle);
5587  if (written1 != written2) {
5588  return false;
5589  }
5591  opPipeline->readOperands(cycle);
5593  archOpPipeline->readOperands(cycle);
5594  if (read1 != read2) {
5595  return false;
5596  }
5597 
5598  PipelineElementUsage usage;
5599  for (int i = 0; i < fu.pipelineElementCount(); i++) {
5600  const PipelineElement* elem = fu.pipelineElement(i);
5601  if (opPipeline->isResourceUsed(elem->name(),cycle)) {
5602  usage.usage1.insert(elem);
5603  }
5604  }
5605 
5606  for (int i = 0; i < arch.architecture().pipelineElementCount();
5607  i++) {
5608  const PipelineElement* elem =
5609  arch.architecture().pipelineElement(i);
5610  if (archOpPipeline->isResourceUsed(elem->name(), cycle)) {
5611  usage.usage2.insert(elem);
5612  }
5613  }
5614 
5615  plineElementUsages.push_back(usage);
5616  }
5617  }
5618 
5619  return areCompatiblePipelines(plineElementUsages);
5620 }

References HDB::FUArchitecture::architecture(), areCompatiblePipelines(), TTAMachine::FunctionUnit::hasOperation(), HDB::FUArchitecture::hasParameterizedWidth(), TTAMachine::HWOperation::io(), TTAMachine::HWOperation::isBound(), TTAMachine::FUPort::isOpcodeSetting(), TTAMachine::ExecutionPipeline::isResourceUsed(), TTAMachine::FUPort::isTriggering(), TTAMachine::HWOperation::latency(), TTAMachine::PipelineElement::name(), TTAMachine::HWOperation::name(), TTAMachine::Port::name(), TTAMachine::FunctionUnit::operation(), TTAMachine::FunctionUnit::operationCount(), TTAMachine::FunctionUnit::operationPort(), TTAMachine::FunctionUnit::operationPortCount(), TTAMachine::HWOperation::pipeline(), TTAMachine::FunctionUnit::pipelineElement(), TTAMachine::FunctionUnit::pipelineElementCount(), TTAMachine::HWOperation::port(), TTAMachine::ExecutionPipeline::readOperands(), HDB::HDBManager::PipelineElementUsage::usage1, HDB::HDBManager::PipelineElementUsage::usage2, TTAMachine::BaseFUPort::width(), and TTAMachine::ExecutionPipeline::writtenOperands().

Referenced by fuEntriesByArchitecture().

Here is the call graph for this function:

◆ modifyCostEstimationData()

void HDB::HDBManager::modifyCostEstimationData ( RowID  id,
const CostEstimationData data 
)
virtual

Updates cost estimation data in the HDB.

Parameters
idRow ID of the data to update.
dataUpdated data.

Reimplemented in HDB::CachedHDBManager.

Definition at line 6999 of file HDBManager.cc.

6999  {
7000  if (!data.hasName() || !data.hasValue() || !data.hasPluginID()) {
7001  throw InvalidData(__FILE__, __LINE__, __func__);
7002  }
7003 
7004  if (!hasCostEstimationDataByID(id)) {
7005  throw KeyNotFound(__FILE__, __LINE__, __func__);
7006  }
7007 
7008  std::string query =
7009  std::string("UPDATE cost_estimation_data SET ") +
7010  " name='" + data.name() +
7011  "', value='" + data.value().stringValue() +
7012  "', plugin_reference=" + Conversion::toString(data.pluginID());
7013 
7014  // FU entry reference.
7015  if (data.hasFUReference()) {
7016  if (!hasFUEntry(data.fuReference())) {
7017  throw KeyNotFound(__FILE__, __LINE__, __func__);
7018  }
7019  query += ", fu_reference=";
7020  query += Conversion::toString(data.fuReference());
7021  } else {
7022  query += ", fu_reference=NULL";
7023  }
7024 
7025  // RF entry reference.
7026  if (data.hasRFReference()) {
7027  if (!hasRFEntry(data.rfReference())) {
7028  throw KeyNotFound(__FILE__, __LINE__, __func__);
7029  }
7030  query += ", rf_reference=";
7031  query += Conversion::toString(data.rfReference());
7032  } else {
7033  query += ", rf_reference=NULL";
7034  }
7035 
7036  // Bus entry reference
7037  if (data.hasBusReference()) {
7038  if (!hasBusEntry(data.busReference())) {
7039  throw KeyNotFound(__FILE__, __LINE__, __func__);
7040  }
7041  query += ", bus_reference=";
7042  query += Conversion::toString(data.busReference());
7043  } else {
7044  query += ", bus_reference=NULL";
7045  }
7046 
7047  // Socket entry reference.
7048  if (data.hasSocketReference()) {
7049  if (!hasSocketEntry(data.socketReference())) {
7050  throw KeyNotFound(__FILE__, __LINE__, __func__);
7051  }
7052  query += ", socket_reference=";
7053  query += Conversion::toString(data.socketReference());
7054  } else {
7055  query += ", socket_reference=NULL";
7056  }
7057 
7058  query += " WHERE id=";
7059  query += Conversion::toString(id);
7060  query += ";";
7061 
7062  try {
7063  dbConnection_->updateQuery(query);
7064  } catch (const Exception& e) {
7065  debugLog(e.errorMessage());
7066  assert(false);
7067  }
7068 }

References __func__, assert, CostEstimationData::busReference(), dbConnection_, debugLog, Exception::errorMessage(), CostEstimationData::fuReference(), hasBusEntry(), CostEstimationData::hasBusReference(), hasCostEstimationDataByID(), hasFUEntry(), CostEstimationData::hasFUReference(), CostEstimationData::hasName(), CostEstimationData::hasPluginID(), hasRFEntry(), CostEstimationData::hasRFReference(), hasSocketEntry(), CostEstimationData::hasSocketReference(), CostEstimationData::hasValue(), CostEstimationData::name(), CostEstimationData::pluginID(), CostEstimationData::rfReference(), CostEstimationData::socketReference(), DataObject::stringValue(), Conversion::toString(), RelationalDBConnection::updateQuery(), and CostEstimationData::value().

Referenced by HDB::CachedHDBManager::modifyCostEstimationData().

Here is the call graph for this function:

◆ modifyCostFunctionPlugin()

void HDB::HDBManager::modifyCostFunctionPlugin ( RowID  id,
const CostFunctionPlugin plugin 
)
virtual

Modifies cost estimation function plugin attributes.

Parameters
idRowID of the plugin to modify.
pluginModified plugin (ID is ignored).
Exceptions
InvalidDataThrows if the given plugin was invalid.
KeyNotFoundThrows if no cost function plugin was found with given RowID.

Reimplemented in HDB::CachedHDBManager.

Definition at line 7080 of file HDBManager.cc.

7081  {
7082  if (plugin.name() == "") {
7083  throw InvalidData(__FILE__, __LINE__, __func__);
7084  }
7085 
7086  if (!hasCostFunctionPluginByID(id)) {
7087  throw KeyNotFound(__FILE__, __LINE__, __func__);
7088  }
7089 
7090  string type = "";
7091  switch (plugin.type()) {
7093  type = COST_PLUGIN_TYPE_FU;
7094  break;
7096  type = COST_PLUGIN_TYPE_RF;
7097  break;
7099  type = COST_PLUGIN_TYPE_DECOMP;
7100  break;
7102  type = COST_PLUGIN_TYPE_ICDEC;
7103  break;
7104  default:
7105  InvalidData ex(
7106  __FILE__, __LINE__, __func__,
7107  (boost::format("Illegal cost_function_plugin type %d.") %
7108  type).str());
7109  throw ex;
7110  break;
7111  }
7112 
7113  std::string query =
7114  std::string("UPDATE cost_function_plugin SET ") +
7115  " name='" + plugin.name() +
7116  "', description='" + plugin.description() +
7117  "', plugin_file_path='" + plugin.pluginFilePath() +
7118  "', type='" + type + "'";
7119 
7120  query += " WHERE id=";
7121  query += Conversion::toString(id);
7122  query += ";";
7123 
7124  try {
7125  dbConnection_->updateQuery(query);
7126  } catch (const Exception& e) {
7127  debugLog(e.errorMessage());
7128  assert(false);
7129  }
7130 }

References __func__, assert, HDB::CostFunctionPlugin::COST_DECOMP, HDB::CostFunctionPlugin::COST_FU, HDB::CostFunctionPlugin::COST_ICDEC, COST_PLUGIN_TYPE_DECOMP, COST_PLUGIN_TYPE_FU, COST_PLUGIN_TYPE_ICDEC, COST_PLUGIN_TYPE_RF, HDB::CostFunctionPlugin::COST_RF, dbConnection_, debugLog, HDB::CostFunctionPlugin::description(), Exception::errorMessage(), hasCostFunctionPluginByID(), HDB::CostFunctionPlugin::name(), HDB::CostFunctionPlugin::pluginFilePath(), Conversion::toString(), HDB::CostFunctionPlugin::type(), and RelationalDBConnection::updateQuery().

Referenced by HDB::CachedHDBManager::modifyCostFunctionPlugin().

Here is the call graph for this function:

◆ opcodesByIDQuery()

std::string HDB::HDBManager::opcodesByIDQuery ( RowID  id)
staticprivate

Creates an SQL query for getting operation code data of the FU that has the given ID.

The result table has fields {operation.name, opcode_map.opcode}.

Parameters
idID of the FU entry in HDB.

Definition at line 5991 of file HDBManager.cc.

5991  {
5992  string idString = Conversion::toString(id);
5993  string query =
5994  "SELECT operation.name AS 'operation.name',"
5995  " opcode_map.opcode AS 'opcode_map.opcode' "
5996  "FROM fu, fu_implementation, operation, opcode_map "
5997  "WHERE fu.id=" + idString + " AND"
5998  " fu_implementation.fu=fu.id AND"
5999  " opcode_map.fu_impl=fu_implementation.id AND"
6000  " operation.id=opcode_map.operation;";
6001  return query;
6002 }

References Conversion::toString().

Referenced by addOpcodesToImplementation().

Here is the call graph for this function:

◆ OperationImplementationByID()

HDB::OperationImplementation HDB::HDBManager::OperationImplementationByID ( RowID  id) const

Returns OperationImplementation.

Returns
OperationImplementation.

Definition at line 2248 of file HDBManager.cc.

2248  {
2249  RelationalDBQueryResult* result = nullptr;
2250  try {
2251  result = dbConnection_->query(
2252  std::string("SELECT * FROM operation_implementation WHERE id = ") +
2253  std::to_string(id) +
2254  std::string(";"));
2255  } catch (const Exception& e) {
2256  debugLog(e.errorMessage());
2257  assert(false);
2258  }
2259 
2260  OperationImplementation retval;
2261  if (result->hasNext()) {
2262  result->next();
2263 
2264  retval.id = id;
2265  retval.latency = result->data("latency").integerValue();
2266  retval.name = result->data("name").stringValue();
2267  retval.postOpImplFileVhdl =
2268  result->data("post_op_vhdl").stringValue();
2269  retval.postOpImplFileVerilog =
2270  result->data("post_op_verilog").stringValue();
2271  retval.absBusDefFile =
2272  result->data("bus_definition").stringValue();
2273  retval.initialImplFileVerilog =
2274  result->data("initial_verilog").stringValue();
2275  retval.initialImplFileVhdl =
2276  result->data("initial_vhdl").stringValue();
2277  }
2278  delete result;
2279  result = nullptr;
2280 
2281  try {
2282  result = dbConnection_->query(
2283  std::string("SELECT block_source_file.file "
2284  "FROM operation_implementation_source_file, "
2285  "block_source_file "
2286  "WHERE operation_implementation_source_"
2287  "file.operation = ") +
2288  std::to_string(id) +
2289  std::string(" AND operation_implementation_source_file.file = "
2290  " block_source_file.id"
2291  " AND block_source_file.format = "
2292  + std::to_string(
2294  ";"));
2295 
2296  } catch (const Exception& e) {
2297  debugLog(e.errorMessage());
2298  assert(false);
2299  }
2300  if (result->hasNext()) {
2301  result->next();
2302  retval.implFileVhdl = result->data("file").stringValue();
2303  }
2304  delete result;
2305  result = nullptr;
2306 
2307  try {
2308  result = dbConnection_->query(
2309  std::string("SELECT block_source_file.file "
2310  "FROM operation_implementation_source_file, "
2311  "block_source_file "
2312  "WHERE operation_implementation_"
2313  "source_file.operation = ") +
2314  std::to_string(id) +
2315  std::string(" AND operation_implementation_source_file.file = "
2316  " block_source_file.id"
2317  " AND block_source_file.format = "
2318  + std::to_string(
2320  ";"));
2321 
2322  } catch (const Exception& e) {
2323  debugLog(e.errorMessage());
2324  assert(false);
2325  }
2326  if (result->hasNext()) {
2327  result->next();
2328  retval.implFileVerilog = result->data("file").stringValue();
2329  }
2330  delete result;
2331  result = nullptr;
2332 
2333  std::string q1 = "SELECT resource, count "
2334  "FROM operation_implementation_resources "
2335  "WHERE operation_implementation_resources.operation = "
2336  + std::to_string(id) + ";";
2337  result = dbConnection_->query(q1);
2338  while (result->hasNext()) {
2339  result->next();
2340  int resource = result->data("resource").integerValue();
2341  OperationImplementationResource r =
2343  r.count = result->data("count").integerValue();
2344  retval.resources.emplace_back(r);
2345  }
2346 
2347  std::string q2 = "SELECT name, width, type, language "
2348  "FROM operation_implementation_variable "
2349  "WHERE CAST(operation as TEXT) = \"" + std::to_string(id) + "\";";
2350  result = dbConnection_->query(q2);
2351  while (result->hasNext()) {
2352  result->next();
2353  std::string name = result->data("name").stringValue();
2354  std::string width = result->data("width").stringValue();
2355  std::string type = result->data("type").stringValue();
2356  std::string lang = result->data("language").stringValue();
2357  // TODO not all HDBs have a rename column yet, so variable renaming is
2358  // hardcoded
2359  bool rename = true;
2360  // std::string renamestr = result->data("rename").stringValue();
2361  // bool rename = renamestr != "0";
2362  if (lang == "VHDL") {
2363  Variable var = {name, width, type, rename};
2364  retval.vhdlVariables.emplace_back(var);
2365  } else if (lang == "Verilog") {
2366  retval.verilogVariables.emplace_back(
2367  Variable{name, width, type, rename});
2368  } else {
2369  throw std::runtime_error("Unknown language");
2370  }
2371  }
2372 
2374  "operation_implementation_globalsignal")) {
2375  std::string q3 =
2376  "SELECT name, width, type, language, rename "
2377  "FROM operation_implementation_globalsignal "
2378  "WHERE CAST(operation as TEXT) = \"" +
2379  std::to_string(id) + "\";";
2380  result = dbConnection_->query(q3);
2381  while (result->hasNext()) {
2382  result->next();
2383  std::string name = result->data("name").stringValue();
2384  std::string width = result->data("width").stringValue();
2385  std::string type = result->data("type").stringValue();
2386  std::string lang = result->data("language").stringValue();
2387  std::string renamestr = result->data("rename").stringValue();
2388  bool rename = renamestr != "0";
2389  if (lang == "VHDL") {
2390  Variable var = {name, width, type, rename};
2391  retval.vhdlGlobalSignals.emplace_back(var);
2392  } else if (lang == "Verilog") {
2393  retval.verilogGlobalSignals.emplace_back(
2394  Variable{name, width, type, rename});
2395  } else {
2396  throw std::runtime_error("Unknown language");
2397  }
2398  }
2399  }
2400 
2401  return retval;
2402 }

References HDB::OperationImplementation::absBusDefFile, assert, HDB::OperationImplementationResource::count, RelationalDBQueryResult::data(), dbConnection_, debugLog, Exception::errorMessage(), RelationalDBQueryResult::hasNext(), HDB::OperationImplementation::id, HDB::OperationImplementation::implFileVerilog, HDB::OperationImplementation::implFileVhdl, HDB::OperationImplementation::initialImplFileVerilog, HDB::OperationImplementation::initialImplFileVhdl, DataObject::integerValue(), HDB::OperationImplementation::latency, HDB::OperationImplementation::name, RelationalDBQueryResult::next(), OperationImplementationResourceByID(), HDB::OperationImplementation::postOpImplFileVerilog, HDB::OperationImplementation::postOpImplFileVhdl, RelationalDBConnection::query(), HDB::OperationImplementation::resources, DataObject::stringValue(), RelationalDBConnection::tableExistsInDB(), HDB::BlockImplementationFile::Verilog, HDB::OperationImplementation::verilogGlobalSignals, HDB::OperationImplementation::verilogVariables, HDB::BlockImplementationFile::VHDL, HDB::OperationImplementation::vhdlGlobalSignals, and HDB::OperationImplementation::vhdlVariables.

Referenced by Automagic::createFUGeneratableOperationInfos(), ProGeTools::createFUGeneratableOperationInfos(), FUGen::createImplementationFiles(), HDBToHtml::OperationImplementationToHtml(), and FUGen::parseOperations().

Here is the call graph for this function:

◆ OperationImplementationIDs()

std::set< RowID > HDB::HDBManager::OperationImplementationIDs ( ) const

Returns a set of Operation Implementation Resource IDs in the database.

Returns
A set containing all the Operation Implementation Resource IDs in the database.

Definition at line 2193 of file HDBManager.cc.

2193  {
2194  RelationalDBQueryResult* result = NULL;
2195  try {
2196  result = dbConnection_->query(
2197  std::string("SELECT id FROM operation_implementation;"));
2198  } catch (const Exception& e) {
2199  debugLog(e.errorMessage());
2200  assert(false);
2201  }
2202 
2203  std::set<RowID> idSet;
2204  while (result->hasNext()) {
2205  result->next();
2206  const DataObject& idData = result->data(0);
2207  idSet.insert(idData.integerValue());
2208  }
2209 
2210  delete result;
2211  return idSet;
2212 }

References assert, RelationalDBQueryResult::data(), dbConnection_, debugLog, Exception::errorMessage(), RelationalDBQueryResult::hasNext(), DataObject::integerValue(), RelationalDBQueryResult::next(), and RelationalDBConnection::query().

Referenced by Automagic::createFUGeneratableOperationInfos(), and ProGeTools::createFUGeneratableOperationInfos().

Here is the call graph for this function:

◆ OperationImplementationResourceByID()

HDB::OperationImplementationResource HDB::HDBManager::OperationImplementationResourceByID ( RowID  id) const

Returns OperationImplementationResource.

Returns
OperationImplementationResource.

Definition at line 2410 of file HDBManager.cc.

2410  {
2411  RelationalDBQueryResult* result = nullptr;
2412  try {
2413  result = dbConnection_->query(
2414  std::string("SELECT * FROM "
2415  "operation_implementation_resource WHERE id = ") +
2416  std::to_string(id) +
2417  std::string(";"));
2418  } catch (const Exception& e) {
2419  debugLog(e.errorMessage());
2420  assert(false);
2421  }
2422 
2423  OperationImplementationResource retval;
2424  if (result->hasNext()) {
2425  result->next();
2426 
2427  retval.id = id;
2428  retval.name = result->data("name").stringValue();
2429  retval.ipxact = result->data("ipxact").stringValue();
2430  }
2431  delete result;
2432  result = nullptr;
2433 
2434  try {
2435  result = dbConnection_->query(
2436  std::string("SELECT block_source_file.file, "
2437  "format.format "
2438  "FROM operation_implementation_resource_"
2439  "source_file, block_source_file, "
2440  "format "
2441  "WHERE operation_implementation_resource_"
2442  "source_file.resource = ") +
2443  std::to_string(id) +
2444  std::string(" AND operation_implementation_resource_"
2445  "source_file.file = "
2446  " block_source_file.id "
2447  "AND block_source_file.format = "
2448  "format.id;"
2449  ));
2450 
2451  } catch (const Exception& e) {
2452  debugLog(e.errorMessage());
2453  assert(false);
2454  }
2455  while (result->hasNext()) {
2456  result->next();
2457  std::string format = result->data("format").stringValue();
2458  if (format == VHDL_FORMAT) {
2459  retval.synFiles.push_back(result->data("file").stringValue());
2460  retval.synFormats.push_back(format);
2461  } else if (format == VHDL_SIM_FORMAT) {
2462  retval.simFiles.push_back(result->data("file").stringValue());
2463  retval.simFormats.push_back(format);
2464  } else if (format == VERILOG_FORMAT) {
2465  retval.synFiles.push_back(result->data("file").stringValue());
2466  retval.synFormats.push_back(format);
2467  } else if (format == VERILOG_SIM_FORMAT) {
2468  retval.simFiles.push_back(result->data("file").stringValue());
2469  retval.simFormats.push_back(format);
2470  }
2471  }
2472  delete result;
2473  result = nullptr;
2474 
2475  return retval;
2476 }

References assert, RelationalDBQueryResult::data(), dbConnection_, debugLog, Exception::errorMessage(), RelationalDBQueryResult::hasNext(), HDB::OperationImplementationResource::id, HDB::OperationImplementationResource::ipxact, HDB::OperationImplementationResource::name, RelationalDBQueryResult::next(), RelationalDBConnection::query(), HDB::OperationImplementationResource::simFiles, HDB::OperationImplementationResource::simFormats, DataObject::stringValue(), HDB::OperationImplementationResource::synFiles, HDB::OperationImplementationResource::synFormats, VERILOG_FORMAT, VERILOG_SIM_FORMAT, VHDL_FORMAT, and VHDL_SIM_FORMAT.

Referenced by OperationImplementationDialog::addAvailableResourcesToList(), OperationImplementationByID(), and HDBToHtml::OperationImplementationResourceToHtml().

Here is the call graph for this function:

◆ OperationImplementationResourceIDs()

std::set< RowID > HDB::HDBManager::OperationImplementationResourceIDs ( ) const

Returns a set of Operation Implementation IDs in the database.

Returns
A set containing all the Operation Implemnetation IDs in the database.

Definition at line 2221 of file HDBManager.cc.

2221  {
2222  RelationalDBQueryResult* result = NULL;
2223  try {
2224  result = dbConnection_->query(
2225  std::string("SELECT id FROM operation_implementation_resource;"));
2226  } catch (const Exception& e) {
2227  debugLog(e.errorMessage());
2228  assert(false);
2229  }
2230 
2231  std::set<RowID> idSet;
2232  while (result->hasNext()) {
2233  result->next();
2234  const DataObject& idData = result->data(0);
2235  idSet.insert(idData.integerValue());
2236  }
2237 
2238  delete result;
2239  return idSet;
2240 }

References assert, RelationalDBQueryResult::data(), dbConnection_, debugLog, Exception::errorMessage(), RelationalDBQueryResult::hasNext(), DataObject::integerValue(), RelationalDBQueryResult::next(), and RelationalDBConnection::query().

Referenced by OperationImplementationDialog::addAvailableResourcesToList().

Here is the call graph for this function:

◆ removeBusEntry()

void HDB::HDBManager::removeBusEntry ( RowID  id) const
virtual

Removes the Bus entry that has the given ID from the database.

The entry is removed entirely, meaning that also cost estimation data of that entry are removed.

Parameters
idThe ID of the Bus entry.

Reimplemented in HDB::CachedHDBManager.

Definition at line 3418 of file HDBManager.cc.

3418  {
3419 
3420  if (!hasBusEntry(id)) {
3421  return;
3422  }
3423 
3424  // remove cost estimation data
3425  try {
3426  // get the IDs of cost estimation datas
3428  std::string(
3429  "SELECT id FROM cost_estimation_data "
3430  "WHERE bus_reference=" + Conversion::toString(id) + ";"));
3431  while (result->hasNext()) {
3432  result->next();
3433  const DataObject& costIDData = result->data(0);
3434  int dataID = costIDData.integerValue();
3435  removeCostEstimationData(dataID);
3436  }
3437  delete result;
3438  } catch (const Exception& e) {
3439  debugLog(e.errorMessage());
3440  assert(false);
3441  }
3442 
3443  // remove from bus table
3444  try {
3446  std::string(
3447  "DELETE FROM bus "
3448  "WHERE id=" + Conversion::toString(id) + ";"));
3449  } catch (const Exception& e) {
3450  debugLog(e.errorMessage());
3451  assert(false);
3452  }
3453 }

References assert, RelationalDBQueryResult::data(), dbConnection_, debugLog, Exception::errorMessage(), hasBusEntry(), RelationalDBQueryResult::hasNext(), DataObject::integerValue(), RelationalDBQueryResult::next(), RelationalDBConnection::query(), removeCostEstimationData(), Conversion::toString(), and RelationalDBConnection::updateQuery().

Referenced by HDBEditorDeleteCmd::Do(), and HDB::CachedHDBManager::removeBusEntry().

Here is the call graph for this function:

◆ removeCostEstimationData()

void HDB::HDBManager::removeCostEstimationData ( RowID  id) const
virtual

Removes the cost estimation data that has the given ID.

Parameters
idID of the cost estimation data.

Reimplemented in HDB::CachedHDBManager.

Definition at line 5479 of file HDBManager.cc.

5479  {
5480  try {
5482  std::string(
5483  "DELETE FROM cost_estimation_data "
5484  "WHERE id=" + Conversion::toString(id) + ";"));
5485  } catch (const Exception& e) {
5486  debugLog(e.errorMessage());
5487  assert(false);
5488  }
5489 }

References assert, dbConnection_, debugLog, Exception::errorMessage(), Conversion::toString(), and RelationalDBConnection::updateQuery().

Referenced by removeBusEntry(), HDB::CachedHDBManager::removeCostEstimationData(), removeFUEntry(), and removeSocketEntry().

Here is the call graph for this function:

◆ removeCostFunctionPlugin()

void HDB::HDBManager::removeCostFunctionPlugin ( RowID  pluginID) const
virtual

Removes the CostFunctionPlugin that has the given ID.

Parameters
pluginIDID of the cost plugin.

Reimplemented in HDB::CachedHDBManager.

Definition at line 684 of file HDBManager.cc.

684  {
685 
686  try {
688 
689  // remove from cost_function_plugin table
691  std::string(
692  "DELETE FROM cost_function_plugin "
693  "WHERE id=" + Conversion::toString(pluginID) + ";"));
695  std::string(
696  "DELETE FROM cost_estimation_data "
697  "WHERE plugin_reference=" +
698  Conversion::toString(pluginID) + ";"));
699 
701  } catch (const Exception& e) {
703  debugLog(e.errorMessage());
704  assert(false);
705  }
706 }

References assert, RelationalDBConnection::beginTransaction(), RelationalDBConnection::commit(), dbConnection_, debugLog, Exception::errorMessage(), RelationalDBConnection::rollback(), Conversion::toString(), and RelationalDBConnection::updateQuery().

Referenced by AddCostFunctionPluginCmd::Do(), HDBEditorDeleteCmd::Do(), and HDB::CachedHDBManager::removeCostFunctionPlugin().

Here is the call graph for this function:

◆ removeFUArchitecture()

void HDB::HDBManager::removeFUArchitecture ( RowID  archID) const
virtual

Removes the FU architecture that has the given ID. The architecture is removed only it is not used by any FU entry. Otherwise an exception is thrown.

Parameters
archIDID of the FU architecture.
Exceptions
InvalidDataIf the architecture cannot be removed since it is used by some FU entry.

Reimplemented in HDB::CachedHDBManager.

Definition at line 941 of file HDBManager.cc.

941  {
942  if (!canRemoveFUArchitecture(archID)) {
943  throw InvalidData(__FILE__, __LINE__, __func__);
944  }
945 
946  try {
948 
949  // remove from io_binding table
951  std::string(
952  "DELETE FROM io_binding "
953  "WHERE port IN "
954  "(SELECT id "
955  "FROM fu_data_port "
956  "WHERE fu_arch=" + Conversion::toString(archID) + ");"));
957 
958  // remove from fu_data_port table
960  std::string(
961  "DELETE FROM fu_data_port "
962  "WHERE fu_arch=" + Conversion::toString(archID) + ";"));
963 
964  // remove from io_usage_table
966  std::string(
967  "DELETE FROM io_usage "
968  "WHERE pipeline IN "
969  "(SELECT id FROM operation_pipeline "
970  "WHERE fu_arch=" + Conversion::toString(archID) + ");"));
971 
972  // remove from pipeline_resource_usage table
974  std::string(
975  "DELETE FROM pipeline_resource_usage "
976  "WHERE pipeline IN "
977  "(SELECT id FROM operation_pipeline "
978  "WHERE fu_arch=" + Conversion::toString(archID) + ");"));
979 
980  // remove from pipeline_resource_table
982  std::string(
983  "DELETE FROM pipeline_resource "
984  "WHERE fu_arch=" + Conversion::toString(archID) + ";"));
985 
986  // remove from operation_pipeline_table
988  std::string(
989  "DELETE FROM operation_pipeline "
990  "WHERE fu_arch=" + Conversion::toString(archID) + ";"));
991 
992  // remove from fu_architecture table
994  std::string(
995  "DELETE FROM fu_architecture "
996  "WHERE id=" + Conversion::toString(archID) + ";"));
997 
999 
1000  } catch (const Exception& e) {
1002  debugLog(e.errorMessage());
1003  assert(false);
1004  }
1005 }

References __func__, assert, RelationalDBConnection::beginTransaction(), canRemoveFUArchitecture(), RelationalDBConnection::commit(), dbConnection_, debugLog, Exception::errorMessage(), RelationalDBConnection::rollback(), Conversion::toString(), and RelationalDBConnection::updateQuery().

Referenced by HDBEditorDeleteCmd::Do(), and HDB::CachedHDBManager::removeFUArchitecture().

Here is the call graph for this function:

◆ removeFUEntry()

void HDB::HDBManager::removeFUEntry ( RowID  id) const
virtual

Removes the FU entry that has the given ID from the database.

The entry is removed entirely, meaning that all also FU implementation and cost estimation data of that entry are removed.

Parameters
idThe ID of the FU entry.

Reimplemented in HDB::CachedHDBManager.

Definition at line 1039 of file HDBManager.cc.

1039  {
1040 
1041  if (!hasFUEntry(id)) {
1042  return;
1043  }
1044 
1045  // remove implementation
1046  try {
1047  // get the ID of the implementation
1049  std::string(
1050  "SELECT id FROM fu_implementation "
1051  "WHERE fu=" + Conversion::toString(id) + ";"));
1052  if (result->hasNext()) {
1053  result->next();
1054  const DataObject& implIDData = result->data(0);
1055  int implID = implIDData.integerValue();
1056  removeFUImplementation(implID);
1057  }
1058  delete result;
1059  } catch (const Exception& e) {
1060  debugLog(e.errorMessage());
1061  assert(false);
1062  }
1063 
1064  // remove cost estimation data
1065  try {
1066  // get the IDs of cost estimation datas
1068  std::string(
1069  "SELECT id FROM cost_estimation_data "
1070  "WHERE fu_reference=" + Conversion::toString(id) + ";"));
1071  while (result->hasNext()) {
1072  result->next();
1073  const DataObject& costIDData = result->data(0);
1074  int dataID = costIDData.integerValue();
1075  removeCostEstimationData(dataID);
1076  }
1077  delete result;
1078  } catch (const Exception& e) {
1079  debugLog(e.errorMessage());
1080  assert(false);
1081  }
1082 
1083  // remove from fu table
1084  try {
1086  std::string(
1087  "DELETE FROM fu "
1088  "WHERE id=" + Conversion::toString(id) + ";"));
1089  } catch (const Exception& e) {
1090  debugLog(e.errorMessage());
1091  assert(false);
1092  }
1093 }

References assert, RelationalDBQueryResult::data(), dbConnection_, debugLog, Exception::errorMessage(), hasFUEntry(), RelationalDBQueryResult::hasNext(), DataObject::integerValue(), RelationalDBQueryResult::next(), RelationalDBConnection::query(), removeCostEstimationData(), removeFUImplementation(), Conversion::toString(), and RelationalDBConnection::updateQuery().

Referenced by HDBEditorDeleteCmd::Do(), and HDB::CachedHDBManager::removeFUEntry().

Here is the call graph for this function:

◆ removeFUImplementation()

void HDB::HDBManager::removeFUImplementation ( RowID  implID) const
virtual

Removes the given FU implementation from the database.

Parameters
implIDID of the FU implementation.

Reimplemented in HDB::CachedHDBManager.

Definition at line 1325 of file HDBManager.cc.

1325  {
1326 
1327  try {
1329 
1330  // remove from fu_ext_port_parameter_dependency table
1332  std::string(
1333  "DELETE FROM fu_ext_port_parameter_dependency "
1334  "WHERE parameter in (SELECT ALL id FROM "
1335  "fu_implementation_parameter WHERE fu_impl="
1336  + Conversion::toString(implID) + ");"));
1337 
1338  // remove from fu_external_port table
1340  std::string(
1341  "DELETE FROM fu_external_port "
1342  "WHERE fu_impl=" + Conversion::toString(implID) + ";"));
1343 
1344  // remove from fu_port_map table
1346  std::string(
1347  "DELETE FROM fu_port_map "
1348  "WHERE fu_impl=" + Conversion::toString(implID) + ";"));
1349 
1350  // remove from opcode_map table
1352  std::string(
1353  "DELETE FROM opcode_map "
1354  "WHERE fu_impl=" + Conversion::toString(implID) + ";"));
1355 
1356  // remove from fu_implementation_parameter
1358  std::string(
1359  "DELETE FROM fu_implementation_parameter "
1360  "WHERE fu_impl=" + Conversion::toString(implID) + ";"));
1361 
1362  // remove from fu_source_file
1364  std::string(
1365  "DELETE FROM fu_source_file "
1366  "WHERE fu_impl=" + Conversion::toString(implID) + ";"));
1367 
1368  // remove from block_source_file
1370  std::string(
1371  "DELETE FROM block_source_file "
1372  "WHERE id NOT IN "
1373  "(SELECT file FROM fu_source_file UNION "
1374  "SELECT file FROM rf_source_file);"));
1375 
1376  // remove from fu_implementation
1378  std::string(
1379  "DELETE FROM fu_implementation "
1380  "WHERE id=" + Conversion::toString(implID) + ";"));
1381 
1382  dbConnection_->commit();
1383 
1384  } catch (const Exception& e) {
1386  debugLog(e.errorMessage());
1387  assert(false);
1388  }
1389 }

References assert, RelationalDBConnection::beginTransaction(), RelationalDBConnection::commit(), dbConnection_, debugLog, Exception::errorMessage(), RelationalDBConnection::rollback(), Conversion::toString(), and RelationalDBConnection::updateQuery().

Referenced by HDBEditorModifyCmd::Do(), removeFUEntry(), and HDB::CachedHDBManager::removeFUImplementation().

Here is the call graph for this function:

◆ removeOperationImplementation()

void HDB::HDBManager::removeOperationImplementation ( RowID  id)

Remove Operation Implemententation from DB.

Definition at line 2622 of file HDBManager.cc.

2622  {
2623  std::string d1 = "DELETE FROM operation_implementation "
2624  "WHERE id = " + std::to_string(id) + ";";
2625  std::string d2 =
2626  "DELETE FROM operation_implementation_source_file "
2627  "WHERE operation = " + std::to_string(id) + ";";
2628  std::string d3 =
2629  "DELETE FROM operation_implementation_resources "
2630  "WHERE operation = " + std::to_string(id) + ";";
2631  std::string d4 =
2632  "DELETE FROM operation_implementation_variable "
2633  "WHERE operation = " + std::to_string(id) + ";";
2634  std::string s1 = "SELECT file FROM "
2635  "operation_implementation_source_file "
2636  "WHERE operation = " + std::to_string(id) + ";";
2637 
2639  while (result->hasNext()) {
2640  result->next();
2641  int file_id = result->data(0).integerValue();
2642  std::string d3lete = "DELETE FROM block_source_file "
2643  "WHERE id = " + std::to_string(file_id) + ";";
2644  dbConnection_->updateQuery(d3lete);
2645  }
2646 
2651  delete result;
2652 }

References RelationalDBQueryResult::data(), dbConnection_, RelationalDBQueryResult::hasNext(), DataObject::integerValue(), RelationalDBQueryResult::next(), RelationalDBConnection::query(), and RelationalDBConnection::updateQuery().

Referenced by HDBEditorDeleteCmd::Do().

Here is the call graph for this function:

◆ removeOperationImplementationResource()

void HDB::HDBManager::removeOperationImplementationResource ( RowID  id)

Remove Operation Implemententation Resource from DB.

Definition at line 2658 of file HDBManager.cc.

2658  {
2659  std::string d1 = "DELETE FROM operation_implementation_resource "
2660  "WHERE id = " + std::to_string(id) + ";";
2661  std::string d2 =
2662  "DELETE FROM operation_implementation_resource_source_file "
2663  "WHERE resource = " + std::to_string(id) + ";";
2664  std::string s1 = "SELECT file FROM "
2665  "operation_implementation_resource_source_file "
2666  "WHERE resource = " + std::to_string(id) + ";";
2667 
2669  while (result->hasNext()) {
2670  result->next();
2671  int file_id = result->data(0).integerValue();
2672  std::string d3 = "DELETE FROM block_source_file "
2673  "WHERE id = " + std::to_string(file_id) + ";";
2675  }
2676 
2679  delete result;
2680 }

References RelationalDBQueryResult::data(), dbConnection_, RelationalDBQueryResult::hasNext(), DataObject::integerValue(), RelationalDBQueryResult::next(), RelationalDBConnection::query(), and RelationalDBConnection::updateQuery().

Referenced by HDBEditorDeleteCmd::Do().

Here is the call graph for this function:

◆ removeRFArchitecture()

void HDB::HDBManager::removeRFArchitecture ( RowID  archID) const
virtual

Removes the RF architecture that has the given ID.

Parameters
archIDID of the RF architecture.
Exceptions
InvalidDataIf the RF architecture cannot be removed.

Reimplemented in HDB::CachedHDBManager.

Definition at line 1535 of file HDBManager.cc.

1535  {
1536  if (!canRemoveRFArchitecture(archID)) {
1537  throw InvalidData(__FILE__, __LINE__, __func__);
1538  }
1539 
1540  try {
1542  std::string(
1543  "DELETE FROM rf_architecture WHERE id=" +
1544  Conversion::toString(archID) + ";"));
1545  } catch (const Exception& e) {
1546  debugLog(e.errorMessage());
1547  assert(false);
1548  }
1549 }

References __func__, assert, canRemoveRFArchitecture(), dbConnection_, debugLog, Exception::errorMessage(), Conversion::toString(), and RelationalDBConnection::updateQuery().

Referenced by HDBEditorDeleteCmd::Do(), and HDB::CachedHDBManager::removeRFArchitecture().

Here is the call graph for this function:

◆ removeRFEntry()

void HDB::HDBManager::removeRFEntry ( RowID  id) const
virtual

Removes the RF entry that has the given ID.

Cost estimation data and implementation of the entry are removed too.

Parameters
idID of the RF entry.

Reimplemented in HDB::CachedHDBManager.

Definition at line 1583 of file HDBManager.cc.

1583  {
1584 
1585  if (!hasRFEntry(id)) {
1586  return;
1587  }
1588 
1589  // remove from cost_estimation_data
1590  try {
1592  std::string(
1593  "DELETE FROM cost_estimation_data WHERE rf_reference=" +
1594  Conversion::toString(id) + ";"));
1595  } catch (const Exception& e) {
1596  debugLog(e.errorMessage());
1597  assert(false);
1598  }
1599 
1600  // remove implementation
1601  try {
1603  std::string(
1604  "SELECT id FROM rf_implementation WHERE rf=" +
1605  Conversion::toString(id) + ";"));
1606  if (result->hasNext()) {
1607  result->next();
1608  RowID implID = result->data(0).integerValue();
1609  removeRFImplementation(implID);
1610  }
1611  delete result;
1612  } catch (const Exception& e) {
1613  debugLog(e.errorMessage());
1614  assert(false);
1615  }
1616 
1617  // remove the entry
1618  try {
1620  std::string(
1621  "DELETE FROM rf WHERE id=" + Conversion::toString(id)
1622  + ";"));
1623  } catch (const Exception& e) {
1624  debugLog(e.errorMessage());
1625  assert(false);
1626  }
1627 }

References assert, RelationalDBQueryResult::data(), dbConnection_, debugLog, Exception::errorMessage(), RelationalDBQueryResult::hasNext(), hasRFEntry(), DataObject::integerValue(), RelationalDBQueryResult::next(), RelationalDBConnection::query(), removeRFImplementation(), Conversion::toString(), and RelationalDBConnection::updateQuery().

Referenced by HDBEditorDeleteCmd::Do(), and HDB::CachedHDBManager::removeRFEntry().

Here is the call graph for this function:

◆ removeRFImplementation()

void HDB::HDBManager::removeRFImplementation ( RowID  implID) const
virtual

Removes the RF implementation that has the given ID.

Parameters
implIDID of the RF implementation.

Reimplemented in HDB::CachedHDBManager.

Definition at line 1808 of file HDBManager.cc.

1808  {
1809 
1810  bool dependencyTableExists =
1811  dbConnection_->tableExistsInDB("rf_ext_port_parameter_dependency");
1812  bool parameterTableExists =
1813  dbConnection_->tableExistsInDB("rf_implementation_parameter");
1814  bool externalPortTableExists =
1815  dbConnection_->tableExistsInDB("rf_external_port");
1816 
1817  try {
1819 
1820  // remove from rf_ext_port_parameter_dependency table if it exists
1821  // (backward compatibility for old HDBs).
1822  if (dependencyTableExists) {
1823  assert(parameterTableExists && externalPortTableExists);
1825  std::string(
1826  "DELETE FROM rf_ext_port_parameter_dependency "
1827  "WHERE parameter in (SELECT ALL id "
1828  "FROM rf_implementation_parameter WHERE rf_impl = " +
1829  Conversion::toString(implID) + ");"));
1830  }
1831 
1832  // remove from rf_external_port table if it exists
1833  // (backward compatibility for old HDBs).
1834  if (externalPortTableExists) {
1836  std::string(
1837  "DELETE FROM rf_external_port "
1838  "WHERE rf_impl=" +
1839  Conversion::toString(implID) + ";"));
1840  }
1841 
1842  // remove from rf_implementation_parameter table if it exists
1843  // (backward compatibility for old HDBs).
1844  if (parameterTableExists) {
1846  std::string(
1847  "DELETE FROM rf_implementation_parameter "
1848  "WHERE rf_impl=" + Conversion::toString(implID) + ";"));
1849  }
1850 
1851  // remove from rf_source_file table
1853  std::string(
1854  "DELETE FROM rf_source_file WHERE rf_impl=" +
1855  Conversion::toString(implID) + ";"));
1856 
1857  // remove from block_source_file table
1859  std::string(
1860  "DELETE FROM block_source_file WHERE id NOT IN "
1861  "(SELECT file FROM fu_source_file UNION "
1862  "SELECT file FROM rf_source_file);"));
1863 
1864  // remove from rf_data_port
1866  std::string(
1867  "DELETE FROM rf_data_port WHERE rf_impl=" +
1868  Conversion::toString(implID) + ";"));
1869 
1870  // remove from rf_implementation
1872  std::string(
1873  "DELETE FROM rf_implementation WHERE id=" +
1874  Conversion::toString(implID) + ";"));
1875 
1876  dbConnection_->commit();
1877 
1878  } catch (const Exception& e) {
1880  debugLog(e.errorMessage());
1881  assert(false);
1882  }
1883 }

References assert, RelationalDBConnection::beginTransaction(), RelationalDBConnection::commit(), dbConnection_, debugLog, Exception::errorMessage(), RelationalDBConnection::rollback(), RelationalDBConnection::tableExistsInDB(), Conversion::toString(), and RelationalDBConnection::updateQuery().

Referenced by HDBEditorModifyCmd::Do(), removeRFEntry(), and HDB::CachedHDBManager::removeRFImplementation().

Here is the call graph for this function:

◆ removeSocketEntry()

void HDB::HDBManager::removeSocketEntry ( RowID  id) const
virtual

Removes the Socket entry that has the given ID from the database.

The entry is removed entirely, meaning that also cost estimation data of that entry are removed.

Parameters
idThe ID of the Socket entry.

Reimplemented in HDB::CachedHDBManager.

Definition at line 3631 of file HDBManager.cc.

3631  {
3632 
3633  if (!hasSocketEntry(id)) {
3634  return;
3635  }
3636 
3637  // remove cost estimation data
3638  try {
3639  // get the IDs of cost estimation datas
3641  std::string(
3642  "SELECT id FROM cost_estimation_data "
3643  "WHERE socket_reference=" + Conversion::toString(id) + ";"));
3644  while (result->hasNext()) {
3645  result->next();
3646  const DataObject& costIDData = result->data(0);
3647  int dataID = costIDData.integerValue();
3648  removeCostEstimationData(dataID);
3649  }
3650  delete result;
3651  } catch (const Exception& e) {
3652  debugLog(e.errorMessage());
3653  assert(false);
3654  }
3655 
3656  // remove from socket table
3657  try {
3659  std::string(
3660  "DELETE FROM socket "
3661  "WHERE id=" + Conversion::toString(id) + ";"));
3662  } catch (const Exception& e) {
3663  debugLog(e.errorMessage());
3664  assert(false);
3665  }
3666 }

References assert, RelationalDBQueryResult::data(), dbConnection_, debugLog, Exception::errorMessage(), RelationalDBQueryResult::hasNext(), hasSocketEntry(), DataObject::integerValue(), RelationalDBQueryResult::next(), RelationalDBConnection::query(), removeCostEstimationData(), Conversion::toString(), and RelationalDBConnection::updateQuery().

Referenced by HDBEditorDeleteCmd::Do(), and HDB::CachedHDBManager::removeSocketEntry().

Here is the call graph for this function:

◆ resolveArchitecturePort()

std::string HDB::HDBManager::resolveArchitecturePort ( const FUArchitecture architecture,
RowID  entryID,
const std::string &  implementedPort 
) const
private

Resolves what is the architectural port corresponding to the given implemented port.

Parameters
architectureThe architecture of the FU.
idID of the FU entry in the database.
implementedPortName of the implemented port to resolve.
Returns
Name of the corresponding port in the FU architecture.

Definition at line 4922 of file HDBManager.cc.

4925  {
4926 
4927  RelationalDBQueryResult* bindingData = NULL;
4928  try {
4929  bindingData = dbConnection_->query(
4930  fuPortBindingByNameQuery(entryID, implementedPort));
4931  } catch (const Exception&) {
4932  assert(false);
4933  }
4934 
4935  int operationColumn = bindingData->column("operation.name");
4936  int ioColumn = bindingData->column("io_binding.io_number");
4937  assert(operationColumn != RelationalDBQueryResult::UNKNOWN_INDEX);
4939 
4940  FunctionUnit& fu = architecture.architecture();
4941  string portName = "";
4942 
4943  while (bindingData->hasNext()) {
4944  bindingData->next();
4945  const DataObject& operationData = bindingData->data(operationColumn);
4946  const DataObject& ioData = bindingData->data(ioColumn);
4947  string operationName = operationData.stringValue();
4948  int io = ioData.integerValue();
4949  assert(fu.hasOperation(operationName));
4950  HWOperation* operation = fu.operation(operationName);
4951  FUPort* port = operation->port(io);
4952  assert(portName == "" || portName == port->name());
4953  portName = port->name();
4954  }
4955 
4956  delete bindingData;
4957  bindingData = NULL;
4958 
4959  return portName;
4960 }

References HDB::FUArchitecture::architecture(), assert, RelationalDBQueryResult::column(), RelationalDBQueryResult::data(), dbConnection_, fuPortBindingByNameQuery(), RelationalDBQueryResult::hasNext(), TTAMachine::FunctionUnit::hasOperation(), DataObject::integerValue(), TTAMachine::Port::name(), RelationalDBQueryResult::next(), TTAMachine::FunctionUnit::operation(), TTAMachine::HWOperation::port(), RelationalDBConnection::query(), DataObject::stringValue(), and RelationalDBQueryResult::UNKNOWN_INDEX.

Referenced by addDataPortsToImplementation().

Here is the call graph for this function:

◆ resourceUsageDataByIDQuery()

std::string HDB::HDBManager::resourceUsageDataByIDQuery ( RowID  id)
staticprivate

Creates an SQL query for getting resource usage data of pipelines of the FU architecture that has the given ID.

The result table has fields {operation.name, pipeline_resource_usage.cycle, pipeline_resource.id}

Parameters
idID of the FU architecture in HDB.

Definition at line 5933 of file HDBManager.cc.

5933  {
5934  string idString = Conversion::toString(id);
5935  string query =
5936  "SELECT operation.name AS 'operation.name',"
5937  " pipeline_resource_usage.cycle AS "
5938  " 'pipeline_resource_usage.cycle',"
5939  " pipeline_resource.id AS 'pipeline_resource.id' "
5940  "FROM pipeline_resource_usage, pipeline_resource, operation,"
5941  " operation_pipeline "
5942  "WHERE operation_pipeline.fu_arch=" + idString + " AND"
5943  " pipeline_resource_usage.pipeline=operation_pipeline.id AND"
5944  " pipeline_resource.id = pipeline_resource_usage.resource AND"
5945  " operation.id=operation_pipeline.operation;";
5946  return query;
5947 }

References Conversion::toString().

Referenced by addOperationPipelinesToFUArchitecture().

Here is the call graph for this function:

◆ rfArchitectureByID()

RFArchitecture * HDB::HDBManager::rfArchitectureByID ( RowID  id) const
virtual

Creates an RFArchitecture instance of the RF architecture that has the given ID.

Parameters
idThe ID of the RF architecture.
Returns
The newly created RFArchitecture instance.
Exceptions
KeyNotFoundIf the HDB does not contain RF architecture with the given ID.

Reimplemented in HDB::CachedHDBManager.

Definition at line 2963 of file HDBManager.cc.

2963  {
2964  if (!containsRFArchitecture(id)) {
2965  throw KeyNotFound(__FILE__, __LINE__, __func__);
2966  }
2967 
2968  RelationalDBQueryResult* architectureData;
2969  try {
2970  architectureData = dbConnection_->query(rfArchitectureByIDQuery(id));
2971  } catch (const Exception& e) {
2972  debugLog(e.errorMessage());
2973  assert(false);
2974  }
2975 
2976  int sizeColumn = architectureData->column("size");
2977  int widthColumn = architectureData->column("width");
2978  int readPortsColumn = architectureData->column("read_ports");
2979  int writePortsColumn = architectureData->column("write_ports");
2980  int bidirPortsColumn = architectureData->column("bidir_ports");
2981  int latencyColumn = architectureData->column("latency");
2982  int maxReadsColumn = architectureData->column("max_reads");
2983  int maxWritesColumn = architectureData->column("max_writes");
2984  int guardSupportColumn = architectureData->column("guard_support");
2985  int guardLatencyColumn = architectureData->column("guard_latency");
2986  int zeroRegisterColumn = architectureData->column("zero_register");
2987 
2988  assert(architectureData->hasNext());
2989  architectureData->next();
2990  assert(!architectureData->hasNext());
2991  const DataObject& sizeData = architectureData->data(sizeColumn);
2992  const DataObject& widthData = architectureData->data(widthColumn);
2993  const DataObject& readPortsData = architectureData->data(
2994  readPortsColumn);
2995  const DataObject& writePortsData = architectureData->data(
2996  writePortsColumn);
2997  const DataObject& bidirPortsData = architectureData->data(
2998  bidirPortsColumn);
2999  const DataObject& latencyData = architectureData->data(
3000  latencyColumn);
3001  const DataObject& maxReadsData = architectureData->data(
3002  maxReadsColumn);
3003  const DataObject& maxWritesData = architectureData->data(
3004  maxWritesColumn);
3005  const DataObject& guardSupportData = architectureData->data(
3006  guardSupportColumn);
3007  const DataObject& guardLatencyData = architectureData->data(
3008  guardLatencyColumn);
3009  const DataObject& zeroRegisterData = architectureData->data(
3010  zeroRegisterColumn);
3011  RFArchitecture* architecture = new RFArchitecture(
3012  readPortsData.integerValue(), writePortsData.integerValue(),
3013  bidirPortsData.integerValue(), maxReadsData.integerValue(),
3014  maxWritesData.integerValue(), latencyData.integerValue(),
3015  guardSupportData.boolValue(), guardLatencyData.integerValue(),
3016  zeroRegisterData.boolValue());
3017  std::cout.flush();
3018  architecture->setID(id);
3019  if (!sizeData.isNull()) {
3020  architecture->setSize(sizeData.integerValue());
3021  }
3022  if (!widthData.isNull()) {
3023  architecture->setWidth(widthData.integerValue());
3024  }
3025  delete architectureData;
3026  return architecture;
3027 }

References __func__, assert, DataObject::boolValue(), RelationalDBQueryResult::column(), containsRFArchitecture(), RelationalDBQueryResult::data(), dbConnection_, debugLog, Exception::errorMessage(), RelationalDBQueryResult::hasNext(), DataObject::integerValue(), DataObject::isNull(), RelationalDBQueryResult::next(), RelationalDBConnection::query(), rfArchitectureByIDQuery(), HWBlockArchitecture::setID(), HDB::RFArchitecture::setSize(), and HDB::RFArchitecture::setWidth().

Referenced by AddIUFromHDBDialog::loadHDB(), AddRFFromHDBDialog::loadHDB(), HDB::CachedHDBManager::rfArchitectureByID(), HDB::CachedHDBManager::rfArchitectureByIDConst(), HDBToHtml::rfArchToHtml(), and rfByEntryID().

Here is the call graph for this function:

◆ rfArchitectureByIDQuery()

std::string HDB::HDBManager::rfArchitectureByIDQuery ( RowID  id)
staticprivate

Creates an SQL query for getting the architecture data of the RF architecture that has the given ID.

The result table has all the fields of rf_architecture table.

Parameters
idID of the RF architecture.
Returns
The SQL query.

Definition at line 6198 of file HDBManager.cc.

6198  {
6199  string idString = Conversion::toString(id);
6200  string query =
6201  "SELECT * "
6202  "FROM rf_architecture "
6203  "WHERE id=" + idString + ";";
6204  return query;
6205 }

References Conversion::toString().

Referenced by rfArchitectureByID().

Here is the call graph for this function:

◆ rfArchitectureID()

RowID HDB::HDBManager::rfArchitectureID ( RowID  rfEntryID) const
private

Returns the ID of the architecture of the given RF entry.

Parameters
rfEntryIDID of the RF entry.
Returns
ID of the RF architecture.
Exceptions
NotAvailableIf the RF entry does not have an architecture.

Definition at line 4305 of file HDBManager.cc.

4305  {
4306  RelationalDBQueryResult* result;
4307  try {
4308  result = dbConnection_->query(
4309  std::string(
4310  "SELECT architecture FROM rf WHERE id=" +
4311  Conversion::toString(rfEntryID) + ";"));
4312  } catch (const Exception& e) {
4313  debugLog(e.errorMessage());
4314  assert(false);
4315  }
4316 
4317  if (!result->hasNext()) {
4318  delete result;
4319  throw NotAvailable(__FILE__, __LINE__, __func__);
4320  }
4321 
4322  result->next();
4323  const DataObject& idData = result->data(0);
4324  if (idData.isNull()) {
4325  delete result;
4326  throw NotAvailable(__FILE__, __LINE__, __func__);
4327  } else {
4328  RowID retValue = idData.integerValue();
4329  delete result;
4330  return retValue;
4331  }
4332 }

References __func__, assert, RelationalDBQueryResult::data(), dbConnection_, debugLog, Exception::errorMessage(), RelationalDBQueryResult::hasNext(), DataObject::integerValue(), DataObject::isNull(), RelationalDBQueryResult::next(), RelationalDBConnection::query(), and Conversion::toString().

Here is the call graph for this function:

◆ rfArchitectureIDs()

std::set< RowID > HDB::HDBManager::rfArchitectureIDs ( ) const

Returns a set of RF architecture IDs in the database.

Returns
A set containing all the RF architecture IDs in the database.

Definition at line 2734 of file HDBManager.cc.

2734  {
2735 
2736  RelationalDBQueryResult* result = NULL;
2737  try {
2738  result = dbConnection_->query(
2739  std::string("SELECT id FROM rf_architecture;"));
2740  } catch (const Exception& e) {
2741  debugLog(e.errorMessage());
2742  assert(false);
2743  }
2744 
2745  std::set<RowID> idSet;
2746  while (result->hasNext()) {
2747  result->next();
2748  const DataObject& idData = result->data(0);
2749  idSet.insert(idData.integerValue());
2750  }
2751 
2752  delete result;
2753  return idSet;
2754 }

References assert, RelationalDBQueryResult::data(), dbConnection_, debugLog, Exception::errorMessage(), RelationalDBQueryResult::hasNext(), DataObject::integerValue(), RelationalDBQueryResult::next(), and RelationalDBConnection::query().

Referenced by SetRFArchitectureCmd::Do(), AddIUFromHDBDialog::loadHDB(), and AddRFFromHDBDialog::loadHDB().

Here is the call graph for this function:

◆ rfByEntryID()

RFEntry * HDB::HDBManager::rfByEntryID ( RowID  id) const

Returns the RF entry that has the given ID.

Parameters
idThe ID of the RF entry.
Returns
The RF entry.
Exceptions
KeyNotFoundIf the HDB does not contain an RF entry with the given ID.

Definition at line 2885 of file HDBManager.cc.

2885  {
2886  std::string query = "SELECT architecture FROM rf WHERE id=";
2887  query += Conversion::toString(id) + ";";
2888 
2889  RelationalDBQueryResult* result = NULL;
2890  try {
2891  result = dbConnection_->query(query);
2892  } catch (const Exception& e) {
2893  debugLog(e.errorMessage());
2894  assert(false);
2895  }
2896 
2897  bool hasArch = false;
2898  RowID archID = -1;
2899  if (result->hasNext()) {
2900  result->next();
2901  DataObject data = result->data(0);
2902  if (!data.isNull()) {
2903  hasArch = true;
2904  archID = data.integerValue();
2905  }
2906  delete result;
2907  result = NULL;
2908  } else {
2909  delete result;
2910  throw KeyNotFound(__FILE__, __LINE__, __func__);
2911  }
2912 
2913  RFEntry* entry = new RFEntry();
2914  entry->setID(id);
2915  if (hasArch) {
2916  RFArchitecture* architecture = rfArchitectureByID(archID);
2917  entry->setArchitecture(architecture);
2918  }
2919 
2920  RFImplementation* implementation = createImplementationOfRF(id);
2921  CostFunctionPlugin* costFunction = createCostFunctionOfRF(id);
2922  entry->setImplementation(implementation);
2923  entry->setCostFunction(costFunction);
2924  entry->setHDBFile(hdbFile_);
2925  delete result;
2926 
2927  return entry;
2928 }

References __func__, assert, createCostFunctionOfRF(), createImplementationOfRF(), RelationalDBQueryResult::data(), dbConnection_, debugLog, Exception::errorMessage(), RelationalDBQueryResult::hasNext(), hdbFile_, implementation, DataObject::integerValue(), DataObject::isNull(), RelationalDBQueryResult::next(), RelationalDBConnection::query(), rfArchitectureByID(), HDB::RFEntry::setArchitecture(), HDB::HDBEntry::setCostFunction(), HDB::HDBEntry::setHDBFile(), HDB::HDBEntry::setID(), HDB::RFEntry::setImplementation(), and Conversion::toString().

Referenced by ProGe::NetlistGenerator::addBaseRFToNetlist(), addRFImplementation(), CostDatabase::buildRegisterFiles(), ProGeTools::checkForSelectableIU(), Automagic::checkForSelectableIU(), ProGeTools::checkForSelectableRF(), Automagic::checkForSelectableRF(), ProGe::ProcessorGenerator::checkIULatencies(), ProGe::BlockSourceCopier::copyBaseRFFiles(), HDBEditorModifyCmd::Do(), AddRFImplementationCmd::Do(), ProGeScriptGenerator::getBlockOrder(), AddRFImplementationCmd::isEnabled(), BlockImplementationDialog::onHDBSelection(), CostEstimator::Estimator::rfCostFunctionPluginOfImplementation(), ImplementationTester::rfEntryFromHdb(), HDBToHtml::rfEntryToHtml(), HDBToHtml::rfImplToHtml(), and setArchitectureForRF().

Here is the call graph for this function:

◆ rfCostEstimationData()

DataObject HDB::HDBManager::rfCostEstimationData ( const std::string &  valueName,
RowID  implementationId,
const std::string &  pluginName 
) const

Returns RF cost estimation data.

This version assumes that there's only one entry with given parameters.

Todo:
Another version for fetching lists of data.
Parameters
valueNameName of the value to fetch.
implementationIdThe ID of the RF entry.
pluginNameName of the cost estimation plugin that owns the data.
Returns
The data.
Exceptions
KeyNotFoundIf the HDB does not contain RF cost estimation data with the given arguments.

Definition at line 3345 of file HDBManager.cc.

3347  {
3348  // make the SQL query to obtain implementation data
3349  RelationalDBQueryResult* queryResult = NULL;
3350  try {
3351  queryResult = dbConnection_->query(
3352  std::string(
3353  "SELECT value "
3354  "FROM cost_estimation_data, cost_function_plugin "
3355  "WHERE plugin_reference = cost_function_plugin.id AND "
3356  "cost_function_plugin.name LIKE('") +
3357  pluginName + "') " +
3358  " AND fu_reference IS NULL " +
3359  " AND bus_reference IS NULL " +
3360  " AND socket_reference IS NULL AND " +
3361  " rf_reference = " + Conversion::toString(implementationId) +
3362  " AND cost_estimation_data.name LIKE('" + valueName + "');");
3363  } catch (const Exception& e) {
3364  // should not throw in any case
3365  debugLog(e.errorMessage());
3366  assert(false);
3367  }
3368 
3369  if (queryResult->hasNext()) {
3370  queryResult->next();
3371 
3372  DataObject value = queryResult->data("value");
3373 
3374  delete queryResult;
3375  queryResult = NULL;
3376 
3377  return value;
3378  } else {
3379  delete queryResult;
3380  throw KeyNotFound(__FILE__, __LINE__, __func__);
3381  }
3382  // silence compiler warning
3383  throw 1;
3384 }

References __func__, assert, RelationalDBQueryResult::data(), dbConnection_, debugLog, Exception::errorMessage(), RelationalDBQueryResult::hasNext(), RelationalDBQueryResult::next(), RelationalDBConnection::query(), and Conversion::toString().

Referenced by StrictMatchRFEstimator::estimateArea(), StrictMatchRFEstimator::estimateEnergy(), StrictMatchRFEstimator::estimateMaximumComputationDelay(), StrictMatchRFEstimator::estimatePortReadDelay(), and StrictMatchRFEstimator::estimatePortWriteDelay().

Here is the call graph for this function:

◆ rfCostEstimationDataIDs()

std::set< RowID > HDB::HDBManager::rfCostEstimationDataIDs ( RowID  rfImplID) const

Returns a set of cost estimation data IDs which reference the give RF implementation.

Parameters
rfImplIDID of the RF implementation.
Returns
Set of cost estimation data IDs.

Definition at line 6432 of file HDBManager.cc.

6432  {
6433 
6434  // make the SQL query to obtain IDs.
6435  RelationalDBQueryResult* queryResult = NULL;
6436  try {
6437  std::string theQuery =
6438  std::string(
6439  "SELECT id "
6440  "FROM cost_estimation_data "
6441  "WHERE rf_reference = ") +
6442  Conversion::toString(rfImplID);
6443 
6444  queryResult = dbConnection_->query(theQuery);
6445 
6446  } catch (const Exception& e) {
6447  // should not throw in any case
6448  debugLog(e.errorMessage());
6449  assert(false);
6450  }
6451 
6452  std::set<RowID> ids;
6453 
6454  while (queryResult->hasNext()) {
6455  queryResult->next();
6456 
6457  ids.insert(queryResult->data("id").integerValue());
6458  }
6459 
6460  delete queryResult;
6461  queryResult = NULL;
6462  return ids;
6463 }

References assert, RelationalDBQueryResult::data(), dbConnection_, debugLog, Exception::errorMessage(), RelationalDBQueryResult::hasNext(), DataObject::integerValue(), RelationalDBQueryResult::next(), RelationalDBConnection::query(), and Conversion::toString().

Referenced by HDBToHtml::rfEntryToHtml(), and HDBToHtml::rfImplToHtml().

Here is the call graph for this function:

◆ rfEntriesByArchitecture()

std::set< RowID > HDB::HDBManager::rfEntriesByArchitecture ( int  readPorts,
int  writePorts,
int  bidirPorts,
int  maxReads,
int  maxWrites,
int  latency,
bool  guardSupport,
int  guardLatency = 0,
int  width = 0,
int  size = 0,
bool  zeroRegister = false 
) const

Returns a set of RF entry IDs that have the described architecture.

In case that size or width is given as a parameter are also the RF entries with a parameterized width or size returned as are the entries with matched width and/or size.

Parameters
readPortsThe number of read ports.
writePortsThe number of write ports.
bidirPortsThe number of bidirectional ports.
maxReadThe (minimum) max reads value.
latencyThe exact latency.
guardSupportGuard support.
guardLatencyThe guard latency.
widthThe bit withd of the register file.
sizeThe number of registers in the register file.
zeroRegisterzero register of the register file
Returns
Set of RF entry IDs.

Definition at line 3133 of file HDBManager.cc.

3144  {
3145 
3146  RelationalDBQueryResult* result = NULL;
3147  try {
3148  string query = "SELECT rf.id FROM rf,rf_architecture "
3149  "WHERE rf_architecture.read_ports=" +
3150  Conversion::toString(readPorts) +
3151  " AND rf_architecture.write_ports=" +
3152  Conversion::toString(writePorts) +
3153  " AND rf_architecture.bidir_ports=" +
3154  Conversion::toString(bidirPorts) +
3155  " AND rf_architecture.max_reads>=" +
3156  Conversion::toString(maxReads) +
3157  " AND rf_architecture.max_writes>=" +
3158  Conversion::toString(maxWrites) +
3159  " AND rf_architecture.latency=" +
3160  Conversion::toString(latency);
3161  if (guardSupport) {
3162  query += " AND rf_architecture.guard_support=" +
3163  Conversion::toString(guardSupport) +
3164  " AND rf_architecture.guard_latency=" +
3165  Conversion::toString(guardLatency);
3166  }
3167  if (size != 0) {
3168  query += " AND (rf_architecture.size=" +
3169  Conversion::toString(size) +
3170  " OR rf_architecture.size is NULL)";
3171  }
3172  if (width != 0) {
3173  query += " AND (rf_architecture.width=" +
3174  Conversion::toString(width) +
3175  " OR rf_architecture.width is NULL)";
3176  }
3177  query += " AND (rf_architecture.zero_register=" +
3178  Conversion::toString(zeroRegister);
3179  if (!zeroRegister) {
3180  query += " OR rf_architecture.zero_register is NULL";
3181  }
3182  query += ")";
3183  query += " AND rf.architecture=rf_architecture.id;";
3184  result = dbConnection_->query(query);
3185  } catch (const Exception& e) {
3186  debugLog(e.errorMessage());
3187  ;
3188  }
3189 
3190  std::set<RowID> entryIDs;
3191  while (result->hasNext()) {
3192  result->next();
3193  entryIDs.insert(result->data(0).integerValue());
3194  }
3195  delete result;
3196 
3197  return entryIDs;
3198 }

References RelationalDBQueryResult::data(), dbConnection_, debugLog, Exception::errorMessage(), RelationalDBQueryResult::hasNext(), DataObject::integerValue(), RelationalDBQueryResult::next(), RelationalDBConnection::query(), and Conversion::toString().

Referenced by ComponentImplementationSelector::iuImplementations(), BlockImplementationDialog::onHDBSelection(), and ComponentImplementationSelector::rfImplementations().

Here is the call graph for this function:

◆ rfEntryByIDQuery()

std::string HDB::HDBManager::rfEntryByIDQuery ( RowID  id)
staticprivate

Creates an SQL query for getting the RF entry that has the given ID.

The result set has fields {id, architecture, cost_function}.

Parameters
idID of the entry.
Returns
The SQL query.

Definition at line 5800 of file HDBManager.cc.

5800  {
5801  string idString = Conversion::toString(id);
5802  string query =
5803  "SELECT * "
5804  "FROM rf "
5805  "WHERE rf.id=" + idString + ";";
5806  return query;
5807 }

References Conversion::toString().

Referenced by hasRFEntry().

Here is the call graph for this function:

◆ rfEntryHasArchitecture()

bool HDB::HDBManager::rfEntryHasArchitecture ( RowID  id) const
private

Tells whether the RF entry that has the given ID has an architecture.

Parameters
idID of the RF entry.
Returns
True if it has an architecture, otherwise false.
Exceptions
KeyNotFoundIf the HDB does not contain a RF entry with the given ID.

Definition at line 4129 of file HDBManager.cc.

4129  {
4130  RelationalDBQueryResult* result;
4131  try {
4132  result = dbConnection_->query(
4133  std::string(
4134  "SELECT architecture FROM rf WHERE id=" +
4135  Conversion::toString(id) + ";"));
4136  } catch (const Exception& e) {
4137  debugLog(e.errorMessage());
4138  assert(false);
4139  }
4140 
4141  if (result->hasNext()) {
4142  result->next();
4143  const DataObject& data = result->data(0);
4144  delete result;
4145  return !data.isNull();
4146  } else {
4147  delete result;
4148  throw KeyNotFound(__FILE__, __LINE__, __func__);
4149  }
4150 }

References __func__, assert, RelationalDBQueryResult::data(), dbConnection_, debugLog, Exception::errorMessage(), RelationalDBQueryResult::hasNext(), DataObject::isNull(), RelationalDBQueryResult::next(), RelationalDBConnection::query(), and Conversion::toString().

Here is the call graph for this function:

◆ rfEntryIDOfImplementation()

RowID HDB::HDBManager::rfEntryIDOfImplementation ( RowID  implID) const

Returns the ID of the RF entry that has the given implementation ID.

Parameters
implIDThe implementation ID.
Returns
The RF entry ID.
Exceptions
KeyNotFoundIf there is no implementation by the given ID.

Definition at line 2796 of file HDBManager.cc.

2796  {
2797  RelationalDBQueryResult* result = NULL;
2798  try {
2799  result = dbConnection_->query(
2800  std::string(
2801  "SELECT rf from rf_implementation WHERE id=" +
2802  Conversion::toString(implID) + ";"));
2803  } catch (const Exception& e) {
2804  debugLog(e.errorMessage());
2805  assert(false);
2806  }
2807 
2808  if (result->hasNext()) {
2809  result->next();
2810  RowID id = result->data(0).integerValue();
2811  delete result;
2812  return id;
2813  } else {
2814  delete result;
2815  throw KeyNotFound(__FILE__, __LINE__, __func__);
2816  }
2817 }

References __func__, assert, RelationalDBQueryResult::data(), dbConnection_, debugLog, Exception::errorMessage(), RelationalDBQueryResult::hasNext(), DataObject::integerValue(), RelationalDBQueryResult::next(), RelationalDBConnection::query(), and Conversion::toString().

Referenced by HDBEditorDeleteCmd::Do(), HDBEditorModifyCmd::Do(), HDB::CachedHDBManager::removeRFImplementation(), and HDBToHtml::rfImplToHtml().

Here is the call graph for this function:

◆ rfEntryIDs()

std::set< RowID > HDB::HDBManager::rfEntryIDs ( ) const

Returns a set of RF entry IDs in the database.

Returns
A set containing all the RF entry IDs in the database.

Definition at line 2067 of file HDBManager.cc.

2067  {
2068 
2069  string query = "SELECT id AS 'rf.id' FROM rf;";
2070 
2071  // make the SQL query to obtain all the IDs
2072  RelationalDBQueryResult* queryResult = NULL;
2073  try {
2074  queryResult = dbConnection_->query(query);
2075  } catch (const Exception& e) {
2076  // should not throw in any case
2077  debugLog(e.errorMessage());
2078  assert(false);
2079  }
2080 
2081  std::set<RowID> idSet;
2082  while (queryResult->hasNext()) {
2083  queryResult->next();
2084  const DataObject& idData = queryResult->data("rf.id");
2085  idSet.insert(idData.integerValue());
2086  }
2087 
2088  delete queryResult;
2089  return idSet;
2090 }

References assert, RelationalDBQueryResult::data(), dbConnection_, debugLog, Exception::errorMessage(), RelationalDBQueryResult::hasNext(), DataObject::integerValue(), RelationalDBQueryResult::next(), and RelationalDBConnection::query().

Referenced by CostDatabase::buildRegisterFiles(), ProGeTools::checkForSelectableIU(), Automagic::checkForSelectableIU(), Automagic::checkForSelectableRF(), ProGeTools::checkForSelectableRF(), and ImplementationTester::rfEntryIDs().

Here is the call graph for this function:

◆ rfExternalPortsByIDQuery()

std::string HDB::HDBManager::rfExternalPortsByIDQuery ( RowID  id)
staticprivate

Creates an SQL query for getting external port data of implementation of the RF that has the given ID.

The result table has fields {rf_external_port.name, rf_external_port.direction, rf_external_port.width_formula, rf_external_port.description}.

Parameters
idID of the RF entry in HDB.
Returns
The SQL query.

Definition at line 6072 of file HDBManager.cc.

6072  {
6073  string idString = Conversion::toString(id);
6074  string query =
6075  "SELECT rf_external_port.name AS 'rf_external_port.name',"
6076  " rf_external_port.direction AS 'rf_external_port.direction',"
6077  " rf_external_port.width_formula AS "
6078  " 'rf_external_port.width_formula',"
6079  " rf_external_port.description AS "
6080  " 'rf_external_port.description' "
6081  "FROM rf, rf_implementation, rf_external_port "
6082  "WHERE rf.id=" + idString + " AND"
6083  " rf_implementation.rf=rf.id AND"
6084  " rf_external_port.rf_impl=rf_implementation.id;";
6085  return query;
6086 }

References Conversion::toString().

Referenced by addRFExternalPortsToImplementation().

Here is the call graph for this function:

◆ rfImplementationByIDQuery()

std::string HDB::HDBManager::rfImplementationByIDQuery ( RowID  id)
staticprivate

Creates an SQL query for getting the implementation of the RF entry that has the given ID.

The result table has fields {id, name, size_param, width_param, clk_port, rst_port, glock_port, guard_port}.

Parameters
idThe ID of the RF entry.
Returns
The SQL query.

Definition at line 6219 of file HDBManager.cc.

6219  {
6220  string idString = Conversion::toString(id);
6221  string query =
6222  "SELECT id,"
6223  " name,"
6224  " size_param,"
6225  " width_param,"
6226  " clk_port,"
6227  " rst_port,"
6228  " glock_port,"
6229  " guard_port "
6230  "FROM rf_implementation "
6231  "WHERE rf_implementation.rf=" + idString + ";";
6232  return query;
6233 }

References Conversion::toString().

Referenced by createImplementationOfRF().

Here is the call graph for this function:

◆ rfImplementationByIDQuery2()

std::string HDB::HDBManager::rfImplementationByIDQuery2 ( RowID  id)
staticprivate

Same as rfImplementationByIDQuery() bus has additional field for separate address cycle.

The result table has fields {id, name, size_param, width_param, clk_port, rst_port, glock_port, guard_port, sac_param}.

Parameters
idThe ID of the RF entry.
Returns
The SQL query.

Definition at line 6246 of file HDBManager.cc.

6246  {
6247  string idString = Conversion::toString(id);
6248  string query =
6249  "SELECT id,"
6250  " name,"
6251  " size_param,"
6252  " width_param,"
6253  " clk_port,"
6254  " rst_port,"
6255  " glock_port,"
6256  " guard_port, "
6257  " sac_param "
6258  "FROM rf_implementation "
6259  "WHERE rf_implementation.rf=" + idString + ";";
6260  return query;
6261 }

References Conversion::toString().

Referenced by createImplementationOfRF().

Here is the call graph for this function:

◆ rfImplementationDataPortsByIDQuery()

std::string HDB::HDBManager::rfImplementationDataPortsByIDQuery ( RowID  id)
staticprivate

Creates an SQL query for getting the data ports of the implementation of the RF entry that has the given ID.

The result table has fields {name, direction, load_port, opcode_port, opcode_port_width_formula}.

Parameters
idID of the RF entry.
Returns
The SQL query.

Definition at line 6274 of file HDBManager.cc.

6274  {
6275  string idString = Conversion::toString(id);
6276  string query =
6277  "SELECT rf_data_port.name AS 'name',"
6278  " rf_data_port.direction AS 'direction',"
6279  " rf_data_port.load_port AS 'load_port',"
6280  " rf_data_port.opcode_port AS 'opcode_port',"
6281  " rf_data_port.opcode_port_width_formula AS "
6282  " 'opcode_port_width_formula' "
6283  "FROM rf_data_port, rf_implementation "
6284  "WHERE rf_implementation.rf=" + idString + " AND"
6285  " rf_data_port.rf_impl=rf_implementation.id;";
6286  return query;
6287 }

References Conversion::toString().

Referenced by addDataPortsToImplementation().

Here is the call graph for this function:

◆ rfImplementationParametersByIDQuery()

std::string HDB::HDBManager::rfImplementationParametersByIDQuery ( RowID  id)
staticprivate

Creates an SQL query for getting the parameters of the implementation of the RF that has the given ID.

The result table has fields {name, type, value}.

Parameters
idID of the RF entry.
Returns
The SQL query.

Definition at line 6122 of file HDBManager.cc.

6122  {
6123  string idString = Conversion::toString(id);
6124  string query =
6125  "SELECT rf_implementation_parameter.name AS 'name',"
6126  " rf_implementation_parameter.type AS 'type',"
6127  " rf_implementation_parameter.value AS 'value' "
6128  "FROM rf_implementation, rf_implementation_parameter "
6129  "WHERE rf_implementation.rf=" + idString + " AND"
6130  " rf_implementation_parameter.rf_impl=rf_implementation.id;";
6131  return query;
6132 }

References Conversion::toString().

Referenced by addRFParametersToImplementation().

Here is the call graph for this function:

◆ rfSourceFilesByIDQuery()

std::string HDB::HDBManager::rfSourceFilesByIDQuery ( RowID  id)
staticprivate

Creates an SQL query for getting the block implementation files of the RF entry that has the given ID.

The result table has fields {block_source_file.file, format.format}.

Parameters
idID of the RF entry.
Returns
The SQL query.

Definition at line 6300 of file HDBManager.cc.

6300  {
6301  string idString = Conversion::toString(id);
6302  string query =
6303  "SELECT block_source_file.file AS 'block_source_file.file',"
6304  " format.format AS 'format.format' "
6305  "FROM block_source_file, format, rf_implementation, rf_source_file "
6306  "WHERE rf_implementation.rf=" + idString + " AND"
6307  " rf_source_file.rf_impl=rf_implementation.id AND"
6308  " block_source_file.id=rf_source_file.file AND"
6309  " format.id=block_source_file.format;";
6310  return query;
6311 }

References Conversion::toString().

Referenced by addBlockImplementationFiles().

Here is the call graph for this function:

◆ setArchitectureForFU()

void HDB::HDBManager::setArchitectureForFU ( RowID  fuID,
RowID  archID 
) const

Sets the given architecture for the given FU entry.

Parameters
fuIDID of the FU entry.
archIDID of the FU architecture.
Exceptions
InvalidDataIf the FU entry has an implementation already or if the HDB does not have FU or architecture by the given ID.

Definition at line 1401 of file HDBManager.cc.

1401  {
1402  if (!hasFUEntry(fuID) || !containsFUArchitecture(archID)) {
1403  throw InvalidData(__FILE__, __LINE__, __func__);
1404  }
1405 
1406  FUEntry* entry = fuByEntryID(fuID);
1407  if (entry->hasImplementation()) {
1408  throw InvalidData(__FILE__, __LINE__, __func__);
1409  }
1410 
1411  // set the architecture
1412  try {
1414  std::string(
1415  "UPDATE fu SET architecture=" +
1416  Conversion::toString(archID) + " WHERE id=" +
1417  Conversion::toString(fuID) + ";"));
1418  } catch (const Exception& e) {
1419  debugLog(e.errorMessage());
1420  assert(false);
1421  }
1422 }

References __func__, assert, containsFUArchitecture(), dbConnection_, debugLog, Exception::errorMessage(), fuByEntryID(), hasFUEntry(), HDB::FUEntry::hasImplementation(), Conversion::toString(), and RelationalDBConnection::updateQuery().

Referenced by AddFUImplementationCmd::Do(), and SetFUArchitectureCmd::Do().

Here is the call graph for this function:

◆ setArchitectureForRF()

void HDB::HDBManager::setArchitectureForRF ( RowID  rfID,
RowID  archID 
) const

Sets architecture for an RF entry.

Parameters
rfIDID of the RF entry.
archIDID of the RF architecture to set.
Exceptions
InvalidDataIf the database does not contain the given IDs or if the RF entry has an architecture already.

Definition at line 1895 of file HDBManager.cc.

1895  {
1896  if (!hasRFEntry(rfID)) {
1897  throw InvalidData(__FILE__, __LINE__, __func__);
1898  }
1899 
1900  RFEntry* entry = rfByEntryID(rfID);
1901  if (entry->hasArchitecture()) {
1902  delete entry;
1903  throw InvalidData(__FILE__, __LINE__, __func__);
1904  }
1905  delete entry;
1906  entry = NULL;
1907 
1908  if (!containsRFArchitecture(archID)) {
1909  throw InvalidData(__FILE__, __LINE__, __func__);
1910  }
1911 
1912  try {
1914  std::string(
1915  "UPDATE rf SET architecture=" +
1916  Conversion::toString(archID) + " WHERE id=" +
1917  Conversion::toString(rfID) + ";"));
1918  } catch (const Exception& e) {
1919  debugLog(e.errorMessage());
1920  assert(false);
1921  }
1922 }

References __func__, assert, containsRFArchitecture(), dbConnection_, debugLog, Exception::errorMessage(), HDB::RFEntry::hasArchitecture(), hasRFEntry(), rfByEntryID(), Conversion::toString(), and RelationalDBConnection::updateQuery().

Referenced by AddRFImplementationCmd::Do(), and SetRFArchitectureCmd::Do().

Here is the call graph for this function:

◆ setCostFunctionPluginForFU()

void HDB::HDBManager::setCostFunctionPluginForFU ( RowID  fuID,
RowID  pluginID 
) const

Sets the given cost function plugin for the given FU entry.

Parameters
fuIDID of the FU entry.
pluginIDID of the cost function plugin.

Definition at line 1950 of file HDBManager.cc.

1950  {
1951 
1952  // set the cost function plugin for fu
1953  try {
1955  std::string(
1956  "UPDATE fu SET cost_function=" +
1957  Conversion::toString(pluginID) + " WHERE id=" +
1958  Conversion::toString(fuID) + ";"));
1959  } catch (const Exception& e) {
1960  debugLog(e.errorMessage());
1961  assert(false);
1962  }
1963 }

References assert, dbConnection_, debugLog, Exception::errorMessage(), Conversion::toString(), and RelationalDBConnection::updateQuery().

Referenced by SetCostFunctionPluginCmd::Do().

Here is the call graph for this function:

◆ setCostFunctionPluginForRF()

void HDB::HDBManager::setCostFunctionPluginForRF ( RowID  rfID,
RowID  pluginID 
) const

Sets the given cost function plugin for the given RF entry.

Parameters
rfIDID of the RF entry.
pluginIDID of the cost function plugin.

Definition at line 1993 of file HDBManager.cc.

1993  {
1994 
1995  // set the cost function plugin for rf
1996  try {
1998  std::string(
1999  "UPDATE rf SET cost_function=" +
2000  Conversion::toString(pluginID) + " WHERE id=" +
2001  Conversion::toString(rfID) + ";"));
2002  } catch (const Exception& e) {
2003  debugLog(e.errorMessage());
2004  assert(false);
2005  }
2006 }

References assert, dbConnection_, debugLog, Exception::errorMessage(), Conversion::toString(), and RelationalDBConnection::updateQuery().

Referenced by SetCostFunctionPluginCmd::Do().

Here is the call graph for this function:

◆ socketCostEstimationData()

DataObject HDB::HDBManager::socketCostEstimationData ( const std::string &  valueName,
RowID  socketID,
const std::string &  pluginName 
) const

Returns socket cost estimation data.

This version assumes that there's only one entry with given parameters.

Parameters
valueNameName of the value to fetch.
socketIDThe ID of the socket entry.
pluginNameName of the cost estimation plugin that owns the data.
Returns
The data.
Exceptions
KeyNotFoundIf the HDB does not contain socket cost estimation data with the given arguments.

Definition at line 3718 of file HDBManager.cc.

3720  {
3721  // make the SQL query to obtain implementation data
3722  RelationalDBQueryResult* queryResult = NULL;
3723  try {
3724  std::string theQuery =
3725  std::string(
3726  "SELECT value "
3727  "FROM cost_estimation_data, cost_function_plugin "
3728  "WHERE plugin_reference = cost_function_plugin.id AND "
3729  "cost_function_plugin.name LIKE('") +
3730  pluginName + "') " +
3731  " AND rf_reference IS NULL " +
3732  " AND bus_reference IS NULL AND " +
3733  " socket_reference = " +
3734  Conversion::toString(socketID) +
3735  " AND cost_estimation_data.name LIKE('" + valueName + "');";
3736  queryResult = dbConnection_->query(theQuery);
3737 
3738  } catch (const Exception& e) {
3739  // should not throw in any case
3740  debugLog(e.errorMessage());
3741  assert(false);
3742  }
3743 
3744  if (queryResult->hasNext()) {
3745  queryResult->next();
3746 
3747  DataObject value = queryResult->data("value");
3748 
3749  delete queryResult;
3750  queryResult = NULL;
3751 
3752  return value;
3753  } else {
3754  delete queryResult;
3755  throw KeyNotFound(__FILE__, __LINE__, __func__);
3756  }
3757  // silence compiler warning
3758  throw 1;
3759 }

References __func__, assert, RelationalDBQueryResult::data(), dbConnection_, debugLog, Exception::errorMessage(), RelationalDBQueryResult::hasNext(), RelationalDBQueryResult::next(), RelationalDBConnection::query(), and Conversion::toString().

Referenced by DefaultICDecoderEstimator::delayOfSocket().

Here is the call graph for this function:

◆ socketCostEstimationDataIDs()

std::set< RowID > HDB::HDBManager::socketCostEstimationDataIDs ( RowID  socketID) const

Returns a set of cost estimation data IDs which reference the given socket entry.

Parameters
socketIDID of the socket entry.
Returns
Set of cost estimation data IDs.

Definition at line 6473 of file HDBManager.cc.

6473  {
6474 
6475  // make the SQL query to obtain IDs.
6476  RelationalDBQueryResult* queryResult = NULL;
6477  try {
6478  std::string theQuery =
6479  std::string(
6480  "SELECT id "
6481  "FROM cost_estimation_data "
6482  "WHERE socket_reference = ") +
6483  Conversion::toString(socketID);
6484 
6485  queryResult = dbConnection_->query(theQuery);
6486 
6487  } catch (const Exception& e) {
6488  // should not throw in any case
6489  debugLog(e.errorMessage());
6490  assert(false);
6491  }
6492 
6493  std::set<RowID> ids;
6494 
6495  while (queryResult->hasNext()) {
6496  queryResult->next();
6497 
6498  ids.insert(queryResult->data("id").integerValue());
6499  }
6500 
6501  delete queryResult;
6502  queryResult = NULL;
6503  return ids;
6504 }

References assert, RelationalDBQueryResult::data(), dbConnection_, debugLog, Exception::errorMessage(), RelationalDBQueryResult::hasNext(), DataObject::integerValue(), RelationalDBQueryResult::next(), RelationalDBConnection::query(), and Conversion::toString().

Referenced by HDBToHtml::socketEntryToHtml().

Here is the call graph for this function:

◆ socketCostEstimationDataList()

HDBManager::DataObjectList * HDB::HDBManager::socketCostEstimationDataList ( const std::string &  valueName,
RowID  socketID,
const std::string &  pluginName 
) const

Returns socket cost estimation data.

Parameters
valueNameName of the value to fetch.
socketIDThe ID of the socket entry.
pluginNameName of the cost estimation plugin that owns the data.
Returns
The data. Becomes property of the caller.
Exceptions
KeyNotFoundIf the HDB does not contain socket cost estimation data with the given arguments.

Definition at line 3772 of file HDBManager.cc.

3774  {
3775  RelationalDBQueryResult* queryResult = NULL;
3776  try {
3777  queryResult = dbConnection_->query(
3778  std::string(
3779  "SELECT value "
3780  "FROM cost_estimation_data, cost_function_plugin "
3781  "WHERE plugin_reference = cost_function_plugin.id AND "
3782  "cost_function_plugin.name LIKE('") +
3783  pluginName + "') " +
3784  " AND rf_reference IS NULL " +
3785  " AND bus_reference IS NULL AND " +
3786  " socket_reference = " +
3787  Conversion::toString(socketID) +
3788  " AND cost_estimation_data.name LIKE('" + valueName + "');");
3789  } catch (const Exception& e) {
3790  // should not throw in any case
3791  debugLog(e.errorMessage());
3792  assert(false);
3793  }
3794 
3795  if (queryResult->hasNext()) {
3796 
3797  DataObjectList* data = new DataObjectList;
3798 
3799  while (queryResult->hasNext()) {
3800  queryResult->next();
3801  DataObject value = queryResult->data("value");
3802  data->push_back(value);
3803  }
3804 
3805  delete queryResult;
3806  queryResult = NULL;
3807  return data;
3808  } else {
3809  delete queryResult;
3810  throw KeyNotFound(__FILE__, __LINE__, __func__);
3811  }
3812  // silence compiler warning
3813  throw 1;
3814 }

References __func__, assert, RelationalDBQueryResult::data(), dbConnection_, debugLog, Exception::errorMessage(), RelationalDBQueryResult::hasNext(), RelationalDBQueryResult::next(), RelationalDBConnection::query(), and Conversion::toString().

Here is the call graph for this function:

◆ socketEntryByIDQuery()

std::string HDB::HDBManager::socketEntryByIDQuery ( RowID  id)
staticprivate

Creates an SQL query for getting the Socket entry that has the given ID.

The result set has fields {id}.

Parameters
idID of the entry.
Returns
The SQL query.

Definition at line 5838 of file HDBManager.cc.

5838  {
5839  string idString = Conversion::toString(id);
5840  string query =
5841  "SELECT * "
5842  "FROM socket "
5843  "WHERE socket.id=" + idString + ";";
5844  return query;
5845 }

References Conversion::toString().

Referenced by hasSocketEntry().

Here is the call graph for this function:

◆ socketEntryIDs()

std::set< RowID > HDB::HDBManager::socketEntryIDs ( ) const

Returns a set of Socket entry IDs in the database.

Returns
A set containing all the Socket entry IDs in the database.

Definition at line 2131 of file HDBManager.cc.

2131  {
2132 
2133  string query = "SELECT id AS 'socket.id' FROM socket;";
2134 
2135  // make the SQL query to obtain all the IDs
2136  RelationalDBQueryResult* queryResult = NULL;
2137  try {
2138  queryResult = dbConnection_->query(query);
2139  } catch (const Exception& e) {
2140  // should not throw in any case
2141  debugLog(e.errorMessage());
2142  assert(false);
2143  }
2144 
2145  std::set<RowID> idSet;
2146  while (queryResult->hasNext()) {
2147  queryResult->next();
2148  const DataObject& idData = queryResult->data("socket.id");
2149  idSet.insert(idData.integerValue());
2150  }
2151 
2152  delete queryResult;
2153  return idSet;
2154 }

References assert, RelationalDBQueryResult::data(), dbConnection_, debugLog, Exception::errorMessage(), RelationalDBQueryResult::hasNext(), DataObject::integerValue(), RelationalDBQueryResult::next(), and RelationalDBConnection::query().

Referenced by CostDatabase::buildSockets().

Here is the call graph for this function:

◆ unsetArchitectureForFU()

void HDB::HDBManager::unsetArchitectureForFU ( RowID  fuID) const

Unsets the architecture of the given FU entry.

Parameters
fuIDID of the FU entry.
Exceptions
InvalidDataIf the HDB does not contain the given FU entry or if the FU entry has an implementation.

Definition at line 1432 of file HDBManager.cc.

1432  {
1433  if (!hasFUEntry(fuID)) {
1434  throw InvalidData(__FILE__, __LINE__, __func__);
1435  }
1436 
1437  FUEntry* entry = fuByEntryID(fuID);
1438  if (entry->hasImplementation()) {
1439  throw InvalidData(__FILE__, __LINE__, __func__);
1440  }
1441 
1442  // unset the architecture
1443  try {
1445  std::string(
1446  "UPDATE fu SET architecture=NULL WHERE id=" +
1447  Conversion::toString(fuID)));
1448  } catch (const Exception& e) {
1449  debugLog(e.errorMessage());
1450  assert(false);
1451  }
1452 }

References __func__, assert, dbConnection_, debugLog, Exception::errorMessage(), fuByEntryID(), hasFUEntry(), HDB::FUEntry::hasImplementation(), Conversion::toString(), and RelationalDBConnection::updateQuery().

Referenced by SetFUArchitectureCmd::Do().

Here is the call graph for this function:

◆ unsetArchitectureForRF()

void HDB::HDBManager::unsetArchitectureForRF ( RowID  rfID) const

Unsets architecture of the given RF entry.

Parameters
rfIDID of the RF entry.

Definition at line 1930 of file HDBManager.cc.

1930  {
1931  try {
1933  std::string(
1934  "UPDATE rf SET architecture=NULL WHERE id=" +
1935  Conversion::toString(rfID)));
1936  } catch (const Exception& e) {
1937  debugLog(e.errorMessage());
1938  assert(false);
1939  }
1940 }

References assert, dbConnection_, debugLog, Exception::errorMessage(), Conversion::toString(), and RelationalDBConnection::updateQuery().

Referenced by SetRFArchitectureCmd::Do().

Here is the call graph for this function:

◆ unsetCostFunctionPluginForFU()

void HDB::HDBManager::unsetCostFunctionPluginForFU ( RowID  fuID) const

Unsets cost function plugin of the given FU entry.

Parameters
fuIDID of the FU entry.

Definition at line 1971 of file HDBManager.cc.

1971  {
1972 
1973  // unset the cost function plugin
1974  try {
1976  std::string(
1977  "UPDATE fu SET cost_function=NULL WHERE id=" +
1978  Conversion::toString(fuID)));
1979  } catch (const Exception& e) {
1980  debugLog(e.errorMessage());
1981  assert(false);
1982  }
1983 }

References assert, dbConnection_, debugLog, Exception::errorMessage(), Conversion::toString(), and RelationalDBConnection::updateQuery().

Referenced by SetCostFunctionPluginCmd::Do().

Here is the call graph for this function:

◆ unsetCostFunctionPluginForRF()

void HDB::HDBManager::unsetCostFunctionPluginForRF ( RowID  rfID) const

Unsets cost function plugin of the given RF entry.

Parameters
rfIDID of the RF entry.

Definition at line 2014 of file HDBManager.cc.

2014  {
2015 
2016  // unset the cost function plugin
2017  try {
2019  std::string(
2020  "UPDATE rf SET cost_function=NULL WHERE id=" +
2021  Conversion::toString(rfID)));
2022  } catch (const Exception& e) {
2023  debugLog(e.errorMessage());
2024  assert(false);
2025  }
2026 }

References assert, dbConnection_, debugLog, Exception::errorMessage(), Conversion::toString(), and RelationalDBConnection::updateQuery().

Referenced by SetCostFunctionPluginCmd::Do().

Here is the call graph for this function:

Friends And Related Function Documentation

◆ HDBManagerTest

friend class HDBManagerTest
friend

Definition at line 84 of file HDBManager.hh.

Member Data Documentation

◆ db_

SQLite* HDB::HDBManager::db_
private

Handle to the database.

Definition at line 400 of file HDBManager.hh.

Referenced by HDBManager(), and ~HDBManager().

◆ dbConnection_

RelationalDBConnection* HDB::HDBManager::dbConnection_
private

Handle to the database connection.

Definition at line 402 of file HDBManager.hh.

Referenced by addBlockImplementationFiles(), addBlockImplementationFileToHDB(), addBooleanColumn(), addBusCostEstimationData(), addBusEntry(), addCostEstimationData(), addCostFunctionPlugin(), addDataPortsToImplementation(), addFUArchitecture(), addFUCostEstimationData(), addFUEntry(), addFUExternalPortsToImplementation(), addFUImplementation(), addFUParametersToImplementation(), addOpcodesToImplementation(), addOperationImplementation(), addOperationImplementationResource(), addOperationPipelinesToFUArchitecture(), addPortsAndBindingsToFUArchitecture(), addRFArchitecture(), addRFCostEstimationData(), addRFEntry(), addRFExternalPortsToImplementation(), addRFImplementation(), addRFParametersToImplementation(), addSocketCostEstimationData(), addSocketEntry(), blockSourceFile(), busCostEstimationData(), busCostEstimationDataIDs(), busCostEstimationDataList(), busEntryIDs(), canRemoveFUArchitecture(), canRemoveRFArchitecture(), containsFUArchitecture(), containsImplementationFile(), containsOperation(), containsRFArchitecture(), costEstimationData(), costEstimationDataIDs(), costEstimationDataValue(), costFunctionPluginByID(), costFunctionPluginDataIDs(), costFunctionPluginIDs(), createCostFunctionOfFU(), createCostFunctionOfRF(), createImplementationOfFU(), createImplementationOfRF(), fuArchitectureID(), fuArchitectureIDs(), fuArchitectureIDsByOperationSet(), fuByEntryID(), fuCostEstimationData(), fuCostEstimationDataIDs(), fuEntriesByArchitecture(), fuEntryHasArchitecture(), fuEntryIDOfImplementation(), fuEntryIDs(), getDBConnection(), hasBusEntry(), hasColumn(), hasCostEstimationDataByID(), hasCostFunctionPluginByID(), hasFUEntry(), hasRFEntry(), hasSocketEntry(), HDBManager(), modifyCostEstimationData(), modifyCostFunctionPlugin(), OperationImplementationByID(), OperationImplementationIDs(), OperationImplementationResourceByID(), OperationImplementationResourceIDs(), removeBusEntry(), removeCostEstimationData(), removeCostFunctionPlugin(), removeFUArchitecture(), removeFUEntry(), removeFUImplementation(), removeOperationImplementation(), removeOperationImplementationResource(), removeRFArchitecture(), removeRFEntry(), removeRFImplementation(), removeSocketEntry(), resolveArchitecturePort(), rfArchitectureByID(), rfArchitectureID(), rfArchitectureIDs(), rfByEntryID(), rfCostEstimationData(), rfCostEstimationDataIDs(), rfEntriesByArchitecture(), rfEntryHasArchitecture(), rfEntryIDOfImplementation(), rfEntryIDs(), setArchitectureForFU(), setArchitectureForRF(), setCostFunctionPluginForFU(), setCostFunctionPluginForRF(), socketCostEstimationData(), socketCostEstimationDataIDs(), socketCostEstimationDataList(), socketEntryIDs(), unsetArchitectureForFU(), unsetArchitectureForRF(), unsetCostFunctionPluginForFU(), unsetCostFunctionPluginForRF(), and ~HDBManager().

◆ hdbFile_

std::string HDB::HDBManager::hdbFile_
private

The HDB file to manager.

Definition at line 404 of file HDBManager.hh.

Referenced by fileName(), fuArchitectureIDsByOperationSet(), fuByEntryID(), and rfByEntryID().

◆ instance_

HDBManager * HDB::HDBManager::instance_ = NULL
staticprivate

Unique instance of the HDBManager.

Definition at line 406 of file HDBManager.hh.


The documentation for this class was generated from the following files:
HDB::HDBManager::formatString
static std::string formatString(BlockImplementationFile::Format format)
Definition: HDBManager.cc:5737
RelationalDBConnection::rollback
virtual void rollback()=0
Definition: RelationalDBConnection.cc:101
CQ_OPERATION_IMPLEMENTATION_VARIABLE
const string CQ_OPERATION_IMPLEMENTATION_VARIABLE
Definition: HDBManager.cc:374
HDB::HDBManager::addPortsAndBindingsToFUArchitecture
void addPortsAndBindingsToFUArchitecture(FUArchitecture &architecture, RowID id) const
Definition: HDBManager.cc:4406
VERILOG_SIM_FORMAT
const string VERILOG_SIM_FORMAT
Definition: HDBManager.cc:91
CostEstimationData::rfReference
RowID rfReference() const
Definition: CostEstimationData.cc:118
CostEstimationData::setName
void setName(const std::string &name)
RelationalDBConnection
Definition: RelationalDBConnection.hh:48
CQ_OPERATION
const string CQ_OPERATION
Definition: HDBManager.cc:138
AssocTools::difference
static void difference(const ContainerType &firstContainer, const ContainerType &secondContainer, ContainerType &difference)
FUValidator::checkOperandBindings
static void checkOperandBindings(const TTAMachine::FunctionUnit &fu, MachineValidatorResults &results)
Definition: FUValidator.cc:54
CQ_RF_IMPL_ENTRY_INDEX
const string CQ_RF_IMPL_ENTRY_INDEX
Definition: HDBManager.cc:337
HDB::HDBManager::createCostEstimatioDataIdsQuery
void createCostEstimatioDataIdsQuery(const CostEstimationData &match, std::string *query, RelationalDBQueryResult *compiledQuery=NULL, short int *queryHash=NULL, bool createBindableQuery=false) const
Definition: HDBManager.cc:6835
HDB::HDBManager::fuArchitectureByID
virtual FUArchitecture * fuArchitectureByID(RowID id) const
Definition: HDBManager.cc:2940
RelationalDBConnection::lastInsertRowID
virtual RowID lastInsertRowID()=0
HDB::HDBManager::fuImplementationByIDQuery
static std::string fuImplementationByIDQuery(RowID id)
Definition: HDBManager.cc:5962
VERILOG_FORMAT
const string VERILOG_FORMAT
Definition: HDBManager.cc:89
CQ_RF_DATA_PORT
const string CQ_RF_DATA_PORT
Definition: HDBManager.cc:270
RelationalDBConnection::updateQuery
virtual int updateQuery(const std::string &queryString)=0
Definition: RelationalDBConnection.cc:54
FileNotFound
Definition: Exception.hh:224
HDB::CostFunctionPlugin::CostFunctionPluginType
CostFunctionPluginType
all supported cost function plugin types
Definition: CostFunctionPlugin.hh:46
CQ_PIPELINE_RESOURCE
const string CQ_PIPELINE_RESOURCE
Definition: HDBManager.cc:112
DEFAULT_PORT_WIDTH
const int DEFAULT_PORT_WIDTH
Definition: HDBManager.cc:93
CostEstimationData::name
std::string name() const
Definition: CostEstimationData.cc:58
HDB::HDBManager::fuExternalPortsByIDQuery
static std::string fuExternalPortsByIDQuery(RowID id)
Definition: HDBManager.cc:6043
HDB::HDBManager::rfImplementationDataPortsByIDQuery
static std::string rfImplementationDataPortsByIDQuery(RowID id)
Definition: HDBManager.cc:6274
HDB::HDBManager::hasSocketEntry
bool hasSocketEntry(RowID id) const
Definition: HDBManager.cc:4008
UnreachableStream
Definition: Exception.hh:171
HDB::HDBManager::rfSourceFilesByIDQuery
static std::string rfSourceFilesByIDQuery(RowID id)
Definition: HDBManager.cc:6300
HDB::HDBManager::directionString
static std::string directionString(HDB::Direction direction)
Definition: HDBManager.cc:5761
RelationalDBException
Definition: Exception.hh:692
TTAMachine::FUPort::isOpcodeSetting
virtual bool isOpcodeSetting() const
Definition: FUPort.cc:195
TTAMachine::HWOperation
Definition: HWOperation.hh:52
HDB::HDBManager::dbConnection_
RelationalDBConnection * dbConnection_
Handle to the database connection.
Definition: HDBManager.hh:402
HDB::HDBManager::busEntryByIDQuery
static std::string busEntryByIDQuery(RowID id)
Definition: HDBManager.cc:5819
HDB::HDBManager::rfImplementationByIDQuery2
static std::string rfImplementationByIDQuery2(RowID id)
Definition: HDBManager.cc:6246
implementation
IDF::MachineImplementation * implementation
the implementation definition of the estimated processor
Definition: EstimatorCmdLineUI.cc:61
DataObject
Definition: DataObject.hh:50
TTAMachine::HWOperation::bindPort
virtual void bindPort(int operand, const FUPort &port)
Definition: HWOperation.cc:269
DataObject::stringValue
virtual std::string stringValue() const
Definition: DataObject.cc:344
CQ_OPERATION_IMPLEMENTATION_RESOURCE_SOURCE_FILE
const string CQ_OPERATION_IMPLEMENTATION_RESOURCE_SOURCE_FILE
Definition: HDBManager.cc:340
CostEstimationData::pluginID
RowID pluginID() const
Definition: CostEstimationData.cc:88
CQ_FU_PORT_MAP
const string CQ_FU_PORT_MAP
Definition: HDBManager.cc:177
RelationalDBQueryResult::data
virtual const DataObject & data(std::size_t column) const =0
Definition: RelationalDBQueryResult.cc:96
HDB::BlockImplementationFile::VHDL
@ VHDL
VHDL file.
Definition: BlockImplementationFile.hh:48
CQ_IO_BINDING
const string CQ_IO_BINDING
Definition: HDBManager.cc:152
CostEstimationData::hasSocketReference
bool hasSocketReference() const
RelationalDBQueryResult::reset
virtual void reset()
Definition: RelationalDBQueryResult.cc:163
HDB::HDBManager::PipelineElementUsageTable
std::vector< PipelineElementUsage > PipelineElementUsageTable
Definition: HDBManager.hh:297
HDB::BlockImplementationFile::Format
Format
Format of the file.
Definition: BlockImplementationFile.hh:47
RelationalDBQueryResult::UNKNOWN_INDEX
static const int UNKNOWN_INDEX
Definition: RelationalDBQueryResult.hh:50
HDB::HDBManager::rfExternalPortsByIDQuery
static std::string rfExternalPortsByIDQuery(RowID id)
Definition: HDBManager.cc:6072
IN_DIRECTION
const string IN_DIRECTION
Definition: HDBManager.cc:85
HDB::HDBManager::fuPortsAndBindingsByIDQuery
static std::string fuPortsAndBindingsByIDQuery(RowID id)
Definition: HDBManager.cc:5880
CQ_BUS
const string CQ_BUS
Definition: HDBManager.cc:304
HDB::HDBManager::removeFUImplementation
virtual void removeFUImplementation(RowID implementationID) const
Definition: HDBManager.cc:1325
HDB::CostFunctionPlugin::COST_DECOMP
@ COST_DECOMP
decompressor cost estimator
Definition: CostFunctionPlugin.hh:49
COST_PLUGIN_TYPE_ICDEC
const std::string COST_PLUGIN_TYPE_ICDEC
Definition: HDBManager.cc:99
CQ_FU
const string CQ_FU
Definition: HDBManager.cc:102
RowID
int RowID
Type definition of row ID in relational databases.
Definition: DBTypes.hh:37
HDB::FUImplementation::Parameter
HDB::Parameter Parameter
Parameter of FU implementation.
Definition: FUImplementation.hh:61
HDB::HDBManager::hasCostFunctionPluginByID
bool hasCostFunctionPluginByID(RowID id) const
Definition: HDBManager.cc:4064
CostEstimationData::setFUReference
void setFUReference(RowID fuEntryID)
RelationalDBConnection::commit
virtual void commit()=0
Definition: RelationalDBConnection.cc:110
CostEstimationData::setRFReference
void setRFReference(RowID rfEntryID)
VHDL_FORMAT
const string VHDL_FORMAT
Definition: HDBManager.cc:88
CQ_RF_IMPLEMENTATION
const string CQ_RF_IMPLEMENTATION
Definition: HDBManager.cc:257
CostEstimationData::hasFUReference
bool hasFUReference() const
HDB::HDBManager::OperationImplementationResourceByID
OperationImplementationResource OperationImplementationResourceByID(RowID id) const
Definition: HDBManager.cc:2410
TTAMachine::ExecutionPipeline::writtenOperands
OperandSet writtenOperands(int cycle) const
Definition: ExecutionPipeline.cc:429
COST_PLUGIN_TYPE_RF
const std::string COST_PLUGIN_TYPE_RF
Definition: HDBManager.cc:97
TTAMachine::PipelineElement::name
const std::string & name() const
TTAMachine::ExecutionPipeline::readOperands
OperandSet readOperands(int cycle) const
Definition: ExecutionPipeline.cc:408
READ_ACTION
const bool READ_ACTION
Definition: HDBManager.cc:82
HDB::HDBManager::hasColumn
bool hasColumn(const std::string &table, const std::string &columnName) const
Definition: HDBManager.cc:4342
HDB::HDBManager::addBlockImplementationFileToHDB
void addBlockImplementationFileToHDB(const BlockImplementationFile &file) const
Definition: HDBManager.cc:5498
TTAMachine::FUPort::isTriggering
virtual bool isTriggering() const
Definition: FUPort.cc:182
CQ_RF_EXT_PORT_PARAMETER_DEPENDENCY
const string CQ_RF_EXT_PORT_PARAMETER_DEPENDENCY
Definition: HDBManager.cc:230
FileSystem::absolutePathOf
static std::string absolutePathOf(const std::string &pathName)
Definition: FileSystem.cc:303
CostEstimationData::hasValue
bool hasValue() const
MachineValidatorResults
Definition: MachineValidatorResults.hh:45
HDB::HDBManager::hasCostEstimationDataByID
bool hasCostEstimationDataByID(RowID id) const
Definition: HDBManager.cc:4035
HDB::HDBManager::containsImplementationFile
bool containsImplementationFile(const std::string &pathToFile) const
Definition: HDBManager.cc:4185
CostEstimationData::setValue
void setValue(const DataObject &value)
Conversion::toString
static std::string toString(const T &source)
CQ_FU_DATA_PORT
const string CQ_FU_DATA_PORT
Definition: HDBManager.cc:143
RelationalDBQueryResult::hasNext
virtual bool hasNext()=0
Definition: RelationalDBQueryResult.cc:126
NotAvailable
Definition: Exception.hh:728
SQLite::connect
virtual RelationalDBConnection & connect(const std::string &database, const std::string &login="", const std::string &password="", bool readOnly=false)
Definition: SQLite.cc:69
HDB::HDBManager::hdbFile_
std::string hdbFile_
The HDB file to manager.
Definition: HDBManager.hh:404
BIDIR_DIRECTION
const string BIDIR_DIRECTION
Definition: HDBManager.cc:87
FileSystem::fileIsCreatable
static bool fileIsCreatable(const std::string fileName)
Definition: FileSystem.cc:123
HDB::HDBManager::containsOperation
bool containsOperation(const std::string &opName) const
Definition: HDBManager.cc:4159
HDB::CostFunctionPlugin::COST_FU
@ COST_FU
function unit cost estimator
Definition: CostFunctionPlugin.hh:47
RelationalDBConnection::version
virtual int version()=0
Definition: RelationalDBConnection.cc:146
assert
#define assert(condition)
Definition: Application.hh:86
TTAMachine::FunctionUnit
Definition: FunctionUnit.hh:55
HDB::HDBManager::hasBusEntry
bool hasBusEntry(RowID id) const
Definition: HDBManager.cc:3980
TTAMachine::HWOperation::port
virtual FUPort * port(int operand) const
Definition: HWOperation.cc:320
HDB::CostFunctionPlugin::COST_ICDEC
@ COST_ICDEC
interconnection network & decoder cost estimator
Definition: CostFunctionPlugin.hh:50
CQ_OPERATION_IMPLEMENTATION_RESOURCE
const string CQ_OPERATION_IMPLEMENTATION_RESOURCE
Definition: HDBManager.cc:354
DataObject::integerValue
virtual int integerValue() const
Definition: DataObject.cc:204
HDB::RFImplementation::Parameter
HDB::Parameter Parameter
Parameter of FU implementation.
Definition: RFImplementation.hh:53
CQ_OPERATION_PIPELINE
const string CQ_OPERATION_PIPELINE
Definition: HDBManager.cc:117
TTAMachine::FUPort
Definition: FUPort.hh:46
CostEstimationData::hasName
bool hasName() const
HDB::HDBManager::addBlockImplementationFiles
void addBlockImplementationFiles(FUImplementation &implementation, RowID entryID) const
Definition: HDBManager.cc:5337
HDB::HDBManager::createCostFunctionOfFU
CostFunctionPlugin * createCostFunctionOfFU(RowID id) const
Definition: HDBManager.cc:4691
HDB::HDBManager::resolveArchitecturePort
std::string resolveArchitecturePort(const FUArchitecture &architecture, RowID entryID, const std::string &implementedPort) const
Definition: HDBManager.cc:4922
CQ_OPERATION_IMPLEMENTATION_SOURCE_FILE
const string CQ_OPERATION_IMPLEMENTATION_SOURCE_FILE
Definition: HDBManager.cc:347
RelationalDBConnection::updateVersion
virtual void updateVersion(int version)=0
Definition: RelationalDBConnection.cc:156
HDB::HDBManager::insertFileFormats
static void insertFileFormats(RelationalDBConnection &connection)
Definition: HDBManager.cc:5689
CostEstimationData::busReference
RowID busReference() const
Definition: CostEstimationData.cc:133
TTAMachine::ExecutionPipeline::addResourceUse
void addResourceUse(const std::string &name, int start, int duration)
Definition: ExecutionPipeline.cc:112
TTAMachine::HWOperation::io
int io(const FUPort &port) const
Definition: HWOperation.cc:364
abortWithError
#define abortWithError(message)
Definition: Application.hh:72
TTAMachine::HWOperation::name
const std::string & name() const
Definition: HWOperation.cc:141
WRITE_ACTION
const bool WRITE_ACTION
Definition: HDBManager.cc:83
InvalidData
Definition: Exception.hh:149
CostEstimationData::setBusReference
void setBusReference(RowID busEntryID)
RelationalDBQueryResult::next
virtual bool next()=0
Definition: RelationalDBQueryResult.cc:138
CQ_FU_EXTERNAL_PORT
const string CQ_FU_EXTERNAL_PORT
Definition: HDBManager.cc:188
HDB::HDBManager::addBooleanColumn
int addBooleanColumn(const std::string &table, const std::string &newcolumn)
Definition: HDBManager.cc:4380
TTAMachine::FunctionUnit::pipelineElement
virtual PipelineElement * pipelineElement(int index) const
Definition: FunctionUnit.cc:523
CQ_PIPELINE_RESOURCE_USAGE
const string CQ_PIPELINE_RESOURCE_USAGE
Definition: HDBManager.cc:123
HDB::HDBManager::canRemoveFUArchitecture
bool canRemoveFUArchitecture(RowID archID) const
Definition: HDBManager.cc:904
RelationalDBQueryResult::bindString
virtual void bindString(unsigned int position, const std::string &value)
Definition: RelationalDBQueryResult.cc:154
HDB::HDBManager::resourceUsageDataByIDQuery
static std::string resourceUsageDataByIDQuery(RowID id)
Definition: HDBManager.cc:5933
HDB::HDBManager::hasFUEntry
bool hasFUEntry(RowID id) const
Definition: HDBManager.cc:3924
HDB::Direction
Direction
Direction of port.
Definition: HDBTypes.hh:40
HDB::BIDIR
@ BIDIR
Bidirectional port.
Definition: HDBTypes.hh:43
HDB::HDBManager::addFUParametersToImplementation
void addFUParametersToImplementation(FUImplementation &implementation, RowID entryID) const
Definition: HDBManager.cc:5240
HDB::HDBManager::rfArchitectureByID
virtual RFArchitecture * rfArchitectureByID(RowID id) const
Definition: HDBManager.cc:2963
DataObject::isNull
virtual bool isNull() const
Definition: DataObject.cc:491
HDB::HDBManager::fuImplementationParametersByIDQuery
static std::string fuImplementationParametersByIDQuery(RowID id)
Definition: HDBManager.cc:6099
HDB::HDBManager::hasRFEntry
bool hasRFEntry(RowID id) const
Definition: HDBManager.cc:3952
TTAMachine::HWOperation::isBound
bool isBound(const FUPort &port) const
Definition: HWOperation.cc:338
RelationalDBQueryResult
Definition: RelationalDBQueryResult.hh:46
CQ_FU_ARCHITECTURE
const string CQ_FU_ARCHITECTURE
Definition: HDBManager.cc:108
__func__
#define __func__
Definition: Application.hh:67
TTAMachine::ExecutionPipeline::addPortRead
void addPortRead(int operand, int start, int duration)
Definition: ExecutionPipeline.cc:141
HDB::HDBManager::fuEntryByIDQuery
static std::string fuEntryByIDQuery(RowID id)
Definition: HDBManager.cc:5781
HDB::HDBManager::addRFExternalPortsToImplementation
void addRFExternalPortsToImplementation(RFImplementation &implementation, RowID entryID) const
Definition: HDBManager.cc:5143
CQ_FU_IMPLEMENTATION_PARAMETER
const string CQ_FU_IMPLEMENTATION_PARAMETER
Definition: HDBManager.cc:208
TTAMachine::FunctionUnit::operationCount
virtual int operationCount() const
Definition: FunctionUnit.cc:419
HDB::HDBManager::createCostFunctionOfRF
CostFunctionPlugin * createCostFunctionOfRF(RowID id) const
Definition: HDBManager.cc:4763
CQ_OPERATION_IMPLEMENTATION
const string CQ_OPERATION_IMPLEMENTATION
Definition: HDBManager.cc:360
FUValidator::checkOperations
static void checkOperations(const TTAMachine::FunctionUnit &fu, MachineValidatorResults &results)
Definition: FUValidator.cc:100
RelationalDBConnection::query
virtual RelationalDBQueryResult * query(const std::string &queryString, bool init=true)=0
Definition: RelationalDBConnection.cc:80
HDB::HDBManager::rfEntryByIDQuery
static std::string rfEntryByIDQuery(RowID id)
Definition: HDBManager.cc:5800
CostEstimationData::socketReference
RowID socketReference() const
Definition: CostEstimationData.cc:148
TTAMachine::FunctionUnit::hasOperation
virtual bool hasOperation(const std::string &name) const
Definition: FunctionUnit.cc:330
MachineValidatorResults::errorCount
int errorCount() const
Definition: MachineValidatorResults.cc:56
Exception
Definition: Exception.hh:54
HDB::HDBManager::socketEntryByIDQuery
static std::string socketEntryByIDQuery(RowID id)
Definition: HDBManager.cc:5838
HDB::BlockImplementationFile::Verilog
@ Verilog
Verilog file.
Definition: BlockImplementationFile.hh:49
TTAMachine::ExecutionPipeline::OperandSet
std::set< int > OperandSet
Set for operand indexes.
Definition: ExecutionPipeline.hh:58
TTAMachine::FunctionUnit::operationPortCount
virtual int operationPortCount() const
Definition: FunctionUnit.cc:182
HDB::HDBManager::containsRFArchitecture
bool containsRFArchitecture(RowID id) const
Definition: HDBManager.cc:4240
CQ_RF_IMPLEMENTATION_PARAMETER
const string CQ_RF_IMPLEMENTATION_PARAMETER
Definition: HDBManager.cc:216
CostEstimationData
Definition: CostEstimationData.hh:42
CQ_RF_ARCHITECTURE
const string CQ_RF_ARCHITECTURE
Definition: HDBManager.cc:242
HDB::HDBManager::DataObjectList
std::list< DataObject > DataObjectList
Definition: HDBManager.hh:86
RelationalDBConnection::beginTransaction
virtual void beginTransaction()=0
Definition: RelationalDBConnection.cc:92
CostEstimationData::value
DataObject value() const
Definition: CostEstimationData.cc:73
Exception::errorMessage
std::string errorMessage() const
Definition: Exception.cc:123
SQLite::close
virtual void close(const RelationalDBConnection &connection)
Definition: SQLite.cc:100
TTAMachine::FunctionUnit::pipelineElementCount
virtual int pipelineElementCount() const
Definition: FunctionUnit.cc:507
CostEstimationData::hasPluginID
bool hasPluginID() const
HDB::HDBManager::addRFParametersToImplementation
void addRFParametersToImplementation(RFImplementation &implementation, RowID entryID) const
Definition: HDBManager.cc:5274
HDB::HDBManager::addOperationPipelinesToFUArchitecture
void addOperationPipelinesToFUArchitecture(FUArchitecture &architecture, RowID id) const
Definition: HDBManager.cc:4517
HDB::CostFunctionPlugin::COST_RF
@ COST_RF
register file cost estimator
Definition: CostFunctionPlugin.hh:48
CQ_RF
const string CQ_RF
Definition: HDBManager.cc:236
TTAMachine::FunctionUnit::hasOperationPort
virtual bool hasOperationPort(const std::string &name) const
Definition: FunctionUnit.cc:204
CQ_SOCKET
const string CQ_SOCKET
Definition: HDBManager.cc:308
CostEstimationData::hasBusReference
bool hasBusReference() const
SetTools::intersection
static void intersection(const std::set< ValueType > &firstContainer, const std::set< ValueType > &secondContainer, std::set< ValueType > &intersection)
CQ_FU_EXT_PORT_PARAMETER_DEPENDENCY
const string CQ_FU_EXT_PORT_PARAMETER_DEPENDENCY
Definition: HDBManager.cc:224
CQ_FORMAT
const string CQ_FORMAT
Definition: HDBManager.cc:299
CQ_FU_IMPLEMENTATION
const string CQ_FU_IMPLEMENTATION
Definition: HDBManager.cc:159
HDB::HDBManager::opcodesByIDQuery
static std::string opcodesByIDQuery(RowID id)
Definition: HDBManager.cc:5991
MapTools::containsKey
static bool containsKey(const MapType &aMap, const KeyType &aKey)
OUT_DIRECTION
const string OUT_DIRECTION
Definition: HDBManager.cc:86
HDB::HDBManager::db_
SQLite * db_
Handle to the database.
Definition: HDBManager.hh:400
RelationalDBConnection::DDLQuery
virtual void DDLQuery(const std::string &queryString)=0
Definition: RelationalDBConnection.cc:69
TTAMachine::PipelineElement
Definition: PipelineElement.hh:46
RelationalDBConnection::tableExistsInDB
virtual bool tableExistsInDB(const std::string &tableName)=0
Definition: RelationalDBConnection.cc:122
CQ_FU_IMPL_ENTRY_INDEX
const string CQ_FU_IMPL_ENTRY_INDEX
Definition: HDBManager.cc:334
CQ_IO_USAGE
const string CQ_IO_USAGE
Definition: HDBManager.cc:130
CQ_FU_SOURCE_FILE
const string CQ_FU_SOURCE_FILE
Definition: HDBManager.cc:293
CostEstimationData::fuReference
RowID fuReference() const
Definition: CostEstimationData.cc:103
HDB::BlockImplementationFile::Verilogsim
@ Verilogsim
Verilog simulation file.
Definition: BlockImplementationFile.hh:51
HDB::HDBManager::fuSourceFilesByIDQuery
static std::string fuSourceFilesByIDQuery(RowID id)
Definition: HDBManager.cc:6174
CostEstimationData::setPluginID
void setPluginID(RowID pluginID)
RelationalDBQueryResult::column
virtual int column(const std::string &name) const
Definition: RelationalDBQueryResult.cc:64
FileSystem::fileExists
static bool fileExists(const std::string fileName)
TTAMachine::Port::name
virtual std::string name() const
Definition: Port.cc:141
RelationalDBQueryResult::bindInt
virtual void bindInt(unsigned int position, int value)
Definition: RelationalDBQueryResult.cc:146
HDB::HDBManager::removeCostEstimationData
virtual void removeCostEstimationData(RowID id) const
Definition: HDBManager.cc:5479
CQ_COST_ESTIMATION_DATA
const string CQ_COST_ESTIMATION_DATA
type: {'fu'|'rf'|'decomp'|'icdec'}
Definition: HDBManager.cc:320
HDB::HDBManager::createImplementationOfFU
virtual FUImplementation * createImplementationOfFU(FUArchitecture &architecture, RowID id) const
Definition: HDBManager.cc:4615
HDB::HDBManager::rfImplementationParametersByIDQuery
static std::string rfImplementationParametersByIDQuery(RowID id)
Definition: HDBManager.cc:6122
CQ_RF_EXTERNAL_PORT
const string CQ_RF_EXTERNAL_PORT
Definition: HDBManager.cc:198
CostEstimationData::hasRFReference
bool hasRFReference() const
HDB::IN
@ IN
Input port.
Definition: HDBTypes.hh:41
HDB::HDBManager::removeRFImplementation
virtual void removeRFImplementation(RowID implID) const
Definition: HDBManager.cc:1808
HDB::HDBManager::rfArchitectureByIDQuery
static std::string rfArchitectureByIDQuery(RowID id)
Definition: HDBManager.cc:6198
COST_PLUGIN_TYPE_DECOMP
const std::string COST_PLUGIN_TYPE_DECOMP
Definition: HDBManager.cc:98
TTAMachine::HWOperation::pipeline
ExecutionPipeline * pipeline() const
Definition: HWOperation.cc:201
CostEstimationData::setSocketReference
void setSocketReference(RowID socketEntryID)
TTAMachine::ExecutionPipeline
Definition: ExecutionPipeline.hh:55
HDB::HDBManager::addOpcodesToImplementation
void addOpcodesToImplementation(FUImplementation &implementation, RowID entryID) const
Definition: HDBManager.cc:4971
HDB::HDBManager::fuPortBindingByNameQuery
static std::string fuPortBindingByNameQuery(RowID fuID, const std::string &portName)
Definition: HDBManager.cc:6146
TTAMachine::ExecutionPipeline::addPortWrite
void addPortWrite(int operand, int start, int duration)
Definition: ExecutionPipeline.cc:167
CQ_OPCODE_MAP
const string CQ_OPCODE_MAP
Definition: HDBManager.cc:170
KeyNotFound
Definition: Exception.hh:285
TTAMachine::FunctionUnit::operation
virtual HWOperation * operation(const std::string &name) const
Definition: FunctionUnit.cc:363
CQ_OPERATION_IMPLEMENTATION_RESOURCES
const string CQ_OPERATION_IMPLEMENTATION_RESOURCES
Definition: HDBManager.cc:366
TTAMachine::HWOperation::latency
int latency() const
Definition: HWOperation.cc:216
IOException
Definition: Exception.hh:130
HDB::HDBManager::addFUExternalPortsToImplementation
void addFUExternalPortsToImplementation(FUImplementation &implementation, RowID entryID) const
Definition: HDBManager.cc:5055
TTAMachine::FunctionUnit::operationPort
virtual FUPort * operationPort(const std::string &name) const
Definition: FunctionUnit.cc:224
HDB::HDBManager::canRemoveRFArchitecture
bool canRemoveRFArchitecture(RowID archID) const
Definition: HDBManager.cc:1508
CQ_RF_SOURCE_FILE
const string CQ_RF_SOURCE_FILE
Definition: HDBManager.cc:287
DataObject::boolValue
virtual bool boolValue() const
Definition: DataObject.cc:470
COST_PLUGIN_TYPE_FU
const std::string COST_PLUGIN_TYPE_FU
Possible cost function plugin types.
Definition: HDBManager.cc:96
FileSystem::fileIsReadable
static bool fileIsReadable(const std::string fileName)
HDB::HDBManager::containsFUArchitecture
bool containsFUArchitecture(RowID id) const
Definition: HDBManager.cc:4212
VHDL_SIM_FORMAT
const string VHDL_SIM_FORMAT
Definition: HDBManager.cc:90
HDB::HDBManager::fuArchitectureID
RowID fuArchitectureID(RowID fuEntryID) const
Definition: HDBManager.cc:4268
debugLog
#define debugLog(text)
Definition: Application.hh:95
TTAMachine::ExecutionPipeline::latency
int latency() const
Definition: ExecutionPipeline.cc:482
HDB::HDBManager::fuImplementationDataPortsByIDQuery
static std::string fuImplementationDataPortsByIDQuery(RowID id)
Definition: HDBManager.cc:6016
HDB::HDBManager::fuByEntryID
FUEntry * fuByEntryID(RowID id) const
Definition: HDBManager.cc:2828
HDB::HDBManager::fileFormat
static BlockImplementationFile::Format fileFormat(const std::string &formatString)
Definition: HDBManager.cc:5714
SQLite
Definition: SQLite.hh:45
HDB::HDBManager::ioUsageDataByIDQuery
static std::string ioUsageDataByIDQuery(RowID id)
Definition: HDBManager.cc:5908
CQ_COST_FUNCTION_PLUGIN
const string CQ_COST_FUNCTION_PLUGIN
Definition: HDBManager.cc:312
HDB::OUT
@ OUT
Output port.
Definition: HDBTypes.hh:42
HDB::HDBManager::rfImplementationByIDQuery
static std::string rfImplementationByIDQuery(RowID id)
Definition: HDBManager.cc:6219
HDB::HDBManager::addDataPortsToImplementation
void addDataPortsToImplementation(FUImplementation &implementation, FUArchitecture &architecture, RowID entryID) const
Definition: HDBManager.cc:5006
HDB::HDBManager::isMatchingArchitecture
static bool isMatchingArchitecture(const TTAMachine::FunctionUnit &fu, const FUArchitecture &arch)
Definition: HDBManager.cc:5519
TTAMachine::BaseFUPort::width
virtual int width() const
Definition: BaseFUPort.cc:109
TTAMachine::ExecutionPipeline::isResourceUsed
bool isResourceUsed(const std::string &name, int cycle) const
Definition: ExecutionPipeline.cc:300
CQ_BLOCK_SOURCE_FILE
const string CQ_BLOCK_SOURCE_FILE
Definition: HDBManager.cc:281
HDB::HDBManager::areCompatiblePipelines
static bool areCompatiblePipelines(const PipelineElementUsageTable &table)
Definition: HDBManager.cc:5634
HDB::BlockImplementationFile::VHDLsim
@ VHDLsim
VHDL simulation file.
Definition: BlockImplementationFile.hh:50
HDB::HDBManager::rfByEntryID
RFEntry * rfByEntryID(RowID id) const
Definition: HDBManager.cc:2885
MachineValidatorResults::error
Error error(int index) const
Definition: MachineValidatorResults.cc:70
HDB::HDBManager::createImplementationOfRF
virtual RFImplementation * createImplementationOfRF(RowID id) const
Definition: HDBManager.cc:4837
CQ_FU_PORT_MAP_ARCH_INDEX
const string CQ_FU_PORT_MAP_ARCH_INDEX
Definition: HDBManager.cc:331