Skip to content

Commit

Permalink
mpl2: add method for placing individual macro
Browse files Browse the repository at this point in the history
Signed-off-by: Arthur Koucher <arthurckoucher@gmail.com>
  • Loading branch information
AcKoucher committed Oct 10, 2023
1 parent c8c250d commit 58fe420
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 10 deletions.
1 change: 1 addition & 0 deletions src/mpl2/include/mpl2/rtl_mp.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ class MacroPlacer2
std::unique_ptr<HierRTLMP> hier_rtlmp_;

utl::Logger* logger_ = nullptr;
odb::dbDatabase* db_ = nullptr;
};

} // namespace mpl2
43 changes: 39 additions & 4 deletions src/mpl2/src/rtl_mp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ void MacroPlacer2::init(sta::dbNetwork* network,
hier_rtlmp_
= std::make_unique<HierRTLMP>(network, db, sta, logger, tritonpart);
logger_ = logger;
db_ = db;
}

bool MacroPlacer2::place(const int max_num_macro,
Expand Down Expand Up @@ -122,7 +123,8 @@ bool MacroPlacer2::place(const int max_num_macro,
return true;
}

odb::dbOrientType MacroPlacer2::stringToOrientType(const std::string& orientation_string)
odb::dbOrientType MacroPlacer2::stringToOrientType(
const std::string& orientation_string)
{
odb::dbOrientType orientation;

Expand All @@ -146,12 +148,45 @@ void MacroPlacer2::placeMacro(odb::dbInst* inst,
float y_origin,
const std::string& orientation_string)
{
std::cout << "Macro = " << inst->getName() << '\n';
std::cout << "Origin Location = " << x_origin << " " << y_origin << '\n';
float dbu_per_micron = db_->getTech()->getDbUnitsPerMicron();

int x1 = micronToDbu(x_origin, dbu_per_micron);
int y1 = micronToDbu(y_origin, dbu_per_micron);
int x2 = x1 + inst->getBBox()->getDX();
int y2 = y1 + inst->getBBox()->getDY();

odb::Rect macro_new_bbox(x1, y1, x2, y2);
odb::Rect core_area = inst->getBlock()->getCoreArea();

if (!core_area.contains(macro_new_bbox)) {
logger_->error(MPL,
34,
"Specified location results in illegal placement. Cannot "
"place macro outside of the core.");
}

odb::dbOrientType orientation = stringToOrientType(orientation_string);

std::cout << "Orientation = " << orientation.getString() << '\n';
// Orientation must be set before location so we don't end up flipping
// and misplacing the macro.
inst->setOrient(orientation);
inst->setLocation(x1, y1);

int manufacturing_grid = db_->getTech()->getManufacturingGrid();

HardMacro macro(inst, dbu_per_micron, manufacturing_grid, 0, 0);

mpl2::Rect macro_new_bbox_micron(x_origin,
y_origin,
dbuToMicron(macro_new_bbox.xMax(), dbu_per_micron),
dbuToMicron(macro_new_bbox.yMax(), dbu_per_micron));

float pitch_x = 0.0;
float pitch_y = 0.0;

macro.alignOriginWithGrids(macro_new_bbox_micron, orientation, pitch_x, pitch_y, inst->getBlock());

inst->setPlacementStatus(odb::dbPlacementStatus::LOCKED);
}

void MacroPlacer2::writeMacroPlacement(const char* file_name)
Expand Down
6 changes: 0 additions & 6 deletions src/mpl2/test/mp_test1.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@ link_design $top_module
#
read_def $floorplan_def -floorplan_initialize

place_macro -macro_name U1 -location {20 20}
place_macro -macro_name U2 -location {34 34} -orientation R180
place_macro -macro_name U3 -location {34 34} -orientation MY
place_macro -macro_name U4 -location {34 34} -orientation MX
place_macro -macro_name U5 -location {34 34} -orientation R0
place_macro -macro_name U5 -location {34 34} -orientation chelou
rtl_macro_placer -report_directory results/mp_test1 -halo_width 5.0

set def_file [make_result_file mp_test1.def]
Expand Down

0 comments on commit 58fe420

Please sign in to comment.