├── src ├── db │ ├── db_set.cpp │ ├── db_setting.h │ ├── db_region.cpp │ ├── db_layer.cpp │ ├── db_place.cpp │ ├── db_td.h │ ├── db_drc.cpp │ ├── db_site.h │ ├── db_snet.h │ ├── db_drc.h │ ├── db_via.h │ ├── db_region.h │ ├── db_route.h │ ├── db_layer.h │ ├── db_place.h │ ├── db_map.h │ ├── db_row.h │ ├── db_net.h │ ├── db_geom.h │ ├── db_map.cpp │ ├── db_cell.cpp │ ├── db_route.cpp │ ├── db_net.cpp │ ├── db_cell.h │ ├── db_geom.cpp │ └── db_get.cpp ├── cugr │ └── bin │ │ └── iccad19gr ├── def58 │ ├── lib │ │ └── libdef.a │ └── inc │ │ ├── defiKRDefs.hpp │ │ ├── defiUtil.hpp │ │ ├── defiAlias.hpp │ │ ├── defiDebug.hpp │ │ ├── defiPropType.hpp │ │ ├── defiMisc.hpp │ │ ├── defiSlot.hpp │ │ ├── defiPinProp.hpp │ │ ├── defiUser.hpp │ │ ├── defiTimingDisable.hpp │ │ ├── defiRegion.hpp │ │ ├── defiFPC.hpp │ │ ├── defiProp.hpp │ │ ├── defiSite.hpp │ │ ├── defiGroup.hpp │ │ ├── defiIOTiming.hpp │ │ └── defiFill.hpp ├── io │ ├── file_verilog.h │ ├── file_lefdef_db.h │ ├── file_liberty.h │ ├── utils.cpp │ ├── utils.h │ ├── io_setting.h │ ├── io.h │ ├── file_liberty.l │ └── file_constraints.cpp ├── lef58 │ ├── lib │ │ └── liblef.a │ └── inc │ │ ├── lefiKRDefs.hpp │ │ ├── lefiEncryptInt.hpp │ │ ├── lefiDebug.hpp │ │ ├── lefiUtil.hpp │ │ ├── lefiPropType.hpp │ │ ├── lefiUser.hpp │ │ ├── lefiUnits.hpp │ │ ├── lefiProp.hpp │ │ ├── lefrCallBacks.hpp │ │ └── lefiArray.hpp ├── lemon │ ├── lib │ │ └── libemon.a │ └── include │ │ └── lemon │ │ ├── soplex.h │ │ ├── config.h │ │ ├── bits │ │ ├── windows.h │ │ ├── lock.h │ │ └── enable_if.h │ │ ├── math.h │ │ ├── lp.h │ │ ├── concept_check.h │ │ ├── nauty_reader.h │ │ └── cbc.h ├── gp │ ├── gp_setting.cpp │ ├── gp_main.h │ ├── gp_draw.h │ ├── gp_region.h │ ├── gp_spread.h │ ├── gp_global.h │ ├── gp_congest.h │ ├── gp_qsolve.h │ ├── gp_setting.h │ ├── gp_inflate.h │ ├── gp_congest.cpp │ ├── gp_draw.cpp │ ├── gp.h │ ├── gp_data.h │ ├── gp_cg.h │ ├── gp_region.cpp │ └── gp.cpp ├── gr │ ├── fastroute.cpp │ ├── fastroute.h │ ├── cugr.h │ ├── ripplegr.h │ ├── gr.h │ ├── gr_setting.h │ └── gr.cpp ├── main.cpp ├── sta │ ├── sta.cpp │ ├── sta.h │ ├── data.h │ └── lib.h ├── ripple │ ├── ripple_data.cpp │ ├── ripple_data.h │ ├── ripple_global.h │ ├── ripple_setting.h │ └── ripple.h ├── dp │ ├── dp_global.h │ ├── dp_setting.h │ └── dp.h ├── setting.h ├── global.h ├── ut │ ├── timer.h │ ├── log.h │ ├── timer.cpp │ └── log.cpp ├── tcl │ └── register.h └── vi │ ├── vi.h │ └── draw.h ├── .gitignore └── LICENSE /src/db/db_set.cpp: -------------------------------------------------------------------------------- 1 | #include "db.h" 2 | using namespace db; 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/cugr/bin/iccad19gr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cuhk-eda/ripple/HEAD/src/cugr/bin/iccad19gr -------------------------------------------------------------------------------- /src/def58/lib/libdef.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cuhk-eda/ripple/HEAD/src/def58/lib/libdef.a -------------------------------------------------------------------------------- /src/io/file_verilog.h: -------------------------------------------------------------------------------- 1 | #ifndef _FILE_VERILOG_H_ 2 | #define _FILE_VERILOG_H_ 3 | 4 | #endif 5 | -------------------------------------------------------------------------------- /src/lef58/lib/liblef.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cuhk-eda/ripple/HEAD/src/lef58/lib/liblef.a -------------------------------------------------------------------------------- /src/lemon/lib/libemon.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cuhk-eda/ripple/HEAD/src/lemon/lib/libemon.a -------------------------------------------------------------------------------- /src/gp/gp_setting.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "gp_setting.h" 4 | 5 | -------------------------------------------------------------------------------- /src/gp/gp_main.h: -------------------------------------------------------------------------------- 1 | #ifndef _GP_GP_MAIN_ 2 | #define _GP_GP_MAIN_ 3 | 4 | void gp_main(); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /src/gr/fastroute.cpp: -------------------------------------------------------------------------------- 1 | #include "../global.h" 2 | #include "../ut/utils.h" 3 | 4 | #include "fastroute.h" 5 | -------------------------------------------------------------------------------- /src/io/file_lefdef_db.h: -------------------------------------------------------------------------------- 1 | #ifndef _FILE_LEFDEF_DB_H_ 2 | #define _FILE_LEFDEF_DB_H_ 3 | 4 | 5 | #endif 6 | 7 | -------------------------------------------------------------------------------- /src/lemon/include/lemon/soplex.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cuhk-eda/ripple/HEAD/src/lemon/include/lemon/soplex.h -------------------------------------------------------------------------------- /src/gp/gp_draw.h: -------------------------------------------------------------------------------- 1 | #ifndef _GP_DRAW_H_ 2 | #define _GP_DRAW_H_ 3 | 4 | void drawcell(const char* prefix, int iter = -1); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ripple/ripple.h" 2 | 3 | int main(int argc, char **argv){ 4 | return ripple::Ripple::run(argc, argv); 5 | } 6 | 7 | -------------------------------------------------------------------------------- /src/gp/gp_region.h: -------------------------------------------------------------------------------- 1 | #ifndef _GP_REGION_H_ 2 | #define _GP_REGION_H_ 3 | 4 | void findCellRegionDist(); 5 | void legalizeRegion(); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /src/io/file_liberty.h: -------------------------------------------------------------------------------- 1 | #ifndef _LIBERTY_H_ 2 | #define _LIBERTY_H_ 3 | 4 | // void read_liberty_benchmark(STATimer *timer); 5 | 6 | #endif 7 | 8 | -------------------------------------------------------------------------------- /src/sta/sta.cpp: -------------------------------------------------------------------------------- 1 | #include "../global.h" 2 | 3 | #include "../db/db.h" 4 | #include "sta.h" 5 | using namespace sta; 6 | 7 | STATimer rtimer; 8 | 9 | -------------------------------------------------------------------------------- /src/ripple/ripple_data.cpp: -------------------------------------------------------------------------------- 1 | #include "ripple_global.h" 2 | #include "../db/db.h" 3 | 4 | #include "ripple_data.h" 5 | using namespace ripple; 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/gp/gp_spread.h: -------------------------------------------------------------------------------- 1 | #ifndef _SPREAD_H_ 2 | #define _SPREAD_H_ 3 | 4 | void spreadCells(const int binSize, const int times, const double td); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /src/ripple/ripple_data.h: -------------------------------------------------------------------------------- 1 | #ifndef _RIPPLE_DATA_H_ 2 | #define _RIPPLE_DATA_H_ 3 | 4 | #include "ripple.h" 5 | 6 | namespace ripple{ 7 | } 8 | 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /src/gp/gp_global.h: -------------------------------------------------------------------------------- 1 | #ifndef _GP_GLOBAL_H_ 2 | #define _GP_GLOBAL_H_ 3 | 4 | #include "../global.h" 5 | #include "../setting.h" 6 | #include "gp.h" 7 | 8 | #endif /* _GLOBAL_H_ */ 9 | -------------------------------------------------------------------------------- /src/gr/fastroute.h: -------------------------------------------------------------------------------- 1 | #ifndef _GR_FASTROUTE_ 2 | #define _GR_FASTROUTE_ 3 | 4 | #include "gr.h" 5 | 6 | inline int fastroute(GRResult& result, bool ndr, bool reset) { return 0; } 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /src/dp/dp_global.h: -------------------------------------------------------------------------------- 1 | #ifndef _DP_GLOBAL_H_ 2 | #define _DP_GLOBAL_H_ 3 | 4 | #include "../global.h" 5 | #include "dp.h" 6 | #include "dp_setting.h" 7 | 8 | #endif /* _GLOBAL_H_ */ 9 | 10 | -------------------------------------------------------------------------------- /src/ripple/ripple_global.h: -------------------------------------------------------------------------------- 1 | #ifndef _DP_GLOBAL_H_ 2 | #define _DP_GLOBAL_H_ 3 | 4 | #include "../global.h" 5 | #include "../utils.h" 6 | #include "ripple_setting.h" 7 | 8 | #endif /* _GLOBAL_H_ */ 9 | -------------------------------------------------------------------------------- /src/gp/gp_congest.h: -------------------------------------------------------------------------------- 1 | #ifndef _CONGESTION_H_ 2 | #define _CONGESTION_H_ 3 | 4 | #include "../gr/gr.h" 5 | 6 | void InitCongestionMap(); 7 | void routerCongEstimation(); 8 | 9 | void updateCongMap(); 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /src/db/db_setting.h: -------------------------------------------------------------------------------- 1 | #ifndef _DB_SETTING_H_ 2 | #define _DB_SETTING_H_ 3 | 4 | class DBSetting{ 5 | public: 6 | string file_out; 7 | DBSetting(){ 8 | file_out = ""; 9 | } 10 | }; 11 | 12 | #endif 13 | 14 | -------------------------------------------------------------------------------- /src/io/utils.cpp: -------------------------------------------------------------------------------- 1 | #include "utils.h" 2 | 3 | bool getInputStream(std::string &file, std::ifstream *ifs){ 4 | ifs = new std::ifstream(file.c_str()); 5 | return true; 6 | } 7 | 8 | bool getOutputStream(std::string &file, std::ofstream &ofs){ 9 | return true; 10 | } 11 | -------------------------------------------------------------------------------- /src/setting.h: -------------------------------------------------------------------------------- 1 | #ifndef _SETTING_H_ 2 | #define _SETTING_H_ 3 | 4 | #include "gp/gp_setting.h" 5 | #include "dp/dp_setting.h" 6 | #include "db/db_setting.h" 7 | #include "gr/gr_setting.h" 8 | #include "io/io_setting.h" 9 | #include "ripple/ripple_setting.h" 10 | 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /src/io/utils.h: -------------------------------------------------------------------------------- 1 | #ifndef _IO_UTILS_ 2 | #define _IO_UTILS_ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | bool getInputStream(std::string &file, std::ifstream &ifs); 9 | bool getOutputStream(std::string &file, std::ofstream &ofs); 10 | bool getTokens(std::string &str, std::vector &token); 11 | 12 | #endif 13 | 14 | -------------------------------------------------------------------------------- /src/gp/gp_qsolve.h: -------------------------------------------------------------------------------- 1 | #ifndef _GP_QSOLVE_H_ 2 | #define _GP_QSOLVE_H_ 3 | 4 | #include "gp_cg.h" 5 | 6 | void lowerBound( 7 | double epsilon, 8 | double pseudoAlpha, 9 | int repeat, 10 | LBMode mode, 11 | NetModel model, 12 | double relax = 0.0, 13 | double maxDisp = -1); 14 | 15 | #endif 16 | 17 | -------------------------------------------------------------------------------- /src/db/db_region.cpp: -------------------------------------------------------------------------------- 1 | #include "db.h" 2 | using namespace db; 3 | 4 | #include "../ut/utils.h" 5 | 6 | /***** Region *****/ 7 | 8 | void Region::addRect(const int xl, const int yl, const int xh, const int yh) { 9 | rects.emplace_back(xl, yl, xh, yh); 10 | lx = min(lx, xl); 11 | ly = min(ly, yl); 12 | hx = max(hx, xh); 13 | hy = max(hy, yh); 14 | } 15 | -------------------------------------------------------------------------------- /src/db/db_layer.cpp: -------------------------------------------------------------------------------- 1 | #include "db.h" 2 | using namespace db; 3 | 4 | /***** Track *****/ 5 | 6 | char Track::macro() const { 7 | switch (direction) { 8 | case 'h': 9 | return 'Y'; 10 | case 'v': 11 | return 'X'; 12 | default: 13 | printlog(LOG_ERROR, "track direction not recognized: %c", direction); 14 | return '\0'; 15 | } 16 | } 17 | 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | -------------------------------------------------------------------------------- /src/db/db_place.cpp: -------------------------------------------------------------------------------- 1 | #include "db.h" 2 | using namespace db; 3 | 4 | Placement& Database::placement(){ 5 | return _placements[_activePlacement]; 6 | } 7 | Placement& Database::placement(unsigned i){ 8 | return _placements[i]; 9 | } 10 | 11 | void Database::setActivePlacement(unsigned i){ 12 | _activePlacement = i; 13 | if(_activePlacement >= _placements.size()){ 14 | _placements.resize(_activePlacement+1); 15 | } 16 | } 17 | 18 | -------------------------------------------------------------------------------- /src/gp/gp_setting.h: -------------------------------------------------------------------------------- 1 | #ifndef _GP_SETTING_H_ 2 | #define _GP_SETTING_H_ 3 | 4 | enum LBMode{ 5 | LBModeSimple = 1, 6 | LBModeFenceBBox = 2, 7 | LBModeFenceRect = 3, 8 | LBModeFenceRelax = 4 9 | }; 10 | 11 | enum NetModel{ 12 | NetModelNone = 0, 13 | NetModelClique = 1, 14 | NetModelStar = 2, 15 | NetModelB2B = 3, 16 | NetModelHybrid = 4, 17 | NetModelMST = 5 18 | }; 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /src/db/db_td.h: -------------------------------------------------------------------------------- 1 | #ifndef _DB_TD_H_ 2 | #define _DB_TD_H_ 3 | 4 | namespace db{ 5 | class TDBins{ 6 | private: 7 | double td{1.0}; 8 | public: 9 | int binL, binR; 10 | int binB, binT; 11 | int binStepX, binStepY; 12 | int binNX, binNY; 13 | 14 | void setTDBin(const double density) { td = density; } 15 | double getTDBin() const { return td; } 16 | }; 17 | } 18 | 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /src/gp/gp_inflate.h: -------------------------------------------------------------------------------- 1 | #ifndef _NEWINFLATION_H_ 2 | #define _NEWINFLATION_H_ 3 | 4 | /* For sorting tiles by routing congestion */ 5 | typedef struct densityTile{ 6 | int x, y; 7 | double density; 8 | }densityTile; 9 | 10 | 11 | void createInflation(); 12 | void deleteCongestionTiles(); 13 | bool cellInflation(int isHorizontal, double restoreRatio); 14 | 15 | //extern double inflationSlope; // For inflation, the slope*(d/s)-(slope-1), slope=1 by default 16 | 17 | #endif 18 | 19 | -------------------------------------------------------------------------------- /src/gp/gp_congest.cpp: -------------------------------------------------------------------------------- 1 | #include "gp_data.h" 2 | #include "gp_global.h" 3 | #include "gp_congest.h" 4 | 5 | void updateCongMap() { 6 | gp_copy_out(); 7 | GRResult gr_result; 8 | // grSetting.gcellTrackX = 30; 9 | // grSetting.gcellTrackY = 30; 10 | // grSetting.fixBlockedDemand = true; 11 | // grSetting.localCongestion = false; 12 | 13 | if (grSetting.ndrMultiplier > 1.0) { 14 | groute(gr_result, true, true); 15 | groute(gr_result, false, false); 16 | }else{ 17 | groute(gr_result, false, true); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/gr/cugr.h: -------------------------------------------------------------------------------- 1 | #ifndef _GR_CUGR_H_ 2 | #define _GR_CUGR_H_ 3 | #include "../db/db.h" 4 | #include "../io/io.h" 5 | 6 | class CUGRSetting { 7 | public: 8 | int iterations; 9 | int threads; 10 | 11 | public: 12 | CUGRSetting() { 13 | iterations = 1; 14 | threads = 8; 15 | } 16 | }; 17 | 18 | void initializeVariable(); 19 | bool cugr(); 20 | bool readCUGROutputTxt(const string& inputTxt); 21 | bool writeComponents(ofstream& ofs); 22 | bool writeDEF(const string& inputDef, const string& outputDef); 23 | string cugrGetOrient(bool flipX, bool flipY); 24 | 25 | #endif -------------------------------------------------------------------------------- /src/gr/ripplegr.h: -------------------------------------------------------------------------------- 1 | #ifndef _GR_RIPPLEGR_H_ 2 | #define _GR_RIPPLEGR_H_ 3 | #include "../db/db.h" 4 | #include "../global.h" 5 | #include "../io/io.h" 6 | #include "../ut/geo.h" 7 | #include "gr.h" 8 | 9 | bool ripplegr(); 10 | 11 | class RippleGR { 12 | public: 13 | void initDemandSupplyMap(); 14 | void calcDemandMap(); 15 | void calcSupplyMap(double BlockPorosity = 1.0); 16 | void writeCongestionMap(); 17 | std::tuple getPinInfo(db::Pin* pin); 18 | std::tuple getTotalTracks(); 19 | std::tuple getWireSpace(); 20 | }; 21 | #endif 22 | -------------------------------------------------------------------------------- /src/global.h: -------------------------------------------------------------------------------- 1 | #ifndef _GLOBAL_H_ 2 | #define _GLOBAL_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | using namespace std; 26 | 27 | #include "ripple/ripple.h" 28 | #include "setting.h" 29 | #include "ut/utils.h" 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /src/lemon/include/lemon/config.h: -------------------------------------------------------------------------------- 1 | #define LEMON_VERSION "1.3.1" 2 | #define LEMON_HAVE_LONG_LONG 1 3 | 4 | /* #undef LEMON_HAVE_LP */ 5 | /* #undef LEMON_HAVE_MIP */ 6 | /* #undef LEMON_HAVE_GLPK */ 7 | /* #undef LEMON_HAVE_CPLEX */ 8 | /* #undef LEMON_HAVE_SOPLEX */ 9 | /* #undef LEMON_HAVE_CLP */ 10 | /* #undef LEMON_HAVE_CBC */ 11 | 12 | #define _LEMON_CPLEX 1 13 | #define _LEMON_CLP 2 14 | #define _LEMON_GLPK 3 15 | #define _LEMON_SOPLEX 4 16 | #define _LEMON_CBC 5 17 | 18 | /* #undef LEMON_DEFAULT_LP */ 19 | /* #undef LEMON_DEFAULT_MIP */ 20 | 21 | #define LEMON_USE_PTHREAD 1 22 | /* #undef LEMON_USE_WIN32_THREADS */ 23 | -------------------------------------------------------------------------------- /src/ripple/ripple_setting.h: -------------------------------------------------------------------------------- 1 | #ifndef _RIPPLE_SETTING_H_ 2 | #define _RIPPLE_SETTING_H_ 3 | 4 | namespace ripple{ 5 | class RippleSetting{ 6 | public: 7 | enum PlaceFlow{ 8 | Default, 9 | Global, 10 | CLI, 11 | Test, 12 | DAC2016, 13 | ICCAD2017, 14 | Eval 15 | }; 16 | 17 | int force_stop; 18 | 19 | PlaceFlow flow; 20 | 21 | RippleSetting(){ 22 | force_stop = 0; 23 | flow = ICCAD2017; 24 | } 25 | }; 26 | } 27 | 28 | extern ripple::RippleSetting rippleSetting; 29 | 30 | #endif 31 | 32 | -------------------------------------------------------------------------------- /src/gp/gp_draw.cpp: -------------------------------------------------------------------------------- 1 | #include "gp_draw.h" 2 | 3 | #include "../db/db.h" 4 | #include "../vi/vi.h" 5 | #include "gp_data.h" 6 | #include "gp_global.h" 7 | 8 | void drawcell(const char* prefix, int iter) 9 | { 10 | gp_copy_out(); 11 | vi::Visualizer vis; 12 | vis.setWindow(3000, 0); 13 | vis.setViewport(database.dieLX, database.dieLY, database.dieHX, database.dieHY); 14 | database.draw(&vis); 15 | 16 | char filenamestr[256]; 17 | if (iter < 0) { 18 | sprintf(filenamestr, "%s.png", prefix); 19 | } else { 20 | sprintf(filenamestr, "%s%d.png", prefix, iter); 21 | } 22 | vis.save(string(filenamestr)); 23 | } 24 | -------------------------------------------------------------------------------- /src/sta/sta.h: -------------------------------------------------------------------------------- 1 | #ifndef _STA_STA_H_ 2 | #define _STA_STA_H_ 3 | 4 | #include "lib.h" 5 | #include "data.h" 6 | 7 | namespace sta{ 8 | 9 | class STATimer{ 10 | public: 11 | enum TimingMode{ 12 | EarlyRise = 0, 13 | EarlyFall = 1, 14 | LateRise = 2, 15 | LateFall = 3 16 | }; 17 | STALibrary eLib; 18 | STALibrary lLib; 19 | bool initialized{false}; 20 | 21 | vector cells; 22 | vector ios; 23 | vector nets; 24 | }; 25 | } 26 | 27 | extern sta::STATimer rtimer; 28 | 29 | #endif 30 | 31 | -------------------------------------------------------------------------------- /src/gr/gr.h: -------------------------------------------------------------------------------- 1 | #ifndef _GR_H_ 2 | #define _GR_H_ 3 | 4 | #include "../global.h" 5 | #include "../tcl/tcl.h" 6 | #include "gr_setting.h" 7 | 8 | typedef struct GRResult GRResult; 9 | 10 | struct GRResult { 11 | int maxHOF; 12 | int maxVOF; 13 | int totalHOF; 14 | int totalVOF; 15 | 16 | int totalWL; 17 | int tof; 18 | int totalVia; 19 | int ofEdge; 20 | }; 21 | 22 | int groute(GRResult& result, bool ndr, bool reset); 23 | inline int groute(GRResult& result) { return groute(result, false, true); } 24 | 25 | namespace gr { 26 | 27 | class GRModule : public ripple::ShellModule { 28 | public: 29 | static int GCellTracksX; 30 | static int GCellTracksY; 31 | 32 | void showOptions() const; 33 | }; 34 | } 35 | 36 | #endif 37 | 38 | -------------------------------------------------------------------------------- /src/ut/timer.h: -------------------------------------------------------------------------------- 1 | #ifndef _UT_TIMER_H_ 2 | #define _UT_TIMER_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | namespace utils { 12 | class Timer { 13 | private: 14 | static std::vector _timers; 15 | std::chrono::time_point _time; 16 | bool _active; 17 | 18 | public: 19 | Timer() { _active = false; } 20 | bool active() { return _active; } 21 | void active(bool a) { _active = a; } 22 | static unsigned start(); 23 | static double time(unsigned id); 24 | static double reset(unsigned id); 25 | static double stop(unsigned id); 26 | static std::string getCurTimeStr(bool long_mode = true); 27 | }; 28 | }; // namespace utils 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /src/gr/gr_setting.h: -------------------------------------------------------------------------------- 1 | #ifndef _GR_SETTING_H_ 2 | #define _GR_SETTING_H_ 3 | 4 | class GRSetting{ 5 | public: 6 | enum GRRouter{ 7 | NONE = 0, 8 | FastRoute = 2, 9 | RippleGR = 3, 10 | CUGR = 5 11 | }; 12 | GRRouter router; 13 | int gcellTrackX; 14 | int gcellTrackY; 15 | 16 | double ndrMultiplier; 17 | bool fixBlockedDemand; 18 | bool localCongestion; 19 | 20 | GRSetting(){ 21 | router = NONE; 22 | gcellTrackX = 30; 23 | gcellTrackY = 30; 24 | // ndrMultiplier = 2.0; 25 | ndrMultiplier = 0.0; 26 | fixBlockedDemand = true; 27 | localCongestion = true; 28 | } 29 | }; 30 | 31 | extern GRSetting grSetting; 32 | 33 | #endif 34 | 35 | -------------------------------------------------------------------------------- /src/dp/dp_setting.h: -------------------------------------------------------------------------------- 1 | #ifndef _DP_SETTING_H_ 2 | #define _DP_SETTING_H_ 3 | 4 | class DPSetting { 5 | public: 6 | DPSetting() { 7 | /* 8 | maxDisplacement = 15000; 9 | maxDensity = 1.0; 10 | 11 | MaxLGIter = 300; 12 | MaxGMIter = 100; 13 | MaxLMIter = 0; 14 | 15 | LGStepSize = 10; 16 | LGThresholdBase = 0; 17 | LGThresholdStep = 20; 18 | LGTrial = 1; 19 | 20 | GMThresholdBase = 10; 21 | GMThresholdStep = 10; 22 | GMTrial = 1; 23 | 24 | enableLocalVert = true; 25 | enableLocalReorder = true; 26 | enableLocalCompact = true; 27 | */ 28 | } 29 | 30 | int check() { return 0; } 31 | }; 32 | 33 | extern DPSetting dpSetting; 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /src/db/db_drc.cpp: -------------------------------------------------------------------------------- 1 | #include "db.h" 2 | using namespace db; 3 | 4 | #include "../ut/utils.h" 5 | 6 | /***** EdgeTypes *****/ 7 | 8 | int EdgeTypes::getEdgeType(const string& name) const 9 | { 10 | unsigned numTypes = types.size(); 11 | for (unsigned i = 0; i != numTypes; ++i) { 12 | if (types[i] == name) { 13 | return i; 14 | } 15 | } 16 | return -1; 17 | } 18 | 19 | int EdgeTypes::getEdgeSpace(const int edge1, const int edge2) const 20 | { 21 | if (!distTable.size()) { 22 | return 0; 23 | } 24 | 25 | #ifdef DEBUG 26 | if (edge1 < 0 || edge1 >= (int)types.size()) { 27 | printlog(LOG_ERROR, "invalid edge ID: %d", edge1); 28 | } 29 | if (edge2 < 0 || edge2 >= (int)types.size()) { 30 | printlog(LOG_ERROR, "invalid edge ID: %d", edge2); 31 | } 32 | #endif 33 | return distTable[edge1][edge2]; 34 | } 35 | -------------------------------------------------------------------------------- /src/gr/gr.cpp: -------------------------------------------------------------------------------- 1 | #include "gr.h" 2 | #include "../db/db.h" 3 | #include "../global.h" 4 | #include "../tcl/register.h" 5 | #include "cugr.h" 6 | #include "fastroute.h" 7 | #include "ripplegr.h" 8 | 9 | using namespace gr; 10 | 11 | GRSetting grSetting; 12 | 13 | 14 | int groute(GRResult& result, bool ndr, bool reset) 15 | { 16 | switch (grSetting.router) { 17 | case GRSetting::FastRoute: 18 | return fastroute(result, ndr, reset); 19 | case GRSetting::RippleGR: 20 | return ripplegr(); 21 | case GRSetting::CUGR: 22 | return cugr(); 23 | default: 24 | return 0; 25 | } 26 | } 27 | 28 | int GRModule::GCellTracksX = 30; 29 | int GRModule::GCellTracksY = 30; 30 | 31 | void GRModule::showOptions() const { 32 | printlog(LOG_INFO, "gcellTracksX : %d", GCellTracksX); 33 | printlog(LOG_INFO, "gcellTracksY : %d", GCellTracksY); 34 | } 35 | 36 | -------------------------------------------------------------------------------- /src/db/db_site.h: -------------------------------------------------------------------------------- 1 | #ifndef _DB_SITE_H_ 2 | #define _DB_SITE_H_ 3 | 4 | namespace db { 5 | class Site { 6 | private: 7 | string _name = ""; 8 | string _siteClassName = ""; 9 | int _width = 0; 10 | int _height = 0; 11 | 12 | public: 13 | Site(const string& name, const string& siteClassName, int width, int height) 14 | : _name(name), _siteClassName(siteClassName), _width(width), _height(height) {} 15 | 16 | const string& name() const { return _name; } 17 | const string& siteClassName() const { return _siteClassName; } 18 | int width() const { return _width; } 19 | int height() const { return _height; } 20 | 21 | void name(const string& value) { _name = value; } 22 | void siteClassName(const string& value) { _siteClassName = value; } 23 | void width(const int value) { _width = value; } 24 | void height(const int value) { _height = value; } 25 | }; 26 | } // namespace db 27 | #endif -------------------------------------------------------------------------------- /src/db/db_snet.h: -------------------------------------------------------------------------------- 1 | #ifndef _DB_SNET_H_ 2 | #define _DB_SNET_H_ 3 | 4 | namespace db { 5 | class SNet : virtual public Drawable { 6 | public: 7 | string name; 8 | vector shapes; 9 | vector vias; 10 | char type = 'x'; 11 | 12 | SNet(const string& name) : name(name) {} 13 | 14 | template 15 | void addShape(Args&&... args) { 16 | shapes.emplace_back(args...); 17 | } 18 | 19 | template 20 | void addVia(Args&&... args) { 21 | vias.emplace_back(args...); 22 | } 23 | 24 | int globalX() const; 25 | int globalY() const; 26 | int localX() const; 27 | int localY() const; 28 | int boundL() const; 29 | int boundR() const; 30 | int boundB() const; 31 | int boundT() const; 32 | 33 | Drawable* parent() const; 34 | void draw(Visualizer* v) const; 35 | void draw(Visualizer* v, Layer& L) const; 36 | }; 37 | } // namespace db 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /src/tcl/register.h: -------------------------------------------------------------------------------- 1 | #ifndef _TCL_R_H_ 2 | #define _TCL_R_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | typedef int (*cmdProc)(int, const char**); 9 | 10 | enum TCL_LINK_TYPE { 11 | TYPE_INT = 1, 12 | TYPE_DOUBLE = 2, 13 | TYPE_BOOLEAN = 3, 14 | TYPE_CSTRING = 4, 15 | TYPE_STD_STRING = 100 16 | }; 17 | 18 | int addTclVariable(const char* varName, void* target, TCL_LINK_TYPE vtype); 19 | int addTclVariable(std::string varName, void* target, TCL_LINK_TYPE vtype); 20 | int addTclCommand(const char* cmdName, cmdProc* cProc); 21 | int addTclCommand(std::string cmdName, cmdProc* cProc); 22 | 23 | void clearUserVariable(); 24 | 25 | typedef struct _VARIABLE { 26 | char* name; 27 | void* target; 28 | int vtype; 29 | } USER_DEFINED_VARIABLE; 30 | 31 | typedef struct _COMMAND { 32 | char* name; 33 | cmdProc* proc; 34 | char* info; 35 | } USER_DEFINED_COMMAND; 36 | 37 | extern std::list<_COMMAND> user_cmds; 38 | extern std::list<_VARIABLE> user_vars; 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /src/db/db_drc.h: -------------------------------------------------------------------------------- 1 | #ifndef _DB_DRC_H_ 2 | #define _DB_DRC_H_ 3 | 4 | namespace db { 5 | class WireRule { 6 | private: 7 | const Layer* _layer; 8 | 9 | public: 10 | const unsigned width; 11 | const unsigned space; 12 | 13 | WireRule(const Layer* layer, const unsigned width, const unsigned space) : _layer(layer), width(width), space(space) {} 14 | 15 | const Layer* layer() const { return _layer; } 16 | }; 17 | 18 | class NDR { 19 | private: 20 | const string _name; 21 | bool _hardSpacing = false; 22 | 23 | public: 24 | vector rules; 25 | vector vias; 26 | 27 | NDR(const string& name, const bool hardSpacing) : _name(name), _hardSpacing(hardSpacing) {} 28 | 29 | const string& name() const { return _name; } 30 | bool hardSpacing() const { return _hardSpacing; } 31 | }; 32 | 33 | class EdgeTypes { 34 | public: 35 | vector types = {"default"}; 36 | vector> distTable = { { 0 } }; 37 | 38 | int getEdgeType(const string& name) const; 39 | int getEdgeSpace(const int edge1, const int edge2) const; 40 | }; 41 | } 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /src/db/db_via.h: -------------------------------------------------------------------------------- 1 | #ifndef _DB_VIA_H_ 2 | #define _DB_VIA_H_ 3 | 4 | #include 5 | 6 | namespace db { 7 | class Via : virtual public Drawable { 8 | public: 9 | int x; 10 | int y; 11 | ViaType* type; 12 | Via(ViaType* type, int x, int y) : x(x), y(y), type(type) {} 13 | 14 | int globalX() const; 15 | int globalY() const; 16 | int localX() const; 17 | int localY() const; 18 | int boundL() const; 19 | int boundR() const; 20 | int boundB() const; 21 | int boundT() const; 22 | 23 | Drawable* parent() const; 24 | void draw(Visualizer* v, Layer& L) const; 25 | }; 26 | 27 | class ViaType { 28 | private: 29 | bool isDef_ = false; 30 | 31 | public: 32 | string name = ""; 33 | set rects; 34 | 35 | ViaType(const string& name = "", const bool isDef = false) : isDef_(isDef), name(name) {} 36 | 37 | template 38 | void addRect(Args&&... args) { 39 | rects.emplace(args...); 40 | } 41 | void isDef(bool b) { isDef_ = b; } 42 | bool isDef() const { return isDef_; } 43 | }; 44 | } // namespace db 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /src/io/io_setting.h: -------------------------------------------------------------------------------- 1 | #ifndef _IO_SETTING_H_ 2 | #define _IO_SETTING_H_ 3 | /* 4 | namespace io{ 5 | class BookShelf{ 6 | public: 7 | }; 8 | class LefDef{ 9 | public: 10 | }; 11 | class IOSetting{ 12 | public: 13 | enum BookshelfFormat{ 14 | Generic, 15 | Wu2016, 16 | Lin2016, 17 | DAC2012, 18 | ICCAD2012, 19 | ICCAD2013 20 | }; 21 | enum IOFormat{ 22 | Bookshelf, 23 | LefDef 24 | }; 25 | IOFormat format; 26 | string aux; 27 | string pl; 28 | 29 | string plPlacement; 30 | BookshelfFormat bookshelfFormat; 31 | 32 | string lefTech; 33 | string lefCell; 34 | string defFloorplan; 35 | string defCell; 36 | 37 | string defPlacement; 38 | 39 | string verilog; 40 | 41 | string size; 42 | 43 | IOSetting(){ 44 | bookshelfFormat = Generic; 45 | } 46 | 47 | }; 48 | }; 49 | */ 50 | //extern io::IOSetting ioSetting; 51 | 52 | #endif 53 | 54 | -------------------------------------------------------------------------------- /src/db/db_region.h: -------------------------------------------------------------------------------- 1 | #ifndef _DB_REGION_H_ 2 | #define _DB_REGION_H_ 3 | 4 | namespace db { 5 | class Region : public Rectangle, virtual public Drawable { 6 | private: 7 | string _name = ""; 8 | // 'f' for fence, 'g' for guide 9 | char _type = 'x'; 10 | 11 | public: 12 | static const unsigned char InvalidRegion = 0xff; 13 | 14 | unsigned char id = InvalidRegion; 15 | double density = 0; 16 | 17 | vector members; 18 | vector rects; 19 | 20 | Region(const string& name = "", const char type = 'x') 21 | : Rectangle(INT_MAX, INT_MAX, INT_MIN, INT_MIN), _name(name), _type(type) {} 22 | 23 | inline const string& name() const { return _name; } 24 | inline char type() const { return _type; } 25 | 26 | void addRect(const int xl, const int yl, const int xh, const int yh); 27 | void resetRects() { sliceH(rects); } 28 | 29 | int globalX() const; 30 | int globalY() const; 31 | int localX() const; 32 | int localY() const; 33 | int boundL() const; 34 | int boundR() const; 35 | int boundB() const; 36 | int boundT() const; 37 | 38 | Drawable* parent() const; 39 | void draw(Visualizer* v) const; 40 | }; 41 | } // namespace db 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /src/io/io.h: -------------------------------------------------------------------------------- 1 | #ifndef _IO_IO_H_ 2 | #define _IO_IO_H_ 3 | 4 | #include "../tcl/tcl.h" 5 | 6 | #include 7 | 8 | namespace io { 9 | class IOModule : public ripple::ShellModule { 10 | private: 11 | static std::string _name; 12 | 13 | void registerCommands(); 14 | void registerOptions(); 15 | void showOptions() const; 16 | 17 | public: 18 | static std::string Format; 19 | 20 | static std::string BookshelfAux; 21 | static std::string BookshelfPl; 22 | static std::string BookshelfVariety; 23 | static std::string BookshelfPlacement; 24 | 25 | static std::string LefTech; 26 | static std::string LefCell; 27 | static std::string DefFloorplan; 28 | static std::string DefCell; 29 | static std::string DefPlacement; 30 | 31 | static std::string Verilog; 32 | static std::string Liberty; 33 | static std::string Size; 34 | static std::string Constraints; 35 | 36 | public: 37 | const std::string& name() const { return _name; } 38 | static bool load(); 39 | static bool load(ripple::ShellOptions& args, ripple::ShellCmdReturn& ret); 40 | static bool save(); 41 | static bool save(ripple::ShellOptions& args, ripple::ShellCmdReturn& ret); 42 | }; 43 | } 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /src/ripple/ripple.h: -------------------------------------------------------------------------------- 1 | #ifndef _RIPPLE_RIPPLE_H_ 2 | #define _RIPPLE_RIPPLE_H_ 3 | 4 | #include 5 | 6 | namespace ripple { 7 | 8 | class ProcessStatus { 9 | public: 10 | enum RunStatus { 11 | NotStarted = 0, 12 | Prepared = 1, 13 | Initializing = 2, 14 | Running = 3, 15 | Aborting = 4, 16 | Aborted = 5, 17 | Finishing = 6, 18 | Finished = 7 19 | }; 20 | std::string process; 21 | RunStatus status; 22 | int step; 23 | ProcessStatus(std::string process) 24 | { 25 | this->process = process; 26 | this->status = NotStarted; 27 | this->step = 0; 28 | } 29 | }; 30 | 31 | class Ripple { 32 | private: 33 | static Ripple* _instance; 34 | ProcessStatus* currentStatus = nullptr; 35 | 36 | Ripple() {} 37 | ~Ripple() {} 38 | 39 | int _run(int argc, char** argv); 40 | int _abort(); 41 | 42 | public: 43 | static Ripple* get(); 44 | 45 | static inline int run(int argc, char** argv) { return get()->_run(argc, argv); } 46 | static inline int abort() { return get()->_abort(); } 47 | 48 | ProcessStatus::RunStatus getStatus(); 49 | int getArgs(int argc, char** argv); 50 | }; 51 | } 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /src/ut/log.h: -------------------------------------------------------------------------------- 1 | #ifndef _UT_LOG_H_ 2 | #define _UT_LOG_H_ 3 | 4 | ///////////////LOGGING FUNCTIONS/////////////////////// 5 | //--log type 6 | #define LOG_DEBUG 1 //0 7 | #define LOG_VERBOSE 2 //1 8 | #define LOG_INFO 4 //2 9 | #define LOG_NOTICE 8 //3 10 | #define LOG_WARN 16 //4 11 | #define LOG_ERROR 32 //5 12 | #define LOG_FATAL 64 //6 13 | #define LOG_OK 128 //7 14 | #define LOG_RESERVED7 256 //8 15 | #define LOG_RESERVED6 1024 //9 16 | #define LOG_RESERVED5 2048 //10 17 | #define LOG_RESERVED4 4096 //12 18 | #define LOG_RESERVED3 8192 //13 19 | #define LOG_RESERVED2 16384 //14 20 | #define LOG_RESERVED1 32768 //15 21 | 22 | #define LOG_ALL 65535 //16-bit 23 | 24 | //--special log type 25 | #define LOG_PROMPT 65536 //16 26 | 27 | #define LOG_FAIL LOG_ERROR | LOG_FATAL 28 | #define LOG_NORMAL LOG_ALL ^ LOG_DEBUG ^ LOG_VERBOSE 29 | 30 | #define LOG_LEVEL_DEFAULT LOG_ALL 31 | 32 | #define LOG_PREFIX "[%8.3lf]%c " 33 | #define LOG_SUFFIX "\n" 34 | 35 | void init_log(int log_level = LOG_LEVEL_DEFAULT); 36 | void printlog(int level, const char *format, ...); 37 | void print_prefix(int level); 38 | void print_suffix(); 39 | 40 | #endif 41 | 42 | -------------------------------------------------------------------------------- /src/gp/gp.h: -------------------------------------------------------------------------------- 1 | #ifndef _GP_GP_H_ 2 | #define _GP_GP_H_ 3 | 4 | #include "../tcl/tcl.h" 5 | #include "gp_data.h" 6 | 7 | int gplace(int argc = 0, char** argv = NULL); 8 | 9 | namespace gp { 10 | 11 | class GPModule : public ripple::ShellModule { 12 | private: 13 | static std::string _name; 14 | 15 | public: 16 | static int NumThreads; 17 | static int InitIterations; 18 | static int MainWLIterations; 19 | static int MainCongIterations; 20 | static int MainGRIterations; 21 | static int LowerBoundIterations; 22 | static int UpperBoundIterations; 23 | static int FinalIterations; 24 | 25 | static double PseudoNetWeightBegin; 26 | static double PseudoNetWeightEnd; 27 | static double TargetDensityBegin; 28 | static double TargetDensityEnd; 29 | 30 | static std::string InitNetModel; 31 | static std::string MainNetModel; 32 | 33 | static bool EnableFence; 34 | static bool EnableKeepInflate; 35 | static bool Experimental; 36 | 37 | void registerCommands(); 38 | void registerOptions(); 39 | void showOptions() const; 40 | 41 | public: 42 | const string& name() const { return _name; } 43 | static bool gplace(ripple::ShellOptions& args, ripple::ShellCmdReturn& ret); 44 | static bool gplace(); 45 | }; 46 | } 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /src/lemon/include/lemon/bits/windows.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C++; indent-tabs-mode: nil; -*- 2 | * 3 | * This file is a part of LEMON, a generic C++ optimization library. 4 | * 5 | * Copyright (C) 2003-2013 6 | * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 | * (Egervary Research Group on Combinatorial Optimization, EGRES). 8 | * 9 | * Permission to use, modify and distribute this software is granted 10 | * provided that this copyright notice appears in all copies. For 11 | * precise terms see the accompanying LICENSE file. 12 | * 13 | * This software is provided "AS IS" with no warranty of any kind, 14 | * express or implied, and with no claim as to its suitability for any 15 | * purpose. 16 | * 17 | */ 18 | 19 | #ifndef LEMON_BITS_WINDOWS_H 20 | #define LEMON_BITS_WINDOWS_H 21 | 22 | #include 23 | 24 | namespace lemon { 25 | namespace bits { 26 | void getWinProcTimes(double &rtime, 27 | double &utime, double &stime, 28 | double &cutime, double &cstime); 29 | std::string getWinFormattedDate(); 30 | int getWinRndSeed(); 31 | 32 | class WinLock { 33 | public: 34 | WinLock(); 35 | ~WinLock(); 36 | void lock(); 37 | void unlock(); 38 | private: 39 | void *_repr; 40 | }; 41 | } 42 | } 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /src/db/db_route.h: -------------------------------------------------------------------------------- 1 | #ifndef _DB_ROUTE_H_ 2 | #define _DB_ROUTE_H_ 3 | 4 | namespace db { 5 | class GCell { 6 | public: 7 | int lx = 0; 8 | int ly = 0; 9 | int hx = 0; 10 | int hy = 0; 11 | float supplyX = 0; 12 | float supplyY = 0; 13 | short supplyZ = 0; 14 | float demandX = 0; 15 | float demandY = 0; 16 | short demandZ = 0; 17 | list netsX; 18 | list netsY; 19 | list netsZ; 20 | list pins; 21 | }; 22 | 23 | class GRGrid { 24 | private: 25 | int nx = 0; 26 | int ny = 0; 27 | int nz = 0; 28 | int tx = 0; 29 | int ty = 0; 30 | int tz = 0; 31 | vector>> gcells; 32 | char* rgrids = nullptr; 33 | 34 | public: 35 | int trackL, trackR; 36 | int trackB, trackT; 37 | int trackStepX, trackStepY; 38 | int trackNX, trackNY; 39 | 40 | int gcellL, gcellR; 41 | int gcellB, gcellT; 42 | unsigned gcellStepX = 0; 43 | unsigned gcellStepY = 0; 44 | unsigned gcellNX = 0; 45 | unsigned gcellNY = 0; 46 | 47 | void initGCells(int nx, int ny, int nz); 48 | 49 | float getGCellSupplyH(int x, int y); 50 | float getGCellSupplyV(int x, int y); 51 | float getGCellDemandH(int x, int y); 52 | float getGCellDemandV(int x, int y); 53 | 54 | GCell* getGCell(int x, int y, int z); 55 | void initRGrids(int tx, int ty, int nlayer); 56 | void setRGrid(int x, int y, int z, char v); 57 | char getRGrid(int x, int y, int z); 58 | 59 | void addBlockage(int lx, int ly, int hx, int hy, int z); 60 | }; 61 | 62 | } 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /src/lef58/inc/lefiKRDefs.hpp: -------------------------------------------------------------------------------- 1 | // ***************************************************************************** 2 | // ***************************************************************************** 3 | // Copyright 2012 - 2013, Cadence Design Systems 4 | // 5 | // This file is part of the Cadence LEF/DEF Open Source 6 | // Distribution, Product Version 5.8. 7 | // 8 | // Licensed under the Apache License, Version 2.0 (the "License"); 9 | // you may not use this file except in compliance with the License. 10 | // You may obtain a copy of the License at 11 | // 12 | // http://www.apache.org/licenses/LICENSE-2.0 13 | // 14 | // Unless required by applicable law or agreed to in writing, software 15 | // distributed under the License is distributed on an "AS IS" BASIS, 16 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 17 | // implied. See the License for the specific language governing 18 | // permissions and limitations under the License. 19 | // 20 | // For updates, support, or to become part of the LEF/DEF Community, 21 | // check www.openeda.org for details. 22 | // 23 | // $Author: dell $ 24 | // $Revision: #7 $ 25 | // $Date: 2015/01/27 $ 26 | // $State: $ 27 | // ***************************************************************************** 28 | // ***************************************************************************** 29 | 30 | #ifndef lefiKRDEFS_h 31 | #define lefiKRDEFS_h 32 | 33 | #define BEGIN_LEFDEF_PARSER_NAMESPACE namespace LefDefParser { 34 | #define END_LEFDEF_PARSER_NAMESPACE } 35 | #define USE_LEFDEF_PARSER_NAMESPACE using namespace LefDefParser; 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /src/def58/inc/defiKRDefs.hpp: -------------------------------------------------------------------------------- 1 | // ***************************************************************************** 2 | // ***************************************************************************** 3 | // Copyright 2013, Cadence Design Systems 4 | // 5 | // This file is part of the Cadence LEF/DEF Open Source 6 | // Distribution, Product Version 5.8. 7 | // 8 | // Licensed under the Apache License, Version 2.0 (the "License"); 9 | // you may not use this file except in compliance with the License. 10 | // You may obtain a copy of the License at 11 | // 12 | // http://www.apache.org/licenses/LICENSE-2.0 13 | // 14 | // Unless required by applicable law or agreed to in writing, software 15 | // distributed under the License is distributed on an "AS IS" BASIS, 16 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 17 | // implied. See the License for the specific language governing 18 | // permissions and limitations under the License. 19 | // 20 | // For updates, support, or to become part of the LEF/DEF Community, 21 | // check www.openeda.org for details. 22 | // 23 | // $Author: dell $ 24 | // $Revision: #7 $ 25 | // $Date: 2015/01/27 $ 26 | // $State: $ 27 | // ***************************************************************************** 28 | // ***************************************************************************** 29 | 30 | #ifndef defiKRDEFS_h 31 | #define defiKRDEFS_h 32 | 33 | #define BEGIN_LEFDEF_PARSER_NAMESPACE namespace LefDefParser { 34 | #define END_LEFDEF_PARSER_NAMESPACE } 35 | #define USE_LEFDEF_PARSER_NAMESPACE using namespace LefDefParser; 36 | 37 | #endif /* defiKRDEFS_h */ 38 | -------------------------------------------------------------------------------- /src/lemon/include/lemon/bits/lock.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C++; indent-tabs-mode: nil; -*- 2 | * 3 | * This file is a part of LEMON, a generic C++ optimization library. 4 | * 5 | * Copyright (C) 2003-2013 6 | * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 | * (Egervary Research Group on Combinatorial Optimization, EGRES). 8 | * 9 | * Permission to use, modify and distribute this software is granted 10 | * provided that this copyright notice appears in all copies. For 11 | * precise terms see the accompanying LICENSE file. 12 | * 13 | * This software is provided "AS IS" with no warranty of any kind, 14 | * express or implied, and with no claim as to its suitability for any 15 | * purpose. 16 | * 17 | */ 18 | 19 | #ifndef LEMON_BITS_LOCK_H 20 | #define LEMON_BITS_LOCK_H 21 | 22 | #include 23 | #if defined(LEMON_USE_PTHREAD) 24 | #include 25 | #elif defined(LEMON_USE_WIN32_THREADS) 26 | #include 27 | #endif 28 | 29 | namespace lemon { 30 | namespace bits { 31 | 32 | #if defined(LEMON_USE_PTHREAD) 33 | class Lock { 34 | public: 35 | Lock() { 36 | pthread_mutex_init(&_lock, 0); 37 | } 38 | ~Lock() { 39 | pthread_mutex_destroy(&_lock); 40 | } 41 | void lock() { 42 | pthread_mutex_lock(&_lock); 43 | } 44 | void unlock() { 45 | pthread_mutex_unlock(&_lock); 46 | } 47 | 48 | private: 49 | pthread_mutex_t _lock; 50 | }; 51 | #elif defined(LEMON_USE_WIN32_THREADS) 52 | class Lock : public WinLock {}; 53 | #else 54 | class Lock { 55 | public: 56 | Lock() {} 57 | ~Lock() {} 58 | void lock() {} 59 | void unlock() {} 60 | }; 61 | #endif 62 | } 63 | } 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /src/ut/timer.cpp: -------------------------------------------------------------------------------- 1 | #include "timer.h" 2 | 3 | using namespace utils; 4 | 5 | std::vector Timer::_timers; 6 | 7 | unsigned Timer::start() { 8 | for (unsigned i = 0; i < _timers.size(); i++) { 9 | if (!_timers[i].active()) { 10 | _timers[i].active(true); 11 | _timers[i]._time = std::chrono::steady_clock::now(); 12 | return i; 13 | } 14 | } 15 | _timers.push_back(Timer()); 16 | _timers.back()._time = std::chrono::steady_clock::now(); 17 | _timers.back().active(true); 18 | return _timers.size() - 1; 19 | } 20 | 21 | double Timer::time(unsigned id) { 22 | if (!_timers[id].active()) { 23 | return 0.0; 24 | } 25 | auto now = std::chrono::steady_clock::now(); 26 | return std::chrono::duration(now - _timers[id]._time).count(); 27 | } 28 | 29 | double Timer::reset(unsigned id) { 30 | if (!_timers[id].active()) { 31 | return 0.0; 32 | } 33 | auto now = std::chrono::steady_clock::now(); 34 | auto old = _timers[id]._time; 35 | _timers[id]._time = now; 36 | return std::chrono::duration(now - old).count(); 37 | } 38 | 39 | double Timer::stop(unsigned id) { 40 | if (!_timers[id].active()) { 41 | return 0.0; 42 | } 43 | double diff = time(id); 44 | _timers[id].active(false); 45 | return diff; 46 | } 47 | 48 | std::string Timer::getCurTimeStr(bool long_mode) { 49 | auto now = std::chrono::system_clock::now(); 50 | auto in_time_t = std::chrono::system_clock::to_time_t(now); 51 | 52 | std::stringstream ss; 53 | if (long_mode) { 54 | ss << std::put_time(std::localtime(&in_time_t), "%Y_%m_%d_%H_%M_%S"); 55 | } else { 56 | ss << std::put_time(std::localtime(&in_time_t), "%H_%M_%S"); 57 | } 58 | return ss.str(); 59 | } -------------------------------------------------------------------------------- /src/lef58/inc/lefiEncryptInt.hpp: -------------------------------------------------------------------------------- 1 | // ***************************************************************************** 2 | // ***************************************************************************** 3 | // Copyright 2012 - 2013, Cadence Design Systems 4 | // 5 | // This file is part of the Cadence LEF/DEF Open Source 6 | // Distribution, Product Version 5.8. 7 | // 8 | // Licensed under the Apache License, Version 2.0 (the "License"); 9 | // you may not use this file except in compliance with the License. 10 | // You may obtain a copy of the License at 11 | // 12 | // http://www.apache.org/licenses/LICENSE-2.0 13 | // 14 | // Unless required by applicable law or agreed to in writing, software 15 | // distributed under the License is distributed on an "AS IS" BASIS, 16 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 17 | // implied. See the License for the specific language governing 18 | // permissions and limitations under the License. 19 | // 20 | // For updates, support, or to become part of the LEF/DEF Community, 21 | // check www.openeda.org for details. 22 | // 23 | // $Author: dell $ 24 | // $Revision: #7 $ 25 | // $Date: 2015/01/27 $ 26 | // $State: $ 27 | // ***************************************************************************** 28 | // ***************************************************************************** 29 | 30 | #ifndef DEFI_ENCRYPTINT_H 31 | #define DEFI_ENCRYPTINT_H 32 | 33 | #include 34 | #include "lefiKRDefs.hpp" 35 | 36 | BEGIN_LEFDEF_PARSER_NAMESPACE 37 | 38 | // Unable the reader to read encrypted lef file. 39 | // This function must be called before lefrRead(). 40 | // / 41 | extern void lefrEnableReadEncrypted(); 42 | 43 | END_LEFDEF_PARSER_NAMESPACE 44 | 45 | USE_LEFDEF_PARSER_NAMESPACE 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /src/gp/gp_data.h: -------------------------------------------------------------------------------- 1 | #ifndef _GP_DATA_H_ 2 | #define _GP_DATA_H_ 3 | 4 | #include "../db/db.h" 5 | 6 | #include 7 | 8 | extern int numNodes; 9 | extern int numCells; 10 | extern int numMacros; 11 | extern int numPads; 12 | extern int numFixed; // numMacros+numPads 13 | 14 | extern int numNets; 15 | extern int numPins; 16 | extern int numFences; 17 | 18 | extern double coreLX, coreLY; 19 | extern double coreHX, coreHY; 20 | extern double siteW, siteH; 21 | extern int numSitesX, numSitesY; 22 | 23 | extern map nameMap; 24 | extern vector cellName; 25 | 26 | extern vector > netCell; 27 | extern vector > netPinX; 28 | extern vector > netPinY; 29 | extern vector netWeight; 30 | extern vector netNDR; 31 | extern vector > cellNet; 32 | extern vector > cellPin; 33 | 34 | extern vector cellX; 35 | extern vector cellY; 36 | extern vector cellW; 37 | extern vector cellH; 38 | extern vector cellAW; 39 | extern vector cellAH; 40 | 41 | //coordinate of the nearest fence region 42 | extern vector cellFenceX; 43 | extern vector cellFenceY; 44 | extern vector cellFenceDist; 45 | extern vector cellFenceRect; 46 | extern vector cellFence; 47 | 48 | extern vector > fenceRectLX; 49 | extern vector > fenceRectLY; 50 | extern vector > fenceRectHX; 51 | extern vector > fenceRectHY; 52 | 53 | //for routing 54 | extern int numRGridX; 55 | extern int numRGridY; 56 | extern double RGridW; 57 | extern double RGridH; 58 | extern double RGridLX; 59 | extern double RGridLY; 60 | extern double RGridHX; 61 | extern double RGridHY; 62 | 63 | void gp_copy_in(bool layout); 64 | void gp_copy_out(); 65 | double hpwl(); 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /src/dp/dp.h: -------------------------------------------------------------------------------- 1 | #ifndef _DP_H_ 2 | #define _DP_H_ 3 | 4 | #include "../tcl/tcl.h" 5 | #include "dp_data.h" 6 | 7 | namespace dp { 8 | 9 | class DPModule : public ripple::ShellModule { 10 | private: 11 | static string _name; 12 | 13 | public: 14 | static unsigned CPU; 15 | static string DefEval; 16 | static unsigned MaxDisp; 17 | static double MaxDensity; 18 | static int MaxLGIter; 19 | static int MaxGMIter; 20 | static int MaxLMIter; 21 | static int MaxMPIter; 22 | static int LGStepSize; 23 | static int LGThresholdBase; 24 | static int LGThresholdStep; 25 | static unsigned LGTrial; 26 | static unsigned LGOperRegSize; 27 | static bool GMEnable; 28 | static unsigned GMThresholdBase; 29 | static unsigned GMThresholdStep; 30 | static int GMTrial; 31 | static int LMThresholdBase; 32 | static int LMThresholdStep; 33 | static int LMTrial; 34 | static bool EnableLocalVert; 35 | static bool EnableLocalReorder; 36 | static bool EnableLocalCompact; 37 | static bool EnablePinAcc; 38 | static bool EnablePinAccRpt; 39 | 40 | // default 1, larger number, higher accuracy 41 | static int MLLAccuracy; 42 | // default false 43 | static bool MLLDispFromInput; 44 | static bool MLLPGAlign; 45 | static unsigned MLLPinCost; 46 | static unsigned MLLMaxDensity; 47 | // default false 48 | static bool MLLUseILP; 49 | static bool MLLTotalDisp; 50 | 51 | void registerCommands(); 52 | void registerOptions(); 53 | void showOptions() const; 54 | 55 | public: 56 | static DPlacer* dplacer; 57 | 58 | static bool dplace(const string& flowName = "iccad2017"); 59 | static bool dplace(ripple::ShellOptions& args, ripple::ShellCmdReturn& ret); 60 | const string& name() const { return _name; } 61 | }; 62 | } // namespace dp 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /src/io/file_liberty.l: -------------------------------------------------------------------------------- 1 | %{ 2 | #include 3 | #include "file_liberty.tab.h" 4 | 5 | #define yyerror file_libertyerror 6 | #define yylval file_libertylval 7 | #define yylex file_libertylex 8 | #define TOKEN(t) (yylval.token=t) 9 | #define YY_DECL extern "C" int yylex() 10 | 11 | void yyerror(const char *s) { 12 | fprintf(stderr, "unable to recognize line %d: '%s'\n", yylineno, s); 13 | exit(1); 14 | } 15 | 16 | %} 17 | %option noinput 18 | %option nounput 19 | %option noyywrap 20 | %option yylineno 21 | %s MULTILINE_COMMENT 22 | %s SINGLELINE_COMMENT 23 | %% 24 | { 25 | "/*" { BEGIN(MULTILINE_COMMENT); } 26 | "//" { BEGIN(SINGLELINE_COMMENT); } 27 | [ \t\n] { ; } 28 | "\\" { ; } 29 | "\"" { ; } 30 | [\ \t]:[\ \t] { return ':'; } 31 | [\(\)\{\},;'] { /* cout << yytext[0] << endl; */ return yytext[0]; } 32 | ([0-9]+:)+[0-9]+ { yylval.sval = strdup(yytext); return STRING; } 33 | [\+\-]*[0-9]+(\.[0-9]*)*([Ee][\+\-]{0,1}[0-9]*)* { yylval.dval = atof(yytext); return NUMBER; } 34 | \"[\+\-]*[0-9]+(\.[0-9]*)*([Ee][\+\-]{0,1}[0-9]*)*\" { unsigned i = 1; for (; yytext[i] != '\0'; ++i); yytext[i - 1] = '\0'; yylval.dval = atof(yytext + 1); return NUMBER; } 35 | [\+\-\*\/] { return yytext[0]; } 36 | (([A-Za-z0-9_\.\-!&]+|\(c\))[\ ])*([A-Za-z0-9_\.\-!&]+|\(c\)) { /* cout << string(yytext) << endl; */ yylval.sval = strdup(yytext); return STRING; } 37 | \"([^,;\\\"]|\\.|,\\\n)+\" { unsigned i = 1; for (; yytext[i] != '\0'; ++i); yytext[i - 1] = '\0'; yylval.sval = strdup(yytext + 1); return STRING; } 38 | . { ; } 39 | } 40 | { 41 | \n { BEGIN(INITIAL); } 42 | . { ; } 43 | } 44 | { 45 | "*/" { BEGIN(INITIAL); } 46 | [^*\n]+ { ; } 47 | "*" { ; } 48 | \n { ; } 49 | } 50 | 51 | %% 52 | 53 | -------------------------------------------------------------------------------- /src/ut/log.cpp: -------------------------------------------------------------------------------- 1 | #include "utils.h" 2 | 3 | ///////////////LOGGING FUNCTIONS/////////////////////// 4 | 5 | unsigned _log_timer = UINT_MAX; 6 | unsigned _log_level = 0; 7 | 8 | void init_log(int log_level){ 9 | _log_level = log_level; 10 | if(_log_timer == UINT_MAX){ 11 | _log_timer = utils::Timer::start(); 12 | } 13 | } 14 | void printlog(int level, const char *format, ...){ 15 | if((level & _log_level) == 0){ 16 | return; 17 | } 18 | print_prefix(level); 19 | va_list ap; 20 | va_start(ap, format); 21 | vfprintf(stdout, format, ap); 22 | print_suffix(); 23 | fflush(stdout); 24 | } 25 | 26 | void print_prefix(int level){ 27 | if(level == LOG_FATAL){ 28 | printf(ESC_BOLD); 29 | printf(ESC_BLACK); 30 | printf(ESC_BG_RED); 31 | printf(LOG_PREFIX, utils::Timer::time(_log_timer), '!'); 32 | }else if(level == LOG_ERROR){ 33 | printf(ESC_BOLD); 34 | printf(ESC_RED); 35 | printf(ESC_BG_DEFAULT); 36 | printf(LOG_PREFIX, utils::Timer::time(_log_timer), 'E'); 37 | }else if(level == LOG_WARN){ 38 | printf(ESC_BOLD); 39 | printf(ESC_YELLOW); 40 | printf(ESC_BG_BLACK); 41 | printf(LOG_PREFIX, utils::Timer::time(_log_timer), 'W'); 42 | }else if(level == LOG_NOTICE){ 43 | printf(LOG_PREFIX, utils::Timer::time(_log_timer), 'N'); 44 | }else if(level == LOG_PROMPT){ 45 | printf(LOG_PREFIX, utils::Timer::time(_log_timer), '>'); 46 | }else if(level == LOG_OK){ 47 | printf(ESC_GREEN); 48 | printf(ESC_BG_DEFAULT); 49 | printf(LOG_PREFIX, utils::Timer::time(_log_timer), ' '); 50 | }else{ 51 | printf(LOG_PREFIX, utils::Timer::time(_log_timer), ' '); 52 | } 53 | fflush(stdout); 54 | } 55 | 56 | void print_suffix(){ 57 | printf(ESC_RESET); 58 | printf(LOG_SUFFIX); 59 | } 60 | -------------------------------------------------------------------------------- /src/def58/inc/defiUtil.hpp: -------------------------------------------------------------------------------- 1 | // ***************************************************************************** 2 | // ***************************************************************************** 3 | // Copyright 2013, Cadence Design Systems 4 | // 5 | // This file is part of the Cadence LEF/DEF Open Source 6 | // Distribution, Product Version 5.8. 7 | // 8 | // Licensed under the Apache License, Version 2.0 (the "License"); 9 | // you may not use this file except in compliance with the License. 10 | // You may obtain a copy of the License at 11 | // 12 | // http://www.apache.org/licenses/LICENSE-2.0 13 | // 14 | // Unless required by applicable law or agreed to in writing, software 15 | // distributed under the License is distributed on an "AS IS" BASIS, 16 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 17 | // implied. See the License for the specific language governing 18 | // permissions and limitations under the License. 19 | // 20 | // For updates, support, or to become part of the LEF/DEF Community, 21 | // check www.openeda.org for details. 22 | // 23 | // $Author: dell $ 24 | // $Revision: #7 $ 25 | // $Date: 2015/01/27 $ 26 | // $State: $ 27 | // ***************************************************************************** 28 | // ***************************************************************************** 29 | 30 | #ifndef defiUtil_h 31 | #define defiUtil_h 32 | 33 | #include "defiKRDefs.hpp" 34 | 35 | BEGIN_LEFDEF_PARSER_NAMESPACE 36 | 37 | /* Return codes Orient and Rotation */ 38 | #define DEF_ORIENT_N 0 39 | #define DEF_ORIENT_W 1 40 | #define DEF_ORIENT_S 2 41 | #define DEF_ORIENT_E 3 42 | #define DEF_ORIENT_FN 4 43 | #define DEF_ORIENT_FW 5 44 | #define DEF_ORIENT_FS 6 45 | #define DEF_ORIENT_FE 7 46 | 47 | const char* defiOrientStr(int orient); 48 | 49 | END_LEFDEF_PARSER_NAMESPACE 50 | 51 | #endif 52 | 53 | -------------------------------------------------------------------------------- /src/lef58/inc/lefiDebug.hpp: -------------------------------------------------------------------------------- 1 | // ***************************************************************************** 2 | // ***************************************************************************** 3 | // Copyright 2012 - 2013, Cadence Design Systems 4 | // 5 | // This file is part of the Cadence LEF/DEF Open Source 6 | // Distribution, Product Version 5.8. 7 | // 8 | // Licensed under the Apache License, Version 2.0 (the "License"); 9 | // you may not use this file except in compliance with the License. 10 | // You may obtain a copy of the License at 11 | // 12 | // http://www.apache.org/licenses/LICENSE-2.0 13 | // 14 | // Unless required by applicable law or agreed to in writing, software 15 | // distributed under the License is distributed on an "AS IS" BASIS, 16 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 17 | // implied. See the License for the specific language governing 18 | // permissions and limitations under the License. 19 | // 20 | // For updates, support, or to become part of the LEF/DEF Community, 21 | // check www.openeda.org for details. 22 | // 23 | // $Author: dell $ 24 | // $Revision: #7 $ 25 | // $Date: 2015/01/27 $ 26 | // $State: $ 27 | // ***************************************************************************** 28 | // ***************************************************************************** 29 | 30 | #ifndef lefiDebug_h 31 | #define lefiDebug_h 1 32 | 33 | #include "lefiKRDefs.hpp" 34 | 35 | BEGIN_LEFDEF_PARSER_NAMESPACE 36 | 37 | // Set flag 38 | extern void lefiSetDebug (int num, int value) ; 39 | 40 | // Read flag 41 | extern int lefiDebug (int num) ; 42 | 43 | // Error reporting routine 44 | extern void lefiError (int check, int msgNum, const char* msg); 45 | 46 | extern const char* CASE(const char *x); 47 | 48 | END_LEFDEF_PARSER_NAMESPACE 49 | 50 | USE_LEFDEF_PARSER_NAMESPACE 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /src/db/db_layer.h: -------------------------------------------------------------------------------- 1 | #ifndef _DB_LAYER_H_ 2 | #define _DB_LAYER_H_ 3 | 4 | namespace db { 5 | class Track { 6 | protected: 7 | vector layers_; 8 | 9 | public: 10 | char direction = 'x'; 11 | int start = INT_MAX; 12 | unsigned num = 0; 13 | unsigned step = 0; 14 | 15 | Track(const char direction = 'x', const int start = INT_MAX, const unsigned num = 0, const unsigned step = 0) 16 | : direction(direction), start(start), num(num), step(step) {} 17 | 18 | void addLayer(const string& layer) { layers_.push_back(layer); } 19 | const vector getLayers() const { return layers_; } 20 | 21 | char macro() const; 22 | unsigned numLayers() const { return layers_.size(); } 23 | const string& layer(unsigned index) const { return layers_[index]; } 24 | }; 25 | 26 | class Layer { 27 | friend class Database; 28 | 29 | private: 30 | string _name = ""; 31 | //'r' for route or 'c' for cut 32 | char _type = 'x'; 33 | 34 | Layer* _below = nullptr; 35 | Layer* _above = nullptr; 36 | 37 | public: 38 | char direction = 'x'; 39 | // int index; 40 | // index at route layers 'M1' = 0 41 | int rIndex = -1; 42 | // index at cut layers 'M12' = 0 43 | int cIndex = -1; 44 | // for route layer 45 | int pitch = -1; 46 | int offset = -1; 47 | int width = -1; 48 | int spacing = -1; 49 | Track track; 50 | 51 | Layer(const string& name = "", const char type = 'x') : _name(name), _type(type) {} 52 | 53 | const string& name() const { return _name; } 54 | 55 | bool isRouteLayer() const { return _type == 'r'; } 56 | bool isCutLayer() const { return _type == 'c'; } 57 | Layer* getLayerBelow() const { return _below; } 58 | Layer* getLayerAbove() const { return _above; } 59 | 60 | bool operator==(const Layer& rhs) const { return rIndex == rhs.rIndex && cIndex == rhs.cIndex; } 61 | bool operator!=(const Layer& rhs) const { return !(*this == rhs); } 62 | }; 63 | } // namespace db 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /src/def58/inc/defiAlias.hpp: -------------------------------------------------------------------------------- 1 | // ***************************************************************************** 2 | // ***************************************************************************** 3 | // Copyright 2013 - 2014, Cadence Design Systems 4 | // 5 | // This file is part of the Cadence LEF/DEF Open Source 6 | // Distribution, Product Version 5.8. 7 | // 8 | // Licensed under the Apache License, Version 2.0 (the "License"); 9 | // you may not use this file except in compliance with the License. 10 | // You may obtain a copy of the License at 11 | // 12 | // http://www.apache.org/licenses/LICENSE-2.0 13 | // 14 | // Unless required by applicable law or agreed to in writing, software 15 | // distributed under the License is distributed on an "AS IS" BASIS, 16 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 17 | // implied. See the License for the specific language governing 18 | // permissions and limitations under the License. 19 | // 20 | // For updates, support, or to become part of the LEF/DEF Community, 21 | // check www.openeda.org for details. 22 | // 23 | // $Author: icftcm $ 24 | // $Revision: #9 $ 25 | // $Date: 2016/10/13 $ 26 | // $State: $ 27 | // ***************************************************************************** 28 | // ***************************************************************************** 29 | 30 | #ifndef defiALIAS_h 31 | #define defiALIAS_h 32 | 33 | #include "defiKRDefs.hpp" 34 | 35 | BEGIN_LEFDEF_PARSER_NAMESPACE 36 | 37 | class defAliasIterator; 38 | class defrData; 39 | 40 | class defiAlias_itr { 41 | public: 42 | defiAlias_itr(defrData *defData = 0); 43 | void Init(); 44 | 45 | void Destroy(); 46 | ~defiAlias_itr(); 47 | 48 | int Next(); 49 | const char* Key(); 50 | const char* Data(); 51 | int Marked(); 52 | 53 | protected: 54 | defAliasIterator *iterator; 55 | int first; 56 | defrData *defData; 57 | }; 58 | 59 | END_LEFDEF_PARSER_NAMESPACE 60 | 61 | USE_LEFDEF_PARSER_NAMESPACE 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /src/lef58/inc/lefiUtil.hpp: -------------------------------------------------------------------------------- 1 | // ***************************************************************************** 2 | // ***************************************************************************** 3 | // Copyright 2012 - 2013, Cadence Design Systems 4 | // 5 | // This file is part of the Cadence LEF/DEF Open Source 6 | // Distribution, Product Version 5.8. 7 | // 8 | // Licensed under the Apache License, Version 2.0 (the "License"); 9 | // you may not use this file except in compliance with the License. 10 | // You may obtain a copy of the License at 11 | // 12 | // http://www.apache.org/licenses/LICENSE-2.0 13 | // 14 | // Unless required by applicable law or agreed to in writing, software 15 | // distributed under the License is distributed on an "AS IS" BASIS, 16 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 17 | // implied. See the License for the specific language governing 18 | // permissions and limitations under the License. 19 | // 20 | // For updates, support, or to become part of the LEF/DEF Community, 21 | // check www.openeda.org for details. 22 | // 23 | // $Author: dell $ 24 | // $Revision: #7 $ 25 | // $Date: 2015/01/27 $ 26 | // $State: $ 27 | // ***************************************************************************** 28 | // ***************************************************************************** 29 | 30 | #ifndef lefiUtil_h 31 | #define lefiUtil_h 32 | 33 | #include "lefiKRDefs.hpp" 34 | 35 | BEGIN_LEFDEF_PARSER_NAMESPACE 36 | 37 | // Structure to return Macro data to FE 38 | struct lefiPoints { 39 | double x; 40 | double y; 41 | }; 42 | 43 | typedef struct lefiPoints lefiNum; 44 | 45 | //int lefiValidTime(); 46 | extern int lefiValidUser(); 47 | 48 | extern char* lefiUser(); 49 | 50 | extern char* lefiOrientStr(int orient); 51 | 52 | extern double convert_name2num(const char *versionName); 53 | 54 | extern bool validateMaskNumber(int num); 55 | 56 | END_LEFDEF_PARSER_NAMESPACE 57 | 58 | USE_LEFDEF_PARSER_NAMESPACE 59 | 60 | #endif 61 | 62 | -------------------------------------------------------------------------------- /src/def58/inc/defiDebug.hpp: -------------------------------------------------------------------------------- 1 | // ***************************************************************************** 2 | // ***************************************************************************** 3 | // Copyright 2013, Cadence Design Systems 4 | // 5 | // This file is part of the Cadence LEF/DEF Open Source 6 | // Distribution, Product Version 5.8. 7 | // 8 | // Licensed under the Apache License, Version 2.0 (the "License"); 9 | // you may not use this file except in compliance with the License. 10 | // You may obtain a copy of the License at 11 | // 12 | // http://www.apache.org/licenses/LICENSE-2.0 13 | // 14 | // Unless required by applicable law or agreed to in writing, software 15 | // distributed under the License is distributed on an "AS IS" BASIS, 16 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 17 | // implied. See the License for the specific language governing 18 | // permissions and limitations under the License. 19 | // 20 | // For updates, support, or to become part of the LEF/DEF Community, 21 | // check www.openeda.org for details. 22 | // 23 | // $Author: icftcm $ 24 | // $Revision: #8 $ 25 | // $Date: 2016/10/13 $ 26 | // $State: $ 27 | // ***************************************************************************** 28 | // ***************************************************************************** 29 | 30 | #ifndef defiDebug_h 31 | #define defiDebug_h 32 | 33 | #include "defiKRDefs.hpp" 34 | 35 | BEGIN_LEFDEF_PARSER_NAMESPACE 36 | 37 | class defrData; 38 | 39 | /* Set flag */ 40 | extern void defiSetDebug (int num, int value) ; 41 | 42 | /* Read flag */ 43 | extern int defiDebug (int num) ; 44 | 45 | /* Error loggin function */ 46 | extern void defiError(int check, int msgNum, const char* message, defrData *defData = NULL); 47 | 48 | /* for auto upshifting names in case insensitive files */ 49 | extern const char* upperCase(const char* c, defrData *defData = NULL); 50 | extern const char* DEFCASE(const char* ch, defrData *defData = NULL); 51 | 52 | END_LEFDEF_PARSER_NAMESPACE 53 | 54 | USE_LEFDEF_PARSER_NAMESPACE 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /src/def58/inc/defiPropType.hpp: -------------------------------------------------------------------------------- 1 | // ***************************************************************************** 2 | // ***************************************************************************** 3 | // Copyright 2013, Cadence Design Systems 4 | // 5 | // This file is part of the Cadence LEF/DEF Open Source 6 | // Distribution, Product Version 5.8. 7 | // 8 | // Licensed under the Apache License, Version 2.0 (the "License"); 9 | // you may not use this file except in compliance with the License. 10 | // You may obtain a copy of the License at 11 | // 12 | // http://www.apache.org/licenses/LICENSE-2.0 13 | // 14 | // Unless required by applicable law or agreed to in writing, software 15 | // distributed under the License is distributed on an "AS IS" BASIS, 16 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 17 | // implied. See the License for the specific language governing 18 | // permissions and limitations under the License. 19 | // 20 | // For updates, support, or to become part of the LEF/DEF Community, 21 | // check www.openeda.org for details. 22 | // 23 | // $Author: dell $ 24 | // $Revision: #7 $ 25 | // $Date: 2015/01/27 $ 26 | // $State: $ 27 | // ***************************************************************************** 28 | // ***************************************************************************** 29 | 30 | #ifndef defiPropType_h 31 | #define defiPropType_h 32 | 33 | #include "defiKRDefs.hpp" 34 | #include 35 | 36 | BEGIN_LEFDEF_PARSER_NAMESPACE 37 | 38 | // Struct holds the data type for one property, if the property is 39 | // either REAL or INTEGER. 40 | class defiPropType { 41 | public: 42 | defiPropType(); 43 | void Init(); 44 | 45 | void Destroy(); 46 | ~defiPropType(); 47 | 48 | void setPropType(const char* name, const char type); 49 | void Clear(); 50 | 51 | const char propType(char* name) const; 52 | void bumpProps(); 53 | 54 | protected: 55 | int numProperties_; 56 | int propertiesAllocated_; 57 | char** propNames_; // name. 58 | char* propTypes_; // 'R' == "REAL", 'I' == "INTEGER" 59 | }; 60 | 61 | 62 | END_LEFDEF_PARSER_NAMESPACE 63 | 64 | USE_LEFDEF_PARSER_NAMESPACE 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /src/lef58/inc/lefiPropType.hpp: -------------------------------------------------------------------------------- 1 | // ***************************************************************************** 2 | // ***************************************************************************** 3 | // Copyright 2012 - 2013, Cadence Design Systems 4 | // 5 | // This file is part of the Cadence LEF/DEF Open Source 6 | // Distribution, Product Version 5.8. 7 | // 8 | // Licensed under the Apache License, Version 2.0 (the "License"); 9 | // you may not use this file except in compliance with the License. 10 | // You may obtain a copy of the License at 11 | // 12 | // http://www.apache.org/licenses/LICENSE-2.0 13 | // 14 | // Unless required by applicable law or agreed to in writing, software 15 | // distributed under the License is distributed on an "AS IS" BASIS, 16 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 17 | // implied. See the License for the specific language governing 18 | // permissions and limitations under the License. 19 | // 20 | // For updates, support, or to become part of the LEF/DEF Community, 21 | // check www.openeda.org for details. 22 | // 23 | // $Author: dell $ 24 | // $Revision: #7 $ 25 | // $Date: 2015/01/27 $ 26 | // $State: $ 27 | // ***************************************************************************** 28 | // ***************************************************************************** 29 | 30 | #ifndef lefiPropType_h 31 | #define lefiPropType_h 32 | 33 | #include "lefiKRDefs.hpp" 34 | #include 35 | 36 | BEGIN_LEFDEF_PARSER_NAMESPACE 37 | 38 | // Struct holds the data type for one property, if the property is 39 | // either REAL or INTEGER. 40 | class lefiPropType { 41 | public: 42 | lefiPropType(); 43 | void Init(); 44 | 45 | void Destroy(); 46 | ~lefiPropType(); 47 | 48 | void setPropType(const char* name, const char type); 49 | void Clear(); 50 | 51 | const char propType(char* name) const; 52 | void bumpProps(); 53 | 54 | protected: 55 | int numProperties_; 56 | int propertiesAllocated_; 57 | char** propNames_; // name. 58 | char* propTypes_; // 'R' == "REAL", 'I' == "INTEGER" 59 | }; 60 | 61 | END_LEFDEF_PARSER_NAMESPACE 62 | 63 | USE_LEFDEF_PARSER_NAMESPACE 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /src/vi/vi.h: -------------------------------------------------------------------------------- 1 | #ifndef _VI_H_ 2 | #define _VI_H_ 3 | 4 | #include "draw.h" 5 | 6 | namespace vi { 7 | class Visualizer; 8 | 9 | class Drawable { 10 | protected: 11 | Drawable* _parent = nullptr; 12 | bool _selected = false; 13 | 14 | public: 15 | Drawable() {} 16 | virtual ~Drawable() {} 17 | 18 | void setParent(Drawable* parent) { _parent = parent; } 19 | void select(bool s = true) { _selected = s; } 20 | bool isSelected(); 21 | 22 | virtual Drawable* parent() const = 0; 23 | virtual int globalX() const = 0; 24 | virtual int globalY() const = 0; 25 | virtual int localX() const = 0; 26 | virtual int localY() const = 0; 27 | virtual int boundL() const = 0; 28 | virtual int boundR() const = 0; 29 | virtual int boundB() const = 0; 30 | virtual int boundT() const = 0; 31 | }; 32 | 33 | class ColorScheme { 34 | public: 35 | Color background; 36 | Color instanceFill; 37 | Color instanceLine; 38 | Color rowFill; 39 | Color rowLine; 40 | Color regionFill; 41 | vector metalFill; 42 | vector metalLine; 43 | vector viaFill; 44 | vector viaLine; 45 | 46 | ColorScheme() { setLight(); } 47 | void setDefault(); 48 | void setLight(); 49 | }; 50 | 51 | class Visualizer { 52 | private: 53 | bool ready = false; 54 | Canvas _canvas; 55 | int w = 0; 56 | int h = 0; 57 | int lx = 0; 58 | int ly = 0; 59 | int hx = 0; 60 | int hy = 0; 61 | 62 | public: 63 | ColorScheme scheme; 64 | 65 | void setWindow(int w, int h); 66 | void setViewport(int lx, int ly, int hx, int hy); 67 | void setup(); 68 | 69 | void save(string file) { _canvas.Save(file); } 70 | void reset(); 71 | void reset(Color color); 72 | 73 | void setLineColor(Color color); 74 | void setFillColor(Color color); 75 | void setLineWidth(int size); 76 | 77 | void drawPoint(int x, int y, int size); 78 | void drawLine(int x1, int y1, int x2, int y2); 79 | void drawRect(int x1, int y1, int x2, int y2, bool fill, bool line); 80 | 81 | void drawText(int num, int x, int y); 82 | void drawText(double num, int x, int y, int precision); 83 | void drawText(string str, int x, int y); 84 | }; 85 | } 86 | 87 | #endif 88 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | READ THIS LICENSE AGREEMENT CAREFULLY BEFORE USING THIS PRODUCT. BY USING THIS PRODUCT YOU INDICATE YOUR ACCEPTANCE OF THE TERMS OF THE FOLLOWING AGREEMENT. THESE TERMS APPLY TO YOU AND ANY SUBSEQUENT LICENSEE OF THIS PRODUCT. 2 | 3 | 4 | 5 | License Agreement for Ripple 6 | 7 | 8 | 9 | Copyright (c) 2021, The Chinese University of Hong Kong 10 | All rights reserved. 11 | 12 | 13 | 14 | CU-SD LICENSE (adapted from the original BSD license) Redistribution of the any code, with or without modification, are permitted provided that the conditions below are met. 15 | 16 | 17 | 18 | 1. Redistributions of source code must retain the above copyright notice, this 19 | list of conditions and the following disclaimer. 20 | 21 | 22 | 23 | 2. Redistributions in binary form must reproduce the above copyright notice, 24 | this list of conditions and the following disclaimer in the documentation 25 | and/or other materials provided with the distribution. 26 | 27 | 28 | 29 | 3. Neither the name nor trademark of the copyright holder or the author may be used to endorse or promote products derived from this software without specific prior written permission. 30 | 31 | 32 | 33 | 4. Users are entirely responsible, to the exclusion of the author, for compliance with (a) regulations set by owners or administrators of employed equipment, (b) licensing terms of any other software, and (c) local, national, and international regulations regarding use, including those regarding import, export, and use of encryption software. 34 | 35 | 36 | 37 | THIS FREE SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR ANY CONTRIBUTOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, EFFECTS OF UNAUTHORIZED OR MALICIOUS NETWORK ACCESS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 38 | -------------------------------------------------------------------------------- /src/lef58/inc/lefiUser.hpp: -------------------------------------------------------------------------------- 1 | // ***************************************************************************** 2 | // ***************************************************************************** 3 | // Copyright 2012 - 2013, Cadence Design Systems 4 | // 5 | // This file is part of the Cadence LEF/DEF Open Source 6 | // Distribution, Product Version 5.8. 7 | // 8 | // Licensed under the Apache License, Version 2.0 (the "License"); 9 | // you may not use this file except in compliance with the License. 10 | // You may obtain a copy of the License at 11 | // 12 | // http://www.apache.org/licenses/LICENSE-2.0 13 | // 14 | // Unless required by applicable law or agreed to in writing, software 15 | // distributed under the License is distributed on an "AS IS" BASIS, 16 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 17 | // implied. See the License for the specific language governing 18 | // permissions and limitations under the License. 19 | // 20 | // For updates, support, or to become part of the LEF/DEF Community, 21 | // check www.openeda.org for details. 22 | // 23 | // $Author: dell $ 24 | // $Revision: #7 $ 25 | // $Date: 2015/01/27 $ 26 | // $State: $ 27 | // ***************************************************************************** 28 | // ***************************************************************************** 29 | 30 | // User header file for the LEF Interface. This includes 31 | // all of the header files which are relevant to both the 32 | // reader and the writer. 33 | // 34 | // lefrReader.h and lefwWriter.h include this file, so that 35 | // an application only needs to include either lefrReader.h(pp) 36 | // or lefwWriter.h(pp). 37 | // 38 | 39 | #ifndef LEFI_USER_H 40 | #define LEFI_USER_H 41 | 42 | #include "lefiDebug.hpp" 43 | #include "lefiUnits.hpp" 44 | #include "lefiLayer.hpp" 45 | #include "lefiVia.hpp" 46 | #include "lefiViaRule.hpp" 47 | #include "lefiMisc.hpp" 48 | #include "lefiNonDefault.hpp" 49 | #include "lefiMacro.hpp" 50 | #include "lefiArray.hpp" 51 | #include "lefiCrossTalk.hpp" 52 | #include "lefiProp.hpp" 53 | #include "lefiPropType.hpp" 54 | 55 | BEGIN_LEFDEF_PARSER_NAMESPACE 56 | 57 | // NEW CALLBACK add the reference here 58 | 59 | END_LEFDEF_PARSER_NAMESPACE 60 | 61 | USE_LEFDEF_PARSER_NAMESPACE 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /src/gp/gp_cg.h: -------------------------------------------------------------------------------- 1 | #ifndef _CG_H_ 2 | #define _CG_H_ 3 | 4 | class SparseMatrix{ 5 | public: 6 | int row; 7 | int col; 8 | double num; 9 | SparseMatrix() : row(-1), col(-1), num(0.0){ 10 | } 11 | SparseMatrix(int r, int c, double v) : row(r), col(c), num(v){ 12 | } 13 | SparseMatrix(int r, int c) : row(r), col(c), num(0.0){ 14 | } 15 | static bool compareRowCol(const SparseMatrix &a, const SparseMatrix &b){ 16 | if(a.row == b.row){ 17 | return a.col < b.col; 18 | } 19 | return a.row < b.row; 20 | } 21 | }; 22 | class JacobiCG_params{ 23 | public: 24 | vector *A; 25 | vector *b; 26 | vector *x; 27 | vector *lo; 28 | vector *hi; 29 | vector *M_inverse; 30 | int i_max; 31 | double epsilon; 32 | int n; 33 | int Asize; 34 | bool box; 35 | }; 36 | /* 37 | CG(Conjuate Gradient) solver using Jacobi preconditioned Ax=b 38 | input: 39 | A : the sparse symmetric matrix 40 | b, x : the vector of Ax=b 41 | M_inverse : the inverse matrix of Jacobi preconditioned matrix M 42 | i_max : the maximum number of iterations in CG 43 | epsilon : error_tolerance<1 44 | n : the size of vector b, x (since the M is diagonal matrix, M_inverse is stored as vector) 45 | Asize : the non-zero elements in matrix A 46 | 47 | */ 48 | void jacobiCG( 49 | vector &Ax, vector &bx, vector &xx, 50 | vector &lox, vector &hix, vector &M_inversex, 51 | int i_maxx, double epsilonx, int nx, int Asizex, 52 | vector &Ay, vector &by, vector &xy, 53 | vector &loy, vector &hiy, vector &M_inversey, 54 | int i_maxy, double epsilony, int ny, int Asizey, 55 | bool box 56 | ); 57 | 58 | void jacobiCG( 59 | vector &A, 60 | vector &b, 61 | vector &x, 62 | vector &lo, 63 | vector &hi, 64 | vector &M_inverse, 65 | int i_max, double epsilon, int n, int Asize, bool box); 66 | 67 | #endif /*_CG_H_*/ 68 | -------------------------------------------------------------------------------- /src/db/db_place.h: -------------------------------------------------------------------------------- 1 | #ifndef _DB_PLACE_H_ 2 | #define _DB_PLACE_H_ 3 | 4 | namespace db{ 5 | class CellPlacement{ 6 | private: 7 | int _x; 8 | int _y; 9 | bool _flipX; 10 | bool _flipY; 11 | public: 12 | const static int Unplaced = INT_MIN; 13 | CellPlacement(){ 14 | _x = _y = INT_MIN; 15 | _flipX = _flipY = false; 16 | } 17 | CellPlacement(int x, int y, bool fx, bool fy){ 18 | _x = x; 19 | _y = y; 20 | _flipX = fx; 21 | _flipY = fy; 22 | } 23 | int x() const { return _x; } 24 | int y() const { return _y; } 25 | bool flipX() const { return _flipX; } 26 | bool flipY() const { return _flipY; } 27 | }; 28 | 29 | class Placement{ 30 | private: 31 | std::unordered_map _placement; 32 | public: 33 | Placement(){ 34 | _placement.clear(); 35 | } 36 | void place(Cell *cell){ 37 | _placement[cell] = CellPlacement(); 38 | } 39 | void place(Cell *cell, int x, int y){ 40 | bool fx = _placement[cell].flipX(); 41 | bool fy = _placement[cell].flipY(); 42 | _placement[cell] = CellPlacement(x, y, fx, fy); 43 | } 44 | void place(Cell *cell, int x, int y, bool fx, bool fy){ 45 | _placement[cell] = CellPlacement(x, y, fx, fy); 46 | } 47 | void clear(){ 48 | _placement.clear(); 49 | } 50 | int x(Cell *cell) const { 51 | return _placement.at(cell).x(); 52 | // return _placement[cell].x(); 53 | } 54 | int y(Cell *cell) const { 55 | return _placement.at(cell).y(); 56 | // return _placement[cell].y(); 57 | } 58 | int flipX(Cell *cell) { 59 | return _placement[cell].flipX(); 60 | } 61 | int flipY(Cell *cell) { 62 | return _placement[cell].flipY(); 63 | } 64 | bool placed(Cell *cell) { 65 | return (x(cell) != INT_MIN) && (y(cell) != INT_MIN); 66 | } 67 | }; 68 | } 69 | 70 | #endif 71 | 72 | -------------------------------------------------------------------------------- /src/lemon/include/lemon/math.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C++; indent-tabs-mode: nil; -*- 2 | * 3 | * This file is a part of LEMON, a generic C++ optimization library. 4 | * 5 | * Copyright (C) 2003-2013 6 | * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 | * (Egervary Research Group on Combinatorial Optimization, EGRES). 8 | * 9 | * Permission to use, modify and distribute this software is granted 10 | * provided that this copyright notice appears in all copies. For 11 | * precise terms see the accompanying LICENSE file. 12 | * 13 | * This software is provided "AS IS" with no warranty of any kind, 14 | * express or implied, and with no claim as to its suitability for any 15 | * purpose. 16 | * 17 | */ 18 | 19 | #ifndef LEMON_MATH_H 20 | #define LEMON_MATH_H 21 | 22 | ///\ingroup misc 23 | ///\file 24 | ///\brief Some extensions to the standard \c cmath library. 25 | /// 26 | ///Some extensions to the standard \c cmath library. 27 | /// 28 | ///This file includes the standard math library (cmath). 29 | 30 | #include 31 | 32 | namespace lemon { 33 | 34 | /// \addtogroup misc 35 | /// @{ 36 | 37 | /// The Euler constant 38 | const long double E = 2.7182818284590452353602874713526625L; 39 | /// log_2(e) 40 | const long double LOG2E = 1.4426950408889634073599246810018921L; 41 | /// log_10(e) 42 | const long double LOG10E = 0.4342944819032518276511289189166051L; 43 | /// ln(2) 44 | const long double LN2 = 0.6931471805599453094172321214581766L; 45 | /// ln(10) 46 | const long double LN10 = 2.3025850929940456840179914546843642L; 47 | /// pi 48 | const long double PI = 3.1415926535897932384626433832795029L; 49 | /// pi/2 50 | const long double PI_2 = 1.5707963267948966192313216916397514L; 51 | /// pi/4 52 | const long double PI_4 = 0.7853981633974483096156608458198757L; 53 | /// sqrt(2) 54 | const long double SQRT2 = 1.4142135623730950488016887242096981L; 55 | /// 1/sqrt(2) 56 | const long double SQRT1_2 = 0.7071067811865475244008443621048490L; 57 | 58 | ///Check whether the parameter is NaN or not 59 | 60 | ///This function checks whether the parameter is NaN or not. 61 | ///Is should be equivalent with std::isnan(), but it is not 62 | ///provided by all compilers. 63 | inline bool isNaN(double v) 64 | { 65 | return v!=v; 66 | } 67 | 68 | ///Round a value to its closest integer 69 | inline double round(double r) { 70 | return (r > 0.0) ? std::floor(r + 0.5) : std::ceil(r - 0.5); 71 | } 72 | 73 | /// @} 74 | 75 | } //namespace lemon 76 | 77 | #endif //LEMON_MATH_H 78 | -------------------------------------------------------------------------------- /src/def58/inc/defiMisc.hpp: -------------------------------------------------------------------------------- 1 | // ***************************************************************************** 2 | // ***************************************************************************** 3 | // Copyright 2013, Cadence Design Systems 4 | // 5 | // This file is part of the Cadence LEF/DEF Open Source 6 | // Distribution, Product Version 5.8. 7 | // 8 | // Licensed under the Apache License, Version 2.0 (the "License"); 9 | // you may not use this file except in compliance with the License. 10 | // You may obtain a copy of the License at 11 | // 12 | // http://www.apache.org/licenses/LICENSE-2.0 13 | // 14 | // Unless required by applicable law or agreed to in writing, software 15 | // distributed under the License is distributed on an "AS IS" BASIS, 16 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 17 | // implied. See the License for the specific language governing 18 | // permissions and limitations under the License. 19 | // 20 | // For updates, support, or to become part of the LEF/DEF Community, 21 | // check www.openeda.org for details. 22 | // 23 | // $Author: icftcm $ 24 | // $Revision: #8 $ 25 | // $Date: 2016/10/13 $ 26 | // $State: $ 27 | // ***************************************************************************** 28 | // ***************************************************************************** 29 | 30 | #ifndef defiMisc_h 31 | #define defiMisc_h 32 | 33 | #include 34 | #include "defiKRDefs.hpp" 35 | 36 | BEGIN_LEFDEF_PARSER_NAMESPACE 37 | 38 | class defrData; 39 | 40 | struct defiPoints { 41 | int numPoints; 42 | int* x; 43 | int* y; 44 | }; 45 | 46 | class defiGeometries { 47 | public: 48 | defiGeometries(defrData *data); 49 | void Init(); 50 | void Reset(); 51 | 52 | void Destroy(); 53 | ~defiGeometries(); 54 | 55 | void startList(int x, int y); 56 | void addToList(int x, int y); 57 | 58 | int numPoints() const; 59 | void points(int index, int* x, int* y) const; 60 | 61 | protected: 62 | int numPoints_; 63 | int pointsAllocated_; 64 | int* x_; 65 | int* y_; 66 | 67 | defrData *defData; 68 | }; 69 | 70 | class defiStyles { 71 | public: 72 | defiStyles(); 73 | void Init(); 74 | 75 | void Destroy(); 76 | ~defiStyles(); 77 | 78 | void clear(); 79 | 80 | void setStyle(int styleNum); 81 | void setPolygon(defiGeometries* geom); 82 | 83 | int style() const; 84 | struct defiPoints getPolygon() const; 85 | 86 | protected: 87 | int styleNum_; 88 | struct defiPoints* polygon_; 89 | int numPointAlloc_; 90 | }; 91 | 92 | END_LEFDEF_PARSER_NAMESPACE 93 | 94 | USE_LEFDEF_PARSER_NAMESPACE 95 | 96 | #endif 97 | -------------------------------------------------------------------------------- /src/db/db_map.h: -------------------------------------------------------------------------------- 1 | #ifndef _DB_MAP_H_ 2 | #define _DB_MAP_H_ 3 | 4 | namespace db { 5 | class SiteMap : virtual public Drawable { 6 | private: 7 | unsigned nx = 0; 8 | unsigned ny = 0; 9 | unsigned char** sites = nullptr; 10 | unsigned char** regions = nullptr; 11 | 12 | public: 13 | static const char SiteBlocked = 1; // nothing can be placed in the site 14 | static const char SiteM2Blocked = 2; // any part of it is blocked by M2 metal 15 | static const char SiteM3Blocked = 4; // any part of it is blocked by M3 metal 16 | static const char SiteM2BlockedIOPin = 8; // any part of it is blocked by M2 metal 17 | int siteL, siteR; 18 | int siteB, siteT; 19 | int siteStepX, siteStepY; 20 | int siteNX, siteNY; 21 | 22 | unsigned long long nSites = 0; 23 | unsigned long long nPlaceable = 0; 24 | vector nRegionSites; 25 | 26 | void initSiteMap(unsigned nx, unsigned ny); 27 | 28 | void setSiteMap(const unsigned x, const unsigned y, const unsigned char property) { setBit(sites[x][y], property); } 29 | inline void unsetSiteMap(const unsigned x, const unsigned y, const unsigned char property) { 30 | unsetBit(sites[x][y], property); 31 | } 32 | inline bool getSiteMap(const unsigned x, const unsigned y, const unsigned char property) const { 33 | return (getBit(sites[x][y], property) == property); 34 | } 35 | unsigned char getSiteMap(int x, int y) const { return sites[x][y]; } 36 | 37 | void getSiteBound(int x, int y, int& lx, int& ly, int& hx, int& hy) const; 38 | 39 | void blockRegion(const unsigned x, const unsigned y); 40 | inline void setRegion(const unsigned x, const unsigned y, unsigned char region) { regions[x][y] = region; } 41 | inline unsigned char getRegion(const unsigned x, const unsigned y) const { return regions[x][y]; } 42 | 43 | void setSites(const int lx, 44 | const int ly, 45 | const int hx, 46 | const int hy, 47 | const unsigned char property, 48 | const bool isContained = false); 49 | 50 | void unsetSites(int lx, int ly, int hx, int hy, unsigned char property); 51 | void blockRegion(int lx, int ly, int hx, int hy); 52 | void setRegion(int lx, int ly, int hx, int hy, unsigned char region); 53 | 54 | int globalX() const; 55 | int globalY() const; 56 | int localX() const; 57 | int localY() const; 58 | int boundL() const; 59 | int boundR() const; 60 | int boundB() const; 61 | int boundT() const; 62 | 63 | Drawable* parent() const; 64 | void draw(Visualizer* v) const; 65 | }; 66 | } // namespace db 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /src/sta/data.h: -------------------------------------------------------------------------------- 1 | #ifndef _STA_DATA_H_ 2 | #define _STA_DATA_H_ 3 | 4 | #include "../global.h" 5 | #include "../db/db.h" 6 | 7 | namespace sta{ 8 | 9 | 10 | /***************** 11 | Timing Analysis 12 | *****************/ 13 | 14 | class STANode{ 15 | public: 16 | double x,y; 17 | int upEdge; 18 | int downEdges[4]; 19 | double cap; //wire capacitance 20 | double downCap; //downstream cap 21 | double load; //extra loading (pin) 22 | double delay; //delay from source 23 | double slew; 24 | STANode(){ 25 | y = INT_MIN; 26 | x = INT_MIN; 27 | upEdge = -1; 28 | for(int i=0; i<4; i++){ 29 | downEdges[i] = -1; 30 | } 31 | cap = 0.0; 32 | downCap = 0.0; 33 | load = 0.0; 34 | delay = DBL_MAX; 35 | slew = DBL_MAX; 36 | } 37 | STANode(double ix, double iy){ 38 | x=ix; 39 | y=iy; 40 | upEdge = -1; 41 | for(int i=0; i<4; i++){ 42 | downEdges[i] = -1; 43 | } 44 | cap = 0.0; 45 | downCap = 0.0; 46 | load = 0.0; 47 | delay = DBL_MAX; 48 | slew = DBL_MAX; 49 | } 50 | }; 51 | class STAEdge{ 52 | public: 53 | int fm; 54 | int to; 55 | double len; 56 | double res; //resistance 57 | double delay; //wire delay 58 | STAEdge(){ 59 | fm = -1; 60 | to = -1; 61 | len = 0.0; 62 | res = 0.0; 63 | delay = DBL_MAX; 64 | } 65 | STAEdge(int f, int t){ 66 | fm = f; 67 | to = t; 68 | len = 0.0; 69 | res = 0.0; 70 | delay = DBL_MAX; 71 | } 72 | STAEdge(int f, int t, double l){ 73 | fm = f; 74 | to = t; 75 | len = l; 76 | res = 0.0; 77 | delay = DBL_MAX; 78 | } 79 | }; 80 | 81 | class STANet{ 82 | public: 83 | db::Net *net; 84 | 85 | vector pins; 86 | 87 | vector nodes; 88 | vector edges; 89 | vector topoNodes; 90 | vector delays; 91 | 92 | bool error{false}; 93 | }; 94 | 95 | class STAIO{ 96 | public: 97 | db::IOPin *iopin; 98 | char dir; 99 | 100 | STAIO(db::IOPin *iopin); 101 | }; 102 | 103 | class STACell{ 104 | public: 105 | db::Cell *cell; 106 | 107 | STACell(db::Cell *dbCell) : cell(dbCell) {} 108 | }; 109 | 110 | } 111 | 112 | #endif 113 | 114 | -------------------------------------------------------------------------------- /src/lemon/include/lemon/lp.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C++; indent-tabs-mode: nil; -*- 2 | * 3 | * This file is a part of LEMON, a generic C++ optimization library. 4 | * 5 | * Copyright (C) 2003-2013 6 | * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 | * (Egervary Research Group on Combinatorial Optimization, EGRES). 8 | * 9 | * Permission to use, modify and distribute this software is granted 10 | * provided that this copyright notice appears in all copies. For 11 | * precise terms see the accompanying LICENSE file. 12 | * 13 | * This software is provided "AS IS" with no warranty of any kind, 14 | * express or implied, and with no claim as to its suitability for any 15 | * purpose. 16 | * 17 | */ 18 | 19 | #ifndef LEMON_LP_H 20 | #define LEMON_LP_H 21 | 22 | #include 23 | 24 | 25 | #ifdef LEMON_HAVE_GLPK 26 | #include 27 | #elif LEMON_HAVE_CPLEX 28 | #include 29 | #elif LEMON_HAVE_SOPLEX 30 | #include 31 | #elif LEMON_HAVE_CLP 32 | #include 33 | #elif LEMON_HAVE_CBC 34 | #include 35 | #endif 36 | 37 | ///\file 38 | ///\brief Defines a default LP solver 39 | ///\ingroup lp_group 40 | namespace lemon { 41 | 42 | #ifdef DOXYGEN 43 | ///The default LP solver identifier 44 | 45 | ///The default LP solver identifier. 46 | ///\ingroup lp_group 47 | /// 48 | ///Currently, the possible values are \c _LEMON_GLPK, \c LEMON__CPLEX, 49 | ///\c _LEMON_SOPLEX or \c LEMON__CLP 50 | #define LEMON_DEFAULT_LP SOLVER 51 | ///The default LP solver 52 | 53 | ///The default LP solver. 54 | ///\ingroup lp_group 55 | /// 56 | ///Currently, it is either \c GlpkLp, \c CplexLp, \c SoplexLp or \c ClpLp 57 | typedef GlpkLp Lp; 58 | 59 | ///The default MIP solver identifier 60 | 61 | ///The default MIP solver identifier. 62 | ///\ingroup lp_group 63 | /// 64 | ///Currently, the possible values are \c _LEMON_GLPK, \c LEMON__CPLEX 65 | ///or \c _LEMON_CBC 66 | #define LEMON_DEFAULT_MIP SOLVER 67 | ///The default MIP solver. 68 | 69 | ///The default MIP solver. 70 | ///\ingroup lp_group 71 | /// 72 | ///Currently, it is either \c GlpkMip, \c CplexMip , \c CbcMip 73 | typedef GlpkMip Mip; 74 | #else 75 | #if LEMON_DEFAULT_LP == _LEMON_GLPK 76 | typedef GlpkLp Lp; 77 | #elif LEMON_DEFAULT_LP == _LEMON_CPLEX 78 | typedef CplexLp Lp; 79 | #elif LEMON_DEFAULT_LP == _LEMON_SOPLEX 80 | typedef SoplexLp Lp; 81 | #elif LEMON_DEFAULT_LP == _LEMON_CLP 82 | typedef ClpLp Lp; 83 | #endif 84 | #if LEMON_DEFAULT_MIP == _LEMON_GLPK 85 | typedef GlpkMip Mip; 86 | #elif LEMON_DEFAULT_MIP == _LEMON_CPLEX 87 | typedef CplexMip Mip; 88 | #elif LEMON_DEFAULT_MIP == _LEMON_CBC 89 | typedef CbcMip Mip; 90 | #endif 91 | #endif 92 | 93 | } //namespace lemon 94 | 95 | #endif //LEMON_LP_H 96 | -------------------------------------------------------------------------------- /src/def58/inc/defiSlot.hpp: -------------------------------------------------------------------------------- 1 | // ***************************************************************************** 2 | // ***************************************************************************** 3 | // Copyright 2013, Cadence Design Systems 4 | // 5 | // This file is part of the Cadence LEF/DEF Open Source 6 | // Distribution, Product Version 5.8. 7 | // 8 | // Licensed under the Apache License, Version 2.0 (the "License"); 9 | // you may not use this file except in compliance with the License. 10 | // You may obtain a copy of the License at 11 | // 12 | // http://www.apache.org/licenses/LICENSE-2.0 13 | // 14 | // Unless required by applicable law or agreed to in writing, software 15 | // distributed under the License is distributed on an "AS IS" BASIS, 16 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 17 | // implied. See the License for the specific language governing 18 | // permissions and limitations under the License. 19 | // 20 | // For updates, support, or to become part of the LEF/DEF Community, 21 | // check www.openeda.org for details. 22 | // 23 | // $Author: icftcm $ 24 | // $Revision: #8 $ 25 | // $Date: 2016/10/13 $ 26 | // $State: $ 27 | // ***************************************************************************** 28 | // ***************************************************************************** 29 | 30 | #ifndef defiSLOT_h 31 | #define defiSLOT_h 32 | 33 | #include 34 | #include "defiKRDefs.hpp" 35 | #include "defiMisc.hpp" 36 | 37 | BEGIN_LEFDEF_PARSER_NAMESPACE 38 | 39 | class defrData; 40 | 41 | class defiSlot { 42 | public: 43 | defiSlot(defrData *data); 44 | void Init(); 45 | 46 | void Destroy(); 47 | ~defiSlot(); 48 | 49 | void clear(); 50 | void clearPoly(); 51 | 52 | void setLayer(const char* name); 53 | void addRect(int xl, int yl, int xh, int yh); 54 | void addPolygon(defiGeometries* geom); 55 | 56 | int hasLayer() const; 57 | const char* layerName() const; 58 | 59 | int numRectangles() const; 60 | int xl(int index) const; 61 | int yl(int index) const; 62 | int xh(int index) const; 63 | int yh(int index) const; 64 | 65 | int numPolygons() const; // 5.6 66 | defiPoints getPolygon(int index) const; // 5.6 67 | 68 | void print(FILE* f) const; 69 | 70 | protected: 71 | int hasLayer_; 72 | char* layerName_; 73 | int layerNameLength_; 74 | int numRectangles_; 75 | int rectsAllocated_; 76 | int* xl_; 77 | int* yl_; 78 | int* xh_; 79 | int* yh_; 80 | int numPolys_; // 5.6 81 | int polysAllocated_; // 5.6 82 | defiPoints** polygons_; // 5.6 83 | 84 | defrData *defData; 85 | }; 86 | 87 | 88 | END_LEFDEF_PARSER_NAMESPACE 89 | 90 | USE_LEFDEF_PARSER_NAMESPACE 91 | 92 | #endif 93 | -------------------------------------------------------------------------------- /src/def58/inc/defiPinProp.hpp: -------------------------------------------------------------------------------- 1 | // ***************************************************************************** 2 | // ***************************************************************************** 3 | // Copyright 2013, Cadence Design Systems 4 | // 5 | // This file is part of the Cadence LEF/DEF Open Source 6 | // Distribution, Product Version 5.8. 7 | // 8 | // Licensed under the Apache License, Version 2.0 (the "License"); 9 | // you may not use this file except in compliance with the License. 10 | // You may obtain a copy of the License at 11 | // 12 | // http://www.apache.org/licenses/LICENSE-2.0 13 | // 14 | // Unless required by applicable law or agreed to in writing, software 15 | // distributed under the License is distributed on an "AS IS" BASIS, 16 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 17 | // implied. See the License for the specific language governing 18 | // permissions and limitations under the License. 19 | // 20 | // For updates, support, or to become part of the LEF/DEF Community, 21 | // check www.openeda.org for details. 22 | // 23 | // $Author: icftcm $ 24 | // $Revision: #8 $ 25 | // $Date: 2016/10/13 $ 26 | // $State: $ 27 | // ***************************************************************************** 28 | // ***************************************************************************** 29 | 30 | #ifndef defiPinProp_h 31 | #define defiPinProp_h 32 | 33 | #include "defiKRDefs.hpp" 34 | #include 35 | 36 | BEGIN_LEFDEF_PARSER_NAMESPACE 37 | 38 | class defrData; 39 | 40 | class defiPinProp { 41 | public: 42 | defiPinProp(defrData *data); 43 | void Init(); 44 | 45 | ~defiPinProp(); 46 | void Destroy(); 47 | 48 | void clear(); 49 | 50 | void setName(const char* inst, const char* pin); 51 | void addProperty(const char* name, const char* value, const char type); 52 | void addNumProperty(const char* name, const double d, 53 | const char* value, const char type); 54 | 55 | int isPin() const; 56 | const char* instName() const; 57 | const char* pinName() const; 58 | 59 | int numProps() const; 60 | const char* propName(int index) const; 61 | const char* propValue(int index) const; 62 | double propNumber(int index) const; 63 | const char propType(int index) const; 64 | int propIsNumber(int index) const; 65 | int propIsString(int index) const; 66 | 67 | void print(FILE* f) const; 68 | 69 | protected: 70 | char isPin_; 71 | int instNameSize_; 72 | char* instName_; 73 | int pinNameSize_; 74 | char* pinName_; 75 | 76 | int numProps_; 77 | int propsAllocated_; 78 | char** propNames_; 79 | char** propValues_; 80 | double* propDValues_; 81 | char* propTypes_; 82 | 83 | defrData *defData; 84 | }; 85 | 86 | 87 | END_LEFDEF_PARSER_NAMESPACE 88 | 89 | USE_LEFDEF_PARSER_NAMESPACE 90 | 91 | #endif 92 | -------------------------------------------------------------------------------- /src/lemon/include/lemon/concept_check.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C++; indent-tabs-mode: nil; -*- 2 | * 3 | * This file is a part of LEMON, a generic C++ optimization library. 4 | * 5 | * Copyright (C) 2003-2013 6 | * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 | * (Egervary Research Group on Combinatorial Optimization, EGRES). 8 | * 9 | * Permission to use, modify and distribute this software is granted 10 | * provided that this copyright notice appears in all copies. For 11 | * precise terms see the accompanying LICENSE file. 12 | * 13 | * This software is provided "AS IS" with no warranty of any kind, 14 | * express or implied, and with no claim as to its suitability for any 15 | * purpose. 16 | * 17 | */ 18 | 19 | // The contents of this file was inspired by the concept checking 20 | // utility of the BOOST library (http://www.boost.org). 21 | 22 | ///\file 23 | ///\brief Basic utilities for concept checking. 24 | /// 25 | 26 | #ifndef LEMON_CONCEPT_CHECK_H 27 | #define LEMON_CONCEPT_CHECK_H 28 | 29 | namespace lemon { 30 | 31 | /* 32 | "inline" is used for ignore_unused_variable_warning() 33 | and function_requires() to make sure there is no 34 | overtarget with g++. 35 | */ 36 | 37 | template inline void ignore_unused_variable_warning(const T&) { } 38 | template 39 | inline void ignore_unused_variable_warning(const T1&, const T2&) { } 40 | template 41 | inline void ignore_unused_variable_warning(const T1&, const T2&, 42 | const T3&) { } 43 | template 44 | inline void ignore_unused_variable_warning(const T1&, const T2&, 45 | const T3&, const T4&) { } 46 | template 47 | inline void ignore_unused_variable_warning(const T1&, const T2&, 48 | const T3&, const T4&, 49 | const T5&) { } 50 | template 51 | inline void ignore_unused_variable_warning(const T1&, const T2&, 52 | const T3&, const T4&, 53 | const T5&, const T6&) { } 54 | 55 | ///\e 56 | template 57 | inline void function_requires() 58 | { 59 | #if !defined(NDEBUG) 60 | void (Concept::*x)() = & Concept::constraints; 61 | ::lemon::ignore_unused_variable_warning(x); 62 | #endif 63 | } 64 | 65 | ///\e 66 | template 67 | inline void checkConcept() { 68 | #if !defined(NDEBUG) 69 | typedef typename Concept::template Constraints ConceptCheck; 70 | void (ConceptCheck::*x)() = & ConceptCheck::constraints; 71 | ::lemon::ignore_unused_variable_warning(x); 72 | #endif 73 | } 74 | 75 | } // namespace lemon 76 | 77 | #endif // LEMON_CONCEPT_CHECK_H 78 | -------------------------------------------------------------------------------- /src/def58/inc/defiUser.hpp: -------------------------------------------------------------------------------- 1 | // ***************************************************************************** 2 | // ***************************************************************************** 3 | // Copyright 2013, Cadence Design Systems 4 | // 5 | // This file is part of the Cadence LEF/DEF Open Source 6 | // Distribution, Product Version 5.8. 7 | // 8 | // Licensed under the Apache License, Version 2.0 (the "License"); 9 | // you may not use this file except in compliance with the License. 10 | // You may obtain a copy of the License at 11 | // 12 | // http://www.apache.org/licenses/LICENSE-2.0 13 | // 14 | // Unless required by applicable law or agreed to in writing, software 15 | // distributed under the License is distributed on an "AS IS" BASIS, 16 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 17 | // implied. See the License for the specific language governing 18 | // permissions and limitations under the License. 19 | // 20 | // For updates, support, or to become part of the LEF/DEF Community, 21 | // check www.openeda.org for details. 22 | // 23 | // $Author: dell $ 24 | // $Revision: #7 $ 25 | // $Date: 2015/01/27 $ 26 | // $State: $ 27 | // ***************************************************************************** 28 | // ***************************************************************************** 29 | 30 | /* 31 | * User header file for the DEF Interface. This includes 32 | * all of the header files which are relevant to both the 33 | * reader and the writer. 34 | * 35 | * defrReader.h and defwWriter.h include this file, so that 36 | * an application only needs to include either defwReader.h 37 | * or defwWriter.h. 38 | */ 39 | 40 | #ifndef DEFI_USER_H 41 | #define DEFI_USER_H 42 | 43 | /* General utilities. */ 44 | /* #include "defiMalloc.hpp" */ 45 | /* #include "defiUtils.hpp" */ 46 | 47 | /* 48 | * API objects 49 | */ 50 | #include "defiDebug.hpp" 51 | #include "defiProp.hpp" 52 | #include "defiSite.hpp" 53 | #include "defiComponent.hpp" 54 | #include "defiNet.hpp" 55 | #include "defiPath.hpp" 56 | #include "defiPinCap.hpp" 57 | #include "defiRowTrack.hpp" 58 | #include "defiVia.hpp" 59 | #include "defiRegion.hpp" 60 | #include "defiGroup.hpp" 61 | #include "defiAssertion.hpp" 62 | #include "defiScanchain.hpp" 63 | #include "defiIOTiming.hpp" 64 | #include "defiFPC.hpp" 65 | #include "defiTimingDisable.hpp" 66 | #include "defiPartition.hpp" 67 | #include "defiPinProp.hpp" 68 | #include "defiBlockage.hpp" 69 | #include "defiSlot.hpp" 70 | #include "defiFill.hpp" 71 | #include "defiNonDefault.hpp" 72 | #include "defiPropType.hpp" 73 | 74 | BEGIN_LEFDEF_PARSER_NAMESPACE 75 | 76 | /* NEW CALLBACK - If you are creating a new .cpp and .hpp file to 77 | * describe a new class of object in the parser, then add a reference 78 | * to the .hpp here. 79 | * 80 | * You must also add an entry for the .h and the .hpp in the package_list 81 | * file of the ../../../release directory. */ 82 | 83 | END_LEFDEF_PARSER_NAMESPACE 84 | 85 | USE_LEFDEF_PARSER_NAMESPACE 86 | 87 | #endif 88 | -------------------------------------------------------------------------------- /src/io/file_constraints.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "../db/db.h" 3 | #include "../global.h" 4 | 5 | using namespace db; 6 | 7 | bool Database::readConstraints(const std::string& file) { 8 | string buffer; 9 | ifstream ifs(file.c_str()); 10 | if (!ifs.good()) { 11 | printlog(LOG_ERROR, "cannot open constraint file: %s", file.c_str()); 12 | return false; 13 | } 14 | while (ifs >> buffer) { 15 | unsigned equal = buffer.find("="); 16 | string key = buffer.substr(0, equal); 17 | if (key == "maximum_utilization") { 18 | if (!maxDensity) { 19 | unsigned unit = buffer.find("%"); 20 | string value = buffer.substr(equal + 1, unit - equal - 1); 21 | maxDensity = atof(value.c_str()) / 100.0; 22 | } else { 23 | printlog(LOG_WARN, "use input max util %f", maxDensity); 24 | } 25 | } else if (key == "maximum_movement") { 26 | if (!maxDisp) { 27 | unsigned unit = buffer.find("rows"); 28 | string value = buffer.substr(equal + 1, unit - equal - 1); 29 | maxDisp = atof(value.c_str()); 30 | } else { 31 | printlog(LOG_WARN, "use input max disp %f", maxDisp); 32 | } 33 | } 34 | } 35 | ifs.close(); 36 | return true; 37 | } 38 | 39 | bool Database::readSize(const std::string& file) { 40 | ifstream fs(file.c_str()); 41 | if (!fs.good()) { 42 | printlog(LOG_ERROR, "cannot open size file: %s", file.c_str()); 43 | return false; 44 | } 45 | 46 | if (siteW == 0 && rows.size() > 0) { 47 | siteW = rows[0]->xStep(); 48 | } 49 | if (siteH == 0 && celltypes.size() > 0) { 50 | siteH = INT_MAX; 51 | for (CellType* celltype : celltypes) { 52 | if (!celltype->stdcell) { 53 | continue; 54 | } 55 | siteH = std::min(siteH, celltype->height); 56 | } 57 | } 58 | if (siteW == 0 || siteH == 0) { 59 | printlog(LOG_INFO, "not enough information to retrieve placement site size"); 60 | return false; 61 | } 62 | 63 | #ifndef NDEBUG 64 | printlog(LOG_INFO, "reading %s", file.c_str()); 65 | #endif 66 | 67 | std::set sized; 68 | do { 69 | string name; 70 | int w, h; 71 | fs >> name >> w >> h; 72 | if (name != "") { 73 | Cell* cell = getCell(name); 74 | if (cell == NULL) { 75 | printlog(LOG_ERROR, "cell not found : %s", name.c_str()); 76 | break; 77 | } else { 78 | CellType* celltype = cell->ctype(); 79 | if (sized.find(celltype) == sized.end()) { 80 | celltype->width = w * siteW; 81 | celltype->height = h * siteH; 82 | sized.insert(celltype); 83 | } 84 | } 85 | } 86 | } while (!fs.eof()); 87 | 88 | fs.close(); 89 | return true; 90 | } 91 | -------------------------------------------------------------------------------- /src/lef58/inc/lefiUnits.hpp: -------------------------------------------------------------------------------- 1 | // ***************************************************************************** 2 | // ***************************************************************************** 3 | // Copyright 2012 - 2013, Cadence Design Systems 4 | // 5 | // This file is part of the Cadence LEF/DEF Open Source 6 | // Distribution, Product Version 5.8. 7 | // 8 | // Licensed under the Apache License, Version 2.0 (the "License"); 9 | // you may not use this file except in compliance with the License. 10 | // You may obtain a copy of the License at 11 | // 12 | // http://www.apache.org/licenses/LICENSE-2.0 13 | // 14 | // Unless required by applicable law or agreed to in writing, software 15 | // distributed under the License is distributed on an "AS IS" BASIS, 16 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 17 | // implied. See the License for the specific language governing 18 | // permissions and limitations under the License. 19 | // 20 | // For updates, support, or to become part of the LEF/DEF Community, 21 | // check www.openeda.org for details. 22 | // 23 | // $Author: dell $ 24 | // $Revision: #7 $ 25 | // $Date: 2015/01/27 $ 26 | // $State: $ 27 | // ***************************************************************************** 28 | // ***************************************************************************** 29 | 30 | #ifndef lefiUnits_h 31 | #define lefiUnits_h 32 | 33 | #include 34 | #include "lefiKRDefs.hpp" 35 | 36 | BEGIN_LEFDEF_PARSER_NAMESPACE 37 | 38 | class lefiUnits { 39 | public: 40 | lefiUnits(); 41 | void Init(); 42 | 43 | void Destroy(); 44 | ~lefiUnits(); 45 | 46 | void setDatabase(const char* name, double num); 47 | void clear(); 48 | void setTime(double num); 49 | void setCapacitance(double num); 50 | void setResistance(double num); 51 | void setPower(double num); 52 | void setCurrent(double num); 53 | void setVoltage(double num); 54 | void setFrequency(double num); 55 | 56 | int hasDatabase() const; 57 | int hasCapacitance()const; 58 | int hasResistance() const; 59 | int hasTime() const; 60 | int hasPower() const; 61 | int hasCurrent() const; 62 | int hasVoltage() const; 63 | int hasFrequency() const; 64 | 65 | const char* databaseName() const; 66 | double databaseNumber() const; 67 | double capacitance() const; 68 | double resistance() const; 69 | double time() const; 70 | double power() const; 71 | double current() const; 72 | double voltage() const; 73 | double frequency() const; 74 | 75 | // Debug print 76 | void print(FILE* f) const ; 77 | 78 | protected: 79 | int hasDatabase_; 80 | int hasCapacitance_; 81 | int hasResistance_; 82 | int hasTime_; 83 | int hasPower_; 84 | int hasCurrent_; 85 | int hasVoltage_; 86 | int hasFrequency_; 87 | char* databaseName_; 88 | double databaseNumber_; 89 | double capacitance_; 90 | double resistance_; 91 | double power_; 92 | double time_; 93 | double current_; 94 | double voltage_; 95 | double frequency_; 96 | }; 97 | 98 | END_LEFDEF_PARSER_NAMESPACE 99 | 100 | USE_LEFDEF_PARSER_NAMESPACE 101 | 102 | #endif 103 | -------------------------------------------------------------------------------- /src/db/db_row.h: -------------------------------------------------------------------------------- 1 | #ifndef _DB_ROW_H_ 2 | #define _DB_ROW_H_ 3 | 4 | namespace db { 5 | class Row : virtual public Drawable { 6 | friend class Database; 7 | 8 | private: 9 | string _name = ""; 10 | string _macro = ""; 11 | int _x = 0; 12 | int _y = 0; 13 | unsigned _xNum = 0; 14 | unsigned _yNum = 0; 15 | bool _flip = false; 16 | unsigned _xStep = 0; 17 | unsigned _yStep = 0; 18 | char _topPower = 'x'; 19 | char _botPower = 'x'; 20 | 21 | public: 22 | std::vector segments; 23 | 24 | Row(const string& name, const string& macro, const int x, const int y, const unsigned xNum = 0, const unsigned yNum = 0, const bool flip = false, const unsigned xStep = 0, const unsigned yStep = 0) 25 | : _name(name) 26 | , _macro(macro) 27 | , _x(x) 28 | , _y(y) 29 | , _xNum(xNum) 30 | , _yNum(yNum) 31 | , _flip(flip) 32 | , _xStep(xStep) 33 | , _yStep(yStep) {} 34 | 35 | // return the left-most site x-index 36 | int getSiteL(int dbLX, int siteW) const { return (_x - dbLX) / siteW; } 37 | // return the right-most site x-index + 1 38 | int getSiteR(int dbLX, int siteW) const { return getSiteL(dbLX, siteW) + _xNum; } 39 | // return the bottom-most site y-index 40 | int getSiteB(int dbLY, int siteH) const { return (_y - dbLY) / siteH; } 41 | // return the top-most site y-index + 1 42 | int getSiteT(int dbLY, int siteH) const { return getSiteB(dbLY, siteH) + _yNum; } 43 | 44 | const string& name() const { return _name; } 45 | const string& macro() const { return _macro; } 46 | int x() const { return _x; } 47 | int y() const { return _y; } 48 | unsigned xNum() const { return _xNum; } 49 | unsigned yNum() const { return _yNum; } 50 | bool flip() const { return _flip; } 51 | unsigned xStep() const { return _xStep; } 52 | unsigned yStep() const { return _yStep; } 53 | char topPower() const { return _topPower; } 54 | char botPower() const { return _botPower; } 55 | 56 | void x(const int value) { _x = value; } 57 | void y(const int value) { _y = value; } 58 | void xNum(const unsigned value) { _xNum = value; } 59 | void yNum(const unsigned value) { _yNum = value; } 60 | void flip(const bool value) { _flip = value; } 61 | void xStep(const unsigned value) { _xStep = value; } 62 | void yStep(const unsigned value) { _yStep = value; } 63 | 64 | unsigned width() const { return _xStep * _xNum; } 65 | bool isPowerValid() const { return (_topPower != _botPower) && (_topPower != 'x') && (_botPower != 'x'); } 66 | 67 | void shiftX(const int value) { _x += value; } 68 | void shiftY(const int value) { _y += value; } 69 | void shrinkXNum(const int value) { _xNum -= value; } 70 | void shrinkYNum(const int value) { _yNum -= value; } 71 | 72 | int globalX() const; 73 | int globalY() const; 74 | int localX() const; 75 | int localY() const; 76 | int boundL() const; 77 | int boundR() const; 78 | int boundB() const; 79 | int boundT() const; 80 | 81 | Drawable* parent() const; 82 | void draw(Visualizer* v) const; 83 | }; 84 | 85 | class RowSegment { 86 | public: 87 | int x = 0; 88 | int w = 0; 89 | Region* region = nullptr; 90 | }; 91 | } 92 | 93 | #endif 94 | -------------------------------------------------------------------------------- /src/gp/gp_region.cpp: -------------------------------------------------------------------------------- 1 | #include "gp_global.h" 2 | #include "gp_data.h" 3 | #include "gp_region.h" 4 | 5 | void findCellRegionDist(){ 6 | for(int i=0; i hx){ 30 | distx = x - hx; 31 | rx = hx; 32 | } 33 | if(y < ly){ 34 | disty = ly - y; 35 | ry = ly; 36 | }else if(y > hy){ 37 | disty = y - hy; 38 | ry = hy; 39 | } 40 | if(r == 0 || distx + disty < dist){ 41 | dist = distx + disty; 42 | regionx = rx; 43 | regiony = ry; 44 | regionr = r; 45 | if(dist == 0){ 46 | break; 47 | } 48 | } 49 | } 50 | if(regionr<0){ 51 | printlog(LOG_ERROR, "no rect defined for region %d", region); 52 | } 53 | cellFenceX[i]=regionx; 54 | cellFenceY[i]=regiony; 55 | cellFenceRect[i]=regionr; 56 | cellFenceDist[i]=dist; 57 | } 58 | } 59 | int legal_count=0; 60 | void legalizeRegion(){ 61 | //assume findCellRegionDist() is called already 62 | double epsilon = 0.1; 63 | for(int i=0; i= coreLX, so when x < lx, lx > coreLX , divided by zero avoided 79 | }else if(x > hx){ 80 | cellX[i] = hx - epsilon + (x - hx) / (coreHX - hx) * epsilon; 81 | //it is always x <= coreHX, so when x > hx, hx < coreHX , divided by zero avoided 82 | }else{ 83 | cellX[i] = lx + epsilon + (x - lx) / (hx - lx)*(hx - lx - epsilon - epsilon); 84 | } 85 | if(y < ly){ 86 | cellY[i] = ly + (y - coreLY) / (ly - coreLY) * epsilon; 87 | }else if(y > hy){ 88 | cellY[i] = hy - epsilon + (y - hy) / (coreHY - hy) * epsilon; 89 | }else{ 90 | cellY[i] = ly + epsilon + (y - ly) / (hy - ly) * (hy - ly - epsilon -epsilon); 91 | } 92 | } 93 | } 94 | 95 | -------------------------------------------------------------------------------- /src/def58/inc/defiTimingDisable.hpp: -------------------------------------------------------------------------------- 1 | // ***************************************************************************** 2 | // ***************************************************************************** 3 | // Copyright 2013, Cadence Design Systems 4 | // 5 | // This file is part of the Cadence LEF/DEF Open Source 6 | // Distribution, Product Version 5.8. 7 | // 8 | // Licensed under the Apache License, Version 2.0 (the "License"); 9 | // you may not use this file except in compliance with the License. 10 | // You may obtain a copy of the License at 11 | // 12 | // http://www.apache.org/licenses/LICENSE-2.0 13 | // 14 | // Unless required by applicable law or agreed to in writing, software 15 | // distributed under the License is distributed on an "AS IS" BASIS, 16 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 17 | // implied. See the License for the specific language governing 18 | // permissions and limitations under the License. 19 | // 20 | // For updates, support, or to become part of the LEF/DEF Community, 21 | // check www.openeda.org for details. 22 | // 23 | // $Author: icftcm $ 24 | // $Revision: #8 $ 25 | // $Date: 2016/10/13 $ 26 | // $State: $ 27 | // ***************************************************************************** 28 | // ***************************************************************************** 29 | 30 | #ifndef defiTimingDisable_h 31 | #define defiTimingDisable_h 32 | 33 | #include 34 | #include "defiKRDefs.hpp" 35 | 36 | BEGIN_LEFDEF_PARSER_NAMESPACE 37 | 38 | // A Timing disable can be a from-to or a thru or a macro. 39 | // A macro is either a fromto macro or a thru macro. 40 | class defrData; 41 | 42 | 43 | class defiTimingDisable { 44 | public: 45 | defiTimingDisable(defrData *data); 46 | void Init(); 47 | 48 | void Destroy(); 49 | ~defiTimingDisable(); 50 | 51 | void clear(); 52 | 53 | void setFromTo(const char* fromInst, const char* fromPin, 54 | const char* toInst, const char* toPin); 55 | void setThru(const char* fromInst, const char* fromPin); 56 | void setMacro(const char* name); 57 | void setMacroThru(const char* thru); 58 | void setMacroFromTo(const char* fromPin, const char* toPin); 59 | void setReentrantPathsFlag(); 60 | 61 | int hasMacroThru() const; 62 | int hasMacroFromTo() const; 63 | int hasThru() const; 64 | int hasFromTo() const; 65 | int hasReentrantPathsFlag() const; 66 | 67 | const char* fromPin() const; 68 | const char* toPin() const; 69 | const char* fromInst() const; 70 | const char* toInst() const; 71 | const char* macroName() const; 72 | const char* thruPin() const; // Also macro thru 73 | const char* thruInst() const; 74 | 75 | // debug print 76 | void print(FILE* f) const; 77 | 78 | protected: 79 | char* fromInst_; // also macro name and thru inst 80 | int fromInstLength_; 81 | char* toInst_; 82 | int toInstLength_; 83 | char* fromPin_; // also macro thru and thru pin 84 | int fromPinLength_; 85 | char* toPin_; 86 | int toPinLength_; 87 | 88 | int hasFromTo_; 89 | int hasThru_; 90 | int hasMacro_; 91 | int hasReentrantPathsFlag_; 92 | 93 | defrData *defData; 94 | }; 95 | 96 | 97 | END_LEFDEF_PARSER_NAMESPACE 98 | 99 | USE_LEFDEF_PARSER_NAMESPACE 100 | 101 | #endif 102 | -------------------------------------------------------------------------------- /src/db/db_net.h: -------------------------------------------------------------------------------- 1 | #ifndef _DB_NET_H_ 2 | #define _DB_NET_H_ 3 | 4 | namespace db { 5 | 6 | class NetRouteNode { 7 | private: 8 | const Layer* _layer = nullptr; 9 | 10 | public: 11 | int x = 0; 12 | int y = 0; 13 | int z = 0; 14 | Pin* pin; 15 | 16 | NetRouteNode(const Layer* layer = nullptr, const int x = 0, const int y = 0, const int z = 0); 17 | 18 | inline bool operator==(const NetRouteNode& r) const { 19 | return _layer == r._layer && x == r.x && y == r.y && z == r.z; 20 | } 21 | }; 22 | 23 | class NetRouteSegment { 24 | public: 25 | int z; 26 | unsigned fromNode; 27 | unsigned toNode; 28 | // path = [] 29 | // direction : N,S,E,W,U,D 30 | vector> path; 31 | 32 | NetRouteSegment(const unsigned fromi = 0, const unsigned toi = 0, const char dir = '\0', const unsigned len = 0); 33 | 34 | long long length() const; 35 | }; 36 | 37 | class NetRouting { 38 | public: 39 | vector nodes; 40 | vector segments; 41 | 42 | void addWire(const Layer* layer, 43 | const int fromx, 44 | const int fromy, 45 | const int fromz, 46 | const int tox, 47 | const int toy, 48 | const int toz); 49 | void clear(); 50 | long long length() const; 51 | }; 52 | 53 | class Net : virtual public Drawable { 54 | private: 55 | NetRouting _routing; 56 | 57 | bool gRouted = false; 58 | bool dRouted = false; 59 | 60 | public: 61 | const string name = ""; 62 | std::vector pins; 63 | const NDR* ndr = nullptr; 64 | 65 | Net(const string& name, const NDR* ndr = nullptr) : name(name), ndr(ndr) {} 66 | Net(const Net& net) : _routing(net._routing), name(net.name), pins(net.pins), ndr(net.ndr) {} 67 | 68 | bool globalRouted() const { return gRouted; } 69 | bool detailedRouted() const { return dRouted; } 70 | unsigned numPins() const { return pins.size(); } 71 | 72 | void resetRouting() { _routing.clear(); } 73 | void addPin(Pin* pin); 74 | void addWire(const Layer* layer, 75 | const int fromx, 76 | const int fromy, 77 | const int fromz, 78 | const int tox, 79 | const int toy, const int toz) { _routing.addWire(layer, fromx, fromy, fromz, tox, toy, toz); } 80 | 81 | int globalX() const; 82 | int globalY() const; 83 | int localX() const; 84 | int localY() const; 85 | int boundL() const; 86 | int boundR() const; 87 | int boundB() const; 88 | int boundT() const; 89 | 90 | Drawable* parent() const; 91 | void draw(Visualizer* v, const Layer& L) const; 92 | }; 93 | 94 | /*only support horizontal power rails*/ 95 | class PowerRail { 96 | public: 97 | SNet* snet; 98 | int lx; 99 | int hx; 100 | PowerRail(SNet* sn, int l, int h) { 101 | snet = sn; 102 | lx = l; 103 | hx = h; 104 | } 105 | }; 106 | 107 | class PowerNet { 108 | private: 109 | std::map rails; 110 | 111 | public: 112 | void addRail(SNet* snet, int lx, int hx, int y); 113 | bool getRowPower(int ly, int hy, char& topPower, char& botPower); 114 | }; 115 | } // namespace db 116 | 117 | #endif 118 | -------------------------------------------------------------------------------- /src/def58/inc/defiRegion.hpp: -------------------------------------------------------------------------------- 1 | // ***************************************************************************** 2 | // ***************************************************************************** 3 | // Copyright 2013, Cadence Design Systems 4 | // 5 | // This file is part of the Cadence LEF/DEF Open Source 6 | // Distribution, Product Version 5.8. 7 | // 8 | // Licensed under the Apache License, Version 2.0 (the "License"); 9 | // you may not use this file except in compliance with the License. 10 | // You may obtain a copy of the License at 11 | // 12 | // http://www.apache.org/licenses/LICENSE-2.0 13 | // 14 | // Unless required by applicable law or agreed to in writing, software 15 | // distributed under the License is distributed on an "AS IS" BASIS, 16 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 17 | // implied. See the License for the specific language governing 18 | // permissions and limitations under the License. 19 | // 20 | // For updates, support, or to become part of the LEF/DEF Community, 21 | // check www.openeda.org for details. 22 | // 23 | // $Author: icftcm $ 24 | // $Revision: #8 $ 25 | // $Date: 2016/10/13 $ 26 | // $State: $ 27 | // ***************************************************************************** 28 | // ***************************************************************************** 29 | 30 | #ifndef defiRegion_h 31 | #define defiRegion_h 32 | 33 | #include "defiKRDefs.hpp" 34 | #include 35 | 36 | BEGIN_LEFDEF_PARSER_NAMESPACE 37 | 38 | class defrData; 39 | 40 | // Struct holds the data for one property. 41 | class defiRegion { 42 | public: 43 | defiRegion(defrData *data); 44 | void Init(); 45 | 46 | void Destroy(); 47 | ~defiRegion(); 48 | 49 | void clear(); 50 | void setup(const char* name); 51 | void addRect(int xl, int yl, int xh, int yh); 52 | void addProperty(const char* name, const char* value, const char type); 53 | void addNumProperty(const char* name, const double d, 54 | const char* value, const char type); 55 | void setType(const char* type); // 5.4.1 56 | 57 | const char* name() const; 58 | 59 | int numProps() const; 60 | const char* propName(int index) const; 61 | const char* propValue(int index) const; 62 | double propNumber(int index) const; 63 | const char propType(int index) const; 64 | int propIsNumber(int index) const; 65 | int propIsString(int index) const; 66 | 67 | int hasType() const; // 5.4.1 68 | const char* type() const; // 5.4.1 69 | 70 | int numRectangles() const; 71 | int xl(int index) const; 72 | int yl(int index) const; 73 | int xh(int index) const; 74 | int yh(int index) const; 75 | 76 | void print(FILE* f) const; 77 | 78 | protected: 79 | char* name_; 80 | int nameLength_; 81 | 82 | int numRectangles_; 83 | int rectanglesAllocated_; 84 | int* xl_; 85 | int* yl_; 86 | int* xh_; 87 | int* yh_; 88 | 89 | int numProps_; 90 | int propsAllocated_; 91 | char** propNames_; 92 | char** propValues_; 93 | double* propDValues_; 94 | char* propTypes_; 95 | 96 | char* type_; 97 | 98 | defrData *defData; 99 | }; 100 | 101 | 102 | 103 | END_LEFDEF_PARSER_NAMESPACE 104 | 105 | USE_LEFDEF_PARSER_NAMESPACE 106 | 107 | #endif 108 | -------------------------------------------------------------------------------- /src/sta/lib.h: -------------------------------------------------------------------------------- 1 | #ifndef _STA_LIB_H_ 2 | #define _STA_LIB_H_ 3 | 4 | #include "../global.h" 5 | //#include "../db/db.h" 6 | 7 | namespace sta{ 8 | 9 | /***************** 10 | Timing Library 11 | *****************/ 12 | class STALibraryLUT { 13 | public: 14 | bool isScalar = false; 15 | double value; 16 | vector indexX; 17 | vector indexY; 18 | vector indexZ; 19 | double minX; 20 | double maxX; 21 | double minY; 22 | double maxY; 23 | double minZ; 24 | double maxZ; 25 | vector>> values; 26 | 27 | STALibraryLUT() {} 28 | STALibraryLUT(double scalar); 29 | 30 | void clear(); 31 | // double get(double x = 0, double y = 0, double z = 0); 32 | void print(); 33 | }; 34 | 35 | class STALibraryTiming { 36 | public: 37 | STALibraryLUT delayRise; 38 | STALibraryLUT delayFall; 39 | STALibraryLUT slewRise; 40 | STALibraryLUT slewFall; 41 | int relatedPin; 42 | string relatedPinName; 43 | char timingSense; //'+' / '-' / 'x' 44 | }; 45 | 46 | class STALibraryOPin { 47 | private: 48 | string _name = ""; 49 | public: 50 | int pin = -1; 51 | double min_capacitance = 0.0; 52 | double max_capacitance = 0.0; 53 | vector timings; 54 | 55 | STALibraryOPin(const string& name = "") : _name(name) {} 56 | STALibraryOPin(const STALibraryOPin& opin); 57 | 58 | inline const string& name() const { return _name; } 59 | inline void name(const string& s) { _name = s; } 60 | }; 61 | 62 | class STALibraryIPin { 63 | private: 64 | string _name = ""; 65 | public: 66 | int pin = -1; 67 | double capacitance = 0.0; 68 | 69 | STALibraryIPin(const string& name = ""); 70 | STALibraryIPin(const STALibraryIPin& ipin); 71 | 72 | inline const string& name() const { return _name; } 73 | inline void name(const string& s) { _name = s; } 74 | }; 75 | 76 | class STALibraryCell { 77 | private: 78 | string _name; 79 | public: 80 | vector pins; 81 | //map from FCell pin index to STALibraryCell index 82 | vector opins; 83 | vector ipins; 84 | vector > timingArcs; 85 | 86 | STALibraryCell(const string& name = ""); 87 | 88 | inline const string& name() const { return _name; } 89 | inline void name(const string& s) { _name = s; } 90 | 91 | inline void addOPin(const string& s) { opins.emplace_back(s); } 92 | inline void addIPin(const string& s) { ipins.emplace_back(s); } 93 | }; 94 | 95 | class STALibrary { 96 | public: 97 | string name; 98 | vector cells; 99 | 100 | void preLoad(); 101 | void postLoad(); 102 | unsigned addCell(const string& name); 103 | }; 104 | } 105 | 106 | #endif 107 | 108 | -------------------------------------------------------------------------------- /src/lef58/inc/lefiProp.hpp: -------------------------------------------------------------------------------- 1 | // ***************************************************************************** 2 | // ***************************************************************************** 3 | // Copyright 2012 - 2013, Cadence Design Systems 4 | // 5 | // This file is part of the Cadence LEF/DEF Open Source 6 | // Distribution, Product Version 5.8. 7 | // 8 | // Licensed under the Apache License, Version 2.0 (the "License"); 9 | // you may not use this file except in compliance with the License. 10 | // You may obtain a copy of the License at 11 | // 12 | // http://www.apache.org/licenses/LICENSE-2.0 13 | // 14 | // Unless required by applicable law or agreed to in writing, software 15 | // distributed under the License is distributed on an "AS IS" BASIS, 16 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 17 | // implied. See the License for the specific language governing 18 | // permissions and limitations under the License. 19 | // 20 | // For updates, support, or to become part of the LEF/DEF Community, 21 | // check www.openeda.org for details. 22 | // 23 | // $Author: dell $ 24 | // $Revision: #7 $ 25 | // $Date: 2015/01/27 $ 26 | // $State: $ 27 | // ***************************************************************************** 28 | // ***************************************************************************** 29 | 30 | #ifndef lefiProp_h 31 | #define lefiProp_h 32 | 33 | #include "lefiKRDefs.hpp" 34 | #include 35 | 36 | BEGIN_LEFDEF_PARSER_NAMESPACE 37 | 38 | // Struct holds the data for one property. 39 | class lefiProp { 40 | public: 41 | lefiProp(); 42 | void Init(); 43 | 44 | void Destroy(); 45 | ~lefiProp(); 46 | 47 | void setPropType(const char* typ, const char* string); 48 | void setRange(double left, double right); 49 | void setNumber(double num); 50 | void setPropInteger(); 51 | void setPropReal(); 52 | void setPropString(); 53 | void setPropQString(const char* string); 54 | void setPropNameMapString(const char* string); 55 | void clear(); 56 | 57 | const char* string() const; 58 | const char* propType() const; 59 | const char* propName() const; 60 | char dataType() const; 61 | // either I:integer R:real S:string Q:quotedstring 62 | // N:property name is not defined in the property definition section 63 | int hasNumber() const; 64 | int hasRange() const; 65 | int hasString() const; 66 | int hasNameMapString() const; 67 | double number() const; 68 | double left() const; 69 | double right() const; 70 | 71 | void bumpSize(int size); 72 | void bumpName(int size); 73 | 74 | void print(FILE* f) const; 75 | 76 | protected: 77 | char* propType_; // "design" "net" "macro" ... 78 | char* propName_; // name. 79 | int nameSize_; // allocated size of name. 80 | char hasRange_; // either 0:NO or 1:YES. 81 | char hasNumber_; // either 0:NO or 1:YES. 82 | char hasNameMapString_; 83 | char dataType_; // either I:integer R:real S:string Q:quotedstring. 84 | // N:property name is not defined. 85 | char* stringData_; // if it is a string the data is here. 86 | int stringLength_; // allocated size of stringData. 87 | double left_; 88 | double right_; // if it has a range the numbers are here. 89 | double d_; // if it is a real or int the number is here. 90 | }; 91 | 92 | END_LEFDEF_PARSER_NAMESPACE 93 | 94 | USE_LEFDEF_PARSER_NAMESPACE 95 | 96 | #endif 97 | -------------------------------------------------------------------------------- /src/db/db_geom.h: -------------------------------------------------------------------------------- 1 | #ifndef _DB_GEOM_H_ 2 | #define _DB_GEOM_H_ 3 | 4 | namespace db { 5 | class Rectangle { 6 | public: 7 | int lx = INT_MAX; 8 | int ly = INT_MAX; 9 | int hx = INT_MIN; 10 | int hy = INT_MIN; 11 | 12 | Rectangle(int lx = INT_MAX, int ly = INT_MAX, int hx = INT_MIN, int hy = INT_MIN) 13 | : lx(lx), ly(ly), hx(hx), hy(hy) {} 14 | 15 | int w() const { return hx - lx; } 16 | int h() const { return hy - ly; } 17 | int cx() const { return (hx + lx) / 2; } 18 | int cy() const { return (hy + ly) / 2; } 19 | bool operator<(const Rectangle& geo) const { return (ly == geo.ly) ? (lx < geo.lx) : (ly < geo.ly); } 20 | bool operator==(const Rectangle& geo) const { return lx == geo.lx && ly == geo.ly && hx == geo.hx && hy == geo.hy; } 21 | Rectangle& operator+=(const Rectangle& geo); 22 | static bool CompareXInc(const Rectangle& a, const Rectangle& b) { 23 | return (a.lx == b.lx) ? (a.hx < b.hx) : (a.lx < b.lx); 24 | } 25 | static bool CompareXDec(const Rectangle& a, const Rectangle& b) { 26 | return (a.hx == b.hx) ? (a.lx > b.lx) : (a.hx > b.hx); 27 | } 28 | static bool CompareYInc(const Rectangle& a, const Rectangle& b) { 29 | return (a.ly == b.ly) ? (a.hy < b.hy) : (a.ly < b.ly); 30 | } 31 | static bool CompareYDec(const Rectangle& a, const Rectangle& b) { 32 | return (a.hy == b.hy) ? (a.ly > b.ly) : (a.hy > b.hy); 33 | } 34 | static bool IsInvalid(const Rectangle& geo) { return (geo.lx >= geo.hx) || (geo.ly >= geo.hy); } 35 | static void sliceH(vector& rects); 36 | static void sliceV(vector& rects); 37 | 38 | friend ostream& operator<<(ostream& os, const Rectangle& r) { 39 | return os << '(' << r.lx << ", " << r.ly << ")\t(" << r.hx << ", " << r.hy << ')'; 40 | } 41 | }; 42 | 43 | class Geometry : public Rectangle, virtual public Drawable { 44 | public: 45 | const Layer& layer; 46 | 47 | Geometry(const Layer& layer, const int lx, const int ly, const int hx, const int hy) 48 | : Rectangle(lx, ly, hx, hy), layer(layer) {} 49 | Geometry(const Geometry& geom) : Rectangle(geom), layer(geom.layer) {} 50 | 51 | inline bool operator==(const Geometry& rhs) const; 52 | 53 | /*Drawable*/ 54 | 55 | Drawable* parent() const; 56 | int globalX() const; 57 | int globalY() const; 58 | int localX() const; 59 | int localY() const; 60 | int boundL() const; 61 | int boundR() const; 62 | int boundB() const; 63 | int boundT() const; 64 | void draw(Visualizer* v, const Layer& L = {}) const; 65 | }; 66 | 67 | class GeoMap : public Rectangle { 68 | private: 69 | map _map; 70 | 71 | public: 72 | bool empty() const noexcept { return _map.empty(); } 73 | size_t size() const noexcept { return _map.size(); } 74 | const Geometry& front() const { return _map.begin()->second; } 75 | const Geometry& front2() const { return (++_map.begin())->second; } 76 | const Geometry& back() const { return _map.rbegin()->second; } 77 | map::const_iterator begin() const noexcept { return _map.begin(); } 78 | map::const_iterator end() const noexcept { return _map.end(); } 79 | map::const_iterator find(const int k) const { return _map.find(k); } 80 | 81 | const Geometry& at(const int k) const { return _map.at(k); } 82 | 83 | void emplace(const int k, const Geometry& shape); 84 | }; 85 | 86 | } // namespace db 87 | 88 | #endif 89 | -------------------------------------------------------------------------------- /src/db/db_map.cpp: -------------------------------------------------------------------------------- 1 | #include "db.h" 2 | using namespace db; 3 | 4 | #include "../ut/utils.h" 5 | 6 | /***** SiteMap *****/ 7 | 8 | void SiteMap::initSiteMap(unsigned nx, unsigned ny) { 9 | this->nx = nx; 10 | this->ny = ny; 11 | 12 | sites = (unsigned char **)malloc(sizeof(unsigned char *) * nx); 13 | sites[0] = (unsigned char *)calloc(nx * ny, sizeof(unsigned char)); 14 | for (unsigned x = 1; x < nx; x++) { 15 | sites[x] = sites[x - 1] + ny; 16 | } 17 | 18 | regions = (unsigned char **)malloc(sizeof(unsigned char *) * nx); 19 | regions[0] = (unsigned char *)calloc(nx * ny, sizeof(unsigned char)); 20 | for (unsigned x = 1; x < nx; x++) { 21 | regions[x] = regions[x - 1] + ny; 22 | } 23 | } 24 | 25 | void SiteMap::getSiteBound(int x, int y, int &lx, int &ly, int &hx, int &hy) const { 26 | lx = siteL + x * siteStepX; 27 | ly = siteB + y * siteStepY; 28 | hx = lx + siteStepX; 29 | hy = ly + siteStepY; 30 | } 31 | 32 | void SiteMap::blockRegion(const unsigned x, const unsigned y) { regions[x][y] = Region::InvalidRegion; } 33 | 34 | void SiteMap::setSites(int lx, int ly, int hx, int hy, unsigned char property, bool isContained) { 35 | int slx = 0; 36 | int sly = 0; 37 | int shx = 0; 38 | int shy = 0; 39 | if (isContained) { 40 | slx = binContainedL(lx, siteL, siteR, siteStepX); 41 | sly = binContainedL(ly, siteB, siteT, siteStepY); 42 | shx = binContainedR(hx, siteL, siteR, siteStepX); 43 | shy = binContainedR(hy, siteB, siteT, siteStepY); 44 | } else { 45 | slx = binOverlappedL(lx, siteL, siteR, siteStepX); 46 | sly = binOverlappedL(ly, siteB, siteT, siteStepY); 47 | shx = binOverlappedR(hx, siteL, siteR, siteStepX); 48 | shy = binOverlappedR(hy, siteB, siteT, siteStepY); 49 | } 50 | for (int x = slx; x <= shx; ++x) { 51 | for (int y = sly; y <= shy; ++y) { 52 | setSiteMap(x, y, property); 53 | } 54 | } 55 | } 56 | 57 | void SiteMap::unsetSites(int lx, int ly, int hx, int hy, unsigned char property) { 58 | const int slx = binOverlappedL(lx, siteL, siteR, siteStepX); 59 | const int sly = binOverlappedL(ly, siteB, siteT, siteStepY); 60 | const int shx = binOverlappedR(hx, siteL, siteR, siteStepX); 61 | const int shy = binOverlappedR(hy, siteB, siteT, siteStepY); 62 | for (int x = slx; x <= shx; ++x) { 63 | for (int y = sly; y <= shy; ++y) { 64 | unsetSiteMap(x, y, property); 65 | } 66 | } 67 | } 68 | 69 | void SiteMap::blockRegion(int lx, int ly, int hx, int hy) { 70 | int slx = binOverlappedL(lx, siteL, siteR, siteStepX); 71 | int sly = binOverlappedL(ly, siteB, siteT, siteStepY); 72 | int shx = binOverlappedR(hx, siteL, siteR, siteStepX); 73 | int shy = binOverlappedR(hy, siteB, siteT, siteStepY); 74 | for (int x = slx; x <= shx; x++) { 75 | for (int y = sly; y <= shy; y++) { 76 | setRegion(x, y, Region::InvalidRegion); 77 | } 78 | } 79 | } 80 | void SiteMap::setRegion(int lx, int ly, int hx, int hy, unsigned char region) { 81 | int slx = binContainedL(lx, siteL, siteR, siteStepX); 82 | int sly = binContainedL(ly, siteB, siteT, siteStepY); 83 | int shx = binContainedR(hx, siteL, siteR, siteStepX); 84 | int shy = binContainedR(hy, siteB, siteT, siteStepY); 85 | for (int x = slx; x <= shx; x++) { 86 | for (int y = sly; y <= shy; y++) { 87 | setRegion(x, y, region); 88 | } 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /src/def58/inc/defiFPC.hpp: -------------------------------------------------------------------------------- 1 | // ***************************************************************************** 2 | // ***************************************************************************** 3 | // Copyright 2013, Cadence Design Systems 4 | // 5 | // This file is part of the Cadence LEF/DEF Open Source 6 | // Distribution, Product Version 5.8. 7 | // 8 | // Licensed under the Apache License, Version 2.0 (the "License"); 9 | // you may not use this file except in compliance with the License. 10 | // You may obtain a copy of the License at 11 | // 12 | // http://www.apache.org/licenses/LICENSE-2.0 13 | // 14 | // Unless required by applicable law or agreed to in writing, software 15 | // distributed under the License is distributed on an "AS IS" BASIS, 16 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 17 | // implied. See the License for the specific language governing 18 | // permissions and limitations under the License. 19 | // 20 | // For updates, support, or to become part of the LEF/DEF Community, 21 | // check www.openeda.org for details. 22 | // 23 | // $Author: icftcm $ 24 | // $Revision: #8 $ 25 | // $Date: 2016/10/13 $ 26 | // $State: $ 27 | // ***************************************************************************** 28 | // ***************************************************************************** 29 | 30 | #ifndef defiFPC_h 31 | #define defiFPC_h 32 | 33 | #include 34 | #include "defiKRDefs.hpp" 35 | 36 | BEGIN_LEFDEF_PARSER_NAMESPACE 37 | 38 | class defrData; 39 | 40 | class defiFPC { 41 | public: 42 | defiFPC(defrData *data); 43 | void Init(); 44 | 45 | void Destroy(); 46 | ~defiFPC(); 47 | 48 | void clear(); 49 | 50 | void setName(const char* name, const char* direction); 51 | void setAlign(); 52 | void setMax(double num); 53 | void setMin(double num); 54 | void setEqual(double num); 55 | void setDoingBottomLeft(); 56 | void setDoingTopRight(); 57 | void addRow(const char* name); 58 | void addComps(const char* name); 59 | void addItem(char typ, const char* name); 60 | 61 | const char* name() const; 62 | int isVertical() const; 63 | int isHorizontal() const; 64 | int hasAlign() const; 65 | int hasMax() const; 66 | int hasMin() const; 67 | int hasEqual() const; 68 | double alignMax() const; 69 | double alignMin() const; 70 | double equal() const; 71 | 72 | int numParts() const; 73 | 74 | // Return the constraint number "index" where index is 75 | // from 0 to numParts() 76 | // The returned corner is 'B' for bottom left 'T' for topright 77 | // The returned typ is 'R' for rows 'C' for comps 78 | // The returned char* points to name of the item. 79 | void getPart(int index, int* corner, int* typ, char** name) const; 80 | 81 | // debug print 82 | void print(FILE* f) const; 83 | 84 | protected: 85 | char* name_; 86 | int nameLength_; 87 | char direction_; // H or V 88 | char hasAlign_; 89 | char hasMin_; 90 | char hasMax_; 91 | char hasEqual_; 92 | char corner_; // Bottomleft or Topright 93 | double minMaxEqual_; 94 | int namesAllocated_; // allocated size of names_ and rowOrComp_ 95 | int namesUsed_; // number of entries used in the arrays 96 | char* rowOrComp_; 97 | char** names_; 98 | 99 | defrData *defData; 100 | }; 101 | 102 | 103 | END_LEFDEF_PARSER_NAMESPACE 104 | 105 | USE_LEFDEF_PARSER_NAMESPACE 106 | 107 | #endif 108 | -------------------------------------------------------------------------------- /src/def58/inc/defiProp.hpp: -------------------------------------------------------------------------------- 1 | // ***************************************************************************** 2 | // ***************************************************************************** 3 | // Copyright 2013, Cadence Design Systems 4 | // 5 | // This file is part of the Cadence LEF/DEF Open Source 6 | // Distribution, Product Version 5.8. 7 | // 8 | // Licensed under the Apache License, Version 2.0 (the "License"); 9 | // you may not use this file except in compliance with the License. 10 | // You may obtain a copy of the License at 11 | // 12 | // http://www.apache.org/licenses/LICENSE-2.0 13 | // 14 | // Unless required by applicable law or agreed to in writing, software 15 | // distributed under the License is distributed on an "AS IS" BASIS, 16 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 17 | // implied. See the License for the specific language governing 18 | // permissions and limitations under the License. 19 | // 20 | // For updates, support, or to become part of the LEF/DEF Community, 21 | // check www.openeda.org for details. 22 | // 23 | // $Author: icftcm $ 24 | // $Revision: #8 $ 25 | // $Date: 2016/10/13 $ 26 | // $State: $ 27 | // ***************************************************************************** 28 | // ***************************************************************************** 29 | 30 | #ifndef defiProp_h 31 | #define defiProp_h 32 | 33 | #include "defiKRDefs.hpp" 34 | #include 35 | 36 | BEGIN_LEFDEF_PARSER_NAMESPACE 37 | 38 | class defrData; 39 | 40 | // Struct holds the data for one property. 41 | class defiProp { 42 | public: 43 | defiProp(defrData *data); 44 | void Init(); 45 | 46 | void Destroy(); 47 | ~defiProp(); 48 | 49 | void setPropType(const char* typ, const char* string); 50 | void setRange(double left, double right); 51 | void setNumber(double num); 52 | void setPropInteger(); 53 | void setPropReal(); 54 | void setPropString(); 55 | void setPropQString(const char* string); 56 | void setPropNameMapString(const char* string); 57 | void clear(); 58 | 59 | const char* string() const; 60 | const char* propType() const; 61 | const char* propName() const; 62 | char dataType() const; 63 | // either I:integer R:real S:string Q:quotedstring N:nameMapString 64 | int hasNumber() const; 65 | int hasRange() const; 66 | int hasString() const; 67 | int hasNameMapString() const; 68 | double number() const; 69 | double left() const; 70 | double right() const; 71 | 72 | void bumpSize(int size); 73 | void bumpName(int size); 74 | 75 | void print(FILE* f) const; 76 | 77 | protected: 78 | char* propType_; // "design" ... 79 | char* propName_; // name. 80 | int nameSize_; // allocated size of name. 81 | char hasRange_; // either 0:NO or 1:YES. 82 | char hasNumber_; // either 0:NO or 1:YES. 83 | char hasNameMapString_; 84 | char dataType_; // either I:integer R:real S:string Q:quotedstring. 85 | // N:nameMapString 86 | char* stringData_; // if it is a string the data is here. 87 | int stringLength_; // allocated size of stringData. 88 | double left_, right_; // if it has a range the numbers are here. 89 | double d_; // if it is a real or int the number is here. 90 | 91 | defrData *defData; 92 | }; 93 | 94 | 95 | END_LEFDEF_PARSER_NAMESPACE 96 | 97 | USE_LEFDEF_PARSER_NAMESPACE 98 | 99 | #endif 100 | -------------------------------------------------------------------------------- /src/db/db_cell.cpp: -------------------------------------------------------------------------------- 1 | #include "db.h" 2 | using namespace db; 3 | 4 | #include "../ut/utils.h" 5 | 6 | /***** Cell *****/ 7 | 8 | Cell::~Cell() { 9 | for (Pin* pin : _pins) { 10 | delete pin; 11 | } 12 | } 13 | 14 | Pin* Cell::pin(const string& name) const { 15 | for (Pin* pin : _pins) { 16 | if (pin->type->name() == name) { 17 | return pin; 18 | } 19 | } 20 | return nullptr; 21 | } 22 | 23 | void Cell::ctype(CellType* t) { 24 | if (!t) { 25 | return; 26 | } 27 | if (_type) { 28 | printlog(LOG_ERROR, "type of cell %s already set", _name.c_str()); 29 | return; 30 | } 31 | _type = t; 32 | ++(_type->usedCount); 33 | _pins.resize(_type->pins.size(), nullptr); 34 | for (unsigned i = 0; i != _pins.size(); ++i) { 35 | _pins[i] = new Pin(this, i); 36 | } 37 | } 38 | 39 | int Cell::lx() const { return database.placement().x(const_cast(this)); } 40 | int Cell::ly() const { return database.placement().y(const_cast(this)); } 41 | bool Cell::flipX() const { return database.placement().flipX(const_cast(this)); } 42 | bool Cell::flipY() const { return database.placement().flipY(const_cast(this)); } 43 | int Cell::siteWidth() const { return width() / database.siteW; } 44 | int Cell::siteHeight() const { return height() / database.siteH; } 45 | bool Cell::placed() const { return database.placement().placed(const_cast(this)); } 46 | 47 | void Cell::place(int x, int y) { 48 | if (_fixed) { 49 | printlog(LOG_WARN, "moving fixed cell %s to (%d,%d)", _name.c_str(), x, y); 50 | } 51 | database.placement().place(this, x, y); 52 | } 53 | 54 | void Cell::place(int x, int y, bool flipX, bool flipY) { 55 | if (_fixed) { 56 | printlog(LOG_WARN, "moving fixed cell %s to (%d,%d)", _name.c_str(), x, y); 57 | } 58 | database.placement().place(this, x, y, flipX, flipY); 59 | } 60 | 61 | void Cell::unplace() { 62 | if (_fixed) { 63 | printlog(LOG_WARN, "unplace fixed cell %s", _name.c_str()); 64 | } 65 | database.placement().place(this); 66 | } 67 | 68 | /***** Cell Type *****/ 69 | 70 | CellType::~CellType() { 71 | for (PinType* pin : pins) { 72 | delete pin; 73 | } 74 | } 75 | 76 | PinType* CellType::addPin(const string& name, const char direction, const char type) { 77 | PinType* newpintype = new PinType(name, direction, type); 78 | pins.push_back(newpintype); 79 | return newpintype; 80 | } 81 | 82 | PinType* CellType::getPin(string& name) { 83 | for (int i = 0; i < (int)pins.size(); i++) { 84 | if (pins[i]->name() == name) { 85 | return pins[i]; 86 | } 87 | } 88 | return nullptr; 89 | } 90 | 91 | void CellType::setOrigin(int x, int y) { 92 | _originX = x; 93 | _originY = y; 94 | } 95 | 96 | bool CellType::operator==(const CellType& r) const { 97 | if (width != r.width || height != r.height) { 98 | return false; 99 | } else if (_originX != r.originX() || _originY != r.originY() || _symmetry != r.symmetry() || 100 | pins.size() != r.pins.size()) { 101 | return false; 102 | } else if (edgetypeL != r.edgetypeL || edgetypeR != r.edgetypeR) { 103 | return false; 104 | } else { 105 | // return PinType::comparePin(pins, r.pins); 106 | for (unsigned i = 0; i != pins.size(); ++i) { 107 | if (*pins[i] != *r.pins[i]) { 108 | return false; 109 | } 110 | } 111 | } 112 | return true; 113 | } 114 | -------------------------------------------------------------------------------- /src/db/db_route.cpp: -------------------------------------------------------------------------------- 1 | #include "db.h" 2 | using namespace db; 3 | 4 | #include "../global.h" 5 | 6 | /***** GRGrid *****/ 7 | 8 | void GRGrid::initGCells(int nx, int ny, int nz) { 9 | this->nx = nx; 10 | this->ny = ny; 11 | this->nz = nz; 12 | 13 | gcells.resize(nx, vector>(ny, vector(nz))); 14 | 15 | for (int x = 0; x < nx; x++) { 16 | for (int y = 0; y < ny; y++) { 17 | for (GCell& gcell : gcells[x][y]) { 18 | gcell.lx = gcellL + x * gcellStepX; 19 | gcell.ly = gcellB + y * gcellStepY; 20 | gcell.hx = gcell.lx + gcellStepX; 21 | gcell.hy = gcell.ly + gcellStepY; 22 | } 23 | } 24 | } 25 | } 26 | 27 | float GRGrid::getGCellSupplyH(int x, int y) { 28 | float supplyH = 0; 29 | for (int z = 0; z < nz; z++) { 30 | supplyH += gcells[x][y][z].supplyX; 31 | } 32 | return supplyH; 33 | } 34 | float GRGrid::getGCellSupplyV(int x, int y) { 35 | float supplyV = 0; 36 | for (int z = 0; z < nz; z++) { 37 | supplyV += gcells[x][y][z].supplyY; 38 | } 39 | return supplyV; 40 | } 41 | float GRGrid::getGCellDemandH(int x, int y) { 42 | float demandH = 0; 43 | for (int z = 0; z < nz; z++) { 44 | demandH += gcells[x][y][z].demandX; 45 | } 46 | return demandH; 47 | } 48 | float GRGrid::getGCellDemandV(int x, int y) { 49 | float demandV = 0; 50 | for (int z = 0; z < nz; z++) { 51 | demandV += gcells[x][y][z].demandY; 52 | } 53 | return demandV; 54 | } 55 | GCell* GRGrid::getGCell(int x, int y, int z) { return &gcells[x][y][z]; } 56 | 57 | void GRGrid::initRGrids(int tx, int ty, int nlayer) { 58 | this->tx = tx; 59 | this->ty = ty; 60 | this->tz = (nlayer - 1) / 8 + 1; 61 | 62 | rgrids = (char*)calloc(tx * ty * tz, sizeof(char)); 63 | 64 | long mem = sizeof(char) * tx * ty * tz; 65 | printlog(LOG_DEBUG, "grids = %d x %d x %d", tx, ty, tz); 66 | printlog(LOG_DEBUG, "mem = %s", show_mem_size(mem).c_str()); 67 | } 68 | 69 | void GRGrid::setRGrid(int x, int y, int z, char v) { 70 | int i = x * (ty * tz) + y * tz + z / 8; 71 | int s = z % 8; 72 | if (v == 0) { 73 | rgrids[i] &= ~(1 << s); 74 | } else { 75 | rgrids[i] |= (1 << s); 76 | } 77 | } 78 | 79 | char GRGrid::getRGrid(int x, int y, int z) { 80 | int i = x * (ty * tz) + y * tz + z / 8; 81 | int s = z % 8; 82 | return (rgrids[i] >> s) & 1; 83 | // return (rgrids[x][y][z/8] >> z) & 1; 84 | } 85 | 86 | void GRGrid::addBlockage(int lx, int ly, int hx, int hy, int z) { 87 | int X3Q = trackStepX * 3 / 4; 88 | int Y3Q = trackStepY * 3 / 4; 89 | int XQ = trackStepX / 4; 90 | int YQ = trackStepY / 4; 91 | if (hx < trackL - X3Q || hy < trackB - Y3Q || lx > trackR + X3Q || ly > trackT + Y3Q) { 92 | return; 93 | } 94 | lx = max(trackL, lx); 95 | ly = max(trackB, ly); 96 | hx = min(trackR, hx); 97 | hy = min(trackT, hy); 98 | int startX = (lx - trackL + XQ) / trackStepX; 99 | int startY = (ly - trackB + YQ) / trackStepY; 100 | int endX = (hx - trackL + X3Q - 1) / trackStepX; 101 | int endY = (hy - trackB + X3Q - 1) / trackStepY; 102 | /* 103 | printlog(LOG_INFO, "block=%d:%d %d:%d tracks=%d:%d %d:%d", 104 | lx, hx, ly, hy, startX, endX, startY, endY); 105 | */ 106 | for (int x = startX; x <= endX; x++) { 107 | for (int y = startY; y <= endY; y++) { 108 | setRGrid(x, y, z, (char)0); 109 | } 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /src/lemon/include/lemon/nauty_reader.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C++; indent-tabs-mode: nil; -*- 2 | * 3 | * This file is a part of LEMON, a generic C++ optimization library. 4 | * 5 | * Copyright (C) 2003-2009 6 | * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 | * (Egervary Research Group on Combinatorial Optimization, EGRES). 8 | * 9 | * Permission to use, modify and distribute this software is granted 10 | * provided that this copyright notice appears in all copies. For 11 | * precise terms see the accompanying LICENSE file. 12 | * 13 | * This software is provided "AS IS" with no warranty of any kind, 14 | * express or implied, and with no claim as to its suitability for any 15 | * purpose. 16 | * 17 | */ 18 | 19 | #ifndef LEMON_NAUTY_READER_H 20 | #define LEMON_NAUTY_READER_H 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | /// \ingroup nauty_group 27 | /// \file 28 | /// \brief Nauty file reader. 29 | 30 | namespace lemon { 31 | 32 | /// \ingroup nauty_group 33 | /// 34 | /// \brief Nauty file reader 35 | /// 36 | /// The \e geng program is in the \e gtools suite of the nauty 37 | /// package. This tool can generate all non-isomorphic undirected 38 | /// graphs of several classes with given node number (e.g. 39 | /// general, connected, biconnected, triangle-free, 4-cycle-free, 40 | /// bipartite and graphs with given edge number and degree 41 | /// constraints). This function reads a \e nauty \e graph6 \e format 42 | /// line from the given stream and builds it in the given graph. 43 | /// 44 | /// The site of nauty package: http://cs.anu.edu.au/~bdm/nauty/ 45 | /// 46 | /// For example, the number of all non-isomorphic planar graphs 47 | /// can be computed with the following code. 48 | ///\code 49 | /// int num = 0; 50 | /// SmartGraph graph; 51 | /// while (readNautyGraph(graph, std::cin)) { 52 | /// PlanarityChecking pc(graph); 53 | /// if (pc.run()) ++num; 54 | /// } 55 | /// std::cout << "Number of planar graphs: " << num << std::endl; 56 | ///\endcode 57 | /// 58 | /// The nauty files are quite huge, therefore instead of the direct 59 | /// file generation pipelining is recommended. For example, 60 | ///\code 61 | /// ./geng -c 10 | ./num_of_planar_graphs 62 | ///\endcode 63 | template 64 | std::istream& readNautyGraph(Graph& graph, std::istream& is = std::cin) { 65 | graph.clear(); 66 | 67 | std::string line; 68 | if (getline(is, line)) { 69 | int index = 0; 70 | 71 | int n; 72 | 73 | if (line[index] == '>') { 74 | index += 10; 75 | } 76 | 77 | char c = line[index++]; c -= 63; 78 | if (c != 63) { 79 | n = int(c); 80 | } else { 81 | c = line[index++]; c -= 63; 82 | n = (int(c) << 12); 83 | c = line[index++]; c -= 63; 84 | n |= (int(c) << 6); 85 | c = line[index++]; c -= 63; 86 | n |= int(c); 87 | } 88 | 89 | std::vector nodes; 90 | for (int i = 0; i < n; ++i) { 91 | nodes.push_back(graph.addNode()); 92 | } 93 | 94 | int bit = -1; 95 | for (int j = 0; j < n; ++j) { 96 | for (int i = 0; i < j; ++i) { 97 | if (bit == -1) { 98 | c = line[index++]; c -= 63; 99 | bit = 5; 100 | } 101 | bool b = (c & (1 << (bit--))) != 0; 102 | 103 | if (b) { 104 | graph.addEdge(nodes[i], nodes[j]); 105 | } 106 | } 107 | } 108 | } 109 | return is; 110 | } 111 | } 112 | 113 | #endif 114 | -------------------------------------------------------------------------------- /src/def58/inc/defiSite.hpp: -------------------------------------------------------------------------------- 1 | // ***************************************************************************** 2 | // ***************************************************************************** 3 | // Copyright 2013, Cadence Design Systems 4 | // 5 | // This file is part of the Cadence LEF/DEF Open Source 6 | // Distribution, Product Version 5.8. 7 | // 8 | // Licensed under the Apache License, Version 2.0 (the "License"); 9 | // you may not use this file except in compliance with the License. 10 | // You may obtain a copy of the License at 11 | // 12 | // http://www.apache.org/licenses/LICENSE-2.0 13 | // 14 | // Unless required by applicable law or agreed to in writing, software 15 | // distributed under the License is distributed on an "AS IS" BASIS, 16 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 17 | // implied. See the License for the specific language governing 18 | // permissions and limitations under the License. 19 | // 20 | // For updates, support, or to become part of the LEF/DEF Community, 21 | // check www.openeda.org for details. 22 | // 23 | // $Author: icftcm $ 24 | // $Revision: #8 $ 25 | // $Date: 2016/10/13 $ 26 | // $State: $ 27 | // ***************************************************************************** 28 | // ***************************************************************************** 29 | 30 | #ifndef defiSite_h 31 | #define defiSite_h 32 | 33 | #include "defiKRDefs.hpp" 34 | #include "defiMisc.hpp" 35 | #include 36 | 37 | BEGIN_LEFDEF_PARSER_NAMESPACE 38 | 39 | class defrData; 40 | 41 | /* 42 | * Struct holds the data for one site. 43 | * It is also used for a canplace and cannotoccupy. 44 | */ 45 | class defiSite { 46 | public: 47 | defiSite(defrData *data); 48 | void Init(); 49 | 50 | ~defiSite(); 51 | void Destroy(); 52 | 53 | void clear(); 54 | 55 | void setName(const char* name); 56 | void setLocation(double xorg, double yorg); 57 | void setOrient(int orient); 58 | void setDo(double x_num, double y_num, double x_step, double y_step); 59 | 60 | double x_num() const; 61 | double y_num() const; 62 | double x_step() const; 63 | double y_step() const; 64 | double x_orig() const; 65 | double y_orig() const; 66 | int orient() const; 67 | const char* orientStr() const; 68 | const char* name() const; 69 | 70 | void print(FILE* f) const; 71 | 72 | void bumpName(int size); 73 | 74 | protected: 75 | char* siteName_; // Name of this. 76 | int nameSize_; // allocated size of siteName_ 77 | double x_orig_, y_orig_; // Origin 78 | double x_step_, y_step_; // Array step size. 79 | double x_num_, y_num_; 80 | int orient_; // orientation 81 | 82 | defrData *defData; 83 | }; 84 | 85 | 86 | 87 | /* Struct holds the data for a Box */ 88 | class defiBox { 89 | public: 90 | // Use the default destructor and constructor. 91 | // 5.6 changed to use it own constructor & destructor 92 | 93 | defiBox(); 94 | void Init(); 95 | void Destroy(); 96 | ~defiBox(); 97 | 98 | // NOTE: 5.6 99 | // The following methods are still here for backward compatibility 100 | // For new reader they should use numPoints & getPoint to get the 101 | // data. 102 | int xl() const; 103 | int yl() const; 104 | int xh() const; 105 | int yh() const; 106 | 107 | void addPoint(defiGeometries* geom); 108 | defiPoints getPoint() const; 109 | 110 | void print(FILE* f) const; 111 | 112 | protected: 113 | int xl_, yl_; 114 | int xh_, yh_; 115 | defiPoints* points_; // 5.6 116 | }; 117 | 118 | 119 | END_LEFDEF_PARSER_NAMESPACE 120 | 121 | USE_LEFDEF_PARSER_NAMESPACE 122 | 123 | #endif 124 | -------------------------------------------------------------------------------- /src/def58/inc/defiGroup.hpp: -------------------------------------------------------------------------------- 1 | // ***************************************************************************** 2 | // ***************************************************************************** 3 | // Copyright 2013, Cadence Design Systems 4 | // 5 | // This file is part of the Cadence LEF/DEF Open Source 6 | // Distribution, Product Version 5.8. 7 | // 8 | // Licensed under the Apache License, Version 2.0 (the "License"); 9 | // you may not use this file except in compliance with the License. 10 | // You may obtain a copy of the License at 11 | // 12 | // http://www.apache.org/licenses/LICENSE-2.0 13 | // 14 | // Unless required by applicable law or agreed to in writing, software 15 | // distributed under the License is distributed on an "AS IS" BASIS, 16 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 17 | // implied. See the License for the specific language governing 18 | // permissions and limitations under the License. 19 | // 20 | // For updates, support, or to become part of the LEF/DEF Community, 21 | // check www.openeda.org for details. 22 | // 23 | // $Author: icftcm $ 24 | // $Revision: #8 $ 25 | // $Date: 2016/10/13 $ 26 | // $State: $ 27 | // ***************************************************************************** 28 | // ***************************************************************************** 29 | 30 | #ifndef defiGroup_h 31 | #define defiGroup_h 32 | 33 | #include 34 | #include "defiKRDefs.hpp" 35 | 36 | BEGIN_LEFDEF_PARSER_NAMESPACE 37 | 38 | class defrData; 39 | 40 | // Struct holds the data for one property. 41 | 42 | class defiGroup { 43 | public: 44 | defiGroup(defrData *data); 45 | void Init(); 46 | 47 | void Destroy(); 48 | ~defiGroup(); 49 | 50 | void clear(); 51 | 52 | void setup(const char* name); 53 | void addProperty(const char* name, const char* value, const char type); 54 | void addNumProperty(const char* name, const double d, 55 | const char* value, const char type); 56 | void addRegionRect(int xl, int yl, int xh, int yh); 57 | void setRegionName(const char* name); 58 | void setMaxX(int x); 59 | void setMaxY(int y); 60 | void setPerim(int p); 61 | 62 | const char* name() const; 63 | const char* regionName() const; 64 | int hasRegionBox() const; 65 | int hasRegionName() const; 66 | int hasMaxX() const; 67 | int hasMaxY() const; 68 | int hasPerim() const; 69 | void regionRects(int* size, int** xl, int**yl, int** xh, int** yh) const; 70 | int maxX() const; 71 | int maxY() const; 72 | int perim() const; 73 | 74 | int numProps() const; 75 | const char* propName(int index) const; 76 | const char* propValue(int index) const; 77 | double propNumber(int index) const; 78 | const char propType(int index) const; 79 | int propIsNumber(int index) const; 80 | int propIsString(int index) const; 81 | 82 | // debug print 83 | void print(FILE* f) const; 84 | 85 | protected: 86 | char* name_; 87 | int nameLength_; 88 | char* region_; 89 | int regionLength_; 90 | 91 | int rectsAllocated_; 92 | int numRects_; 93 | int* xl_; 94 | int* yl_; 95 | int* xh_; 96 | int* yh_; 97 | 98 | int maxX_; 99 | int maxY_; 100 | int perim_; 101 | char hasRegionBox_; 102 | char hasRegionName_; 103 | char hasPerim_; 104 | char hasMaxX_; 105 | char hasMaxY_; 106 | 107 | int numProps_; 108 | int propsAllocated_; 109 | char** propNames_; 110 | char** propValues_; 111 | double* propDValues_; 112 | char* propTypes_; 113 | 114 | defrData *defData; 115 | }; 116 | 117 | 118 | END_LEFDEF_PARSER_NAMESPACE 119 | 120 | USE_LEFDEF_PARSER_NAMESPACE 121 | 122 | #endif 123 | -------------------------------------------------------------------------------- /src/lemon/include/lemon/bits/enable_if.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C++; indent-tabs-mode: nil; -*- 2 | * 3 | * This file is a part of LEMON, a generic C++ optimization library. 4 | * 5 | * Copyright (C) 2003-2009 6 | * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 | * (Egervary Research Group on Combinatorial Optimization, EGRES). 8 | * 9 | * Permission to use, modify and distribute this software is granted 10 | * provided that this copyright notice appears in all copies. For 11 | * precise terms see the accompanying LICENSE file. 12 | * 13 | * This software is provided "AS IS" with no warranty of any kind, 14 | * express or implied, and with no claim as to its suitability for any 15 | * purpose. 16 | * 17 | */ 18 | 19 | // This file contains a modified version of the enable_if library from BOOST. 20 | // See the appropriate copyright notice below. 21 | 22 | // Boost enable_if library 23 | 24 | // Copyright 2003 (c) The Trustees of Indiana University. 25 | 26 | // Use, modification, and distribution is subject to the Boost Software 27 | // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at 28 | // http://www.boost.org/LICENSE_1_0.txt) 29 | 30 | // Authors: Jaakko Jarvi (jajarvi at osl.iu.edu) 31 | // Jeremiah Willcock (jewillco at osl.iu.edu) 32 | // Andrew Lumsdaine (lums at osl.iu.edu) 33 | 34 | 35 | #ifndef LEMON_BITS_ENABLE_IF_H 36 | #define LEMON_BITS_ENABLE_IF_H 37 | 38 | //\file 39 | //\brief Miscellaneous basic utilities 40 | 41 | namespace lemon 42 | { 43 | 44 | // Basic type for defining "tags". A "YES" condition for \c enable_if. 45 | 46 | // Basic type for defining "tags". A "YES" condition for \c enable_if. 47 | // 48 | //\sa False 49 | struct True { 50 | //\e 51 | static const bool value = true; 52 | }; 53 | 54 | // Basic type for defining "tags". A "NO" condition for \c enable_if. 55 | 56 | // Basic type for defining "tags". A "NO" condition for \c enable_if. 57 | // 58 | //\sa True 59 | struct False { 60 | //\e 61 | static const bool value = false; 62 | }; 63 | 64 | 65 | 66 | template 67 | struct Wrap { 68 | const T &value; 69 | Wrap(const T &t) : value(t) {} 70 | }; 71 | 72 | /**************** dummy class to avoid ambiguity ****************/ 73 | 74 | template struct dummy { dummy(int) {} }; 75 | 76 | /**************** enable_if from BOOST ****************/ 77 | 78 | template 79 | struct exists { 80 | typedef T type; 81 | }; 82 | 83 | 84 | template 85 | struct enable_if_c { 86 | typedef T type; 87 | }; 88 | 89 | template 90 | struct enable_if_c {}; 91 | 92 | template 93 | struct enable_if : public enable_if_c {}; 94 | 95 | template 96 | struct lazy_enable_if_c { 97 | typedef typename T::type type; 98 | }; 99 | 100 | template 101 | struct lazy_enable_if_c {}; 102 | 103 | template 104 | struct lazy_enable_if : public lazy_enable_if_c {}; 105 | 106 | 107 | template 108 | struct disable_if_c { 109 | typedef T type; 110 | }; 111 | 112 | template 113 | struct disable_if_c {}; 114 | 115 | template 116 | struct disable_if : public disable_if_c {}; 117 | 118 | template 119 | struct lazy_disable_if_c { 120 | typedef typename T::type type; 121 | }; 122 | 123 | template 124 | struct lazy_disable_if_c {}; 125 | 126 | template 127 | struct lazy_disable_if : public lazy_disable_if_c {}; 128 | 129 | } // namespace lemon 130 | 131 | #endif 132 | -------------------------------------------------------------------------------- /src/def58/inc/defiIOTiming.hpp: -------------------------------------------------------------------------------- 1 | // ***************************************************************************** 2 | // ***************************************************************************** 3 | // Copyright 2013, Cadence Design Systems 4 | // 5 | // This file is part of the Cadence LEF/DEF Open Source 6 | // Distribution, Product Version 5.8. 7 | // 8 | // Licensed under the Apache License, Version 2.0 (the "License"); 9 | // you may not use this file except in compliance with the License. 10 | // You may obtain a copy of the License at 11 | // 12 | // http://www.apache.org/licenses/LICENSE-2.0 13 | // 14 | // Unless required by applicable law or agreed to in writing, software 15 | // distributed under the License is distributed on an "AS IS" BASIS, 16 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 17 | // implied. See the License for the specific language governing 18 | // permissions and limitations under the License. 19 | // 20 | // For updates, support, or to become part of the LEF/DEF Community, 21 | // check www.openeda.org for details. 22 | // 23 | // $Author: icftcm $ 24 | // $Revision: #8 $ 25 | // $Date: 2016/10/13 $ 26 | // $State: $ 27 | // ***************************************************************************** 28 | // ***************************************************************************** 29 | 30 | #ifndef defiIOTiming_h 31 | #define defiIOTiming_h 32 | 33 | #include 34 | #include "defiKRDefs.hpp" 35 | 36 | BEGIN_LEFDEF_PARSER_NAMESPACE 37 | 38 | class defrData; 39 | 40 | class defiIOTiming { 41 | public: 42 | defiIOTiming(defrData *data); 43 | void Init(); 44 | 45 | void Destroy(); 46 | ~defiIOTiming(); 47 | 48 | void clear(); 49 | 50 | void setName(const char* inst, const char* pin); 51 | void setVariable(const char* riseFall, double min, double max); 52 | void setSlewRate(const char* riseFall, double min, double max); 53 | void setCapacitance(double num); 54 | void setDriveCell(const char* name); 55 | void setFrom(const char* name); 56 | void setTo(const char* name); 57 | void setParallel(double num); 58 | 59 | 60 | int hasVariableRise() const; 61 | int hasVariableFall() const; 62 | int hasSlewRise() const; 63 | int hasSlewFall() const; 64 | int hasCapacitance() const; 65 | int hasDriveCell() const; 66 | int hasFrom() const; 67 | int hasTo() const; 68 | int hasParallel() const; 69 | 70 | const char* inst() const; 71 | const char* pin() const; 72 | double variableFallMin() const; 73 | double variableRiseMin() const; 74 | double variableFallMax() const; 75 | double variableRiseMax() const; 76 | double slewFallMin() const; 77 | double slewRiseMin() const; 78 | double slewFallMax() const; 79 | double slewRiseMax() const; 80 | double capacitance() const; 81 | const char* driveCell() const; 82 | const char* from() const; 83 | const char* to() const; 84 | double parallel() const; 85 | 86 | // debug print 87 | void print(FILE* f) const; 88 | 89 | protected: 90 | char* inst_; 91 | int instLength_; 92 | char* pin_; 93 | int pinLength_; 94 | char* from_; 95 | int fromLength_; 96 | char* to_; 97 | int toLength_; 98 | char* driveCell_; 99 | char driveCellLength_; 100 | char hasVariableRise_; 101 | char hasVariableFall_; 102 | char hasSlewRise_; 103 | char hasSlewFall_; 104 | char hasCapacitance_; 105 | char hasDriveCell_; 106 | char hasFrom_; 107 | char hasTo_; 108 | char hasParallel_; 109 | double variableFallMin_; 110 | double variableRiseMin_; 111 | double variableFallMax_; 112 | double variableRiseMax_; 113 | double slewFallMin_; 114 | double slewRiseMin_; 115 | double slewFallMax_; 116 | double slewRiseMax_; 117 | double capacitance_; 118 | double parallel_; 119 | 120 | defrData *defData; 121 | }; 122 | 123 | 124 | END_LEFDEF_PARSER_NAMESPACE 125 | 126 | USE_LEFDEF_PARSER_NAMESPACE 127 | 128 | #endif 129 | -------------------------------------------------------------------------------- /src/db/db_net.cpp: -------------------------------------------------------------------------------- 1 | #include "db.h" 2 | using namespace db; 3 | 4 | #include "../ut/utils.h" 5 | 6 | /***** NetRouteNode *****/ 7 | 8 | NetRouteNode::NetRouteNode(const Layer* layer, const int x, const int y, const int z) 9 | : _layer(layer), x(x), y(y), z(z) {} 10 | 11 | /***** NetRouteSegment *****/ 12 | 13 | NetRouteSegment::NetRouteSegment(const unsigned fromi, const unsigned toi, const char dir, const unsigned len) 14 | : fromNode(fromi), toNode(toi) { 15 | if (len) { 16 | path.emplace_back(dir, len); 17 | } 18 | } 19 | 20 | long long NetRouteSegment::length() const { 21 | long long len = 0; 22 | for (const auto& [dir, plen] : path) { 23 | if (dir != 'U' && dir != 'D') { 24 | len += plen; 25 | } 26 | } 27 | return len; 28 | } 29 | 30 | /***** NetRouting *****/ 31 | 32 | void NetRouting::addWire(const Layer* layer, 33 | const int fromx, 34 | const int fromy, 35 | const int fromz, 36 | const int tox, 37 | const int toy, 38 | const int toz) { 39 | NetRouteNode fromNode(layer, fromx, fromy, fromz); 40 | NetRouteNode toNode(layer, tox, toy, toz); 41 | 42 | int fromi = -1; 43 | int toi = -1; 44 | for (unsigned i = 0; i != nodes.size(); ++i) { 45 | if (nodes[i] == fromNode) { 46 | fromi = i; 47 | } 48 | if (nodes[i] == toNode) { 49 | toi = i; 50 | } 51 | } 52 | if (fromi < 0) { 53 | fromi = nodes.size(); 54 | nodes.push_back(fromNode); 55 | } 56 | if (toi < 0) { 57 | toi = nodes.size(); 58 | nodes.push_back(toNode); 59 | } 60 | 61 | if (fromi == toi) { 62 | return; 63 | } 64 | 65 | char dir = '\0'; 66 | unsigned len = 0; 67 | if (fromx < tox) { 68 | dir = 'E'; 69 | len = tox - fromx; 70 | } else if (fromx > tox) { 71 | dir = 'W'; 72 | len = fromx - tox; 73 | } else if (fromy < toy) { 74 | dir = 'N'; 75 | len = toy - fromy; 76 | } else { 77 | dir = 'S'; 78 | len = fromy - toy; 79 | } 80 | 81 | segments.emplace_back(fromi, toi, dir, len); 82 | } 83 | 84 | void NetRouting::clear() { 85 | segments.clear(); 86 | nodes.clear(); 87 | } 88 | 89 | long long NetRouting::length() const { 90 | long long len = 0; 91 | for (const NetRouteSegment& seg : segments) { 92 | len += seg.length(); 93 | } 94 | return len; 95 | } 96 | 97 | /***** Net *****/ 98 | 99 | void Net::addPin(Pin* pin) { 100 | if (pin->type->direction() == 'o' && pins.size()) { 101 | Pin* firstPin = pins[0]; 102 | pins[0] = pin; 103 | pins.push_back(firstPin); 104 | } else { 105 | pins.push_back(pin); 106 | } 107 | } 108 | 109 | /***** PowerNet *****/ 110 | 111 | void PowerNet::addRail(SNet* snet, int lx, int hx, int y) { 112 | map::iterator rail = rails.find(y); 113 | if (rail != rails.end() && rail->second != snet) { 114 | printlog(LOG_ERROR, "rail %s already exists at y=%d , new rail %s is from %d to %d", rail->second->name.c_str(), 115 | y, snet->name.c_str(), 116 | lx, 117 | hx); 118 | return; 119 | 120 | } 121 | rails.emplace(y, snet); 122 | } 123 | 124 | bool PowerNet::getRowPower(int ly, int hy, char& topPower, char& botPower) { 125 | bool valid = true; 126 | topPower = 'x'; 127 | botPower = 'x'; 128 | map::iterator topRail = rails.find(hy); 129 | if (topRail != rails.end()) { 130 | topPower = topRail->second->type; 131 | } else { 132 | valid = false; 133 | } 134 | map::iterator botRail = rails.find(ly); 135 | if (botRail != rails.end()) { 136 | botPower = botRail->second->type; 137 | } else { 138 | valid = false; 139 | } 140 | return valid; 141 | } 142 | 143 | -------------------------------------------------------------------------------- /src/db/db_cell.h: -------------------------------------------------------------------------------- 1 | #ifndef _DB_CELL_H_ 2 | #define _DB_CELL_H_ 3 | 4 | #include "../sta/sta.h" 5 | 6 | namespace db { 7 | class CellType { 8 | friend class Database; 9 | 10 | private: 11 | int _originX = 0; 12 | int _originY = 0; 13 | // X=1 Y=2 R90=4 (can be combined) 14 | char _symmetry = 0; 15 | string _siteName = ""; 16 | char _botPower = 'x'; 17 | char _topPower = 'x'; 18 | vector _obs; 19 | 20 | int _libcell = -1; 21 | 22 | public: 23 | std::string name = ""; 24 | char cls = 'x'; 25 | bool stdcell = false; 26 | int width = 0; 27 | int height = 0; 28 | vector pins; 29 | int edgetypeL = 0; 30 | int edgetypeR = 0; 31 | int usedCount = 0; 32 | 33 | CellType(const string& name, int libcell) : _libcell(libcell), name(name) {} 34 | ~CellType(); 35 | 36 | PinType* addPin(const string& name, const char direction, const char type); 37 | void addPin(PinType& pintype); 38 | 39 | template 40 | void addObs(Args&&... args) { 41 | _obs.emplace_back(args...); 42 | } 43 | 44 | PinType* getPin(string& name); 45 | 46 | int originX() const { return _originX; } 47 | int originY() const { return _originY; } 48 | char symmetry() const { return _symmetry; } 49 | char botPower() const { return _botPower; } 50 | char topPower() const { return _topPower; } 51 | const std::vector& obs() const { return _obs; } 52 | int libcell() const { return _libcell; } 53 | 54 | void setOrigin(int x, int y); 55 | void setXSymmetry() { _symmetry &= 1; } 56 | void setYSymmetry() { _symmetry &= 2; } 57 | void set90Symmetry() { _symmetry &= 4; } 58 | void siteName(const std::string& name) { _siteName = name; } 59 | 60 | bool operator==(const CellType& r) const; 61 | bool operator!=(const CellType& r) const { return !(*this == r); } 62 | }; 63 | 64 | class Cell : virtual public Drawable { 65 | private: 66 | string _name = ""; 67 | int _spaceL = 0; 68 | int _spaceR = 0; 69 | int _spaceB = 0; 70 | int _spaceT = 0; 71 | bool _fixed = false; 72 | CellType* _type = nullptr; 73 | std::vector _pins; 74 | 75 | public: 76 | bool highlighted = false; 77 | Region* region = nullptr; 78 | 79 | Cell(const string& name = "", CellType* t = nullptr) : _name(name) { ctype(t); } 80 | ~Cell(); 81 | 82 | const std::string& name() const { return _name; } 83 | Pin* pin(const std::string& name) const; 84 | Pin* pin(unsigned i) const { return _pins[i]; } 85 | CellType* ctype() const { return _type; } 86 | void ctype(CellType* t); 87 | int lx() const; 88 | int ly() const; 89 | int hx() const { return lx() + width(); } 90 | int hy() const { return ly() + height(); } 91 | int cx() const { return lx() + width() / 2; } 92 | int cy() const { return ly() + height() / 2; } 93 | bool flipX() const; 94 | bool flipY() const; 95 | int width() const { return _type->width + _spaceL + _spaceR; } 96 | int height() const { return _type->height + _spaceB + _spaceT; } 97 | int siteWidth() const; 98 | int siteHeight() const; 99 | bool fixed() const { return _fixed; } 100 | void fixed(bool fix) { _fixed = fix; } 101 | bool placed() const; 102 | void place(int x, int y); 103 | void place(int x, int y, bool flipX, bool flipY); 104 | void unplace(); 105 | unsigned numPins() const { return _pins.size(); } 106 | 107 | /*Drawable*/ 108 | int globalX() const; 109 | int globalY() const; 110 | int localX() const; 111 | int localY() const; 112 | int boundL() const; 113 | int boundR() const; 114 | int boundB() const; 115 | int boundT() const; 116 | 117 | Drawable* parent() const; 118 | void draw(Visualizer* v) const; 119 | 120 | friend ostream& operator<<(ostream& os, const Cell& c) { 121 | return os << c._name << "\t(" << c.lx() << ", " << c.ly() << ')'; 122 | } 123 | }; 124 | } // namespace db 125 | 126 | #endif 127 | -------------------------------------------------------------------------------- /src/gp/gp.cpp: -------------------------------------------------------------------------------- 1 | #include "gp.h" 2 | #include "../global.h" 3 | #include "../tcl/register.h" 4 | #include "gp_data.h" 5 | #include "gp_global.h" 6 | #include "gp_main.h" 7 | 8 | using namespace gp; 9 | 10 | std::string GPModule::_name = "gp"; 11 | 12 | int GPModule::NumThreads = 2; 13 | int GPModule::InitIterations = 6; // xbar: 0 14 | int GPModule::MainWLIterations = 10; 15 | int GPModule::MainCongIterations = 40; 16 | int GPModule::MainGRIterations = 4; 17 | int GPModule::LowerBoundIterations = 6; 18 | int GPModule::UpperBoundIterations = 5; 19 | int GPModule::FinalIterations = 1; 20 | 21 | double GPModule::PseudoNetWeightBegin = 0.1; 22 | double GPModule::PseudoNetWeightEnd = 2.0; 23 | double GPModule::TargetDensityBegin = 0.8; 24 | double GPModule::TargetDensityEnd = 0.8; 25 | std::string GPModule::InitNetModel = "B2B"; 26 | std::string GPModule::MainNetModel = "B2B"; 27 | 28 | bool GPModule::EnableFence = true; 29 | bool GPModule::EnableKeepInflate = false; 30 | bool GPModule::Experimental = false; 31 | 32 | void GPModule::registerCommands() { ripple::Shell::addCommand(this, "gplace", GPModule::gplace); } 33 | void GPModule::registerOptions() { 34 | ripple::Shell::addOption(this, "numThreads", &NumThreads); 35 | ripple::Shell::addOption(this, "initIter", &InitIterations); 36 | ripple::Shell::addOption(this, "mainWireIter", &MainWLIterations); 37 | ripple::Shell::addOption(this, "mainCongIter", &MainCongIterations); 38 | ripple::Shell::addOption(this, "mainGRIter", &MainGRIterations); 39 | ripple::Shell::addOption(this, "lbIter", &LowerBoundIterations); 40 | ripple::Shell::addOption(this, "ubIter", &UpperBoundIterations); 41 | ripple::Shell::addOption(this, "finalIter", &FinalIterations); 42 | ripple::Shell::addOption(this, "pseudoNetWeightBegin", &PseudoNetWeightBegin); 43 | ripple::Shell::addOption(this, "pseudoNetWeightEnd", &PseudoNetWeightEnd); 44 | ripple::Shell::addOption(this, "targetDensityBegin", &TargetDensityBegin); 45 | ripple::Shell::addOption(this, "targetDensityEnd", &TargetDensityEnd); 46 | ripple::Shell::addOption(this, "initNetModel", &InitNetModel); 47 | ripple::Shell::addOption(this, "mainNetModel", &MainNetModel); 48 | ripple::Shell::addOption(this, "enableFence", &EnableFence); 49 | ripple::Shell::addOption(this, "enableKeepInflate", &EnableKeepInflate); 50 | ripple::Shell::addOption(this, "experimental", &Experimental); 51 | } 52 | void GPModule::showOptions() const { 53 | printlog(LOG_INFO, "numThreads : %d", NumThreads); 54 | printlog(LOG_INFO, "initIter : %d", InitIterations); 55 | printlog(LOG_INFO, "mainWireIter : %d", MainWLIterations); 56 | printlog(LOG_INFO, "mainCongIter : %d", MainCongIterations); 57 | printlog(LOG_INFO, "mainGRIter : %d", MainGRIterations); 58 | printlog(LOG_INFO, "lbIter : %d", LowerBoundIterations); 59 | printlog(LOG_INFO, "ubIter : %d", UpperBoundIterations); 60 | printlog(LOG_INFO, "finalIter : %d", FinalIterations); 61 | printlog(LOG_INFO, "pseudoNetWeightBegin : %.2lf", PseudoNetWeightBegin); 62 | printlog(LOG_INFO, "pseudoNetWeightEnd : %.2lf", PseudoNetWeightEnd); 63 | printlog(LOG_INFO, "targetDensityBegin : %.2lf", TargetDensityBegin); 64 | printlog(LOG_INFO, "targetDensityEnd : %.2lf", TargetDensityEnd); 65 | printlog(LOG_INFO, "initNetModel : %s", InitNetModel.c_str()); 66 | printlog(LOG_INFO, "mainNetModel : %s", MainNetModel.c_str()); 67 | printlog(LOG_INFO, "enableFence : %s", EnableFence ? "true" : "false"); 68 | printlog(LOG_INFO, "enableKeepInflate : %s", EnableKeepInflate ? "true" : "false"); 69 | printlog(LOG_INFO, "experimental : %s", Experimental ? "true" : "false"); 70 | } 71 | 72 | bool GPModule::gplace(ripple::ShellOptions& args, ripple::ShellCmdReturn& ret) { 73 | gp_copy_in(true); 74 | gp_main(); 75 | gp_copy_out(); 76 | return true; 77 | } 78 | 79 | bool GPModule::gplace() { 80 | #ifndef NDEBUG 81 | ripple::Shell::showOptions(_name); 82 | #endif 83 | 84 | gp_copy_in(true); 85 | gp_main(); 86 | gp_copy_out(); 87 | return true; 88 | } 89 | -------------------------------------------------------------------------------- /src/vi/draw.h: -------------------------------------------------------------------------------- 1 | #ifndef _VI_DRAW_H_ 2 | #define _VI_DRAW_H_ 3 | 4 | #ifdef LIBGD 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #endif 14 | 15 | #include 16 | using namespace std; 17 | 18 | namespace vi { 19 | 20 | class Color { 21 | public: 22 | unsigned char a = 0; 23 | unsigned char r = 0; 24 | unsigned char g = 0; 25 | unsigned char b = 0; 26 | 27 | // #00000000 28 | static const Color BLACK; 29 | // #00404040 30 | static const Color VERY_DARK_GRAY; 31 | // #00808080 32 | static const Color DARK_GRAY; 33 | // #00DADADA 34 | static const Color VERY_LIGHT_GRAY; 35 | // #00FFFFFF 36 | static const Color WHITE; 37 | // #0068372B 38 | static const Color VERY_DARK_DESATURATED_RED; 39 | // #00B1001C 40 | static const Color OMNI_LIGHT_CAYENNE; 41 | // #00D16E57 42 | static const Color MODERATE_RED; 43 | // #00F7788A 44 | static const Color OMNI_SALMON; 45 | static const Color OMNI_SALMON5; 46 | // #00FF0000 47 | static const Color PURE_RED; 48 | // #0068BC36 49 | static const Color OMNI_FERN; 50 | static const Color OMNI_FERN5; 51 | // #0037682B 52 | static const Color VERY_DARK_DESATURATED_LIME_GREEN; 53 | // #006ED157 54 | static const Color MODERATE_LIME_GREEN; 55 | // #0000BFC0 56 | static const Color OMNI_LIGHT_TEAL; 57 | static const Color OMNI_LIGHT_TEAL5; 58 | // #003A8EED 59 | static const Color OMNI_DEEP_SKY_BLUE; 60 | static const Color OMNI_DEEP_SKY_BLUE5; 61 | // #000000FF 62 | static const Color PURE_BLUE; 63 | static const Color PURE_BLUE5; 64 | 65 | Color(); 66 | Color(int a, int r, int g, int b); 67 | Color(int r, int g, int b); 68 | Color(unsigned int color); 69 | }; 70 | 71 | class ColorScale { 72 | private: 73 | map keys; 74 | 75 | public: 76 | ColorScale() {} 77 | 78 | void addColor(double value, Color color) { keys[value] = color; } 79 | Color getColor(double value); 80 | 81 | void setTransition(Color color0, Color color1); 82 | 83 | void setDefaultRainbow(); 84 | void setDefaultBlackYellowRed(); 85 | }; 86 | 87 | class Canvas { 88 | private: 89 | 90 | #ifdef LIBGD 91 | gdImagePtr _image; 92 | gdFontPtr _font; 93 | #endif 94 | 95 | int _lineColor; 96 | int _fillColor; 97 | int _lineSize; 98 | 99 | protected: 100 | double _lx, _ly; 101 | double _hx, _hy; 102 | int _imgw; 103 | int _imgh; 104 | bool _fx; 105 | bool _fy; 106 | 107 | private: 108 | int getImgX(double x); 109 | int getImgY(double y); 110 | 111 | public: 112 | enum Font { 113 | FontTiny, 114 | FontSmall, 115 | FontMediumBold, 116 | FontLarge, 117 | FontGiant 118 | }; 119 | 120 | Canvas(); 121 | Canvas(int w, int h, bool fx = false, bool fy = false); 122 | Canvas(int w, int h, double lx, double ly, double hx, double hy, bool fx = false, bool fy = true); 123 | ~Canvas(); 124 | 125 | void SetViewport(double lx, double ly, double hx, double hy); 126 | void SetWindow(int w, int h); 127 | void Init(); 128 | void Free(); 129 | 130 | void Clear(); 131 | void Clear(Color color); 132 | 133 | void DrawLine(double x1, double y1, double x2, double y2); 134 | void DrawRect(double x1, double y1, double x2, double y2, bool fill = true, bool line = true); 135 | void DrawPoint(double x, double y, int size = 1); 136 | void DrawString(string str, double x, double y); 137 | void DrawNumber(int num, double x, double y); 138 | void DrawNumber(double num, double x, double y, int precision = 2); 139 | 140 | void SetLineColor(Color color); 141 | 142 | #ifdef LIBGD 143 | void SetFillColor(Color color) { _fillColor = gdImageColorAllocateAlpha(_image, color.r, color.g, color.b, color.a); } 144 | #endif 145 | 146 | void SetLineWidth(int size); 147 | void SetFont(Font size); 148 | 149 | void Save(string file); 150 | }; 151 | } 152 | 153 | #endif 154 | -------------------------------------------------------------------------------- /src/def58/inc/defiFill.hpp: -------------------------------------------------------------------------------- 1 | // ***************************************************************************** 2 | // ***************************************************************************** 3 | // Copyright 2013, Cadence Design Systems 4 | // 5 | // This file is part of the Cadence LEF/DEF Open Source 6 | // Distribution, Product Version 5.8. 7 | // 8 | // Licensed under the Apache License, Version 2.0 (the "License"); 9 | // you may not use this file except in compliance with the License. 10 | // You may obtain a copy of the License at 11 | // 12 | // http://www.apache.org/licenses/LICENSE-2.0 13 | // 14 | // Unless required by applicable law or agreed to in writing, software 15 | // distributed under the License is distributed on an "AS IS" BASIS, 16 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 17 | // implied. See the License for the specific language governing 18 | // permissions and limitations under the License. 19 | // 20 | // For updates, support, or to become part of the LEF/DEF Community, 21 | // check www.openeda.org for details. 22 | // 23 | // $Author: icftcm $ 24 | // $Revision: #8 $ 25 | // $Date: 2016/10/13 $ 26 | // $State: $ 27 | // ***************************************************************************** 28 | // ***************************************************************************** 29 | 30 | #ifndef defiFILL_h 31 | #define defiFILL_h 32 | 33 | #include 34 | #include "defiKRDefs.hpp" 35 | #include "defiMisc.hpp" 36 | 37 | BEGIN_LEFDEF_PARSER_NAMESPACE 38 | 39 | class defrData; 40 | 41 | class defiFill { 42 | public: 43 | defiFill(defrData *data); 44 | void Init(); 45 | 46 | void Destroy(); 47 | ~defiFill(); 48 | 49 | void clear(); 50 | void clearPoly(); 51 | void clearPts(); 52 | 53 | void setLayer(const char* name); 54 | void setLayerOpc(); // 5.7 55 | void addRect(int xl, int yl, int xh, int yh); 56 | void addPolygon(defiGeometries* geom); 57 | void setVia(const char* name); // 5.7 58 | void setViaOpc(); // 5.7 59 | void addPts(defiGeometries* geom); // 5.7 60 | 61 | int hasLayer() const; 62 | const char* layerName() const; 63 | int hasLayerOpc() const; // 5.7 64 | 65 | void setMask(int colorMask); // 5.8 66 | int layerMask() const; // 5.8 67 | int viaTopMask() const; // 5.8 68 | int viaCutMask() const; // 5.8 69 | int viaBottomMask() const; // 5.8 70 | 71 | int numRectangles() const; 72 | int xl(int index) const; 73 | int yl(int index) const; 74 | int xh(int index) const; 75 | int yh(int index) const; 76 | 77 | int numPolygons() const; // 5.6 78 | struct defiPoints getPolygon(int index) const; // 5.6 79 | 80 | int hasVia() const; // 5.7 81 | const char* viaName() const; // 5.7 82 | int hasViaOpc() const; // 5.7 83 | 84 | int numViaPts() const; // 5.7 85 | struct defiPoints getViaPts(int index) const; // 5.7 86 | 87 | void print(FILE* f) const; 88 | 89 | protected: 90 | int hasLayer_; 91 | char* layerName_; 92 | int layerNameLength_; 93 | int layerOpc_; // 5.7 94 | int numRectangles_; 95 | int rectsAllocated_; 96 | int* xl_; 97 | int* yl_; 98 | int* xh_; 99 | int* yh_; 100 | int numPolys_; // 5.6 101 | int polysAllocated_; // 5.6 102 | struct defiPoints** polygons_; // 5.6 103 | int hasVia_; // 5.7 104 | char* viaName_; // 5.7 105 | int viaNameLength_; // 5.7 106 | int viaOpc_; // 5.7 107 | int numPts_; // 5.7 108 | int ptsAllocated_; // 5.7 109 | int mask_; // 5.8 110 | struct defiPoints** viaPts_; // 5.7 111 | 112 | defrData *defData; 113 | }; 114 | 115 | 116 | END_LEFDEF_PARSER_NAMESPACE 117 | 118 | USE_LEFDEF_PARSER_NAMESPACE 119 | 120 | #endif 121 | -------------------------------------------------------------------------------- /src/lemon/include/lemon/cbc.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C++; indent-tabs-mode: nil; -*- 2 | * 3 | * This file is a part of LEMON, a generic C++ optimization library. 4 | * 5 | * Copyright (C) 2003-2013 6 | * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 | * (Egervary Research Group on Combinatorial Optimization, EGRES). 8 | * 9 | * Permission to use, modify and distribute this software is granted 10 | * provided that this copyright notice appears in all copies. For 11 | * precise terms see the accompanying LICENSE file. 12 | * 13 | * This software is provided "AS IS" with no warranty of any kind, 14 | * express or implied, and with no claim as to its suitability for any 15 | * purpose. 16 | * 17 | */ 18 | 19 | #ifndef LEMON_CBC_H 20 | #define LEMON_CBC_H 21 | 22 | ///\file 23 | ///\brief Header of the LEMON-CBC mip solver interface. 24 | ///\ingroup lp_group 25 | 26 | #include 27 | 28 | class CoinModel; 29 | class OsiSolverInterface; 30 | class CbcModel; 31 | 32 | namespace lemon { 33 | 34 | /// \brief Interface for the CBC MIP solver 35 | /// 36 | /// This class implements an interface for the CBC MIP solver. 37 | ///\ingroup lp_group 38 | class CbcMip : public MipSolver { 39 | protected: 40 | 41 | CoinModel *_prob; 42 | OsiSolverInterface *_osi_solver; 43 | CbcModel *_cbc_model; 44 | 45 | public: 46 | 47 | /// \e 48 | CbcMip(); 49 | /// \e 50 | CbcMip(const CbcMip&); 51 | /// \e 52 | ~CbcMip(); 53 | /// \e 54 | virtual CbcMip* newSolver() const; 55 | /// \e 56 | virtual CbcMip* cloneSolver() const; 57 | 58 | protected: 59 | 60 | virtual const char* _solverName() const; 61 | 62 | virtual int _addCol(); 63 | virtual int _addRow(); 64 | virtual int _addRow(Value l, ExprIterator b, ExprIterator e, Value u); 65 | 66 | virtual void _eraseCol(int i); 67 | virtual void _eraseRow(int i); 68 | 69 | virtual void _eraseColId(int i); 70 | virtual void _eraseRowId(int i); 71 | 72 | virtual void _getColName(int col, std::string& name) const; 73 | virtual void _setColName(int col, const std::string& name); 74 | virtual int _colByName(const std::string& name) const; 75 | 76 | virtual void _getRowName(int row, std::string& name) const; 77 | virtual void _setRowName(int row, const std::string& name); 78 | virtual int _rowByName(const std::string& name) const; 79 | 80 | virtual void _setRowCoeffs(int i, ExprIterator b, ExprIterator e); 81 | virtual void _getRowCoeffs(int i, InsertIterator b) const; 82 | 83 | virtual void _setColCoeffs(int i, ExprIterator b, ExprIterator e); 84 | virtual void _getColCoeffs(int i, InsertIterator b) const; 85 | 86 | virtual void _setCoeff(int row, int col, Value value); 87 | virtual Value _getCoeff(int row, int col) const; 88 | 89 | virtual void _setColLowerBound(int i, Value value); 90 | virtual Value _getColLowerBound(int i) const; 91 | virtual void _setColUpperBound(int i, Value value); 92 | virtual Value _getColUpperBound(int i) const; 93 | 94 | virtual void _setRowLowerBound(int i, Value value); 95 | virtual Value _getRowLowerBound(int i) const; 96 | virtual void _setRowUpperBound(int i, Value value); 97 | virtual Value _getRowUpperBound(int i) const; 98 | 99 | virtual void _setObjCoeffs(ExprIterator b, ExprIterator e); 100 | virtual void _getObjCoeffs(InsertIterator b) const; 101 | 102 | virtual void _setObjCoeff(int i, Value obj_coef); 103 | virtual Value _getObjCoeff(int i) const; 104 | 105 | virtual void _setSense(Sense sense); 106 | virtual Sense _getSense() const; 107 | 108 | virtual ColTypes _getColType(int col) const; 109 | virtual void _setColType(int col, ColTypes col_type); 110 | 111 | virtual SolveExitStatus _solve(); 112 | virtual ProblemType _getType() const; 113 | virtual Value _getSol(int i) const; 114 | virtual Value _getSolValue() const; 115 | 116 | virtual void _clear(); 117 | 118 | virtual void _messageLevel(MessageLevel level); 119 | void _applyMessageLevel(); 120 | 121 | int _message_level; 122 | 123 | 124 | 125 | }; 126 | 127 | } 128 | 129 | #endif 130 | -------------------------------------------------------------------------------- /src/db/db_geom.cpp: -------------------------------------------------------------------------------- 1 | #include "../global.h" 2 | 3 | #include "db.h" 4 | using namespace db; 5 | /***** Rectangle *****/ 6 | 7 | Rectangle& Rectangle::operator+=(const Rectangle& geo) { 8 | lx = min(lx, geo.lx); 9 | ly = min(ly, geo.ly); 10 | hx = max(hx, geo.hx); 11 | hy = max(hy, geo.hy); 12 | return *this; 13 | } 14 | 15 | void Rectangle::sliceH(vector& rects) { 16 | // sort all bottom and top bounds 17 | vector ys; 18 | for (const Rectangle& rect : rects) { 19 | ys.push_back(rect.ly); 20 | ys.push_back(rect.hy); 21 | } 22 | sort(ys.begin(), ys.end()); 23 | 24 | // remove duplicated values 25 | ys.erase(unique(ys.begin(), ys.end()), ys.end()); 26 | 27 | // cut each rect with the y values 28 | vector slices; 29 | for (const Rectangle& rect : rects) { 30 | vector::iterator yi = lower_bound(ys.begin(), ys.end(), rect.ly); 31 | vector::iterator ye = upper_bound(yi, ys.end(), rect.hy); 32 | int lasty = *(yi++); 33 | for (; yi != ye; yi++) { 34 | slices.push_back(Rectangle(rect.lx, lasty, rect.hx, *yi)); 35 | lasty = *yi; 36 | } 37 | } 38 | // merge overlapping rect 39 | sort(slices.begin(), slices.end(), [](const Rectangle& a, const Rectangle& b) -> bool { 40 | return a.ly == b.ly ? a.lx < b.lx : a.ly < b.ly; 41 | }); 42 | for (int i = 1; i < (int)slices.size(); ++i) { 43 | Rectangle& L = slices[i - 1]; 44 | Rectangle& R = slices[i]; 45 | if (L.ly != R.ly || L.hy != R.hy) { 46 | continue; 47 | } 48 | if (L.hx >= R.lx) { 49 | R.lx = min(L.lx, R.lx); 50 | R.hx = max(L.hx, R.hx); 51 | L.hx = L.lx; 52 | } 53 | } 54 | // remove empty rects 55 | vector::iterator sEnd = remove_if(slices.begin(), slices.end(), Rectangle::IsInvalid); 56 | if (sEnd != slices.end()) { 57 | slices.resize(distance(slices.begin(), sEnd)); 58 | } 59 | rects.swap(slices); 60 | } 61 | 62 | void Rectangle::sliceV(vector& rects) { 63 | // sort all left and right bounds 64 | vector xs; 65 | for (const Rectangle& rect : rects) { 66 | xs.push_back(rect.lx); 67 | xs.push_back(rect.hx); 68 | } 69 | sort(xs.begin(), xs.end()); 70 | 71 | // remove duplicated values 72 | xs.erase(unique(xs.begin(), xs.end()), xs.end()); 73 | 74 | // cut each rect with the y values 75 | vector slices; 76 | for (const Rectangle& rect : rects) { 77 | vector::iterator xi = lower_bound(xs.begin(), xs.end(), rect.lx); 78 | vector::iterator xe = upper_bound(xi, xs.end(), rect.hx); 79 | int lastx = *(xi++); 80 | for (; xi != xe; xi++) { 81 | slices.push_back(Rectangle(lastx, rect.ly, *xi, rect.hy)); 82 | lastx = *xi; 83 | } 84 | } 85 | // merge overlapping rect 86 | sort(slices.begin(), slices.end(), [](const Rectangle& a, const Rectangle& b) -> bool { 87 | return a.lx == b.lx ? a.ly < b.ly : a.lx < b.lx; 88 | }); 89 | for (int i = 1; i < (int)slices.size(); ++i) { 90 | Rectangle& L = slices[i - 1]; 91 | Rectangle& R = slices[i]; 92 | if (L.lx != R.lx || L.hx != R.hx) { 93 | continue; 94 | } 95 | if (L.hy >= R.ly) { 96 | R.ly = min(L.ly, R.ly); 97 | R.hy = max(L.hy, R.hy); 98 | L.hy = L.ly; 99 | } 100 | } 101 | // remove empty rects 102 | vector::iterator sEnd = remove_if(slices.begin(), slices.end(), Rectangle::IsInvalid); 103 | if (sEnd != slices.end()) { 104 | slices.resize(distance(slices.begin(), sEnd)); 105 | } 106 | rects.swap(slices); 107 | } 108 | 109 | /***** Geometry *****/ 110 | 111 | bool Geometry::operator==(const Geometry& rhs) const { return layer == rhs.layer && Rectangle::operator==(rhs); }; 112 | 113 | /***** GeoMap *****/ 114 | 115 | void GeoMap::emplace(const int k, const Geometry& shape) { 116 | if (_map.find(k) == _map.end()) { 117 | _map.emplace(k, shape); 118 | } else { 119 | _map.at(k) += shape; 120 | } 121 | Rectangle::operator+=(shape); 122 | } 123 | 124 | -------------------------------------------------------------------------------- /src/db/db_get.cpp: -------------------------------------------------------------------------------- 1 | #include "db.h" 2 | using namespace db; 3 | 4 | #include "../ut/utils.h" 5 | 6 | /* get layer by name */ 7 | Layer* Database::getLayer(const string& name) { 8 | for (Layer& layer : layers) { 9 | if (layer.name() == name) { 10 | return &layer; 11 | } 12 | } 13 | return nullptr; 14 | } 15 | 16 | /* get routing layer by index : 0=M1 */ 17 | Layer* Database::getRLayer(const int index) { 18 | for (Layer& layer : layers) { 19 | if (layer.rIndex == index) { 20 | return &layer; 21 | } 22 | } 23 | return nullptr; 24 | } 25 | 26 | /* get cut layer by index : 0=M1/2 */ 27 | const Layer* Database::getCLayer(const unsigned index) const { 28 | for (const Layer& layer : layers) { 29 | if (layer.cIndex == static_cast(index)) { 30 | return &layer; 31 | } 32 | } 33 | return nullptr; 34 | } 35 | 36 | /* get cell type by name */ 37 | CellType* Database::getCellType(const string& name) { 38 | unordered_map::iterator mi = name_celltypes.find(name); 39 | if (mi == name_celltypes.end()) { 40 | return nullptr; 41 | } 42 | return mi->second; 43 | } 44 | 45 | Cell* Database::getCell(const string& name) { 46 | unordered_map::iterator mi = name_cells.find(name); 47 | if (mi == name_cells.end()) { 48 | return nullptr; 49 | } 50 | return mi->second; 51 | } 52 | 53 | Net* Database::getNet(const string& name) { 54 | unordered_map::iterator mi = name_nets.find(name); 55 | if (mi == name_nets.end()) { 56 | return nullptr; 57 | } 58 | return mi->second; 59 | } 60 | 61 | Region* Database::getRegion(const string& name) { 62 | for (Region* region : regions) { 63 | if (region->name() == name) { 64 | return region; 65 | } 66 | } 67 | return nullptr; 68 | } 69 | 70 | Region* Database::getRegion(const unsigned char id) { 71 | if (id == Region::InvalidRegion) { 72 | return nullptr; 73 | } 74 | return regions[id]; 75 | } 76 | 77 | NDR* Database::getNDR(const string& name) const { 78 | map::const_iterator mi = ndrs.find(name); 79 | if (mi == ndrs.end()) { 80 | return nullptr; 81 | } 82 | return mi->second; 83 | } 84 | 85 | IOPin* Database::getIOPin(const string& name) const { 86 | unordered_map::const_iterator mi = name_iopins.find(name); 87 | if (mi == name_iopins.end()) { 88 | return nullptr; 89 | } 90 | return mi->second; 91 | } 92 | 93 | ViaType* Database::getViaType(const string& name) const { 94 | unordered_map::const_iterator mi = name_viatypes.find(name); 95 | if (mi == name_viatypes.end()) { 96 | return nullptr; 97 | } 98 | return mi->second; 99 | } 100 | 101 | int Database::getContainedSites(const int lx, const int ly, const int hx, const int hy, int& slx, int& sly, int& shx, int& shy) const { 102 | slx = binContainedL(lx, coreLX, coreHX, siteW); 103 | sly = binContainedL(ly, coreLY, coreHY, siteH); 104 | shx = binContainedR(hx, coreLX, coreHX, siteW); 105 | shy = binContainedR(hy, coreLY, coreHY, siteH); 106 | if (slx > shx || sly > shy) { 107 | return 0; 108 | } 109 | return (shx - slx + 1) * (shy - sly + 1); 110 | } 111 | 112 | int Database::getOverlappedSites(const int lx, const int ly, const int hx, const int hy, int& slx, int& sly, int& shx, int& shy) const { 113 | slx = binOverlappedL(lx, coreLX, coreHX, siteW); 114 | sly = binOverlappedL(ly, coreLY, coreHY, siteH); 115 | shx = binOverlappedR(hx, coreLX, coreHX, siteW); 116 | shy = binOverlappedR(hy, coreLY, coreHY, siteH); 117 | if (slx > shx || sly > shy) { 118 | return 0; 119 | } 120 | return (shx - slx + 1) * (shy - sly + 1); 121 | } 122 | 123 | unsigned Database::getNumRLayers() const { 124 | unsigned numRLayers = 0; 125 | for (const Layer& layer : layers) { 126 | if (layer.rIndex != -1) { 127 | numRLayers++; 128 | } 129 | } 130 | return numRLayers; 131 | } 132 | 133 | unsigned Database::getNumCLayers() const { 134 | unsigned numCLayers = 0; 135 | for (const Layer& layer : layers) { 136 | if (layer.cIndex != -1) { 137 | numCLayers++; 138 | } 139 | } 140 | return numCLayers; 141 | } 142 | -------------------------------------------------------------------------------- /src/lef58/inc/lefrCallBacks.hpp: -------------------------------------------------------------------------------- 1 | // ***************************************************************************** 2 | // ***************************************************************************** 3 | // Copyright 2012 - 2017, Cadence Design Systems 4 | // 5 | // This file is part of the Cadence LEF/DEF Open Source 6 | // Distribution, Product Version 5.8. 7 | // 8 | // Licensed under the Apache License, Version 2.0 (the "License"); 9 | // you may not use this file except in compliance with the License. 10 | // You may obtain a copy of the License at 11 | // 12 | // http://www.apache.org/licenses/LICENSE-2.0 13 | // 14 | // Unless required by applicable law or agreed to in writing, software 15 | // distributed under the License is distributed on an "AS IS" BASIS, 16 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 17 | // implied. See the License for the specific language governing 18 | // permissions and limitations under the License. 19 | // 20 | // For updates, support, or to become part of the LEF/DEF Community, 21 | // check www.openeda.org for details. 22 | // 23 | // $Author: dell $ 24 | // $Revision: #8 $ 25 | // $Date: 2017/02/27 $ 26 | // $State: $ 27 | // ***************************************************************************** 28 | // ***************************************************************************** 29 | 30 | #ifndef lefrCallbacks_h 31 | #define lefrCallbacks_h 32 | 33 | #include "lefiKRDefs.hpp" 34 | #include "lefrReader.hpp" 35 | 36 | BEGIN_LEFDEF_PARSER_NAMESPACE 37 | 38 | class lefrCallbacks { 39 | public: 40 | lefrCallbacks(); 41 | static void reset(); 42 | 43 | // List of call back routines 44 | // These are filled in by the user. See the 45 | // "set" routines at the end of the file 46 | lefrDoubleCbkFnType AntennaInoutCbk; 47 | lefrDoubleCbkFnType AntennaInputCbk; 48 | lefrDoubleCbkFnType AntennaOutputCbk; 49 | lefrStringCbkFnType ArrayBeginCbk; 50 | lefrArrayCbkFnType ArrayCbk; 51 | lefrStringCbkFnType ArrayEndCbk; 52 | lefrStringCbkFnType BusBitCharsCbk; 53 | lefrIntegerCbkFnType CaseSensitiveCbk; 54 | lefrStringCbkFnType ClearanceMeasureCbk; 55 | lefrCorrectionTableCbkFnType CorrectionTableCbk; 56 | lefrDensityCbkFnType DensityCbk; 57 | lefrDoubleCbkFnType DielectricCbk; 58 | lefrStringCbkFnType DividerCharCbk; 59 | lefrDoubleCbkFnType EdgeRateScaleFactorCbk; 60 | lefrDoubleCbkFnType EdgeRateThreshold1Cbk; 61 | lefrDoubleCbkFnType EdgeRateThreshold2Cbk; 62 | lefrStringCbkFnType ExtensionCbk; 63 | lefrIntegerCbkFnType FixedMaskCbk; 64 | lefrVoidCbkFnType IRDropBeginCbk; 65 | lefrIRDropCbkFnType IRDropCbk; 66 | lefrVoidCbkFnType IRDropEndCbk; 67 | lefrDoubleCbkFnType InoutAntennaCbk; 68 | lefrDoubleCbkFnType InputAntennaCbk; 69 | lefrLayerCbkFnType LayerCbk; 70 | lefrVoidCbkFnType LibraryEndCbk; 71 | lefrStringCbkFnType MacroBeginCbk; 72 | lefrMacroCbkFnType MacroCbk; 73 | lefrStringCbkFnType MacroClassTypeCbk; 74 | lefrStringCbkFnType MacroEndCbk; 75 | lefrIntegerCbkFnType MacroFixedMaskCbk; 76 | lefrMacroNumCbkFnType MacroOriginCbk; 77 | lefrMacroSiteCbkFnType MacroSiteCbk; 78 | lefrMacroForeignCbkFnType MacroForeignCbk; 79 | lefrMacroNumCbkFnType MacroSizeCbk; 80 | lefrDoubleCbkFnType ManufacturingCbk; 81 | lefrMaxStackViaCbkFnType MaxStackViaCbk; 82 | lefrMinFeatureCbkFnType MinFeatureCbk; 83 | lefrStringCbkFnType NoWireExtensionCbk; 84 | lefrNoiseMarginCbkFnType NoiseMarginCbk; 85 | lefrNoiseTableCbkFnType NoiseTableCbk; 86 | lefrNonDefaultCbkFnType NonDefaultCbk; 87 | lefrObstructionCbkFnType ObstructionCbk; 88 | lefrDoubleCbkFnType OutputAntennaCbk; 89 | lefrPinCbkFnType PinCbk; 90 | lefrVoidCbkFnType PropBeginCbk; 91 | lefrPropCbkFnType PropCbk; 92 | lefrVoidCbkFnType PropEndCbk; 93 | lefrSiteCbkFnType SiteCbk; 94 | lefrVoidCbkFnType SpacingBeginCbk; 95 | lefrSpacingCbkFnType SpacingCbk; 96 | lefrVoidCbkFnType SpacingEndCbk; 97 | lefrTimingCbkFnType TimingCbk; 98 | lefrUnitsCbkFnType UnitsCbk; 99 | lefrUseMinSpacingCbkFnType UseMinSpacingCbk; 100 | lefrDoubleCbkFnType VersionCbk; 101 | lefrStringCbkFnType VersionStrCbk; 102 | lefrViaCbkFnType ViaCbk; 103 | lefrViaRuleCbkFnType ViaRuleCbk; 104 | }; 105 | 106 | extern lefrCallbacks *lefCallbacks; 107 | 108 | END_LEFDEF_PARSER_NAMESPACE 109 | 110 | USE_LEFDEF_PARSER_NAMESPACE 111 | 112 | #endif 113 | -------------------------------------------------------------------------------- /src/lef58/inc/lefiArray.hpp: -------------------------------------------------------------------------------- 1 | // ***************************************************************************** 2 | // ***************************************************************************** 3 | // Copyright 2012 - 2013, Cadence Design Systems 4 | // 5 | // This file is part of the Cadence LEF/DEF Open Source 6 | // Distribution, Product Version 5.8. 7 | // 8 | // Licensed under the Apache License, Version 2.0 (the "License"); 9 | // you may not use this file except in compliance with the License. 10 | // You may obtain a copy of the License at 11 | // 12 | // http://www.apache.org/licenses/LICENSE-2.0 13 | // 14 | // Unless required by applicable law or agreed to in writing, software 15 | // distributed under the License is distributed on an "AS IS" BASIS, 16 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 17 | // implied. See the License for the specific language governing 18 | // permissions and limitations under the License. 19 | // 20 | // For updates, support, or to become part of the LEF/DEF Community, 21 | // check www.openeda.org for details. 22 | // 23 | // $Author: dell $ 24 | // $Revision: #7 $ 25 | // $Date: 2015/01/27 $ 26 | // $State: $ 27 | // ***************************************************************************** 28 | // ***************************************************************************** 29 | 30 | #ifndef lefiArray_h 31 | #define lefiArray_h 32 | 33 | #include 34 | #include "lefiKRDefs.hpp" 35 | #include "lefiMisc.hpp" 36 | 37 | BEGIN_LEFDEF_PARSER_NAMESPACE 38 | 39 | class lefiArrayFloorPlan { 40 | public: 41 | void Init(const char* name); 42 | void Destroy(); 43 | void addSitePattern(const char* typ, lefiSitePattern* s); 44 | 45 | int numPatterns() const; 46 | lefiSitePattern* pattern(int index) const; 47 | char* typ(int index) const; 48 | const char* name() const; 49 | 50 | protected: 51 | int numPatterns_; 52 | int patternsAllocated_; 53 | lefiSitePattern** patterns_; 54 | char** types_; 55 | char* name_; 56 | }; 57 | 58 | class lefiArray { 59 | public: 60 | lefiArray(); 61 | void Init(); 62 | 63 | void Destroy(); 64 | ~lefiArray(); 65 | 66 | void setName(const char* name); 67 | void addSitePattern(lefiSitePattern* s); 68 | void setTableSize(int tsize); 69 | void addDefaultCap(int minPins, double cap); 70 | void addCanPlace(lefiSitePattern* s); 71 | void addCannotOccupy(lefiSitePattern* s); 72 | void addTrack(lefiTrackPattern* t); 73 | void addGcell(lefiGcellPattern* g); 74 | void addFloorPlan(const char* name); 75 | void addSiteToFloorPlan(const char* typ, lefiSitePattern* p); 76 | void clear(); 77 | void bump(void*** arr, int used, int* allocated); 78 | 79 | int numSitePattern() const; 80 | int numCanPlace() const; 81 | int numCannotOccupy() const; 82 | int numTrack() const; 83 | int numGcell() const; 84 | int hasDefaultCap() const; 85 | 86 | const char* name() const; 87 | lefiSitePattern* sitePattern(int index) const; 88 | lefiSitePattern* canPlace(int index) const; 89 | lefiSitePattern* cannotOccupy(int index) const; 90 | lefiTrackPattern* track(int index) const; 91 | lefiGcellPattern* gcell(int index) const; 92 | 93 | int tableSize() const; 94 | int numDefaultCaps() const; 95 | int defaultCapMinPins(int index) const; 96 | double defaultCap(int index) const; 97 | 98 | int numFloorPlans() const; 99 | const char* floorPlanName(int index) const; 100 | int numSites(int index) const; 101 | const char* siteType(int floorIndex, int siteIndex) const; 102 | lefiSitePattern* site(int floorIndex, int siteIndex) const; 103 | 104 | // Debug print 105 | void print(FILE* f) const; 106 | 107 | protected: 108 | int nameSize_; 109 | char* name_; 110 | 111 | int patternsAllocated_; 112 | int numPatterns_; 113 | lefiSitePattern** pattern_; 114 | 115 | int canAllocated_; 116 | int numCan_; 117 | lefiSitePattern** canPlace_; 118 | 119 | int cannotAllocated_; 120 | int numCannot_; 121 | lefiSitePattern** cannotOccupy_; 122 | 123 | int tracksAllocated_; 124 | int numTracks_; 125 | lefiTrackPattern** track_; 126 | 127 | int gAllocated_; 128 | int numG_; 129 | lefiGcellPattern** gcell_; 130 | 131 | int hasDefault_; 132 | int tableSize_; 133 | int numDefault_; 134 | int defaultAllocated_; 135 | int* minPins_; 136 | double* caps_; 137 | 138 | int numFloorPlans_; 139 | int floorPlansAllocated_; 140 | lefiArrayFloorPlan** floors_; 141 | }; 142 | 143 | END_LEFDEF_PARSER_NAMESPACE 144 | 145 | USE_LEFDEF_PARSER_NAMESPACE 146 | 147 | #endif 148 | --------------------------------------------------------------------------------