Skip to content

Commit

Permalink
Odb Schema, commit 1
Browse files Browse the repository at this point in the history
  • Loading branch information
andyfox-rushc committed Mar 14, 2024
1 parent ca905ef commit 95adc2e
Show file tree
Hide file tree
Showing 62 changed files with 5,129 additions and 177 deletions.
2 changes: 1 addition & 1 deletion src/dbSta/src/dbNetwork.cc
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ const char* dbNetwork::name(const Instance* instance) const
if (db_inst) {
return tmpStringCopy(db_inst->getConstName());
}
return tmpStringCopy(mod_inst->getName().c_str());
return tmpStringCopy(mod_inst->getName());
}

Cell* dbNetwork::cell(const Instance* instance) const
Expand Down
170 changes: 160 additions & 10 deletions src/odb/include/odb/db.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,10 @@ class dbIsolation;
class dbLevelShifter;
class dbLogicPort;
class dbMetalWidthViaMap;
class dbModBTerm;
class dbModInst;
class dbModITerm;
class dbModNet;
class dbModule;
class dbNetTrack;
class dbPowerDomain;
Expand Down Expand Up @@ -863,7 +866,7 @@ class dbBlock : public dbObject
/// Get block chip name.
///
std::string getName();

void dumpDebug();
///
/// Get the block chip name.
///
Expand Down Expand Up @@ -910,6 +913,8 @@ class dbBlock : public dbObject
///
dbSet<dbBlock> getChildren();

void getChildModules(std::vector<dbModule*>& child_modules);

///
/// Find a specific child-block of this block.
/// Returns nullptr if the object was not found.
Expand Down Expand Up @@ -946,6 +951,8 @@ class dbBlock : public dbObject
/// Get the modinsts of this block.
///
dbSet<dbModInst> getModInsts();
dbSet<dbModNet> getModNets();
dbSet<dbModBTerm> getModBTerms();

///
/// Get the Power Domains of this block.
Expand Down Expand Up @@ -1719,13 +1726,17 @@ class dbBTerm : public dbObject
///
dbNet* getNet();

// AF
dbModNet* getModNet();

/// Disconnect the block-terminal from it's net.
///
void disconnect();

/// Connect the block-terminal to net.
///
void connect(dbNet* net);
void connect(dbModNet* mod_net);

///
/// Get the block of this block-terminal.
Expand Down Expand Up @@ -3227,24 +3238,30 @@ class dbInst : public dbObject
/// If false, it will be added to the top module.
/// Returns nullptr if an instance with this name already exists.
/// Returns nullptr if the master is not FROZEN.
///
/// If dbmodule is non null the dbInst is added to that module.

static dbInst* create(dbBlock* block,
dbMaster* master,
const char* name,
bool physical_only = false);
bool physical_only = false,
dbModule* = nullptr);

///
/// Create a new instance within the specified region.
/// If physicalOnly is true the instance can't bee added to a dbModule.
/// If false, it will be added to the top module.
/// Returns nullptr if an instance with this name already exists.
/// Returns nullptr if the master is not FROZEN.
///
/// If db module present then the dbinst is added to that module

static dbInst* create(dbBlock* block,
dbMaster* master,
const char* name,
dbRegion* region,
bool physical_only = false);
bool physical_only = false,
dbModule* parent_module = nullptr

);

///
/// Create a new instance of child_block in top_block.
Expand Down Expand Up @@ -3298,6 +3315,9 @@ class dbITerm : public dbObject
///
dbNet* getNet();

// AF
dbModNet* getModNet();

///
/// Get the master-terminal that this instance-terminal is representing.
///
Expand Down Expand Up @@ -3449,6 +3469,10 @@ class dbITerm : public dbObject
///
void connect(dbNet* net);

// connect this iterm to a dbmodNet
// AF.
void connect(dbModNet* net);

///
/// Disconnect this iterm from the net it is connected to.
///
Expand Down Expand Up @@ -7456,9 +7480,58 @@ class dbMetalWidthViaMap : public dbObject
// User Code End dbMetalWidthViaMap
};

class dbModBTerm : public dbObject
{
public:
const char* getName() const;

dbModule* getParent() const;

void setNet(dbModNet* net);

dbModNet* getNet() const;

void setNextNetModbterm(dbModBTerm* next_net_modbterm);

dbModBTerm* getNextNetModbterm() const;

void setPrevNetModbterm(dbModBTerm* prev_net_modbterm);

dbModBTerm* getPrevNetModbterm() const;

void setNextEntry(dbModBTerm* next_entry);

dbModBTerm* getNextEntry() const;

// User Code Begin dbModBTerm

void setSigType(dbSigType type);
dbSigType getSigType();
void setIoType(dbIoType type);
dbIoType getIoType();

static dbModBTerm* create(dbModule* parentModule, const char* name);

void connect(dbModNet*);
void disconnect();

char* getName();

void staSetPort(void* p);
void* staPort();

private:
void setFlags(uint flags);
uint getFlags() const;

// User Code End dbModBTerm
};

