Skip to content

Commit

Permalink
mpl2: add origin and orientation to interface
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 9, 2023
1 parent 7e7e9b6 commit c8c250d
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 9 deletions.
7 changes: 6 additions & 1 deletion src/mpl2/include/mpl2/rtl_mp.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
namespace odb {
class dbDatabase;
class dbInst;
class dbOrientType;
}

namespace sta {
Expand Down Expand Up @@ -100,7 +101,11 @@ class MacroPlacer2
const bool bus_planning_flag,
const char* report_directory);

void placeMacro(odb::dbInst* inst);
void placeMacro(odb::dbInst* inst,
float x_origin,
float y_origin,
const std::string& orientation_string);
odb::dbOrientType stringToOrientType(const std::string& orientation_string);

void writeMacroPlacement(const char* file_name);

Expand Down
6 changes: 4 additions & 2 deletions src/mpl2/src/mpl.i
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,11 @@ set_debug_cmd()
}

void
place_macro(odb::dbInst* macro_name)
place_macro(odb::dbInst* macro_name, float x_origin, float y_origin, const char* orientation)
{
getMacroPlacer2()->placeMacro(macro_name);
std::string orientation_string = orientation;

getMacroPlacer2()->placeMacro(macro_name, x_origin, y_origin, orientation_string);
}

void
Expand Down
29 changes: 26 additions & 3 deletions src/mpl2/src/mpl.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,14 @@ proc rtl_macro_placer { args } {
return true
}

sta::define_cmd_args "place_macro" {[-macro_name macro_name]}
sta::define_cmd_args "place_macro" {[-macro_name macro_name] \
[-location location] \
[-orientation orientation] \
}

proc place_macro { args } {
sta::parse_key_args "place_macro" args \
keys {-macro_name} \
keys {-macro_name -location -orientation} \

if [info exists keys(-macro_name)] {
set macro_name $keys(-macro_name)
Expand All @@ -266,7 +269,27 @@ proc place_macro { args } {

set macro [mpl2::parse_macro_name "place_macro" $macro_name]

mpl2::place_macro $macro
if [info exists keys(-location)] {
set location $keys(-location)
} else {
utl::error MPL 22 "-location is required."
}

if { [llength $location] != 2 } {
utl::error MPL 12 "-location is not a list of 2 values."
}
lassign $location x_origin y_origin
set x_origin $x_origin
set y_origin $y_origin

set orientation R0
if [info exists keys(-orientation)] {
set orientation $keys(-orientation)
} else {
utl::warn MPL 18 "No orientation specified for [$macro getName], defaulting to R0."
}

mpl2::place_macro $macro $x_origin $y_origin $orientation
}

sta::define_cmd_args "write_macro_placement" { file_name }
Expand Down
29 changes: 28 additions & 1 deletion src/mpl2/src/rtl_mp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,36 @@ bool MacroPlacer2::place(const int max_num_macro,
return true;
}

void MacroPlacer2::placeMacro(odb::dbInst* inst)
odb::dbOrientType MacroPlacer2::stringToOrientType(const std::string& orientation_string)
{
odb::dbOrientType orientation;

if (orientation_string == "R0") {
orientation = odb::dbOrientType::R0;
} else if (orientation_string == "MY") {
orientation = odb::dbOrientType::MY;
} else if (orientation_string == "MX") {
orientation = odb::dbOrientType::MX;
} else if (orientation_string == "R180") {
orientation = odb::dbOrientType::R180;
} else {
logger_->error(MPL, 33, "Invalid orientation {}.", orientation_string);
}

return orientation;
}

void MacroPlacer2::placeMacro(odb::dbInst* inst,
float x_origin,
float y_origin,
const std::string& orientation_string)
{
std::cout << "Macro = " << inst->getName() << '\n';
std::cout << "Origin Location = " << x_origin << " " << y_origin << '\n';

odb::dbOrientType orientation = stringToOrientType(orientation_string);

std::cout << "Orientation = " << orientation.getString() << '\n';
}

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


place_macro -macro_name xabalau
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 c8c250d

Please sign in to comment.