refine code structure to accelerate compilation time
This commit is contained in:
parent
af663f475c
commit
500ed28a7f
@ -1,6 +1,6 @@
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
cmake_minimum_required(VERSION 3.18)
|
||||
|
||||
project(xplace C CXX)
|
||||
project(xplace LANGUAGES C CXX CUDA)
|
||||
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE Release)
|
||||
@ -48,7 +48,25 @@ find_package(Cairo)
|
||||
message(STATUS "CAIRO_INCLUDE_DIRS: ${CAIRO_INCLUDE_DIRS}")
|
||||
message(STATUS "CAIRO_LIBRARIES: ${CAIRO_LIBRARIES}")
|
||||
|
||||
# Get Torch info
|
||||
# CUDA
|
||||
# set cuda arch and nvcc flags
|
||||
if (NOT DEFINED CMAKE_CUDA_ARCHITECTURES)
|
||||
set(CMAKE_CUDA_ARCHITECTURES 80 86 CACHE STRING "CUDA architectures" FORCE)
|
||||
endif()
|
||||
message(STATUS "CMAKE_CUDA_ARCHITECTURES: ${CMAKE_CUDA_ARCHITECTURES}")
|
||||
find_package(CUDAToolkit)
|
||||
|
||||
# set nvcc flags
|
||||
set(CUDA_USE_STATIC_CUDA_RUNTIME OFF)
|
||||
set(CMAKE_CUDA17_EXTENSION_COMPILE_OPTION "-std=c++17")
|
||||
list(APPEND BASIC_CUDA_FLAGS --compiler-options;-fPIC;-std=c++17)
|
||||
list(APPEND BASIC_CUDA_FLAGS --expt-relaxed-constexpr) # suppress warning from pytorch
|
||||
message(STATUS "BASIC_CUDA_FLAGS: ${BASIC_CUDA_FLAGS}")
|
||||
add_compile_options(
|
||||
"$<$<COMPILE_LANGUAGE:CUDA>:${BASIC_CUDA_FLAGS}>"
|
||||
)
|
||||
|
||||
# Torch
|
||||
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c
|
||||
"import torch; print(torch.__path__[0]); print(int(torch.cuda.is_available())); print(torch.__version__);"
|
||||
OUTPUT_VARIABLE TORCH_OUTPUT OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
@ -61,35 +79,10 @@ list(GET TORCH_VERSION_LIST 0 TORCH_VERSION_MAJOR)
|
||||
list(GET TORCH_VERSION_LIST 1 TORCH_VERSION_MINOR)
|
||||
message(STATUS TORCH_INSTALL_PREFIX=${TORCH_INSTALL_PREFIX})
|
||||
message(STATUS TORCH_VERSION=${TORCH_VERSION_MAJOR}.${TORCH_VERSION_MINOR})
|
||||
|
||||
# find CUDA
|
||||
if (TORCH_ENABLE_CUDA)
|
||||
find_package(CUDA 11.4)
|
||||
find_package(CUDAToolkit)
|
||||
if (NOT CUDA_FOUND)
|
||||
set(TORCH_ENABLE_CUDA 0 CACHE BOOL "Whether enable CUDA" FORCE)
|
||||
message(FATAL_ERROR "Xplace only supports CUDA mode, CMake will exit." )
|
||||
endif(NOT CUDA_FOUND)
|
||||
endif()
|
||||
message(STATUS TORCH_ENABLE_CUDA=${TORCH_ENABLE_CUDA})
|
||||
|
||||
# set cuda arch and nvcc flags
|
||||
if (CUDA_FOUND)
|
||||
if (NOT CUDA_ARCH_LIST)
|
||||
set(CUDA_ARCH_LIST 6.0 6.1 7.0 7.5 8.0 8.6)
|
||||
endif(NOT CUDA_ARCH_LIST)
|
||||
# for cuda_add_library
|
||||
cuda_select_nvcc_arch_flags(CUDA_ARCH_FLAGS ${CUDA_ARCH_LIST})
|
||||
message(STATUS "CUDA_ARCH_FLAGS: ${CUDA_ARCH_FLAGS}")
|
||||
# set nvcc flags
|
||||
set(CUDA_USE_STATIC_CUDA_RUNTIME OFF)
|
||||
set(CMAKE_CUDA17_EXTENSION_COMPILE_OPTION "-std=c++17")
|
||||
list(APPEND CUDA_NVCC_FLAGS ${CUDA_ARCH_FLAGS} --compiler-options;-fPIC;-std=c++17)
|
||||
list(APPEND CUDA_NVCC_FLAGS ${CUDA_ARCH_FLAGS} --extended-lambda)
|
||||
list(APPEND TORCH_NVCC_FLAGS --expt-relaxed-constexpr)
|
||||
list(APPEND CUDA_NVCC_FLAGS ${TORCH_NVCC_FLAGS})
|
||||
message(STATUS "CUDA_NVCC_FLAGS: ${CUDA_NVCC_FLAGS}")
|
||||
endif(CUDA_FOUND)
|
||||
if (NOT TORCH_ENABLE_CUDA)
|
||||
message(FATAL_ERROR "Xplace only supports Torch-CUDA mode, exit CMAKE." )
|
||||
endif()
|
||||
|
||||
# set torch lib
|
||||
add_library(torch STATIC IMPORTED)
|
||||
@ -131,7 +124,7 @@ function(add_pytorch_extension target_name)
|
||||
set(CUDA_SRCS "${ARG_UNPARSED_ARGUMENTS}")
|
||||
list(FILTER CUDA_SRCS INCLUDE REGEX ".*cu$")
|
||||
if (CUDA_SRCS)
|
||||
cuda_add_library(${target_name}_cuda_tmp STATIC ${CUDA_SRCS})
|
||||
add_library(${target_name}_cuda_tmp STATIC ${CUDA_SRCS})
|
||||
target_include_directories(${target_name}_cuda_tmp PRIVATE ${ARG_EXTRA_INCLUDE_DIRS} ${TORCH_INCLUDE_DIRS})
|
||||
target_link_libraries(${target_name}_cuda_tmp ${ARG_EXTRA_LINK_LIBRARIES} ${TORCH_LIBRARY})
|
||||
target_compile_definitions(${target_name}_cuda_tmp PRIVATE
|
||||
|
||||
@ -59,7 +59,7 @@ make -j40 && make install
|
||||
```
|
||||
|
||||
### 1.1. Dependencies
|
||||
- [CMake](https://cmake.org/) >= 3.17
|
||||
- [CMake](https://cmake.org/) >= 3.18
|
||||
- [GCC](https://gcc.gnu.org/) >= 7.5.0
|
||||
- [Boost](https://www.boost.org/) >= 1.56.0
|
||||
- [CUDA](https://developer.nvidia.com/cuda-toolkit) >= 11.3
|
||||
|
||||
@ -1,6 +1,10 @@
|
||||
#pragma once
|
||||
#include <vector>
|
||||
|
||||
namespace db {
|
||||
|
||||
using std::vector;
|
||||
|
||||
class BsRouteInfo {
|
||||
// specially restore ICCAD2012/DAC2012 bookshelf routing info
|
||||
public:
|
||||
|
||||
@ -1,4 +1,9 @@
|
||||
#include "Database.h"
|
||||
#include "Cell.h"
|
||||
|
||||
#include "DatabaseClass.h"
|
||||
#include "Geometry.h"
|
||||
#include "Pin.h"
|
||||
|
||||
using namespace db;
|
||||
|
||||
/***** Cell *****/
|
||||
@ -37,9 +42,7 @@ void Cell::ctype(CellType* t) {
|
||||
|
||||
int Cell::lx() const { return _lx; }
|
||||
int Cell::ly() const { return _ly; }
|
||||
int Cell::orient() const {
|
||||
return _orient;
|
||||
}
|
||||
int Cell::orient() const { return _orient; }
|
||||
|
||||
bool Cell::placed() const { return (lx() != INT_MIN) && (ly() != INT_MIN); }
|
||||
// int Cell::siteWidth() const { return width() / database.siteW; }
|
||||
|
||||
@ -1,6 +1,24 @@
|
||||
#pragma once
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "Geometry.h"
|
||||
|
||||
namespace db {
|
||||
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
class CellType;
|
||||
class Cell;
|
||||
class Database;
|
||||
class Rectangle;
|
||||
class Geometry;
|
||||
class Pin;
|
||||
class Region;
|
||||
class Net;
|
||||
class PinType;
|
||||
|
||||
class CellType {
|
||||
friend class Database;
|
||||
|
||||
|
||||
@ -1,11 +1,32 @@
|
||||
#include "Database.h"
|
||||
|
||||
#include "BsRouteInfo.h"
|
||||
#include "Cell.h"
|
||||
#include "DatabaseClass.h"
|
||||
#include "DesignRule.h"
|
||||
#include "GCellGrid.h"
|
||||
#include "Geometry.h"
|
||||
#include "Layer.h"
|
||||
#include "Net.h"
|
||||
#include "Pin.h"
|
||||
#include "Region.h"
|
||||
#include "Row.h"
|
||||
#include "SNet.h"
|
||||
#include "Site.h"
|
||||
#include "SiteMap.h"
|
||||
#include "Via.h"
|
||||
|
||||
using namespace db;
|
||||
|
||||
/***** Database *****/
|
||||
Database::Database() {
|
||||
clear();
|
||||
_buffer = new char[_bufferCapacity];
|
||||
powerNet = new PowerNet();
|
||||
siteMap = new SiteMap();
|
||||
gcellgrid = new GCellGrid();
|
||||
bsRouteInfo = new BsRouteInfo();
|
||||
edgetypes = new EdgeTypes();
|
||||
}
|
||||
|
||||
Database::~Database() {
|
||||
@ -72,16 +93,15 @@ void Database::reset() {
|
||||
name_viatypes.clear();
|
||||
|
||||
layers.clear();
|
||||
sites.clear();
|
||||
|
||||
routeBlockages.clear();
|
||||
placeBlockages.clear();
|
||||
|
||||
powerNet = PowerNet();
|
||||
|
||||
siteMap = SiteMap();
|
||||
gcellgrid = GCellGrid();
|
||||
edgetypes = EdgeTypes();
|
||||
powerNet = new PowerNet();
|
||||
siteMap = new SiteMap();
|
||||
gcellgrid = new GCellGrid();
|
||||
bsRouteInfo = new BsRouteInfo();
|
||||
edgetypes = new EdgeTypes();
|
||||
dbIssues.clear();
|
||||
|
||||
dieLX = 0;
|
||||
@ -114,6 +134,11 @@ void Database::clearTechnology() {
|
||||
CLEAR_POINTER_MAP(ndrs);
|
||||
}
|
||||
|
||||
void Database::clearLibrary() {
|
||||
CLEAR_POINTER_LIST(lefsites);
|
||||
CLEAR_POINTER_LIST(celltypes);
|
||||
}
|
||||
|
||||
void Database::clearDesign() {
|
||||
CLEAR_POINTER_LIST(cells);
|
||||
CLEAR_POINTER_LIST(iopins);
|
||||
@ -126,6 +151,22 @@ void Database::clearDesign() {
|
||||
DBU_Micron = -1.0;
|
||||
designName = "";
|
||||
regions.push_back(new Region("default"));
|
||||
|
||||
if (!powerNet) {
|
||||
delete powerNet;
|
||||
}
|
||||
if (!siteMap) {
|
||||
delete siteMap;
|
||||
}
|
||||
if (!gcellgrid) {
|
||||
delete gcellgrid;
|
||||
}
|
||||
if (!bsRouteInfo) {
|
||||
delete bsRouteInfo;
|
||||
}
|
||||
if (!edgetypes) {
|
||||
delete edgetypes;
|
||||
}
|
||||
}
|
||||
|
||||
void Database::save(const std::string& given_prefix) {
|
||||
@ -246,17 +287,17 @@ void Database::SetupFloorplan() {
|
||||
coreHY = std::max(row->y() + siteH, coreHY);
|
||||
}
|
||||
|
||||
for (Site& site : sites) {
|
||||
if (site.siteClassName() == "CORE") {
|
||||
if (siteW != (unsigned)site.width()) {
|
||||
for (Site* lefsite : lefsites) {
|
||||
if (lefsite->siteClassName() == "CORE") {
|
||||
if (siteW != (unsigned)lefsite->width()) {
|
||||
logger.warning("siteW %d in DEF is inconsistent with siteW %d in LEF.",
|
||||
static_cast<int>(siteW),
|
||||
static_cast<int>(site.width()));
|
||||
static_cast<int>(lefsite->width()));
|
||||
}
|
||||
if (siteH != site.height()) {
|
||||
if (siteH != lefsite->height()) {
|
||||
logger.warning("siteH %d in DEF is inconsistent with siteH %d in LEF.",
|
||||
static_cast<int>(siteH),
|
||||
static_cast<int>(site.height()));
|
||||
static_cast<int>(lefsite->height()));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -319,15 +360,15 @@ void Database::SetupRegions() {
|
||||
|
||||
void Database::SetupSiteMap() {
|
||||
// set up site map
|
||||
siteMap.siteL = coreLX;
|
||||
siteMap.siteR = coreHX;
|
||||
siteMap.siteB = coreLY;
|
||||
siteMap.siteT = coreHY;
|
||||
siteMap.siteStepX = siteW;
|
||||
siteMap.siteStepY = siteH;
|
||||
siteMap.siteNX = nSitesX;
|
||||
siteMap.siteNY = nSitesY;
|
||||
siteMap.initSiteMap(nSitesX, nSitesY);
|
||||
siteMap->siteL = coreLX;
|
||||
siteMap->siteR = coreHX;
|
||||
siteMap->siteB = coreLY;
|
||||
siteMap->siteT = coreHY;
|
||||
siteMap->siteStepX = siteW;
|
||||
siteMap->siteStepY = siteH;
|
||||
siteMap->siteNX = nSitesX;
|
||||
siteMap->siteNY = nSitesY;
|
||||
siteMap->initSiteMap(nSitesX, nSitesY);
|
||||
|
||||
// mark site partially overlapped by fence
|
||||
int nRegions = regions.size();
|
||||
@ -342,20 +383,20 @@ void Database::SetupSiteMap() {
|
||||
for (int j = 0; j < (int)hSlices.size(); j++) {
|
||||
int lx = hSlices[j].lx;
|
||||
int hx = hSlices[j].hx;
|
||||
int olx = binOverlappedL(lx, siteMap.siteL, siteMap.siteR, siteMap.siteStepX);
|
||||
int ohx = binOverlappedR(hx, siteMap.siteL, siteMap.siteR, siteMap.siteStepX);
|
||||
int clx = binContainedL(lx, siteMap.siteL, siteMap.siteR, siteMap.siteStepX);
|
||||
int chx = binContainedR(hx, siteMap.siteL, siteMap.siteR, siteMap.siteStepX);
|
||||
int sly = binOverlappedL(hSlices[j].ly, siteMap.siteB, siteMap.siteT, siteMap.siteStepY);
|
||||
int shy = binOverlappedR(hSlices[j].hy, siteMap.siteB, siteMap.siteT, siteMap.siteStepY);
|
||||
int olx = binOverlappedL(lx, siteMap->siteL, siteMap->siteR, siteMap->siteStepX);
|
||||
int ohx = binOverlappedR(hx, siteMap->siteL, siteMap->siteR, siteMap->siteStepX);
|
||||
int clx = binContainedL(lx, siteMap->siteL, siteMap->siteR, siteMap->siteStepX);
|
||||
int chx = binContainedR(hx, siteMap->siteL, siteMap->siteR, siteMap->siteStepX);
|
||||
int sly = binOverlappedL(hSlices[j].ly, siteMap->siteB, siteMap->siteT, siteMap->siteStepY);
|
||||
int shy = binOverlappedR(hSlices[j].hy, siteMap->siteB, siteMap->siteT, siteMap->siteStepY);
|
||||
if (olx != clx) {
|
||||
for (int y = sly; y <= shy; y++) {
|
||||
siteMap.blockRegion(olx, y);
|
||||
siteMap->blockRegion(olx, y);
|
||||
}
|
||||
}
|
||||
if (ohx != chx) {
|
||||
for (int y = sly; y <= shy; y++) {
|
||||
siteMap.blockRegion(ohx, y);
|
||||
siteMap->blockRegion(ohx, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -365,34 +406,34 @@ void Database::SetupSiteMap() {
|
||||
for (const Rectangle& vSlice : vSlices) {
|
||||
int ly = vSlice.ly;
|
||||
int hy = vSlice.hy;
|
||||
const unsigned oly = binOverlappedL(ly, siteMap.siteB, siteMap.siteT, siteMap.siteStepY);
|
||||
const unsigned ohy = binOverlappedR(hy, siteMap.siteB, siteMap.siteT, siteMap.siteStepY);
|
||||
const int cly = binContainedL(ly, siteMap.siteB, siteMap.siteT, siteMap.siteStepY);
|
||||
const int chy = binContainedR(hy, siteMap.siteB, siteMap.siteT, siteMap.siteStepY);
|
||||
const unsigned slx = binOverlappedL(vSlice.lx, siteMap.siteL, siteMap.siteR, siteMap.siteStepX);
|
||||
const unsigned shx = binOverlappedR(vSlice.hx, siteMap.siteL, siteMap.siteR, siteMap.siteStepX);
|
||||
const unsigned oly = binOverlappedL(ly, siteMap->siteB, siteMap->siteT, siteMap->siteStepY);
|
||||
const unsigned ohy = binOverlappedR(hy, siteMap->siteB, siteMap->siteT, siteMap->siteStepY);
|
||||
const int cly = binContainedL(ly, siteMap->siteB, siteMap->siteT, siteMap->siteStepY);
|
||||
const int chy = binContainedR(hy, siteMap->siteB, siteMap->siteT, siteMap->siteStepY);
|
||||
const unsigned slx = binOverlappedL(vSlice.lx, siteMap->siteL, siteMap->siteR, siteMap->siteStepX);
|
||||
const unsigned shx = binOverlappedR(vSlice.hx, siteMap->siteL, siteMap->siteR, siteMap->siteStepX);
|
||||
if ((int)oly != cly) {
|
||||
for (unsigned x = slx; x <= shx; ++x) {
|
||||
siteMap.blockRegion(x, oly);
|
||||
siteMap->blockRegion(x, oly);
|
||||
}
|
||||
}
|
||||
if ((int)ohy != chy) {
|
||||
for (unsigned x = slx; x <= shx; ++x) {
|
||||
siteMap.blockRegion(x, ohy);
|
||||
siteMap->blockRegion(x, ohy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const Rectangle& rect : hSlices) {
|
||||
siteMap.setRegion(rect.lx, rect.ly, rect.hx, rect.hy, region->id);
|
||||
siteMap->setRegion(rect.lx, rect.ly, rect.hx, rect.hy, region->id);
|
||||
}
|
||||
for (const Rectangle& rect : vSlices) {
|
||||
siteMap.setRegion(rect.lx, rect.ly, rect.hx, rect.hy, region->id);
|
||||
siteMap->setRegion(rect.lx, rect.ly, rect.hx, rect.hy, region->id);
|
||||
}
|
||||
}
|
||||
|
||||
// mark all sites blocked
|
||||
siteMap.setSites(coreLX, coreLY, coreHX, coreHY, SiteMap::SiteBlocked);
|
||||
siteMap->setSites(coreLX, coreLY, coreHX, coreHY, SiteMap::SiteBlocked);
|
||||
|
||||
// mark rows as non-blocked
|
||||
for (const Row* row : rows) {
|
||||
@ -400,7 +441,7 @@ void Database::SetupSiteMap() {
|
||||
int ly = row->y();
|
||||
int hx = row->x() + row->width();
|
||||
int hy = row->y() + siteH;
|
||||
siteMap.unsetSites(lx, ly, hx, hy, SiteMap::SiteBlocked);
|
||||
siteMap->unsetSites(lx, ly, hx, hy, SiteMap::SiteBlocked);
|
||||
}
|
||||
|
||||
// mark blocked sites
|
||||
@ -413,8 +454,8 @@ void Database::SetupSiteMap() {
|
||||
int hx = cell->hx();
|
||||
int hy = cell->hy();
|
||||
|
||||
siteMap.setSites(lx, ly, hx, hy, SiteMap::SiteBlocked);
|
||||
siteMap.blockRegion(lx, ly, hx, hy);
|
||||
siteMap->setSites(lx, ly, hx, hy, SiteMap::SiteBlocked);
|
||||
siteMap->blockRegion(lx, ly, hx, hy);
|
||||
}
|
||||
|
||||
for (const Rectangle& placeBlockage : placeBlockages) {
|
||||
@ -422,8 +463,8 @@ void Database::SetupSiteMap() {
|
||||
int ly = placeBlockage.ly;
|
||||
int hx = placeBlockage.hx;
|
||||
int hy = placeBlockage.hy;
|
||||
siteMap.setSites(lx, ly, hx, hy, SiteMap::SiteBlocked);
|
||||
siteMap.blockRegion(lx, ly, hx, hy);
|
||||
siteMap->setSites(lx, ly, hx, hy, SiteMap::SiteBlocked);
|
||||
siteMap->blockRegion(lx, ly, hx, hy);
|
||||
}
|
||||
|
||||
for (const SNet* snet : snets) {
|
||||
@ -431,11 +472,11 @@ void Database::SetupSiteMap() {
|
||||
switch (geo.layer.rIndex) {
|
||||
case 1:
|
||||
if (geo.layer.direction == 'v') {
|
||||
siteMap.setSites(geo.lx, geo.ly, geo.hx, geo.hy, SiteMap::SiteM2Blocked);
|
||||
siteMap->setSites(geo.lx, geo.ly, geo.hx, geo.hy, SiteMap::SiteM2Blocked);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
siteMap.setSites(geo.lx, geo.ly, geo.hx, geo.hy, SiteMap::SiteM3Blocked);
|
||||
siteMap->setSites(geo.lx, geo.ly, geo.hx, geo.hy, SiteMap::SiteM3Blocked);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -449,11 +490,11 @@ void Database::SetupSiteMap() {
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
siteMap.setSites(shape.lx + iopin->x,
|
||||
shape.ly + iopin->y,
|
||||
shape.hx + iopin->x,
|
||||
shape.hy + iopin->y,
|
||||
SiteMap::SiteM2BlockedIOPin);
|
||||
siteMap->setSites(shape.lx + iopin->x,
|
||||
shape.ly + iopin->y,
|
||||
shape.hx + iopin->x,
|
||||
shape.hy + iopin->y,
|
||||
SiteMap::SiteM2BlockedIOPin);
|
||||
break;
|
||||
case 2:
|
||||
break;
|
||||
@ -463,31 +504,31 @@ void Database::SetupSiteMap() {
|
||||
}
|
||||
}
|
||||
|
||||
siteMap.nSites = siteMap.siteNX * siteMap.siteNY;
|
||||
siteMap.nPlaceable = 0;
|
||||
siteMap.nRegionSites.resize(regions.size(), 0);
|
||||
for (int y = 0; y < siteMap.siteNY; y++) {
|
||||
for (int x = 0; x < siteMap.siteNX; x++) {
|
||||
if (siteMap.getSiteMap(x, y, SiteMap::SiteBlocked) || siteMap.getSiteMap(x, y, SiteMap::SiteM2Blocked) ||
|
||||
siteMap.getSiteMap(x, y, SiteMap::SiteM2BlockedIOPin)) {
|
||||
siteMap->nSites = siteMap->siteNX * siteMap->siteNY;
|
||||
siteMap->nPlaceable = 0;
|
||||
siteMap->nRegionSites.resize(regions.size(), 0);
|
||||
for (int y = 0; y < siteMap->siteNY; y++) {
|
||||
for (int x = 0; x < siteMap->siteNX; x++) {
|
||||
if (siteMap->getSiteMap(x, y, SiteMap::SiteBlocked) || siteMap->getSiteMap(x, y, SiteMap::SiteM2Blocked) ||
|
||||
siteMap->getSiteMap(x, y, SiteMap::SiteM2BlockedIOPin)) {
|
||||
continue;
|
||||
}
|
||||
siteMap.nPlaceable++;
|
||||
unsigned char region = siteMap.getRegion(x, y);
|
||||
siteMap->nPlaceable++;
|
||||
unsigned char region = siteMap->getRegion(x, y);
|
||||
if (region != Region::InvalidRegion) {
|
||||
siteMap.nRegionSites[region]++;
|
||||
siteMap->nRegionSites[region]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
logger.verbose("core area: %ld", siteMap.nSites);
|
||||
logger.verbose("core area: %ld", siteMap->nSites);
|
||||
logger.verbose(
|
||||
"placeable: %ld (%lf%%)", siteMap.nPlaceable, (double)siteMap.nPlaceable / (double)siteMap.nSites * 100.0);
|
||||
"placeable: %ld (%lf%%)", siteMap->nPlaceable, (double)siteMap->nPlaceable / (double)siteMap->nSites * 100.0);
|
||||
for (int i = 0; i < (int)regions.size(); i++) {
|
||||
logger.verbose("region %d : %ld (%lf%%)",
|
||||
i,
|
||||
siteMap.nRegionSites[i],
|
||||
(double)siteMap.nRegionSites[i] / (double)siteMap.nPlaceable);
|
||||
siteMap->nRegionSites[i],
|
||||
(double)siteMap->nRegionSites[i] / (double)siteMap->nPlaceable);
|
||||
}
|
||||
}
|
||||
|
||||
@ -499,7 +540,8 @@ void Database::SetupRows() {
|
||||
for (Row* row : rows) {
|
||||
char isFlip = (row->flip() ? 1 : 2);
|
||||
int y = (row->y() - coreLY) / siteH;
|
||||
orients[y] = row->orient(); // TODO: how to handle multiple ROW definitions on same y?
|
||||
orients[y] = row->orient(); // TODO: how to handle multiple ROW
|
||||
// definitions on same y?
|
||||
if (flip[y] == 0) {
|
||||
flip[y] = isFlip;
|
||||
} else if (flip[y] != isFlip) {
|
||||
@ -543,27 +585,42 @@ void Database::SetupRows() {
|
||||
Row* row = rows[y];
|
||||
int ly = row->y();
|
||||
int hy = row->y() + siteH;
|
||||
if (!powerNet.getRowPower(ly, hy, row->_topPower, row->_botPower)) {
|
||||
if (!powerNet->getRowPower(ly, hy, row->_topPower, row->_botPower)) {
|
||||
if (topNormal && row->topPower() == 'x') {
|
||||
if (y + 1 == nSitesY) {
|
||||
logger.warning("Top power rail of the row at y=%d is not connected to power rail", row->y());
|
||||
logger.warning(
|
||||
"Top power rail of the row at y=%d is not connected to "
|
||||
"power rail",
|
||||
row->y());
|
||||
} else {
|
||||
logger.error("Top power rail of the row at y=%d is not connected to power rail", row->y());
|
||||
logger.error(
|
||||
"Top power rail of the row at y=%d is not connected to "
|
||||
"power rail",
|
||||
row->y());
|
||||
topNormal = false;
|
||||
}
|
||||
}
|
||||
if (botNormal && row->botPower() == 'x') {
|
||||
if (y) {
|
||||
logger.error("Bottom power rail of the row at y=%d is not connected to power rail", row->y());
|
||||
logger.error(
|
||||
"Bottom power rail of the row at y=%d is not connected "
|
||||
"to power rail",
|
||||
row->y());
|
||||
botNormal = false;
|
||||
} else {
|
||||
logger.warning("Bottom power rail of the row at y=%d is not connected to power rail", row->y());
|
||||
logger.warning(
|
||||
"Bottom power rail of the row at y=%d is not connected "
|
||||
"to power rail",
|
||||
row->y());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (shrNormal && row->topPower() == row->botPower()) {
|
||||
logger.error(
|
||||
"Top and Bottom power rail of the row at y=%d share the same power %c", row->y(), row->topPower());
|
||||
"Top and Bottom power rail of the row at y=%d share the same "
|
||||
"power %c",
|
||||
row->y(),
|
||||
row->topPower());
|
||||
shrNormal = false;
|
||||
}
|
||||
}
|
||||
@ -584,15 +641,15 @@ void Database::SetupRowSegments() {
|
||||
b2 = true;
|
||||
r2 = NULL;
|
||||
} else {
|
||||
b2 = siteMap.getSiteMap(x, y, SiteMap::SiteBlocked);
|
||||
b2 = siteMap->getSiteMap(x, y, SiteMap::SiteBlocked);
|
||||
if (setting.EnablePG) {
|
||||
b2 = b2 || siteMap.getSiteMap(x, y, SiteMap::SiteM2Blocked);
|
||||
b2 = b2 || siteMap->getSiteMap(x, y, SiteMap::SiteM2Blocked);
|
||||
}
|
||||
if (setting.EnableIOPin) {
|
||||
b2 = b2 || siteMap.getSiteMap(x, y, SiteMap::SiteM2BlockedIOPin);
|
||||
b2 = b2 || siteMap->getSiteMap(x, y, SiteMap::SiteM2BlockedIOPin);
|
||||
}
|
||||
if (setting.EnableFence) {
|
||||
r2 = getRegion(siteMap.getRegion(x, y));
|
||||
r2 = getRegion(siteMap->getRegion(x, y));
|
||||
} else {
|
||||
r2 = regions[0];
|
||||
}
|
||||
@ -650,15 +707,16 @@ Layer& Database::addLayer(const string& name, const char type) {
|
||||
return newlayer;
|
||||
}
|
||||
|
||||
Site& Database::addSite(const string& name, const string& siteClassName, const int w, const int h) {
|
||||
for (unsigned i = 0; i < sites.size(); i++) {
|
||||
if (name == sites[i].name()) {
|
||||
Site* Database::addSite(const string& name, const string& siteClassName, const int w, const int h) {
|
||||
for (unsigned i = 0; i < lefsites.size(); i++) {
|
||||
if (name == lefsites[i]->name()) {
|
||||
logger.warning("site re-defined: %s", name.c_str());
|
||||
return sites[i];
|
||||
return lefsites[i];
|
||||
}
|
||||
}
|
||||
sites.emplace_back(name, siteClassName, w, h);
|
||||
return sites.back();
|
||||
Site* site = new Site(name, siteClassName, w, h);
|
||||
lefsites.push_back(site);
|
||||
return site;
|
||||
}
|
||||
|
||||
ViaType* Database::addViaType(const string& name, bool isDef) {
|
||||
@ -793,7 +851,7 @@ long long Database::getFreeArea(Region* region) const {
|
||||
if (region && region != regions[i]) {
|
||||
continue;
|
||||
}
|
||||
freeArea += siteMap.nRegionSites[i];
|
||||
freeArea += siteMap->nRegionSites[i];
|
||||
}
|
||||
return freeArea;
|
||||
}
|
||||
@ -919,6 +977,12 @@ ViaType* Database::getViaType(const string& name) const {
|
||||
return mi->second;
|
||||
}
|
||||
|
||||
int Database::getCellTypeSpace(const CellType* L, const CellType* R) const {
|
||||
return edgetypes->getEdgeSpace(L->edgetypeR, R->edgetypeL);
|
||||
}
|
||||
|
||||
int Database::getCellTypeSpace(const Cell* L, const Cell* R) const { return getCellTypeSpace(L->ctype(), R->ctype()); }
|
||||
|
||||
int Database::getContainedSites(
|
||||
const int lx, const int ly, const int hx, const int hy, int& slx, int& sly, int& shx, int& shy) const {
|
||||
slx = binContainedL(lx, coreLX, coreHX, siteW);
|
||||
@ -963,6 +1027,8 @@ unsigned Database::getNumCLayers() const {
|
||||
return numCLayers;
|
||||
}
|
||||
|
||||
unsigned Database::getNumLayers() const { return layers.size(); }
|
||||
|
||||
void Database::errorCheck(bool autoFix) {
|
||||
vector<Row*>::iterator ri = rows.begin();
|
||||
vector<Row*>::iterator re = rows.end();
|
||||
|
||||
@ -1,54 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "DatabaseClass.h"
|
||||
#include "Setting.h"
|
||||
#include "common/common.h"
|
||||
|
||||
namespace db {
|
||||
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
class Rectangle;
|
||||
class Geometry;
|
||||
class GeoMap;
|
||||
class Cell;
|
||||
class CellType;
|
||||
class Pin;
|
||||
class PinType;
|
||||
class IOPin;
|
||||
class CellPin;
|
||||
class Net;
|
||||
class Row;
|
||||
class RowSegment;
|
||||
class Track;
|
||||
class Layer;
|
||||
class Via;
|
||||
class ViaRule;
|
||||
class ViaType;
|
||||
class Region;
|
||||
class NDR;
|
||||
class SNet;
|
||||
class Site;
|
||||
class PowerNet;
|
||||
class EdgeTypes;
|
||||
class GCellGrid;
|
||||
class BsRouteInfo;
|
||||
} // namespace db
|
||||
|
||||
#include "BsRouteInfo.h"
|
||||
#include "Cell.h"
|
||||
#include "DesignRule.h"
|
||||
#include "GCellGrid.h"
|
||||
#include "Geometry.h"
|
||||
#include "Layer.h"
|
||||
#include "Net.h"
|
||||
#include "Pin.h"
|
||||
#include "Region.h"
|
||||
#include "Row.h"
|
||||
#include "SNet.h"
|
||||
#include "Site.h"
|
||||
#include "SiteMap.h"
|
||||
#include "Via.h"
|
||||
|
||||
namespace db {
|
||||
|
||||
@ -86,7 +39,7 @@ public:
|
||||
robin_hood::unordered_map<string, ViaType*> name_viatypes;
|
||||
|
||||
vector<Layer> layers;
|
||||
vector<Site> sites;
|
||||
vector<Site*> lefsites;
|
||||
vector<ViaType*> viatypes;
|
||||
vector<CellType*> celltypes;
|
||||
|
||||
@ -102,7 +55,7 @@ public:
|
||||
vector<Geometry> routeBlockages;
|
||||
vector<Rectangle> placeBlockages;
|
||||
|
||||
PowerNet powerNet;
|
||||
PowerNet* powerNet = nullptr;
|
||||
|
||||
private:
|
||||
static const size_t _bufferCapacity = 128 * 1024;
|
||||
@ -115,11 +68,11 @@ public:
|
||||
unsigned nSitesX = 0;
|
||||
unsigned nSitesY = 0;
|
||||
|
||||
SiteMap siteMap;
|
||||
GCellGrid gcellgrid;
|
||||
SiteMap* siteMap = nullptr;
|
||||
GCellGrid* gcellgrid = nullptr;
|
||||
|
||||
BsRouteInfo bsRouteInfo;
|
||||
EdgeTypes edgetypes;
|
||||
BsRouteInfo* bsRouteInfo = nullptr;
|
||||
EdgeTypes* edgetypes = nullptr;
|
||||
|
||||
int dieLX, dieLY, dieHX, dieHY;
|
||||
int coreLX, coreLY, coreHX, coreHY;
|
||||
@ -139,13 +92,13 @@ public:
|
||||
~Database();
|
||||
void clear();
|
||||
void clearTechnology();
|
||||
inline void clearLibrary() { CLEAR_POINTER_LIST(celltypes); }
|
||||
void clearLibrary();
|
||||
void clearDesign();
|
||||
|
||||
Layer& addLayer(const string& name, const char type = 'x');
|
||||
Site& addSite(const string& name, const string& siteClassName, const int w, const int h);
|
||||
Site* addSite(const string& name, const string& siteClassName, const int w, const int h);
|
||||
ViaType* addViaType(const string& name, bool isDef);
|
||||
inline ViaType* addViaType(const string& name) { return addViaType(name, false); }
|
||||
ViaType* addViaType(const string& name) { return addViaType(name, false); }
|
||||
CellType* addCellType(const string& name, unsigned libcell);
|
||||
void reserveCells(const size_t n) { cells.reserve(n); }
|
||||
Cell* addCell(const string& name, CellType* type = nullptr);
|
||||
@ -183,17 +136,15 @@ public:
|
||||
|
||||
unsigned getNumRLayers() const;
|
||||
unsigned getNumCLayers() const;
|
||||
inline unsigned getNumLayers() const { return layers.size(); }
|
||||
inline unsigned getNumCells() const { return cells.size(); }
|
||||
inline unsigned getNumNets() const { return nets.size(); }
|
||||
inline unsigned getNumRegions() const { return regions.size(); }
|
||||
inline unsigned getNumIOPins() const { return iopins.size(); }
|
||||
inline unsigned getNumCellTypes() const { return celltypes.size(); }
|
||||
unsigned getNumLayers() const;
|
||||
unsigned getNumCells() const { return cells.size(); }
|
||||
unsigned getNumNets() const { return nets.size(); }
|
||||
unsigned getNumRegions() const { return regions.size(); }
|
||||
unsigned getNumIOPins() const { return iopins.size(); }
|
||||
unsigned getNumCellTypes() const { return celltypes.size(); }
|
||||
|
||||
inline int getCellTypeSpace(const CellType* L, const CellType* R) const {
|
||||
return edgetypes.getEdgeSpace(L->edgetypeR, R->edgetypeL);
|
||||
}
|
||||
inline int getCellTypeSpace(const Cell* L, const Cell* R) const { return getCellTypeSpace(L->ctype(), R->ctype()); }
|
||||
int getCellTypeSpace(const CellType* L, const CellType* R) const;
|
||||
int getCellTypeSpace(const Cell* L, const Cell* R) const;
|
||||
int getContainedSites(
|
||||
const int lx, const int ly, const int hx, const int hy, int& slx, int& sly, int& shx, int& shy) const;
|
||||
int getOverlappedSites(
|
||||
|
||||
45
cpp_to_py/common/db/DatabaseClass.h
Normal file
45
cpp_to_py/common/db/DatabaseClass.h
Normal file
@ -0,0 +1,45 @@
|
||||
#include <climits>
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "common/utils/utils.h"
|
||||
|
||||
using utils::assert_msg;
|
||||
using utils::logger;
|
||||
|
||||
namespace db {
|
||||
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
class Database;
|
||||
class Rectangle;
|
||||
class Geometry;
|
||||
class GeoMap;
|
||||
class Cell;
|
||||
class CellType;
|
||||
class Pin;
|
||||
class PinType;
|
||||
class IOPin;
|
||||
class CellPin;
|
||||
class Net;
|
||||
class Row;
|
||||
class RowSegment;
|
||||
class Track;
|
||||
class Layer;
|
||||
class Via;
|
||||
class ViaRule;
|
||||
class ViaType;
|
||||
class Region;
|
||||
class NDR;
|
||||
class SNet;
|
||||
class Site;
|
||||
class SiteMap;
|
||||
class PowerNet;
|
||||
class EdgeTypes;
|
||||
class GCellGrid;
|
||||
class BsRouteInfo;
|
||||
} // namespace db
|
||||
@ -1,4 +1,7 @@
|
||||
#include "Database.h"
|
||||
#include "DesignRule.h"
|
||||
|
||||
#include "DatabaseClass.h"
|
||||
|
||||
using namespace db;
|
||||
|
||||
/***** EdgeTypes *****/
|
||||
|
||||
@ -1,6 +1,15 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace db {
|
||||
|
||||
class Layer;
|
||||
class ViaType;
|
||||
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
class WireRule {
|
||||
private:
|
||||
const Layer* _layer;
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#include <vector>
|
||||
|
||||
namespace db {
|
||||
|
||||
|
||||
@ -1,4 +1,7 @@
|
||||
#include "Database.h"
|
||||
#include "DatabaseClass.h"
|
||||
#include "Geometry.h"
|
||||
#include "Layer.h"
|
||||
|
||||
using namespace db;
|
||||
|
||||
/***** Rectangle *****/
|
||||
|
||||
@ -1,6 +1,15 @@
|
||||
#pragma once
|
||||
#include <climits>
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
namespace db {
|
||||
|
||||
using std::vector;
|
||||
|
||||
class Layer;
|
||||
|
||||
class Rectangle {
|
||||
public:
|
||||
int lx = INT_MAX;
|
||||
@ -47,7 +56,7 @@ public:
|
||||
: Rectangle(lx, ly, hx, hy), layer(layer) {}
|
||||
Geometry(const Geometry& geom) : Rectangle(geom), layer(geom.layer) {}
|
||||
|
||||
inline bool operator==(const Geometry& rhs) const;
|
||||
bool operator==(const Geometry& rhs) const;
|
||||
};
|
||||
|
||||
class GeoMap : public Rectangle {
|
||||
|
||||
@ -1,4 +1,7 @@
|
||||
#include "Database.h"
|
||||
#include "Layer.h"
|
||||
|
||||
#include "DatabaseClass.h"
|
||||
|
||||
using namespace db;
|
||||
|
||||
/***** Track *****/
|
||||
|
||||
@ -1,6 +1,17 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <tuple>
|
||||
#include <climits>
|
||||
|
||||
namespace db {
|
||||
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
class Layer;
|
||||
class Track;
|
||||
|
||||
class Track {
|
||||
// contain DEF track info
|
||||
// support multi layer track DEF definition
|
||||
@ -68,7 +79,7 @@ public:
|
||||
// ParallelRunLength Spacing
|
||||
vector<int> parLength;
|
||||
vector<int> parWidth;
|
||||
vector<vector<int>> parWidthSpace; // 2D table: (parWidth, parLength) -> widthSpacing
|
||||
vector<vector<int>> parWidthSpace; // 2D table: (parWidth, parLength) -> widthSpacing
|
||||
|
||||
vector<Track> tracks;
|
||||
vector<Track> nonPreferDirTracks;
|
||||
|
||||
@ -1,4 +1,12 @@
|
||||
#include "Database.h"
|
||||
#include "Net.h"
|
||||
|
||||
#include "DatabaseClass.h"
|
||||
#include "DesignRule.h"
|
||||
#include "Layer.h"
|
||||
#include "SNet.h"
|
||||
#include "Via.h"
|
||||
#include "Geometry.h"
|
||||
|
||||
using namespace db;
|
||||
|
||||
/***** NetRouteNode *****/
|
||||
@ -6,6 +14,10 @@ using namespace db;
|
||||
NetRouteNode::NetRouteNode(const Layer* layer, const int x, const int y, const int z)
|
||||
: _layer(layer), x(x), y(y), z(z) {}
|
||||
|
||||
bool NetRouteNode::operator==(const NetRouteNode& r) const {
|
||||
return _layer == r._layer && x == r.x && y == r.y && z == r.z;
|
||||
}
|
||||
|
||||
/***** NetRouteSegment *****/
|
||||
|
||||
NetRouteSegment::NetRouteSegment(const unsigned fromi, const unsigned toi, const char dir, const unsigned len)
|
||||
@ -94,6 +106,9 @@ long long NetRouting::length() const {
|
||||
|
||||
/***** Net *****/
|
||||
|
||||
Net::Net(const string& name, const NDR* ndr) : name(name), ndr(ndr) {}
|
||||
Net::Net(const Net& net) : _routing(net._routing), name(net.name), pins(net.pins), ndr(net.ndr) {}
|
||||
|
||||
void Net::addPin(Pin* pin) {
|
||||
// if (pin->type->direction() == 'o' && pins.size()) {
|
||||
// Pin* firstPin = pins[0];
|
||||
@ -111,12 +126,13 @@ void Net::addPin(Pin* pin) {
|
||||
void PowerNet::addRail(SNet* snet, int lx, int hx, int y) {
|
||||
std::map<int, SNet*>::iterator rail = rails.find(y);
|
||||
if (rail != rails.end() && rail->second != snet) {
|
||||
logger.error("rail %s already exists at y=%d , new rail %s is from %d to %d", rail->second->name.c_str(),
|
||||
y, snet->name.c_str(),
|
||||
lx,
|
||||
hx);
|
||||
logger.error("rail %s already exists at y=%d , new rail %s is from %d to %d",
|
||||
rail->second->name.c_str(),
|
||||
y,
|
||||
snet->name.c_str(),
|
||||
lx,
|
||||
hx);
|
||||
return;
|
||||
|
||||
}
|
||||
rails.emplace(y, snet);
|
||||
}
|
||||
@ -139,4 +155,3 @@ bool PowerNet::getRowPower(int ly, int hy, char& topPower, char& botPower) {
|
||||
}
|
||||
return valid;
|
||||
}
|
||||
|
||||
|
||||
@ -1,7 +1,24 @@
|
||||
#pragma once
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <climits>
|
||||
|
||||
namespace db {
|
||||
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
class Layer;
|
||||
class Pin;
|
||||
class Cell;
|
||||
class NDR;
|
||||
class NetRouteNode;
|
||||
class NetRouteSegment;
|
||||
class NetRouting;
|
||||
class Net;
|
||||
class SNet;
|
||||
|
||||
class NetRouteNode {
|
||||
private:
|
||||
const Layer* _layer = nullptr;
|
||||
@ -11,12 +28,9 @@ public:
|
||||
int y = 0;
|
||||
int z = 0;
|
||||
Pin* pin;
|
||||
|
||||
NetRouteNode(const Layer* layer = nullptr, const int x = 0, const int y = 0, const int z = 0);
|
||||
|
||||
inline bool operator==(const NetRouteNode& r) const {
|
||||
return _layer == r._layer && x == r.x && y == r.y && z == r.z;
|
||||
}
|
||||
bool operator==(const NetRouteNode& r) const;
|
||||
};
|
||||
|
||||
class NetRouteSegment {
|
||||
@ -62,8 +76,8 @@ public:
|
||||
const NDR* ndr = nullptr;
|
||||
int gpdb_id = -1;
|
||||
|
||||
Net(const string& name, const NDR* ndr = nullptr) : name(name), ndr(ndr) {}
|
||||
Net(const Net& net) : _routing(net._routing), name(net.name), pins(net.pins), ndr(net.ndr) {}
|
||||
Net(const string& name, const NDR* ndr = nullptr);
|
||||
Net(const Net& net);
|
||||
|
||||
bool globalRouted() const { return gRouted; }
|
||||
bool detailedRouted() const { return dRouted; }
|
||||
@ -100,6 +114,7 @@ private:
|
||||
std::map<int, SNet*> rails;
|
||||
|
||||
public:
|
||||
~PowerNet() { rails.clear(); }
|
||||
void addRail(SNet* snet, int lx, int hx, int y);
|
||||
bool getRowPower(int ly, int hy, char& topPower, char& botPower);
|
||||
};
|
||||
|
||||
@ -1,4 +1,12 @@
|
||||
#include "Database.h"
|
||||
#include "Pin.h"
|
||||
|
||||
#include "Cell.h"
|
||||
#include "DatabaseClass.h"
|
||||
#include "Geometry.h"
|
||||
#include "Layer.h"
|
||||
#include "Net.h"
|
||||
#include "common/utils/utils.h"
|
||||
|
||||
using namespace db;
|
||||
|
||||
/***** PinSTA *****/
|
||||
@ -38,6 +46,11 @@ void IOPin::getBounds(int& lx, int& ly, int& hx, int& hy, int& rIndex) const {
|
||||
|
||||
/***** Pin *****/
|
||||
|
||||
Pin::Pin(const PinType* type) : type(type) {}
|
||||
Pin::Pin(Cell* cell, int i) : cell(cell), type(cell->ctype()->pins[i]), parentCellPinId(i) {}
|
||||
Pin::Pin(IOPin* iopin) : iopin(iopin), type(iopin->type) {}
|
||||
Pin::Pin(const Pin& pin) : cell(pin.cell), net(pin.net), type(pin.type) {}
|
||||
|
||||
void Pin::getPinCenter(int& x, int& y) {
|
||||
int lx, ly, hx, hy;
|
||||
type->getBounds(lx, ly, hx, hy);
|
||||
@ -160,3 +173,8 @@ bool PinType::comparePin(vector<PinType*> pins1, vector<PinType*> pins2) {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PinType::operator==(const PinType& r) const {
|
||||
return _type == r._type && boundLX == r.boundLX && boundLY == r.boundLY && boundHX == r.boundHX &&
|
||||
boundHY == r.boundHY && shapes[0].layer.rIndex == r.shapes[0].layer.rIndex;
|
||||
}
|
||||
@ -1,6 +1,30 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <climits>
|
||||
|
||||
namespace utils {
|
||||
template <class T>
|
||||
class BoxT;
|
||||
template <class T>
|
||||
class PointT;
|
||||
} // namespace utils
|
||||
|
||||
namespace db {
|
||||
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
class Geometry;
|
||||
class Layer;
|
||||
class PinType;
|
||||
class IOPin;
|
||||
class Pin;
|
||||
class PinSTA;
|
||||
class Cell;
|
||||
class Net;
|
||||
|
||||
class PinType {
|
||||
private:
|
||||
string _name = "";
|
||||
@ -30,10 +54,7 @@ public:
|
||||
unsigned getW() const { return boundHX - boundLX; }
|
||||
unsigned getH() const { return boundHY - boundLY; }
|
||||
void getBounds(int& lx, int& ly, int& hx, int& hy) const;
|
||||
bool operator==(const PinType& r) const {
|
||||
return _type == r._type && boundLX == r.boundLX && boundLY == r.boundLY && boundHX == r.boundHX &&
|
||||
boundHY == r.boundHY && shapes[0].layer.rIndex == r.shapes[0].layer.rIndex;
|
||||
}
|
||||
bool operator==(const PinType& r) const;
|
||||
bool operator!=(const PinType& r) const { return !(*this == r); }
|
||||
bool operator<(const PinType& r) const;
|
||||
bool operator>(const PinType& r) const { return r < *this; }
|
||||
@ -95,10 +116,10 @@ public:
|
||||
|
||||
PinSTA* staInfo = nullptr;
|
||||
|
||||
Pin(const PinType* type = nullptr) : type(type) {}
|
||||
Pin(Cell* cell, int i) : cell(cell), type(cell->ctype()->pins[i]), parentCellPinId(i) {}
|
||||
Pin(IOPin* iopin) : iopin(iopin), type(iopin->type) {}
|
||||
Pin(const Pin& pin) : cell(pin.cell), net(pin.net), type(pin.type) {}
|
||||
Pin(const PinType* type = nullptr);
|
||||
Pin(Cell* cell, int i);
|
||||
Pin(IOPin* iopin);
|
||||
Pin(const Pin& pin);
|
||||
|
||||
void getPinCenter(int& x, int& y);
|
||||
void getPinBounds(int& lx, int& ly, int& hx, int& hy, int& rIndex);
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
#include "Database.h"
|
||||
#include "Region.h"
|
||||
using namespace db;
|
||||
|
||||
/***** Region *****/
|
||||
|
||||
@ -1,6 +1,14 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "Geometry.h"
|
||||
|
||||
namespace db {
|
||||
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
class Region : public Rectangle {
|
||||
private:
|
||||
string _name = "";
|
||||
@ -19,12 +27,10 @@ public:
|
||||
Region(const string& name = "", const char type = 'x')
|
||||
: Rectangle(INT_MAX, INT_MAX, INT_MIN, INT_MIN), _name(name), _type(type) {}
|
||||
|
||||
inline const string& name() const { return _name; }
|
||||
inline char type() const { return _type; }
|
||||
const string& name() const { return _name; }
|
||||
char type() const { return _type; }
|
||||
|
||||
void addRect(const int xl, const int yl, const int xh, const int yh);
|
||||
void resetRects() { sliceH(rects); }
|
||||
|
||||
};
|
||||
} // namespace db
|
||||
|
||||
|
||||
@ -1,6 +1,16 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace db {
|
||||
|
||||
class Region;
|
||||
class Row;
|
||||
class RowSegment;
|
||||
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
class Row {
|
||||
friend class Database;
|
||||
|
||||
@ -11,7 +21,7 @@ private:
|
||||
int _y = 0;
|
||||
unsigned _xNum = 0;
|
||||
unsigned _yNum = 0;
|
||||
int _orient = 0; // 0:N, 1:W, 2:S, 3:E, 4:FN, 5:FW, 6:FS, 7:FE, -1:NONE
|
||||
int _orient = 0; // 0:N, 1:W, 2:S, 3:E, 4:FN, 5:FW, 6:FS, 7:FE, -1:NONE
|
||||
bool _flip = false;
|
||||
unsigned _xStep = 0;
|
||||
unsigned _yStep = 0;
|
||||
@ -71,7 +81,6 @@ public:
|
||||
void shiftY(const int value) { _y += value; }
|
||||
void shrinkXNum(const int value) { _xNum -= value; }
|
||||
void shrinkYNum(const int value) { _yNum -= value; }
|
||||
|
||||
};
|
||||
|
||||
class RowSegment {
|
||||
@ -80,5 +89,4 @@ public:
|
||||
int w = 0;
|
||||
Region* region = nullptr;
|
||||
};
|
||||
} // namespace db
|
||||
|
||||
} // namespace db
|
||||
|
||||
@ -1,6 +1,14 @@
|
||||
#pragma once
|
||||
#include <vector>
|
||||
|
||||
#include "Via.h"
|
||||
|
||||
namespace db {
|
||||
|
||||
using std::vector;
|
||||
|
||||
class Geometry;
|
||||
|
||||
class SNet {
|
||||
public:
|
||||
string name;
|
||||
@ -19,7 +27,5 @@ public:
|
||||
void addVia(Args&&... args) {
|
||||
vias.emplace_back(args...);
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
} // namespace db
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
#include "common/common.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace db {
|
||||
|
||||
|
||||
@ -1,5 +1,10 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
|
||||
namespace db {
|
||||
|
||||
using std::string;
|
||||
|
||||
class Site {
|
||||
private:
|
||||
string _name = "";
|
||||
|
||||
@ -1,4 +1,9 @@
|
||||
#include "Database.h"
|
||||
#include "SiteMap.h"
|
||||
|
||||
#include "DatabaseClass.h"
|
||||
#include "Region.h"
|
||||
#include "common/utils/utils.h"
|
||||
|
||||
using namespace db;
|
||||
|
||||
/***** SiteMap *****/
|
||||
@ -10,6 +15,18 @@ void SiteMap::initSiteMap(unsigned nx, unsigned ny) {
|
||||
regions.resize(nx, vector<unsigned char>(ny));
|
||||
}
|
||||
|
||||
void SiteMap::setSiteMap(const unsigned x, const unsigned y, const unsigned char property) {
|
||||
setBit(sites[x][y], property);
|
||||
}
|
||||
|
||||
void SiteMap::unsetSiteMap(const unsigned x, const unsigned y, const unsigned char property) {
|
||||
unsetBit(sites[x][y], property);
|
||||
}
|
||||
|
||||
bool SiteMap::getSiteMap(const unsigned x, const unsigned y, const unsigned char property) const {
|
||||
return (getBit(sites[x][y], property) == property);
|
||||
}
|
||||
|
||||
void SiteMap::getSiteBound(int x, int y, int &lx, int &ly, int &hx, int &hy) const {
|
||||
lx = siteL + x * siteStepX;
|
||||
ly = siteB + y * siteStepY;
|
||||
|
||||
@ -1,6 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace db {
|
||||
|
||||
using std::vector;
|
||||
|
||||
class SiteMap {
|
||||
private:
|
||||
unsigned nx = 0;
|
||||
@ -24,13 +29,9 @@ public:
|
||||
|
||||
void initSiteMap(unsigned nx, unsigned ny);
|
||||
|
||||
void setSiteMap(const unsigned x, const unsigned y, const unsigned char property) { setBit(sites[x][y], property); }
|
||||
inline void unsetSiteMap(const unsigned x, const unsigned y, const unsigned char property) {
|
||||
unsetBit(sites[x][y], property);
|
||||
}
|
||||
inline bool getSiteMap(const unsigned x, const unsigned y, const unsigned char property) const {
|
||||
return (getBit(sites[x][y], property) == property);
|
||||
}
|
||||
void setSiteMap(const unsigned x, const unsigned y, const unsigned char property);
|
||||
void unsetSiteMap(const unsigned x, const unsigned y, const unsigned char property);
|
||||
bool getSiteMap(const unsigned x, const unsigned y, const unsigned char property) const;
|
||||
unsigned char getSiteMap(int x, int y) const { return sites[x][y]; }
|
||||
|
||||
void getSiteBound(int x, int y, int& lx, int& ly, int& hx, int& hy) const;
|
||||
|
||||
@ -1,8 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
namespace db {
|
||||
|
||||
using std::string;
|
||||
|
||||
class Geometry;
|
||||
class Via;
|
||||
class ViaRule;
|
||||
class ViaType;
|
||||
|
||||
class Via {
|
||||
public:
|
||||
int x;
|
||||
|
||||
@ -1,4 +1,16 @@
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
#include "common/db/BsRouteInfo.h"
|
||||
#include "common/db/Cell.h"
|
||||
#include "common/db/Database.h"
|
||||
#include "common/db/GCellGrid.h"
|
||||
#include "common/db/Layer.h"
|
||||
#include "common/db/Net.h"
|
||||
#include "common/db/Pin.h"
|
||||
#include "common/db/Row.h"
|
||||
|
||||
using namespace db;
|
||||
|
||||
@ -463,7 +475,8 @@ bool Database::readBSAux(const std::string& auxFile, const std::string& plFile)
|
||||
if (minRowXStep != bsData.siteWidth) {
|
||||
if (bsData.siteWidth % minRowXStep == 0) {
|
||||
logger.warning(
|
||||
"estimated siteWidth %d is not equal to the min rowXStep %d, but is a multiple of min rowXStep. Set "
|
||||
"estimated siteWidth %d is not equal to the min rowXStep %d, "
|
||||
"but is a multiple of min rowXStep. Set "
|
||||
"estimated siteWidth as %d.",
|
||||
bsData.siteWidth,
|
||||
minRowXStep,
|
||||
@ -471,7 +484,10 @@ bool Database::readBSAux(const std::string& auxFile, const std::string& plFile)
|
||||
bsData.siteWidth = minRowXStep;
|
||||
} else {
|
||||
logger.error(
|
||||
"estimated siteWidth %d is not equal to the minimum rowXStep %d.", bsData.siteWidth, minRowXStep);
|
||||
"estimated siteWidth %d is not equal to the minimum rowXStep "
|
||||
"%d.",
|
||||
bsData.siteWidth,
|
||||
minRowXStep);
|
||||
}
|
||||
}
|
||||
|
||||
@ -481,17 +497,17 @@ bool Database::readBSAux(const std::string& auxFile, const std::string& plFile)
|
||||
if (bsData.format == "dac2012") {
|
||||
isDac2012 = true;
|
||||
nLayers = bsData.gridNZ;
|
||||
this->gcellgrid.numX = {bsData.gridNX + 1};
|
||||
this->gcellgrid.numY = {bsData.gridNY + 1};
|
||||
this->gcellgrid.startX = {bsData.gridOriginX};
|
||||
this->gcellgrid.startY = {bsData.gridOriginY};
|
||||
this->gcellgrid.stepX = {bsData.tileW};
|
||||
this->gcellgrid.stepY = {bsData.tileH};
|
||||
this->bsRouteInfo.hasInfo = true;
|
||||
this->bsRouteInfo.capV = std::move(bsData.capV);
|
||||
this->bsRouteInfo.capH = std::move(bsData.capH);
|
||||
this->bsRouteInfo.viaSpace = std::move(bsData.viaSpace);
|
||||
this->bsRouteInfo.blockagePorosity = bsData.blockagePorosity;
|
||||
this->gcellgrid->numX = {bsData.gridNX + 1};
|
||||
this->gcellgrid->numY = {bsData.gridNY + 1};
|
||||
this->gcellgrid->startX = {bsData.gridOriginX};
|
||||
this->gcellgrid->startY = {bsData.gridOriginY};
|
||||
this->gcellgrid->stepX = {bsData.tileW};
|
||||
this->gcellgrid->stepY = {bsData.tileH};
|
||||
this->bsRouteInfo->hasInfo = true;
|
||||
this->bsRouteInfo->capV = std::move(bsData.capV);
|
||||
this->bsRouteInfo->capH = std::move(bsData.capH);
|
||||
this->bsRouteInfo->viaSpace = std::move(bsData.viaSpace);
|
||||
this->bsRouteInfo->blockagePorosity = bsData.blockagePorosity;
|
||||
// this->grGrid.gcellNX = bsData.gridNX;
|
||||
// this->grGrid.gcellNY = bsData.gridNY;
|
||||
// this->grGrid.gcellL = bsData.gridOriginX;
|
||||
@ -505,13 +521,15 @@ bool Database::readBSAux(const std::string& auxFile, const std::string& plFile)
|
||||
// this->grGrid.viaSpacing = std::move(bsData.viaSpace);
|
||||
// this->grGrid.minPitch.resize(nLayers);
|
||||
// for (int i = 0; i < nLayers; i++) {
|
||||
// this->grGrid.minPitch[i] = this->grGrid.minWireWidth[i] + this->grGrid.minWireSpacing[i];
|
||||
// this->grGrid.minPitch[i] = this->grGrid.minWireWidth[i] +
|
||||
// this->grGrid.minWireSpacing[i];
|
||||
// }
|
||||
}
|
||||
|
||||
// NOTE: ICCAD/DAC 2012 does not define trackPitch and the capacity of each GCell
|
||||
// cannot be directly computed by tracks. We restore the bookshelf capacity value
|
||||
// in Database::Others::capV(H) and will handle them in GRDatabase.
|
||||
// NOTE: ICCAD/DAC 2012 does not define trackPitch and the capacity of each
|
||||
// GCell cannot be directly computed by tracks. We restore the bookshelf
|
||||
// capacity value in Database::Others::capV(H) and will handle them in
|
||||
// GRDatabase.
|
||||
logger.info("parsing layers");
|
||||
int defaultPitch = bsData.siteWidth;
|
||||
int defaultWidth = bsData.siteWidth / 2;
|
||||
@ -519,8 +537,8 @@ bool Database::readBSAux(const std::string& auxFile, const std::string& plFile)
|
||||
char m1direction = 'h'; // M1 Route layer, rIndex == 0
|
||||
char m2direction = 'v'; // M2 Route layer, rIndex == 1
|
||||
if ((nLayers > 1) && (bsData.format == "dac2012")) {
|
||||
m1direction = (this->bsRouteInfo.capV[1] > 0) ? 'h' : 'v';
|
||||
m2direction = (this->bsRouteInfo.capV[1] > 0) ? 'v' : 'h';
|
||||
m1direction = (this->bsRouteInfo->capV[1] > 0) ? 'h' : 'v';
|
||||
m2direction = (this->bsRouteInfo->capV[1] > 0) ? 'v' : 'h';
|
||||
}
|
||||
for (unsigned i = 0; i != nLayers; ++i) {
|
||||
Layer& layer = this->addLayer(string("M").append(std::to_string(i + 1)), 'r');
|
||||
@ -579,7 +597,8 @@ bool Database::readBSAux(const std::string& auxFile, const std::string& plFile)
|
||||
direction = 'o';
|
||||
break;
|
||||
case 'B':
|
||||
// We temporarily use 'x' to represent pin direction B in Bookshelf
|
||||
// We temporarily use 'x' to represent pin direction B in
|
||||
// Bookshelf
|
||||
direction = 'x';
|
||||
break;
|
||||
default:
|
||||
@ -620,7 +639,8 @@ bool Database::readBSAux(const std::string& auxFile, const std::string& plFile)
|
||||
} else {
|
||||
string celltypename(bsData.typeName[typeID]);
|
||||
Cell* cell = this->addCell(bsData.cellName[i], this->getCellType(celltypename));
|
||||
// In Bookshelf, we don't need to consider the cell orient, set it as -1
|
||||
// In Bookshelf, we don't need to consider the cell orient, set it
|
||||
// as -1
|
||||
cell->place(bsData.cellX[i], bsData.cellY[i], -1);
|
||||
// cout<<cell->x<<","<<cell->y<<endl;
|
||||
cell->fixed((bsData.cellFixed[i] == (char)1));
|
||||
@ -717,7 +737,8 @@ bool Database::readBSNodes(const std::string& file) {
|
||||
cType = tokens[3];
|
||||
}
|
||||
// if (cWidth == 0 || cHeight == 0) {
|
||||
// logger.warning("Node %s (Type %s) has irregular shape: width %d height %d.",
|
||||
// logger.warning("Node %s (Type %s) has irregular shape: width
|
||||
// %d height %d.",
|
||||
// cName.c_str(),
|
||||
// cType.c_str(),
|
||||
// cWidth,
|
||||
@ -810,11 +831,14 @@ bool Database::readBSNets(const std::string& file) {
|
||||
pinY = bsData.typeHeight[typeID] * 0.5 + (double)atof(tokens[3].c_str());
|
||||
/*
|
||||
if(tokens.size() >= 6){
|
||||
//pinX = (int)round(atof(tokens[4].c_str())*bsData.siteWidth);
|
||||
//pinY = (int)round(atof(tokens[5].c_str())*bsData.siteWidth);
|
||||
}else{
|
||||
pinX = bsData.typeWidth[typeID] * 0.5 + (int)round(atof(tokens[2].c_str()));
|
||||
pinY = bsData.typeHeight[typeID] * 0.5 + (int)round(atof(tokens[3].c_str()));
|
||||
//pinX =
|
||||
(int)round(atof(tokens[4].c_str())*bsData.siteWidth);
|
||||
//pinY =
|
||||
(int)round(atof(tokens[5].c_str())*bsData.siteWidth); }else{
|
||||
pinX = bsData.typeWidth[typeID] * 0.5 +
|
||||
(int)round(atof(tokens[2].c_str())); pinY =
|
||||
bsData.typeHeight[typeID] * 0.5 +
|
||||
(int)round(atof(tokens[3].c_str()));
|
||||
}
|
||||
*/
|
||||
string pinName = (tokens.size() < 7) ? "" : tokens[6];
|
||||
@ -953,7 +977,8 @@ bool Database::readBSRoute(const std::string& file) {
|
||||
bsData.tileH = atoi(tokens[2].c_str());
|
||||
} else if (tokens[0] == "BlockagePorosity") {
|
||||
bsData.blockagePorosity = atof(tokens[1].c_str());
|
||||
// assert_msg(bsData.blockagePorosity == 0, "We haven't yet supported non-zero blockagePorosity");
|
||||
// assert_msg(bsData.blockagePorosity == 0, "We haven't yet
|
||||
// supported non-zero blockagePorosity");
|
||||
} else if (tokens[0] == "NumNiTerminals") {
|
||||
status = ReadingPinLayer;
|
||||
} else if (tokens[0] == "NumBlockageNodes") {
|
||||
@ -994,7 +1019,8 @@ bool Database::readBSRoute(const std::string& file) {
|
||||
int ty = atoi(tokens[4].c_str());
|
||||
int tz = atoi(tokens[5].c_str());
|
||||
int cap = atoi(tokens[6].c_str());
|
||||
cout<<fx<<" "<<fy<<" "<<fz<<" "<<tx<<" "<<ty<<" "<<tz<<" "<<cap<<endl;
|
||||
cout<<fx<<" "<<fy<<" "<<fz<<" "<<tx<<" "<<ty<<" "<<tz<<"
|
||||
"<<cap<<endl;
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,8 @@
|
||||
#include "common/db/Cell.h"
|
||||
#include "common/db/Database.h"
|
||||
#include "common/db/DatabaseClass.h"
|
||||
#include "common/db/Layer.h"
|
||||
#include "common/db/Row.h"
|
||||
|
||||
using namespace db;
|
||||
|
||||
|
||||
@ -1,4 +1,24 @@
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
#include "common/db/BsRouteInfo.h"
|
||||
#include "common/db/Cell.h"
|
||||
#include "common/db/Database.h"
|
||||
#include "common/db/DatabaseClass.h"
|
||||
#include "common/db/DesignRule.h"
|
||||
#include "common/db/GCellGrid.h"
|
||||
#include "common/db/Geometry.h"
|
||||
#include "common/db/Layer.h"
|
||||
#include "common/db/Net.h"
|
||||
#include "common/db/Pin.h"
|
||||
#include "common/db/Region.h"
|
||||
#include "common/db/Row.h"
|
||||
#include "common/db/SNet.h"
|
||||
#include "common/db/Site.h"
|
||||
#include "common/db/SiteMap.h"
|
||||
#include "common/db/Via.h"
|
||||
|
||||
// tcl have another definition of EXTERN
|
||||
#undef EXTERN
|
||||
@ -349,7 +369,7 @@ bool Database::readDEFPG(const std::string& file) {
|
||||
}
|
||||
// snet->addShape(*layer, lx, ly, hx, hy);
|
||||
if ((layer->rIndex == 0 || layer->rIndex == 1) && direction == 'h') {
|
||||
// db->powerNet.addRail(snet, lx, hx, fy);
|
||||
// db->powerNet->addRail(snet, lx, hx, fy);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -385,17 +405,20 @@ bool Database::writeComponents(std::ofstream& ofs) {
|
||||
std::ofstream& oss = ofs;
|
||||
#endif
|
||||
oss << " - " << cell->name() << " " << cell->ctype()->name << std::endl;
|
||||
// ofs << " - " << cell->name() << " " << cell->ctype()->name << std::endl;
|
||||
// ofs << " - " << cell->name() << " " << cell->ctype()->name <<
|
||||
// std::endl;
|
||||
if (cell->fixed()) {
|
||||
oss << " + FIXED ( " << cell->lx() << " " << cell->ly() << " ) " << getOrient(cell->orient()) << " ;"
|
||||
<< std::endl;
|
||||
// ofs << " + FIXED ( " << cell->lx() << " " << cell->ly() << " ) "
|
||||
// ofs << " + FIXED ( " << cell->lx() << " " << cell->ly() << "
|
||||
// ) "
|
||||
// << getOrient(cell->orient())
|
||||
// << " ;" << std::endl;
|
||||
} else if (cell->placed()) {
|
||||
oss << " + PLACED ( " << cell->lx() << " " << cell->ly() << " ) " << getOrient(cell->orient()) << " ;"
|
||||
<< std::endl;
|
||||
// ofs << " + PLACED ( " << cell->lx() << " " << cell->ly() << " ) "
|
||||
// ofs << " + PLACED ( " << cell->lx() << " " << cell->ly() <<
|
||||
// " ) "
|
||||
// << getOrient(cell->orient())
|
||||
// << " ;" << std::endl;
|
||||
} else {
|
||||
@ -463,7 +486,8 @@ bool Database::writeICCAD2017(const string& outputDef) {
|
||||
}
|
||||
logger.info("writing %s", outputDef.c_str());
|
||||
|
||||
writeComponents(ofs); // just replace the information of components, while others keep remain.
|
||||
writeComponents(ofs); // just replace the information of components, while
|
||||
// others keep remain.
|
||||
|
||||
ofs << "END DESIGN\n\n" << std::endl;
|
||||
|
||||
@ -620,7 +644,9 @@ bool Database::writeBuffer(std::ofstream& ofs, const string& line) {
|
||||
b += nw;
|
||||
}
|
||||
|
||||
ofs.write(_buffer, _bufferCapacity); // From _buffer write _bufferCapacity charcters to ostream
|
||||
ofs.write(_buffer,
|
||||
_bufferCapacity); // From _buffer write _bufferCapacity
|
||||
// charcters to ostream
|
||||
_bufferSize = 0;
|
||||
}
|
||||
|
||||
@ -698,36 +724,36 @@ int readLefProp(lefrCallbackType_e c, lefiProp* prop, lefiUserData ud) {
|
||||
if (setting.EdgeSpacing) {
|
||||
dbdist = (int)round(microndist * db->LefConvertFactor);
|
||||
}
|
||||
int type1_idx = db->edgetypes.getEdgeType(type1);
|
||||
int type2_idx = db->edgetypes.getEdgeType(type2);
|
||||
int type1_idx = db->edgetypes->getEdgeType(type1);
|
||||
int type2_idx = db->edgetypes->getEdgeType(type2);
|
||||
|
||||
if (type1_idx < 0) {
|
||||
type1_idx = db->edgetypes.types.size();
|
||||
db->edgetypes.types.push_back(type1);
|
||||
type1_idx = db->edgetypes->types.size();
|
||||
db->edgetypes->types.push_back(type1);
|
||||
}
|
||||
if (type2_idx < 0) {
|
||||
type2_idx = db->edgetypes.types.size();
|
||||
db->edgetypes.types.push_back(type2);
|
||||
type2_idx = db->edgetypes->types.size();
|
||||
db->edgetypes->types.push_back(type2);
|
||||
}
|
||||
|
||||
int numEdgeTypes = db->edgetypes.types.size();
|
||||
if (numEdgeTypes > (int)db->edgetypes.distTable.size()) {
|
||||
db->edgetypes.distTable.resize(numEdgeTypes);
|
||||
int numEdgeTypes = db->edgetypes->types.size();
|
||||
if (numEdgeTypes > (int)db->edgetypes->distTable.size()) {
|
||||
db->edgetypes->distTable.resize(numEdgeTypes);
|
||||
}
|
||||
for (int i = 0; i < numEdgeTypes; i++) {
|
||||
db->edgetypes.distTable[i].resize(numEdgeTypes, 0);
|
||||
db->edgetypes->distTable[i].resize(numEdgeTypes, 0);
|
||||
}
|
||||
db->edgetypes.distTable[type1_idx][type2_idx] = dbdist;
|
||||
db->edgetypes.distTable[type2_idx][type1_idx] = dbdist;
|
||||
db->edgetypes->distTable[type1_idx][type2_idx] = dbdist;
|
||||
db->edgetypes->distTable[type2_idx][type1_idx] = dbdist;
|
||||
}
|
||||
if (buffer == ";") {
|
||||
break;
|
||||
}
|
||||
}
|
||||
// default edge type dist
|
||||
for (unsigned i = 0; i < db->edgetypes.types.size(); i++) {
|
||||
db->edgetypes.distTable[0][i] = 0;
|
||||
db->edgetypes.distTable[i][0] = 0;
|
||||
for (unsigned i = 0; i < db->edgetypes->types.size(); i++) {
|
||||
db->edgetypes->distTable[0][i] = 0;
|
||||
db->edgetypes->distTable[i][0] = 0;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
@ -820,7 +846,8 @@ int readLefLayer(lefrCallbackType_e c, lefiLayer* leflayer, lefiUserData ud) {
|
||||
|
||||
if (leflayer->lefiLayer::hasSpacingNumber()) {
|
||||
for (int i = 0; i < leflayer->lefiLayer::numSpacing(); i++) {
|
||||
// spaceType: 0 -> minSpacing, 1 -> maxEOLSpace, 2 -> maxEOLSpaceParallelEdge
|
||||
// spaceType: 0 -> minSpacing, 1 -> maxEOLSpace, 2 ->
|
||||
// maxEOLSpaceParallelEdge
|
||||
int spaceType = 0;
|
||||
int spacing, width, within, parSpace, parWithin;
|
||||
spacing = lround(leflayer->lefiLayer::spacing(i) * convertFactor);
|
||||
@ -1233,9 +1260,9 @@ int readLefMacro(lefrCallbackType_e c, lefiMacro* macro, lefiUserData ud) {
|
||||
string edgetype;
|
||||
ssedgetype >> edgeside >> edgetype;
|
||||
if (edgeside == "LEFT") {
|
||||
celltype->edgetypeL = db->edgetypes.getEdgeType(edgetype);
|
||||
celltype->edgetypeL = db->edgetypes->getEdgeType(edgetype);
|
||||
} else if (edgeside == "RIGHT") {
|
||||
celltype->edgetypeR = db->edgetypes.getEdgeType(edgetype);
|
||||
celltype->edgetypeR = db->edgetypes->getEdgeType(edgetype);
|
||||
} else if (edgeside == "BOTTOM") {
|
||||
static bool missBot = true;
|
||||
if (missBot) {
|
||||
@ -1350,13 +1377,13 @@ int readDefGcellGrid(defrCallbackType_e c, defiGcellGrid* dgrid, defiUserData ud
|
||||
Database* db = (Database*)ud;
|
||||
const string macro(dgrid->macro());
|
||||
if (macro == "X") {
|
||||
db->gcellgrid.numX.emplace_back(dgrid->xNum());
|
||||
db->gcellgrid.stepX.emplace_back(dgrid->xStep());
|
||||
db->gcellgrid.startX.emplace_back(dgrid->x());
|
||||
db->gcellgrid->numX.emplace_back(dgrid->xNum());
|
||||
db->gcellgrid->stepX.emplace_back(dgrid->xStep());
|
||||
db->gcellgrid->startX.emplace_back(dgrid->x());
|
||||
} else if (macro == "Y") {
|
||||
db->gcellgrid.numY.emplace_back(dgrid->xNum());
|
||||
db->gcellgrid.stepY.emplace_back(dgrid->xStep());
|
||||
db->gcellgrid.startY.emplace_back(dgrid->x());
|
||||
db->gcellgrid->numY.emplace_back(dgrid->xNum());
|
||||
db->gcellgrid->stepY.emplace_back(dgrid->xStep());
|
||||
db->gcellgrid->startY.emplace_back(dgrid->x());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -1500,10 +1527,12 @@ int readDefComponent(defrCallbackType_e c, defiComponent* co, defiUserData ud) {
|
||||
cell->fixed(true);
|
||||
if (co->placementOrient() % 2 == 1) {
|
||||
// 0:N, 1:W, 2:S, 3:E, 4:FN, 5:FW, 6:FS, 7:FE, -1:NONE
|
||||
logger.warning("Fixed Cell [%s]'s placementOrient [%s] is not supported, CLASS: %s.",
|
||||
cell->name().c_str(),
|
||||
getOrient(co->placementOrient()).c_str(),
|
||||
celltype->cls.c_str());
|
||||
logger.warning(
|
||||
"Fixed Cell [%s]'s placementOrient [%s] is not supported, "
|
||||
"CLASS: %s.",
|
||||
cell->name().c_str(),
|
||||
getOrient(co->placementOrient()).c_str(),
|
||||
celltype->cls.c_str());
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
@ -1550,8 +1579,10 @@ int readDefPin(defrCallbackType_e c, defiPin* dpin, defiUserData ud) {
|
||||
for (int j = 0; j < dpin->numPorts(); j++) {
|
||||
if (j > 1) {
|
||||
string pinName(dpin->pinName());
|
||||
logger.warning("DefPin %s has multiple ports. We currently only support single port definition",
|
||||
pinName.c_str());
|
||||
logger.warning(
|
||||
"DefPin %s has multiple ports. We currently only support "
|
||||
"single port definition",
|
||||
pinName.c_str());
|
||||
break;
|
||||
}
|
||||
defiPinPort* port = dpin->pinPort(j);
|
||||
@ -1686,7 +1717,7 @@ int readDefSNet(defrCallbackType_e c, defiNet* dnet, defiUserData ud) {
|
||||
}
|
||||
snet->addShape(*layer, lx, ly, hx, hy);
|
||||
if ((layer->rIndex == 0 || layer->rIndex == 1) && fy == ty) {
|
||||
db->powerNet.addRail(snet, lx, hx, fy);
|
||||
db->powerNet->addRail(snet, lx, hx, fy);
|
||||
}
|
||||
fx = tx;
|
||||
fy = ty;
|
||||
@ -1717,7 +1748,7 @@ int readDefSNet(defrCallbackType_e c, defiNet* dnet, defiUserData ud) {
|
||||
}
|
||||
snet->addShape(*layer, lx, ly, hx, hy);
|
||||
if ((layer->rIndex == 0 || layer->rIndex == 1) && fy == ty) {
|
||||
db->powerNet.addRail(snet, lx, hx, fy);
|
||||
db->powerNet->addRail(snet, lx, hx, fy);
|
||||
}
|
||||
fx = tx;
|
||||
fy = ty;
|
||||
@ -1891,7 +1922,8 @@ int readDefRegion(defrCallbackType_e c, defiRegion* dreg, defiUserData ud) {
|
||||
}
|
||||
|
||||
//-----Group-----
|
||||
// #define GROUP_MARKER 9999999 //first mark all group member cell with this marker, then replace the value in one scan
|
||||
// #define GROUP_MARKER 9999999 //first mark all group member cell with this
|
||||
// marker, then replace the value in one scan
|
||||
int readDefGroupName(defrCallbackType_e c, const char* cl, defiUserData ud) { return 0; }
|
||||
|
||||
int readDefGroupMember(defrCallbackType_e c, const char* cl, defiUserData ud) {
|
||||
|
||||
@ -1,4 +1,8 @@
|
||||
#include "common/db/Cell.h"
|
||||
#include "common/db/Database.h"
|
||||
#include "common/db/Layer.h"
|
||||
#include "common/db/Net.h"
|
||||
#include "common/db/Pin.h"
|
||||
|
||||
using namespace db;
|
||||
|
||||
@ -135,7 +139,7 @@ bool Database::readVerilog(const std::string &file) {
|
||||
if (!iopin) {
|
||||
logger.error("io pin not found: %s", pinName.c_str());
|
||||
}
|
||||
Pin* pin = iopin->pin;
|
||||
Pin *pin = iopin->pin;
|
||||
iopin->is_connected = true;
|
||||
Net *net = addNet(pinName);
|
||||
|
||||
|
||||
@ -10,6 +10,4 @@ target_compile_definitions(${TARGET_NAME} PRIVATE
|
||||
TORCH_MINOR_VERSION=${TORCH_MINOR_VERSION}
|
||||
ENABLE_CUDA=0)
|
||||
|
||||
install(TARGETS
|
||||
${TARGET_NAME}
|
||||
DESTINATION ${XPLACE_LIB_DIR})
|
||||
install(TARGETS ${TARGET_NAME} DESTINATION ${XPLACE_LIB_DIR})
|
||||
@ -8,30 +8,27 @@ file(GLOB_RECURSE SRC_FILES_DP_CUDA ${CMAKE_CURRENT_SOURCE_DIR}/*.cu)
|
||||
# OpenMP
|
||||
find_package(OpenMP REQUIRED)
|
||||
|
||||
# CUDA DP Kernel
|
||||
cuda_add_library(dp_cuda_tmp STATIC ${SRC_FILES_DP_CUDA})
|
||||
# CUDA/CPP DP Kernel
|
||||
add_library(dp STATIC ${CMAKE_CURRENT_SOURCE_DIR}/../io_parser/gp/GPDatabase.cpp
|
||||
${SRC_FILES_DP}
|
||||
${SRC_FILES_DP_CUDA})
|
||||
|
||||
set_target_properties(dp_cuda_tmp PROPERTIES CUDA_RESOLVE_DEVICE_SYMBOLS ON)
|
||||
set_target_properties(dp_cuda_tmp PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
|
||||
set_target_properties(dp_cuda_tmp PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
||||
set_target_properties(dp PROPERTIES
|
||||
CUDA_RESOLVE_DEVICE_SYMBOLS ON
|
||||
POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
target_include_directories(dp_cuda_tmp PRIVATE ${PROJECT_SOURCE_DIR}/cpp_to_py ${TORCH_INCLUDE_DIRS} ${FLUTE_INCLUDE_DIR})
|
||||
target_link_libraries(dp_cuda_tmp torch ${TORCH_PYTHON_LIBRARY} xplace_common flute OpenMP::OpenMP_CXX)
|
||||
|
||||
# CPU DP object
|
||||
add_library(dp SHARED ${CMAKE_CURRENT_SOURCE_DIR}/../io_parser/gp/GPDatabase.cpp
|
||||
${SRC_FILES_DP}
|
||||
${SRC_FILES_DP_CUDA})
|
||||
|
||||
target_include_directories(dp PRIVATE ${PROJECT_SOURCE_DIR}/cpp_to_py ${TORCH_INCLUDE_DIRS} ${FLUTE_INCLUDE_DIR})
|
||||
target_link_libraries(dp PRIVATE torch ${TORCH_PYTHON_LIBRARY} xplace_common flute dp_cuda_tmp pthread CUDA::curand)
|
||||
target_include_directories(dp PRIVATE ${TORCH_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/cpp_to_py)
|
||||
target_link_libraries(dp PRIVATE torch ${TORCH_PYTHON_LIBRARY} xplace_common OpenMP::OpenMP_CXX pthread CUDA::curand)
|
||||
target_compile_options(dp PRIVATE -fPIC)
|
||||
|
||||
install(TARGETS dp DESTINATION ${XPLACE_LIB_DIR})
|
||||
pybind11_add_module(gpudp MODULE PyBindCppMain.cpp)
|
||||
|
||||
# For Pybind
|
||||
add_pytorch_extension(gpudp PyBindCppMain.cpp
|
||||
EXTRA_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/cpp_to_py ${FLUTE_INCLUDE_DIR}
|
||||
EXTRA_LINK_LIBRARIES xplace_common flute io_parser dp)
|
||||
target_include_directories(gpudp PRIVATE ${TORCH_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/cpp_to_py)
|
||||
target_link_libraries(gpudp PRIVATE torch ${TORCH_PYTHON_LIBRARY} xplace_common io_parser dp)
|
||||
target_compile_definitions(gpudp PRIVATE
|
||||
TORCH_EXTENSION_NAME=gpudp
|
||||
TORCH_VERSION_MAJOR=${TORCH_VERSION_MAJOR}
|
||||
TORCH_VERSION_MINOR=${TORCH_VERSION_MINOR}
|
||||
ENABLE_CUDA=${TORCH_ENABLE_CUDA})
|
||||
|
||||
install(TARGETS gpudp DESTINATION ${XPLACE_LIB_DIR})
|
||||
|
||||
@ -2,7 +2,10 @@
|
||||
|
||||
#include <torch/extension.h>
|
||||
#include "common/common.h"
|
||||
#include "common/db/Database.h"
|
||||
|
||||
namespace db {
|
||||
class Database;
|
||||
}
|
||||
|
||||
namespace dp {
|
||||
|
||||
|
||||
@ -4,7 +4,6 @@
|
||||
#include <cuda_runtime.h>
|
||||
|
||||
#include "common/common.h"
|
||||
#include "common/db/Database.h"
|
||||
#include "gpudp/db/dp_torch.h"
|
||||
#include "pitch_nested_vector.cuh"
|
||||
#include "utils.cuh"
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "common/common.h"
|
||||
#include "common/db/Database.h"
|
||||
#include "gpudp/db/dp_torch.h"
|
||||
|
||||
namespace dp {
|
||||
|
||||
@ -3,67 +3,29 @@ file(GLOB_RECURSE SRC_FILES_GGR ${CMAKE_CURRENT_SOURCE_DIR}/db/*.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/gr/*.cpp)
|
||||
file(GLOB_RECURSE SRC_FILES_GGR_CUDA ${CMAKE_CURRENT_SOURCE_DIR}/*.cu)
|
||||
|
||||
# CUDA GGR Kernel
|
||||
cuda_add_library(ggr_cuda_tmp STATIC ${SRC_FILES_GGR_CUDA})
|
||||
|
||||
set_target_properties(ggr_cuda_tmp PROPERTIES CUDA_RESOLVE_DEVICE_SYMBOLS ON)
|
||||
set_target_properties(ggr_cuda_tmp PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
|
||||
set_target_properties(ggr_cuda_tmp PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
target_include_directories(ggr_cuda_tmp PRIVATE ${PROJECT_SOURCE_DIR}/cpp_to_py ${TORCH_INCLUDE_DIRS} ${FLUTE_INCLUDE_DIR})
|
||||
target_link_libraries(ggr_cuda_tmp torch ${TORCH_PYTHON_LIBRARY} xplace_common flute)
|
||||
# target_compile_options(ggr_cuda_tmp PRIVATE "$<$<COMPILE_LANGUAGE:CUDA>:SHELL:-use_fast_math>") # not work...
|
||||
|
||||
|
||||
# CPU GGR object
|
||||
add_library(ggr SHARED ${CMAKE_CURRENT_SOURCE_DIR}/../io_parser/gp/GPDatabase.cpp
|
||||
# CUDA/CPP GGR Kernel
|
||||
add_library(ggr STATIC ${CMAKE_CURRENT_SOURCE_DIR}/../io_parser/gp/GPDatabase.cpp
|
||||
${SRC_FILES_GGR}
|
||||
${SRC_FILES_GGR_CUDA})
|
||||
|
||||
target_include_directories(ggr PRIVATE ${PROJECT_SOURCE_DIR}/cpp_to_py ${TORCH_INCLUDE_DIRS} ${FLUTE_INCLUDE_DIR})
|
||||
target_link_libraries(ggr PRIVATE torch ${TORCH_PYTHON_LIBRARY} xplace_common flute ggr_cuda_tmp pthread)
|
||||
set_target_properties(ggr PROPERTIES
|
||||
CUDA_RESOLVE_DEVICE_SYMBOLS ON
|
||||
POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
target_include_directories(ggr PRIVATE ${TORCH_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/cpp_to_py ${FLUTE_INCLUDE_DIR})
|
||||
target_link_libraries(ggr PRIVATE torch ${TORCH_PYTHON_LIBRARY} xplace_common flute pthread)
|
||||
target_compile_options(ggr PRIVATE -fPIC)
|
||||
target_compile_options(ggr PRIVATE "$<$<COMPILE_LANGUAGE:CUDA>:--extended-lambda>")
|
||||
|
||||
install(TARGETS ggr DESTINATION ${XPLACE_LIB_DIR})
|
||||
pybind11_add_module(gpugr MODULE PyBindCppMain.cpp)
|
||||
|
||||
target_include_directories(gpugr PRIVATE ${TORCH_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/cpp_to_py ${FLUTE_INCLUDE_DIR})
|
||||
target_link_libraries(gpugr PRIVATE torch ${TORCH_PYTHON_LIBRARY} xplace_common flute io_parser ggr)
|
||||
target_compile_definitions(gpugr PRIVATE
|
||||
TORCH_EXTENSION_NAME=gpugr
|
||||
TORCH_VERSION_MAJOR=${TORCH_VERSION_MAJOR}
|
||||
TORCH_VERSION_MINOR=${TORCH_VERSION_MINOR}
|
||||
ENABLE_CUDA=${TORCH_ENABLE_CUDA})
|
||||
|
||||
# For Pybind
|
||||
add_pytorch_extension(gpugr PyBindCppMain.cpp
|
||||
EXTRA_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/cpp_to_py ${FLUTE_INCLUDE_DIR}
|
||||
EXTRA_LINK_LIBRARIES xplace_common flute io_parser ggr)
|
||||
|
||||
install(TARGETS gpugr DESTINATION ${XPLACE_LIB_DIR})
|
||||
|
||||
################ For debug only ##################
|
||||
|
||||
# set(CMAKE_BUILD_TYPE Release)
|
||||
# set(CMAKE_CXX_STANDARD 17)
|
||||
# set(CMAKE_CUDA17_EXTENSION_COMPILE_OPTION "-std=c++17")
|
||||
# set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -arch sm_86 --extended-lambda --use_fast_math ")
|
||||
# project(ggr LANGUAGES C CXX CUDA)
|
||||
|
||||
# file(GLOB_RECURSE SRC_FILES_GR2 ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
|
||||
# file(GLOB_RECURSE SRC_FILES_GR2_CUDA ${CMAKE_CURRENT_SOURCE_DIR}/*.cu)
|
||||
|
||||
# add_executable(gpugr_cpp PyBindCppMain.cpp
|
||||
# ${CMAKE_CURRENT_SOURCE_DIR}/../io_parser/gp/GPDatabase.cpp
|
||||
# ${SRC_FILES_GR2}
|
||||
# ${SRC_FILES_GR2_CUDA})
|
||||
|
||||
# set_target_properties(gpugr_cpp PROPERTIES CUDA_RESOLVE_DEVICE_SYMBOLS ON)
|
||||
# set_target_properties(gpugr_cpp PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
|
||||
# set_target_properties(gpugr_cpp PROPERTIES LINK_FLAGS "-Wl,--whole-archive -rdynamic -lpthread -Wl,--no-whole-archive")
|
||||
|
||||
# target_include_directories(
|
||||
# gpugr_cpp PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/.. ${PROJECT_SOURCE_DIR}/cpp_to_py ${FLUTE_INCLUDE_DIR} ${TORCH_INCLUDE_DIRS})
|
||||
# target_link_libraries(
|
||||
# gpugr_cpp PRIVATE torch ${TORCH_PYTHON_LIBRARY} flute xplace_common)
|
||||
|
||||
# target_compile_options(gpugr_cpp PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:
|
||||
# -arch=sm_86
|
||||
# --use_fast_math
|
||||
# -std=c++17
|
||||
# >)
|
||||
|
||||
# install(TARGETS
|
||||
# gpugr_cpp
|
||||
# DESTINATION ${XPLACE_LIB_DIR})
|
||||
@ -1,5 +1,6 @@
|
||||
#include "common/common.h"
|
||||
#include "common/db/Database.h"
|
||||
#include "io_parser/gp/GPDatabase.h"
|
||||
#include "gpugr/db/GRDatabase.h"
|
||||
#include "gpugr/gr/RouteForce.h"
|
||||
#include "flute.h"
|
||||
|
||||
@ -1,5 +1,16 @@
|
||||
#include "GRDatabase.h"
|
||||
|
||||
#include "common/db/BsRouteInfo.h"
|
||||
#include "common/db/Cell.h"
|
||||
#include "common/db/Database.h"
|
||||
#include "common/db/Layer.h"
|
||||
#include "common/db/GCellGrid.h"
|
||||
#include "common/db/Net.h"
|
||||
#include "common/db/Pin.h"
|
||||
#include "common/db/SNet.h"
|
||||
#include "common/db/Via.h"
|
||||
#include "io_parser/gp/GPDatabase.h"
|
||||
|
||||
namespace gr {
|
||||
|
||||
GRDatabase::~GRDatabase() { logger.info("destruct grdb"); }
|
||||
@ -67,9 +78,9 @@ GRDatabase::GRDatabase(std::shared_ptr<db::Database> rawdb_, std::shared_ptr<gp:
|
||||
|
||||
// 2) init gcellgrid
|
||||
// 2.1) grid lines
|
||||
db::GCellGrid& gcellgrid = rawdb.gcellgrid;
|
||||
db::GCellGrid* gcellgrid = rawdb.gcellgrid;
|
||||
gridlines.resize(2);
|
||||
if (!gcellgrid.numX.size() || !gcellgrid.numY.size()) {
|
||||
if (!gcellgrid->numX.size() || !gcellgrid->numY.size()) {
|
||||
if (grSetting.routeXSize <= 0 || grSetting.routeYSize <= 0) {
|
||||
grSetting.routeXSize = 512;
|
||||
grSetting.routeYSize = 512;
|
||||
@ -77,16 +88,16 @@ GRDatabase::GRDatabase(std::shared_ptr<db::Database> rawdb_, std::shared_ptr<gp:
|
||||
}
|
||||
if (grSetting.routeXSize <= 0 || grSetting.routeYSize <= 0) {
|
||||
gridlines[0].emplace_back(0);
|
||||
for (int idx = 0; idx < gcellgrid.numX.size(); idx++) {
|
||||
for (int i = 1; i < gcellgrid.numX[idx]; i++) {
|
||||
gridlines[0].emplace_back(gcellgrid.startX[idx] + i * gcellgrid.stepX[idx]);
|
||||
for (int idx = 0; idx < gcellgrid->numX.size(); idx++) {
|
||||
for (int i = 1; i < gcellgrid->numX[idx]; i++) {
|
||||
gridlines[0].emplace_back(gcellgrid->startX[idx] + i * gcellgrid->stepX[idx]);
|
||||
}
|
||||
}
|
||||
|
||||
gridlines[1].emplace_back(0);
|
||||
for (int idx = 0; idx < gcellgrid.numY.size(); idx++) {
|
||||
for (int i = 1; i < gcellgrid.numY[idx]; i++) {
|
||||
gridlines[1].emplace_back(gcellgrid.startY[idx] + i * gcellgrid.stepY[idx]);
|
||||
for (int idx = 0; idx < gcellgrid->numY.size(); idx++) {
|
||||
for (int i = 1; i < gcellgrid->numY[idx]; i++) {
|
||||
gridlines[1].emplace_back(gcellgrid->startY[idx] + i * gcellgrid->stepY[idx]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -109,16 +120,16 @@ GRDatabase::GRDatabase(std::shared_ptr<db::Database> rawdb_, std::shared_ptr<gp:
|
||||
|
||||
if (grSetting.routeXSize <= 0 || grSetting.routeYSize <= 0) {
|
||||
int largeNumX = -1, largeNumY = -1;
|
||||
for (int idx = 0; idx < gcellgrid.numX.size(); idx++) {
|
||||
if (largeNumX < gcellgrid.numX[idx]) {
|
||||
largeNumX = gcellgrid.numX[idx];
|
||||
mainGcellStepX = gcellgrid.stepX[idx];
|
||||
for (int idx = 0; idx < gcellgrid->numX.size(); idx++) {
|
||||
if (largeNumX < gcellgrid->numX[idx]) {
|
||||
largeNumX = gcellgrid->numX[idx];
|
||||
mainGcellStepX = gcellgrid->stepX[idx];
|
||||
}
|
||||
}
|
||||
for (int idx = 0; idx < gcellgrid.numY.size(); idx++) {
|
||||
if (largeNumY < gcellgrid.numY[idx]) {
|
||||
largeNumY = gcellgrid.numY[idx];
|
||||
mainGcellStepY = gcellgrid.stepY[idx];
|
||||
for (int idx = 0; idx < gcellgrid->numY.size(); idx++) {
|
||||
if (largeNumY < gcellgrid->numY[idx]) {
|
||||
largeNumY = gcellgrid->numY[idx];
|
||||
mainGcellStepY = gcellgrid->stepY[idx];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -191,7 +202,7 @@ void GRDatabase::setupCapacity() {
|
||||
void GRDatabase::setupCapacityBookshelf() {
|
||||
capacity.resize(gridGraphSize, 0);
|
||||
for (int i = 0; i < nLayers; i++) {
|
||||
int oricap = std::max(rawdb.bsRouteInfo.capH[i], rawdb.bsRouteInfo.capV[i]);
|
||||
int oricap = std::max(rawdb.bsRouteInfo->capH[i], rawdb.bsRouteInfo->capV[i]);
|
||||
float cap = oricap / (layerPitch[i]);
|
||||
if ((i & 1) ^ m1direction) {
|
||||
for (int j = 0; j < xSize; j++) {
|
||||
@ -608,7 +619,7 @@ void GRDatabase::markObsBookShelf(std::vector<RectOnLayer>& allObs,
|
||||
|
||||
std::vector<float> layer2oricap(nLayers, 0.0);
|
||||
for (int i = 0; i < nLayers; i++) {
|
||||
int oricap = std::max(rawdb.bsRouteInfo.capH[i], rawdb.bsRouteInfo.capV[i]);
|
||||
int oricap = std::max(rawdb.bsRouteInfo->capH[i], rawdb.bsRouteInfo->capV[i]);
|
||||
float cap = oricap / (layerPitch[i]);
|
||||
layer2oricap[i] = oricap;
|
||||
}
|
||||
@ -695,7 +706,7 @@ void GRDatabase::markObsBookShelf(std::vector<RectOnLayer>& allObs,
|
||||
ovlpLen = buf[0].range();
|
||||
}
|
||||
// Follow perl script dac2012_evaluate_solution.pl
|
||||
float blocked = floor((float)ovlpLen * (1.0 - rawdb.bsRouteInfo.blockagePorosity));
|
||||
float blocked = floor((float)ovlpLen * (1.0 - rawdb.bsRouteInfo->blockagePorosity));
|
||||
float availableSpace = ((float)gridIntvl.range() - blocked) / (float)gridIntvl.range();
|
||||
int adjustedCap = layer2oricap[l] * availableSpace;
|
||||
adjustedCap = std::max(0, adjustedCap);
|
||||
|
||||
@ -1,9 +1,15 @@
|
||||
#pragma once
|
||||
#include "GRSetting.h"
|
||||
#include "GrNet.h"
|
||||
#include "common/common.h"
|
||||
#include "common/db/Database.h"
|
||||
#include "io_parser/gp/GPDatabase.h"
|
||||
#include "GRSetting.h"
|
||||
|
||||
namespace db {
|
||||
class Database;
|
||||
class Cell;
|
||||
}
|
||||
namespace gp {
|
||||
class GPDatabase;
|
||||
}
|
||||
|
||||
namespace gr {
|
||||
|
||||
|
||||
@ -1,4 +1,7 @@
|
||||
#include "RouteForce.h"
|
||||
#include "common/db/Database.h"
|
||||
#include "io_parser/gp/GPDatabase.h"
|
||||
#include "gpugr/db/GRDatabase.h"
|
||||
|
||||
namespace gr {
|
||||
|
||||
|
||||
@ -1,9 +1,11 @@
|
||||
#pragma once
|
||||
#include "common/common.h"
|
||||
#include "common/db/Database.h"
|
||||
#include "gpugr/db/GRDatabase.h"
|
||||
#include "gpugr/gr/GPURouter.h"
|
||||
|
||||
namespace gr {
|
||||
class GRDatabase;
|
||||
}
|
||||
|
||||
namespace gr {
|
||||
|
||||
class RouteForce {
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
#include "BindHelper.h"
|
||||
#include "common/db/Database.h"
|
||||
#include "io_parser/gp/GPDatabase.h"
|
||||
|
||||
namespace Xplace {
|
||||
|
||||
|
||||
@ -1,8 +1,5 @@
|
||||
#pragma once
|
||||
#include "common/common.h"
|
||||
#include "common/db/Database.h"
|
||||
#include "io_parser/gp/GPDatabase.h"
|
||||
|
||||
#include <pybind11/pybind11.h>
|
||||
#include <pybind11/stl.h>
|
||||
#include <pybind11/stl_bind.h>
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
#include "BindHelper.h"
|
||||
#include "common/db/Database.h"
|
||||
#include "io_parser/gp/GPDatabase.h"
|
||||
|
||||
namespace Xplace {
|
||||
|
||||
|
||||
@ -1,5 +1,15 @@
|
||||
#include "GPDatabase.h"
|
||||
|
||||
#include "common/db/Cell.h"
|
||||
#include "common/db/Database.h"
|
||||
#include "common/db/Layer.h"
|
||||
#include "common/db/Net.h"
|
||||
#include "common/db/Pin.h"
|
||||
#include "common/db/Region.h"
|
||||
#include "common/db/Row.h"
|
||||
#include "common/db/SNet.h"
|
||||
#include "common/db/Via.h"
|
||||
|
||||
namespace gp {
|
||||
|
||||
GPDatabase::~GPDatabase() { logger.info("destruct gpdb"); }
|
||||
@ -364,7 +374,6 @@ orient_type rotate_180_orient(orient_type orient) {
|
||||
|
||||
orient_type vflip_orient(orient_type orient) { return hflip_orient(rotate_180_orient(orient)); }
|
||||
|
||||
|
||||
void GPDatabase::transferOrient() {
|
||||
// Transfer all gpdb nodes to "N" direction for global placement
|
||||
// NOTE: we don't change rawdb
|
||||
@ -592,6 +601,8 @@ void GPDatabase::setup_random_place() {
|
||||
}
|
||||
}
|
||||
|
||||
const int GPDatabase::getM1Direction() const { return database.getRLayer(0)->direction == 'v' ? 1 : 0; }
|
||||
|
||||
// Torch Related
|
||||
torch::Tensor GPDatabase::getNodeLPosTensor() {
|
||||
torch::Tensor node_lpos = torch::zeros({num_nodes, 2});
|
||||
|
||||
@ -1,7 +1,12 @@
|
||||
#pragma once
|
||||
#include <torch/extension.h>
|
||||
#include "common/common.h"
|
||||
#include "common/db/Database.h"
|
||||
|
||||
namespace db {
|
||||
class Database;
|
||||
class Pin;
|
||||
class PinType;
|
||||
}
|
||||
|
||||
namespace gp {
|
||||
|
||||
@ -210,7 +215,7 @@ public:
|
||||
const std::tuple<int, int, int, int>& getCoreInfo() const { return coreInfo; }
|
||||
const int getSiteWidth() const { return siteW; }
|
||||
const int getSiteHeight() const { return siteH; }
|
||||
const int getM1Direction() const { return database.getRLayer(0)->direction == 'v' ? 1 : 0; }
|
||||
const int getM1Direction() const;
|
||||
|
||||
// Torch related
|
||||
torch::Tensor getNodeLPosTensor();
|
||||
|
||||
@ -1,7 +1,10 @@
|
||||
#include <torch/extension.h>
|
||||
#include "common/common.h"
|
||||
#include "common/db/Database.h"
|
||||
#include "flute.h"
|
||||
#include "common/db/Geometry.h"
|
||||
#include "common/db/Layer.h"
|
||||
#include "common/db/SNet.h"
|
||||
#include "common/db/Via.h"
|
||||
#include "io_parser/gp/GPDatabase.h"
|
||||
|
||||
namespace routedp {
|
||||
|
||||
2
thirdparty/flute/CMakeLists.txt
vendored
2
thirdparty/flute/CMakeLists.txt
vendored
@ -29,7 +29,7 @@
|
||||
## USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
################################################################################
|
||||
|
||||
CMAKE_MINIMUM_REQUIRED (VERSION 3.1)
|
||||
CMAKE_MINIMUM_REQUIRED (VERSION 3.18)
|
||||
PROJECT(flute)
|
||||
|
||||
SET(CMAKE_CXX_STANDARD 11)
|
||||
|
||||
2
thirdparty/pybind11
vendored
2
thirdparty/pybind11
vendored
@ -1 +1 @@
|
||||
Subproject commit 128d988ef183cfb6334714f0bcf8b8e7b7e2e95b
|
||||
Subproject commit 83b92ceb3537666fb0188f564e1d53bf8c80b0ba
|
||||
Loading…
Reference in New Issue
Block a user