class dbModInst : public dbObject
{
public:
const char* getName() const;

dbModule* getParent() const;

dbModule* getMaster() const;
Expand All @@ -7476,30 +7549,99 @@ class dbModInst : public dbObject

static dbModInst* getModInst(dbBlock* block_, uint dbid_);

std::string getName() const;

std::string getHierarchicalName() const;

bool findModITerm(const char* name, dbModITerm*& ret);

dbSet<dbModITerm> getModITerms();

// User Code End dbModInst
};

class dbModITerm : public dbObject
{
public:
dbModInst* getParent() const;

void setNet(dbModNet* net);

dbModNet* getNet() const;

void setNextNetModiterm(dbModITerm* next_net_moditerm);

dbModITerm* getNextNetModiterm() const;

void setPrevNetModiterm(dbModITerm* prev_net_moditerm);

dbModITerm* getPrevNetModiterm() const;

void setNextEntry(dbModITerm* next_entry);

dbModITerm* getNextEntry() const;

// User Code Begin dbModITerm
void setSigType(dbSigType type);
dbSigType getSigType();
void setIoType(dbIoType type);
dbIoType getIoType();

static dbModITerm* create(dbModInst* parentInstance, const char* name);
bool connect(dbModNet*);
char* getName();

private:
void setFlags(uint flags);
uint getFlags() const;

// User Code End dbModITerm
};

class dbModNet : public dbObject
{
public:
dbModule* getParent() const;

// User Code Begin dbModNet
dbSet<dbModITerm> getModITerms();
dbSet<dbModBTerm> getModBTerms();
dbSet<dbITerm> getITerms();
dbSet<dbBTerm> getBTerms();

static dbModNet* create(dbModule* parentModule, const char* name);
const char* getName() const;
dbModBTerm* connectedToModBTerm();
// User Code End dbModNet
};

class dbModule : public dbObject
{
public:
const char* getName() const;

void setModInst(dbModInst* mod_inst);

dbModInst* getModInst() const;

// User Code Begin dbModule

std::string getHierarchicalName(std::string& separator);
std::string getHierarchicalName() const;
std::string hierarchicalNameR(std::string& separator);
// Adding an inst to a new module will remove it from its previous
// module.
void addInst(dbInst* inst);

dbSet<dbInst> getInsts();
dbBlock* getOwner();

dbSet<dbModInst> getChildren();
dbSet<dbModInst> getModInsts();
dbSet<dbModNet> getModNets();
dbModNet* getModNet(const char* net_name);
dbSet<dbModBTerm> getModBTerms();
dbSet<dbInst> getInsts();

dbModInst* findModInst(const char* name);
dbInst* findDbInst(const char* name);
dbModBTerm* findModBTerm(const char* name);

std::vector<dbInst*> getLeafInsts();

Expand All @@ -7509,7 +7651,15 @@ class dbModule : public dbObject

static dbModule* getModule(dbBlock* block_, uint dbid_);

std::string getHierarchicalName() const;
unsigned getModInstCount();
unsigned getDbInstCount();

bool findPortIx(const char* port_name, unsigned& ix);

void staSetCell(void* cell);
void* getStaCell();

private:
// User Code End dbModule
};

Expand Down
3 changes: 3 additions & 0 deletions src/odb/include/odb/dbObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,10 @@ enum dbObjectType
dbLevelShifterObj,
dbLogicPortObj,
dbMetalWidthViaMapObj,
dbModBTermObj,
dbModInstObj,
dbModITermObj,
dbModNetObj,
dbModuleObj,
dbNetTrackObj,
dbPowerDomainObj,
Expand Down
31 changes: 28 additions & 3 deletions src/odb/include/odb/dbStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
#include "map"
#include "odb.h"
#include "tuple"
#include "vector"

namespace odb {

Expand Down Expand Up @@ -191,7 +192,7 @@ class dbOStream
return *this;
} else {
*this << std::get<I>(tup);
return ((*this).operator<< <I + 1>(tup));
return ((*this).operator<<<I + 1>(tup));
}
}

Expand Down Expand Up @@ -219,6 +220,17 @@ class dbOStream
return *this;
}

template <class T1>
dbOStream& operator<<(const std::vector<T1>& m)
{
uint sz = m.size();
*this << sz;
for (auto val : m) {
*this << val;
}
return *this;
}

template <class T, std::size_t SIZE>
dbOStream& operator<<(const std::array<T, SIZE>& a)
{
Expand Down Expand Up @@ -249,12 +261,11 @@ class dbOStream
*this << (uint32_t) v.index();
*this << std::get<I>(v);
}
return ((*this).operator<< <I + 1>(v));
return ((*this).operator<<<I + 1>(v));
}
}

double lefarea(int value) { return ((double) value * _lef_area_factor); }

double lefdist(int value) { return ((double) value * _lef_dist_factor); }

Position pos() const { return _f.tellp(); }
Expand Down Expand Up @@ -420,6 +431,20 @@ class dbIStream
}
return *this;
}

template <class T1>
dbIStream& operator>>(std::vector<T1>& m)
{
uint sz;
*this >> sz;
for (uint i = 0; i < sz; i++) {
T1 val;
*this >> val;
m.push_back(val);
}
return *this;
}

template <class T, std::size_t SIZE>
dbIStream& operator>>(std::array<T, SIZE>& a)
{
Expand Down
Loading

0 comments on commit 95adc2e

Please sign in to comment.