diff --git a/src/mpl2/include/mpl2/rtl_mp.h b/src/mpl2/include/mpl2/rtl_mp.h index 49cb76332a2..2baa527efc1 100644 --- a/src/mpl2/include/mpl2/rtl_mp.h +++ b/src/mpl2/include/mpl2/rtl_mp.h @@ -40,6 +40,7 @@ namespace odb { class dbDatabase; class dbInst; +class dbOrientType; } namespace sta { @@ -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); diff --git a/src/mpl2/src/mpl.i b/src/mpl2/src/mpl.i index 868c77c4995..a5bbaecb180 100644 --- a/src/mpl2/src/mpl.i +++ b/src/mpl2/src/mpl.i @@ -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 diff --git a/src/mpl2/src/mpl.tcl b/src/mpl2/src/mpl.tcl index 96fe2fd7b9b..1e08637ac86 100644 --- a/src/mpl2/src/mpl.tcl +++ b/src/mpl2/src/mpl.tcl @@ -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) @@ -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 } diff --git a/src/mpl2/src/rtl_mp.cpp b/src/mpl2/src/rtl_mp.cpp index f8d77e76a3f..901b6446316 100644 --- a/src/mpl2/src/rtl_mp.cpp +++ b/src/mpl2/src/rtl_mp.cpp @@ -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) diff --git a/src/mpl2/test/mp_test1.tcl b/src/mpl2/test/mp_test1.tcl index 2dd19fbbed5..b19c7cb3c06 100644 --- a/src/mpl2/test/mp_test1.tcl +++ b/src/mpl2/test/mp_test1.tcl @@ -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]