From b5702d3410f03ba8bcdbeafafa8b7b311e62071c Mon Sep 17 00:00:00 2001 From: Hao Date: Wed, 22 Oct 2025 04:48:44 +0000 Subject: [PATCH 1/7] build: add AIEDA build.sh option Signed-off-by: Hao --- build.sh | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/build.sh b/build.sh index 2763549e0..607145629 100755 --- a/build.sh +++ b/build.sh @@ -36,9 +36,7 @@ BUILD_THREADS="$(nproc)" CMAKE_OPTIONS=( "-DCMAKE_BUILD_TYPE=Release" "-DCMD_BUILD=ON" - "-DBUILD_STATIC_LIB=${BUILD_STATIC_LIB:-ON}" ) - # "-DBUILD_PYTHON=${BUILD_PYTHON:-OFF}" # "-DBUILD_GUI=${BUILD_GUI:-OFF}" # "-DCOMPATIBILITY_MODE=${COMPATIBILITY_MODE:-OFF}" # "-DUSE_PROFILER=${USE_PROFILER:-OFF}" @@ -70,7 +68,7 @@ echo -e " ${bold}-r${clear} run iEDA hello test after build (default OFF)" echo -e " ${bold}-j${clear} job threads for building iEDA (default ${BUILD_THREADS} (num of cores))" echo -e " ${bold}-b${clear} iEDA binary path (default at ${BINARY_DIR})" echo -e " ${bold}-i${clear} apt-get install (root/sudo required) dependencies before build (default OFF)" -echo -e " ${bold}-p${clear} build Python bindings (default OFF)" +echo -e " ${bold}-p${clear} build AIEDA (default OFF)" echo -e " ${bold}-g${clear} enable GUI components (default OFF)" echo -e " ${bold}-s${clear} enable address sanitizer (default OFF)" echo -e " ${bold}-P${clear} enable performance profiling (default OFF)" @@ -361,7 +359,7 @@ perform_clean() opt_build_target() { - BINARY_TARGET=${OPTARG} + BINARY_TARGET=$1 } opt_dry_run() @@ -374,29 +372,34 @@ opt_non_interactive() NON_INTERACTIVE="ON" } +opt_build_aieda() +{ + CMAKE_OPTIONS+=("-DBUILD_AIEDA=ON") + opt_build_target "ieda_py" +} + # invalid args if [[ $1 != "" ]] && [[ $1 != -* ]]; then help_msg_exit 1 fi -while getopts j:b:t:i:rndDypx opt; do +while getopts j:b:t:i:rndDyp opt; do case "${opt}" in - j) opt_thread_num "$OPTARG" ;; - b) opt_binary_dir "$OPTARG" ;; - t) opt_build_target "$OPTARG" ;; + j) opt_thread_num "$OPTARG" ;; + b) opt_binary_dir "$OPTARG" ;; + t) opt_build_target "$OPTARG" ;; i) opt_install_dependencies "$OPTARG" ;; r) opt_run_ieda ;; n) opt_no_build ;; d) opt_del_build ;; D) opt_dry_run ;; y) opt_non_interactive ;; - p) CMAKE_OPTIONS+=("-DBUILD_PYTHON=ON") ;; + p) opt_build_aieda ;; g) CMAKE_OPTIONS+=("-DBUILD_GUI=ON") ;; s) CMAKE_OPTIONS+=("-DSANITIZER=ON") ;; P) CMAKE_OPTIONS+=("-DUSE_PROFILER=ON") ;; G) CMAKE_OPTIONS+=("-DUSE_GPU=ON") ;; C) CMAKE_OPTIONS+=("-DCOMPATIBILITY_MODE=ON") ;; - x) CMAKE_OPTIONS+=("-DCCLOUD_WORKAROUND=ON") ;; h) help_msg_exit 0 ;; *) help_msg_exit 1 ;; esac -- Gitee From d158b8b616ca9c339718428b671e369d53e05a7c Mon Sep 17 00:00:00 2001 From: ZhishengZeng Date: Wed, 22 Oct 2025 15:05:37 +0800 Subject: [PATCH 2/7] update ino --- .../source/module/fix_fanout/FixFanout.cpp | 58 +++++++++---------- 1 file changed, 28 insertions(+), 30 deletions(-) diff --git a/src/operation/iNO/source/module/fix_fanout/FixFanout.cpp b/src/operation/iNO/source/module/fix_fanout/FixFanout.cpp index 00a4e1672..765cd9d27 100644 --- a/src/operation/iNO/source/module/fix_fanout/FixFanout.cpp +++ b/src/operation/iNO/source/module/fix_fanout/FixFanout.cpp @@ -48,12 +48,12 @@ void FixFanout::fixIO() { continue; } if (idb_io_pin->get_pin_name() == idb_io_pin->get_net()->get_net_name()) { - idb::IdbNet *origin_net = idb_io_pin->get_net(); + idb::IdbNet *io_net = idb_io_pin->get_net(); std::vector instance_pin_list = - origin_net->get_instance_pin_list()->get_pin_list(); - // 在origin net中解开所有instance_pin + io_net->get_instance_pin_list()->get_pin_list(); + // 在io net中解开所有instance_pin for (idb::IdbPin *instance_pin : instance_pin_list) { - origin_net->remove_pin(instance_pin); + io_net->remove_pin(instance_pin); } // 构建新的net idb::IdbNet *new_net = new IdbNet(); @@ -72,19 +72,18 @@ void FixFanout::fixIO() { idb_instance_list->add_instance(new_buf); // 插入buf for (idb::IdbPin *buf_pin : new_buf->get_pin_list()->get_pin_list()) { - if (buf_pin->get_term()->get_type() == idb::IdbConnectType::kPower || - buf_pin->get_term()->get_type() == idb::IdbConnectType::kGround) { - continue; - } - if (buf_pin->get_term()->get_direction() == idb::IdbConnectDirection::kInput) { - origin_net->add_instance_pin(buf_pin); - buf_pin->set_net(origin_net); - buf_pin->set_net_name(origin_net->get_net_name()); - } else if (buf_pin->get_term()->get_direction() == - idb::IdbConnectDirection::kOutput) { - new_net->add_instance_pin(buf_pin); - buf_pin->set_net(new_net); - buf_pin->set_net_name(new_net->get_net_name()); + if (buf_pin->get_term()->get_direction() == idb::IdbConnectDirection::kInput || + buf_pin->get_term()->get_direction() == idb::IdbConnectDirection::kOutput) { + if (buf_pin->get_term()->get_direction() == + idb_io_pin->get_term()->get_direction()) { + io_net->add_instance_pin(buf_pin); + buf_pin->set_net(io_net); + buf_pin->set_net_name(io_net->get_net_name()); + } else { + new_net->add_instance_pin(buf_pin); + buf_pin->set_net(new_net); + buf_pin->set_net_name(new_net->get_net_name()); + } } } @@ -108,19 +107,18 @@ void FixFanout::fixIO() { idb_instance_list->add_instance(new_buf); // 插入buf for (idb::IdbPin *buf_pin : new_buf->get_pin_list()->get_pin_list()) { - if (buf_pin->get_term()->get_type() == idb::IdbConnectType::kPower || - buf_pin->get_term()->get_type() == idb::IdbConnectType::kGround) { - continue; - } - if (buf_pin->get_term()->get_direction() == idb::IdbConnectDirection::kInput) { - origin_net->add_instance_pin(buf_pin); - buf_pin->set_net(origin_net); - buf_pin->set_net_name(origin_net->get_net_name()); - } else if (buf_pin->get_term()->get_direction() == - idb::IdbConnectDirection::kOutput) { - io_net->add_instance_pin(buf_pin); - buf_pin->set_net(io_net); - buf_pin->set_net_name(io_net->get_net_name()); + if (buf_pin->get_term()->get_direction() == idb::IdbConnectDirection::kInput || + buf_pin->get_term()->get_direction() == idb::IdbConnectDirection::kOutput) { + if (buf_pin->get_term()->get_direction() == + idb_io_pin->get_term()->get_direction()) { + io_net->add_instance_pin(buf_pin); + buf_pin->set_net(io_net); + buf_pin->set_net_name(io_net->get_net_name()); + } else { + origin_net->add_instance_pin(buf_pin); + buf_pin->set_net(origin_net); + buf_pin->set_net_name(origin_net->get_net_name()); + } } } } -- Gitee From df7e0f4d9e7012ba2ecb178f5f6b5f09b055e6a4 Mon Sep 17 00:00:00 2001 From: ZhishengZeng Date: Wed, 22 Oct 2025 16:39:21 +0800 Subject: [PATCH 3/7] update ino --- src/operation/iNO/source/module/fix_fanout/FixFanout.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/operation/iNO/source/module/fix_fanout/FixFanout.cpp b/src/operation/iNO/source/module/fix_fanout/FixFanout.cpp index 765cd9d27..ed3a1d92e 100644 --- a/src/operation/iNO/source/module/fix_fanout/FixFanout.cpp +++ b/src/operation/iNO/source/module/fix_fanout/FixFanout.cpp @@ -57,7 +57,7 @@ void FixFanout::fixIO() { } // 构建新的net idb::IdbNet *new_net = new IdbNet(); - new_net->set_net_name("zzs_net_" + std::to_string(new_idx++)); + new_net->set_net_name("fixio_net_" + std::to_string(new_idx++)); idb_net_list->add_net(new_net); // 将原instance pin加入新net for (idb::IdbPin *instance_pin : instance_pin_list) { @@ -67,7 +67,7 @@ void FixFanout::fixIO() { } // 生成buf idb::IdbInstance *new_buf = new IdbInstance(); - new_buf->set_name("zzs_buf_" + std::to_string(new_idx++)); + new_buf->set_name("fixio_buf_" + std::to_string(new_idx++)); new_buf->set_cell_master(idb_cell_master_list->find_cell_master(buffer_name)); idb_instance_list->add_instance(new_buf); // 插入buf @@ -102,7 +102,7 @@ void FixFanout::fixIO() { idb_io_pin->set_net_name(io_net->get_net_name()); // 生成buf idb::IdbInstance *new_buf = new IdbInstance(); - new_buf->set_name("zzs_buf_" + std::to_string(new_idx++)); + new_buf->set_name("fixio_buf_" + std::to_string(new_idx++)); new_buf->set_cell_master(idb_cell_master_list->find_cell_master(buffer_name)); idb_instance_list->add_instance(new_buf); // 插入buf -- Gitee From 644eeeeb78ceb9c9df4709b4b75c3c928276d070 Mon Sep 17 00:00:00 2001 From: ZhishengZeng Date: Thu, 23 Oct 2025 22:02:08 +0800 Subject: [PATCH 4/7] add bend cost --- .../module/detailed_router/DetailedRouter.cpp | 123 ++++++++++++++---- .../module/detailed_router/DetailedRouter.hpp | 2 + .../dr_data_manager/DRGroup.hpp | 9 +- .../dr_data_manager/DRIterParam.hpp | 6 +- .../dr_data_manager/DRNode.hpp | 5 + .../topology_generator/TopologyGenerator.cpp | 37 ++++-- .../topology_generator/TopologyGenerator.hpp | 3 +- .../tg_data_manager/TGCandidate.hpp | 18 ++- 8 files changed, 160 insertions(+), 43 deletions(-) diff --git a/src/operation/iRT/source/module/detailed_router/DetailedRouter.cpp b/src/operation/iRT/source/module/detailed_router/DetailedRouter.cpp index 9683a6396..50bbf995d 100644 --- a/src/operation/iRT/source/module/detailed_router/DetailedRouter.cpp +++ b/src/operation/iRT/source/module/detailed_router/DetailedRouter.cpp @@ -105,22 +105,23 @@ void DetailedRouter::routeDRModel(DRModel& dr_model) int32_t cost_unit = RTDM.getOnlyPitch(); double prefer_wire_unit = 1; double non_prefer_wire_unit = 2.5 * prefer_wire_unit; + double bend_unit = 2 * prefer_wire_unit * cost_unit; double via_unit = 2 * non_prefer_wire_unit * cost_unit; double fixed_rect_unit = 4 * non_prefer_wire_unit * cost_unit; double routed_rect_unit = 2 * non_prefer_wire_unit * cost_unit; double violation_unit = 4 * non_prefer_wire_unit * cost_unit; /** - * prefer_wire_unit, non_prefer_wire_unit, via_unit, size, offset, schedule_interval, fixed_rect_unit, routed_rect_unit, violation_unit, max_routed_times, - * max_candidate_patch_num + * prefer_wire_unit, non_prefer_wire_unit, bend_unit, via_unit, size, offset, schedule_interval, fixed_rect_unit, routed_rect_unit, violation_unit, + * max_routed_times, max_candidate_patch_num */ std::vector dr_iter_param_list; // clang-format off - dr_iter_param_list.emplace_back(prefer_wire_unit, non_prefer_wire_unit, via_unit, 3, 0, 3, fixed_rect_unit, routed_rect_unit, violation_unit, 3, 10); - dr_iter_param_list.emplace_back(prefer_wire_unit, non_prefer_wire_unit, via_unit, 3, 1, 3, fixed_rect_unit, routed_rect_unit, violation_unit, 3, 10); - dr_iter_param_list.emplace_back(prefer_wire_unit, non_prefer_wire_unit, via_unit, 3, 2, 3, fixed_rect_unit, routed_rect_unit, violation_unit, 3, 10); - dr_iter_param_list.emplace_back(prefer_wire_unit, non_prefer_wire_unit, via_unit, 3, 0, 3, fixed_rect_unit, routed_rect_unit, violation_unit, 3, 10); - dr_iter_param_list.emplace_back(prefer_wire_unit, non_prefer_wire_unit, via_unit, 3, 1, 3, fixed_rect_unit, routed_rect_unit, violation_unit, 3, 10); - dr_iter_param_list.emplace_back(prefer_wire_unit, non_prefer_wire_unit, via_unit, 3, 2, 3, fixed_rect_unit, routed_rect_unit, violation_unit, 3, 10); + dr_iter_param_list.emplace_back(prefer_wire_unit, non_prefer_wire_unit, bend_unit, via_unit, 3, 0, 3, fixed_rect_unit, routed_rect_unit, violation_unit, 3, 10); + dr_iter_param_list.emplace_back(prefer_wire_unit, non_prefer_wire_unit, bend_unit, via_unit, 3, 1, 3, fixed_rect_unit, routed_rect_unit, violation_unit, 3, 10); + dr_iter_param_list.emplace_back(prefer_wire_unit, non_prefer_wire_unit, bend_unit, via_unit, 3, 2, 3, fixed_rect_unit, routed_rect_unit, violation_unit, 3, 10); + dr_iter_param_list.emplace_back(prefer_wire_unit, non_prefer_wire_unit, bend_unit, via_unit, 3, 0, 3, fixed_rect_unit, routed_rect_unit, violation_unit, 3, 10); + dr_iter_param_list.emplace_back(prefer_wire_unit, non_prefer_wire_unit, bend_unit, via_unit, 3, 1, 3, fixed_rect_unit, routed_rect_unit, violation_unit, 3, 10); + dr_iter_param_list.emplace_back(prefer_wire_unit, non_prefer_wire_unit, bend_unit, via_unit, 3, 2, 3, fixed_rect_unit, routed_rect_unit, violation_unit, 3, 10); // clang-format on initRoutingState(dr_model); for (int32_t i = 0, iter = 1; i < static_cast(dr_iter_param_list.size()); i++, iter++) { @@ -164,6 +165,7 @@ void DetailedRouter::setDRIterParam(DRModel& dr_model, int32_t iter, DRIterParam dr_model.set_iter(iter); RTLOG.info(Loc::current(), "prefer_wire_unit: ", dr_iter_param.get_prefer_wire_unit()); RTLOG.info(Loc::current(), "non_prefer_wire_unit: ", dr_iter_param.get_non_prefer_wire_unit()); + RTLOG.info(Loc::current(), "bend_unit: ", dr_iter_param.get_bend_unit()); RTLOG.info(Loc::current(), "via_unit: ", dr_iter_param.get_via_unit()); RTLOG.info(Loc::current(), "size: ", dr_iter_param.get_size()); RTLOG.info(Loc::current(), "offset: ", dr_iter_param.get_offset()); @@ -450,6 +452,8 @@ void DetailedRouter::buildNetPatch(DRBox& dr_box) void DetailedRouter::initDRTaskList(DRModel& dr_model, DRBox& dr_box) { + std::vector& routing_layer_list = RTDM.getDatabase().get_routing_layer_list(); + std::vector& dr_net_list = dr_model.get_dr_net_list(); std::vector& dr_task_list = dr_box.get_dr_task_list(); @@ -465,14 +469,15 @@ void DetailedRouter::initDRTaskList(DRModel& dr_model, DRBox& dr_box) if (!RTUTIL.isInside(box_real_rect, access_point->get_real_coord())) { continue; } - pin_group_map[access_point->get_pin_idx()].get_coord_list().push_back(access_point->getRealLayerCoord()); + pin_group_map[access_point->get_pin_idx()].get_coord_direction_map()[access_point->getRealLayerCoord()].insert( + routing_layer_list[access_point->get_layer_idx()].get_prefer_direction()); } for (auto& [pin_idx, group] : pin_group_map) { net_group_list_map[net_idx].push_back(group); } } for (auto& [net_idx, segment_list] : net_task_detailed_result_map) { - std::vector coord_list; + std::map, CmpLayerCoordByXASC> coord_direction_map; for (const Segment& segment : segment_list) { const LayerCoord& first = segment.get_first(); const LayerCoord& second = segment.get_second(); @@ -487,10 +492,12 @@ void DetailedRouter::initDRTaskList(DRModel& dr_model, DRBox& dr_box) } RTUTIL.swapByASC(first_x, second_x); if (first_x <= box_real_rect.get_ll_x() && box_real_rect.get_ll_x() <= second_x) { - coord_list.emplace_back(box_real_rect.get_ll_x(), first.get_y(), first.get_layer_idx()); + LayerCoord layer_coord(box_real_rect.get_ll_x(), first.get_y(), first.get_layer_idx()); + coord_direction_map[layer_coord].insert(Direction::kHorizontal); } if (first_x <= box_real_rect.get_ur_x() && box_real_rect.get_ur_x() <= second_x) { - coord_list.emplace_back(box_real_rect.get_ur_x(), first.get_y(), first.get_layer_idx()); + LayerCoord layer_coord(box_real_rect.get_ur_x(), first.get_y(), first.get_layer_idx()); + coord_direction_map[layer_coord].insert(Direction::kHorizontal); } } else if (RTUTIL.isVertical(first, second)) { int32_t first_y = first.get_y(); @@ -500,18 +507,20 @@ void DetailedRouter::initDRTaskList(DRModel& dr_model, DRBox& dr_box) } RTUTIL.swapByASC(first_y, second_y); if (first_y <= box_real_rect.get_ll_y() && box_real_rect.get_ll_y() <= second_y) { - coord_list.emplace_back(first.get_x(), box_real_rect.get_ll_y(), first.get_layer_idx()); + LayerCoord layer_coord(first.get_x(), box_real_rect.get_ll_y(), first.get_layer_idx()); + coord_direction_map[layer_coord].insert(Direction::kVertical); } if (first_y <= box_real_rect.get_ur_y() && box_real_rect.get_ur_y() <= second_y) { - coord_list.emplace_back(first.get_x(), box_real_rect.get_ur_y(), first.get_layer_idx()); + LayerCoord layer_coord(first.get_x(), box_real_rect.get_ur_y(), first.get_layer_idx()); + coord_direction_map[layer_coord].insert(Direction::kVertical); } } else { RTLOG.error(Loc::current(), "The segment is oblique!"); } } - for (LayerCoord& coord : coord_list) { + for (auto& [coord, direction_set] : coord_direction_map) { DRGroup dr_group; - dr_group.get_coord_list().push_back(coord); + dr_group.get_coord_direction_map()[coord] = direction_set; net_group_list_map[net_idx].push_back(dr_group); } } @@ -527,7 +536,7 @@ void DetailedRouter::initDRTaskList(DRModel& dr_model, DRBox& dr_box) { std::vector coord_list; for (DRGroup& dr_group : dr_task->get_dr_group_list()) { - for (LayerCoord& coord : dr_group.get_coord_list()) { + for (auto& [coord, _] : dr_group.get_coord_direction_map()) { coord_list.push_back(coord); } } @@ -610,7 +619,7 @@ void DetailedRouter::buildBoxTrackAxis(DRBox& dr_box) } for (DRTask* dr_task : dr_box.get_dr_task_list()) { for (DRGroup& dr_group : dr_task->get_dr_group_list()) { - for (LayerCoord& coord : dr_group.get_coord_list()) { + for (auto& [coord, _] : dr_group.get_coord_direction_map()) { int32_t layer_idx = coord.get_layer_idx(); if (routing_layer_list[layer_idx].isPreferH()) { layer_axis_map[layer_idx].first.insert(coord.get_x()); @@ -630,7 +639,7 @@ void DetailedRouter::buildBoxTrackAxis(DRBox& dr_box) } for (DRTask* dr_task : dr_box.get_dr_task_list()) { for (DRGroup& dr_group : dr_task->get_dr_group_list()) { - for (LayerCoord& coord : dr_group.get_coord_list()) { + for (auto& [coord, _] : dr_group.get_coord_direction_map()) { x_scale_list.push_back(coord.get_x()); y_scale_list.push_back(coord.get_y()); } @@ -962,6 +971,7 @@ void DetailedRouter::routeDRTask(DRBox& dr_box, DRTask* dr_task) while (!isConnectedAllEnd(dr_box)) { routeSinglePath(dr_box); updatePathResult(dr_box); + updateDirectionSet(dr_box); resetStartAndEnd(dr_box); resetSinglePath(dr_box); } @@ -981,12 +991,13 @@ void DetailedRouter::initSingleRouteTask(DRBox& dr_box, DRTask* dr_task) std::vector& dr_group_list = dr_task->get_dr_group_list(); for (DRGroup& dr_group : dr_group_list) { std::vector node_list; - for (LayerCoord& coord : dr_group.get_coord_list()) { + for (auto& [coord, direction_set] : dr_group.get_coord_direction_map()) { if (!RTUTIL.existTrackGrid(coord, box_track_axis)) { RTLOG.error(Loc::current(), "The coord can not find grid!"); } PlanarCoord grid_coord = RTUTIL.getTrackGrid(coord, box_track_axis); DRNode& dr_node = layer_node_map[coord.get_layer_idx()][grid_coord.get_x()][grid_coord.get_y()]; + dr_node.set_direction_set(direction_set); node_list.push_back(&dr_node); } node_list_list.push_back(node_list); @@ -1121,6 +1132,20 @@ std::vector> DetailedRouter::getRoutingSegmentListByNode(DRN return routing_segment_list; } +void DetailedRouter::updateDirectionSet(DRBox& dr_box) +{ + DRNode* path_head_node = dr_box.get_path_head_node(); + + DRNode* curr_node = path_head_node; + DRNode* pre_node = curr_node->get_parent_node(); + while (pre_node != nullptr) { + curr_node->get_direction_set().insert(RTUTIL.getDirection(*curr_node, *pre_node)); + pre_node->get_direction_set().insert(RTUTIL.getDirection(*pre_node, *curr_node)); + curr_node = pre_node; + pre_node = curr_node->get_parent_node(); + } +} + void DetailedRouter::resetStartAndEnd(DRBox& dr_box) { std::vector>& start_node_list_list = dr_box.get_start_node_list_list(); @@ -1190,7 +1215,7 @@ std::vector> DetailedRouter::getRoutingSegmentList(DRBox& dr std::map, CmpLayerCoordByXASC> key_coord_pin_map; std::vector& dr_group_list = curr_route_task->get_dr_group_list(); for (size_t i = 0; i < dr_group_list.size(); i++) { - for (LayerCoord& coord : dr_group_list[i].get_coord_list()) { + for (auto& [coord, _] : dr_group_list[i].get_coord_direction_map()) { candidate_root_coord_list.push_back(coord); key_coord_pin_map[coord].insert(static_cast(i)); } @@ -1210,6 +1235,9 @@ void DetailedRouter::resetSingleRouteTask(DRBox& dr_box) dr_box.get_start_node_list_list().clear(); dr_box.get_end_node_list_list().clear(); dr_box.get_path_node_list().clear(); + for (DRNode* single_task_visited_node : dr_box.get_single_task_visited_node_list()) { + single_task_visited_node->get_direction_set().clear(); + } dr_box.get_single_task_visited_node_list().clear(); dr_box.get_routing_segment_list().clear(); } @@ -1262,6 +1290,7 @@ double DetailedRouter::getKnownCost(DRBox& dr_box, DRNode* start_node, DRNode* e cost += getNodeCost(dr_box, end_node, RTUTIL.getOrientation(*end_node, *start_node)); cost += getKnownWireCost(dr_box, start_node, end_node); cost += getKnownViaCost(dr_box, start_node, end_node); + cost += getKnownBendCost(dr_box, start_node, end_node); cost += getKnownSelfCost(dr_box, start_node, end_node); return cost; } @@ -1308,6 +1337,26 @@ double DetailedRouter::getKnownViaCost(DRBox& dr_box, DRNode* start_node, DRNode return via_cost; } +double DetailedRouter::getKnownBendCost(DRBox& dr_box, DRNode* start_node, DRNode* end_node) +{ + double bend_unit = dr_box.get_dr_iter_param()->get_bend_unit(); + + double bend_cost = 0; + if (start_node->get_layer_idx() == end_node->get_layer_idx()) { + std::set direction_set; + direction_set.insert(start_node->get_direction_set().begin(), start_node->get_direction_set().end()); + if (start_node->get_parent_node() != nullptr) { + direction_set.insert(RTUTIL.getDirection(*start_node->get_parent_node(), *start_node)); + } + direction_set.insert(end_node->get_direction_set().begin(), end_node->get_direction_set().end()); + direction_set.insert(RTUTIL.getDirection(*start_node, *end_node)); + if (direction_set.size() == 2) { + bend_cost += bend_unit; + } + } + return bend_cost; +} + double DetailedRouter::getKnownSelfCost(DRBox& dr_box, DRNode* start_node, DRNode* end_node) { std::vector& routing_layer_list = RTDM.getDatabase().get_routing_layer_list(); @@ -3492,10 +3541,10 @@ void DetailedRouter::debugCheckDRBox(DRBox& dr_box) RTLOG.error(Loc::current(), "The idx of origin net is illegal!"); } for (DRGroup& dr_group : dr_task->get_dr_group_list()) { - if (dr_group.get_coord_list().empty()) { - RTLOG.error(Loc::current(), "The coord_list is empty!"); + if (dr_group.get_coord_direction_map().empty()) { + RTLOG.error(Loc::current(), "The coord_direction_map is empty!"); } - for (LayerCoord& coord : dr_group.get_coord_list()) { + for (auto& [coord, _] : dr_group.get_coord_direction_map()) { int32_t layer_idx = coord.get_layer_idx(); if (routing_layer_list.back().get_layer_idx() < layer_idx || layer_idx < routing_layer_list.front().get_layer_idx()) { RTLOG.error(Loc::current(), "The layer idx of group coord is illegal!"); @@ -3787,6 +3836,30 @@ void DetailedRouter::debugPlotDRBox(DRBox& dr_box, std::string flag) gp_text_orient_violation_number_map_info.set_presentation(GPTextPresentation::kLeftMiddle); dr_node_map_struct.push(gp_text_orient_violation_number_map_info); } + + y -= y_reduced_span; + GPText gp_text_direction_set; + gp_text_direction_set.set_coord(real_rect.get_ll_x(), y); + gp_text_direction_set.set_text_type(static_cast(GPDataType::kInfo)); + gp_text_direction_set.set_message("direction_set: "); + gp_text_direction_set.set_layer_idx(RTGP.getGDSIdxByRouting(dr_node.get_layer_idx())); + gp_text_direction_set.set_presentation(GPTextPresentation::kLeftMiddle); + dr_node_map_struct.push(gp_text_direction_set); + + if (!dr_node.get_direction_set().empty()) { + y -= y_reduced_span; + GPText gp_text_direction_set_info; + gp_text_direction_set_info.set_coord(real_rect.get_ll_x(), y); + gp_text_direction_set_info.set_text_type(static_cast(GPDataType::kInfo)); + std::string direction_set_info_message = "--"; + for (Direction direction : dr_node.get_direction_set()) { + direction_set_info_message += RTUTIL.getString("(", GetDirectionName()(direction), ")"); + } + gp_text_direction_set_info.set_message(direction_set_info_message); + gp_text_direction_set_info.set_layer_idx(RTGP.getGDSIdxByRouting(dr_node.get_layer_idx())); + gp_text_direction_set_info.set_presentation(GPTextPresentation::kLeftMiddle); + dr_node_map_struct.push(gp_text_direction_set_info); + } } } } @@ -3895,7 +3968,7 @@ void DetailedRouter::debugPlotDRBox(DRBox& dr_box, std::string flag) GPStruct task_struct(RTUTIL.getString("task(net_", dr_task->get_net_idx(), ")")); for (DRGroup& dr_group : dr_task->get_dr_group_list()) { - for (LayerCoord& coord : dr_group.get_coord_list()) { + for (auto& [coord, _] : dr_group.get_coord_direction_map()) { GPBoundary gp_boundary; gp_boundary.set_data_type(static_cast(GPDataType::kKey)); gp_boundary.set_rect(RTUTIL.getEnlargedRect(coord, point_size)); diff --git a/src/operation/iRT/source/module/detailed_router/DetailedRouter.hpp b/src/operation/iRT/source/module/detailed_router/DetailedRouter.hpp index d1fc35f8a..0cd521e56 100644 --- a/src/operation/iRT/source/module/detailed_router/DetailedRouter.hpp +++ b/src/operation/iRT/source/module/detailed_router/DetailedRouter.hpp @@ -91,6 +91,7 @@ class DetailedRouter void resetPathHead(DRBox& dr_box); void updatePathResult(DRBox& dr_box); std::vector> getRoutingSegmentListByNode(DRNode* node); + void updateDirectionSet(DRBox& dr_box); void resetStartAndEnd(DRBox& dr_box); void resetSinglePath(DRBox& dr_box); void updateTaskResult(DRBox& dr_box); @@ -102,6 +103,7 @@ class DetailedRouter double getNodeCost(DRBox& dr_box, DRNode* curr_node, Orientation orientation); double getKnownWireCost(DRBox& dr_box, DRNode* start_node, DRNode* end_node); double getKnownViaCost(DRBox& dr_box, DRNode* start_node, DRNode* end_node); + double getKnownBendCost(DRBox& dr_box, DRNode* start_node, DRNode* end_node); double getKnownSelfCost(DRBox& dr_box, DRNode* start_node, DRNode* end_node); double getEstimateCostToEnd(DRBox& dr_box, DRNode* curr_node); double getEstimateCost(DRBox& dr_box, DRNode* start_node, DRNode* end_node); diff --git a/src/operation/iRT/source/module/detailed_router/dr_data_manager/DRGroup.hpp b/src/operation/iRT/source/module/detailed_router/dr_data_manager/DRGroup.hpp index 3fc55f254..8811ebe54 100644 --- a/src/operation/iRT/source/module/detailed_router/dr_data_manager/DRGroup.hpp +++ b/src/operation/iRT/source/module/detailed_router/dr_data_manager/DRGroup.hpp @@ -27,13 +27,16 @@ class DRGroup DRGroup() = default; ~DRGroup() = default; // getter - std::vector& get_coord_list() { return _coord_list; } + std::map, CmpLayerCoordByXASC>& get_coord_direction_map() { return _coord_direction_map; } // setter - void set_coord_list(const std::vector& coord_list) { _coord_list = coord_list; } + void set_coord_direction_map(const std::map, CmpLayerCoordByXASC>& coord_direction_map) + { + _coord_direction_map = coord_direction_map; + } // function private: - std::vector _coord_list; + std::map, CmpLayerCoordByXASC> _coord_direction_map; }; } // namespace irt diff --git a/src/operation/iRT/source/module/detailed_router/dr_data_manager/DRIterParam.hpp b/src/operation/iRT/source/module/detailed_router/dr_data_manager/DRIterParam.hpp index bedd8218d..296e7919f 100644 --- a/src/operation/iRT/source/module/detailed_router/dr_data_manager/DRIterParam.hpp +++ b/src/operation/iRT/source/module/detailed_router/dr_data_manager/DRIterParam.hpp @@ -22,11 +22,12 @@ class DRIterParam { public: DRIterParam() = default; - DRIterParam(double prefer_wire_unit, double non_prefer_wire_unit, double via_unit, int32_t size, int32_t offset, int32_t schedule_interval, + DRIterParam(double prefer_wire_unit, double non_prefer_wire_unit, double bend_unit, double via_unit, int32_t size, int32_t offset, int32_t schedule_interval, double fixed_rect_unit, double routed_rect_unit, double violation_unit, int32_t max_routed_times, int32_t max_candidate_patch_num) { _prefer_wire_unit = prefer_wire_unit; _non_prefer_wire_unit = non_prefer_wire_unit; + _bend_unit = bend_unit; _via_unit = via_unit; _size = size; _offset = offset; @@ -41,6 +42,7 @@ class DRIterParam // getter double get_prefer_wire_unit() const { return _prefer_wire_unit; } double get_non_prefer_wire_unit() const { return _non_prefer_wire_unit; } + double get_bend_unit() const { return _bend_unit; } double get_via_unit() const { return _via_unit; } int32_t get_size() const { return _size; } int32_t get_offset() const { return _offset; } @@ -53,6 +55,7 @@ class DRIterParam // setter void set_prefer_wire_unit(const double prefer_wire_unit) { _prefer_wire_unit = prefer_wire_unit; } void set_non_prefer_wire_unit(const double non_prefer_wire_unit) { _non_prefer_wire_unit = non_prefer_wire_unit; } + void set_bend_unit(const double bend_unit) { _bend_unit = bend_unit; } void set_via_unit(const double via_unit) { _via_unit = via_unit; } void set_size(const int32_t size) { _size = size; } void set_offset(const int32_t offset) { _offset = offset; } @@ -66,6 +69,7 @@ class DRIterParam private: double _prefer_wire_unit = 0; double _non_prefer_wire_unit = 0; + double _bend_unit = 0; double _via_unit = 0; int32_t _size = -1; int32_t _offset = -1; diff --git a/src/operation/iRT/source/module/detailed_router/dr_data_manager/DRNode.hpp b/src/operation/iRT/source/module/detailed_router/dr_data_manager/DRNode.hpp index 39f1ba2b2..b8532fb5a 100644 --- a/src/operation/iRT/source/module/detailed_router/dr_data_manager/DRNode.hpp +++ b/src/operation/iRT/source/module/detailed_router/dr_data_manager/DRNode.hpp @@ -111,6 +111,9 @@ class DRNode : public LayerCoord return cost; } #if 1 // astar + // single task + std::set& get_direction_set() { return _direction_set; } + void set_direction_set(std::set& direction_set) { _direction_set = direction_set; } // single path DRNodeState& get_state() { return _state; } DRNode* get_parent_node() const { return _parent_node; } @@ -136,6 +139,8 @@ class DRNode : public LayerCoord // violation std::map _orient_violation_number_map; #if 1 // astar + // single task + std::set _direction_set; // single path DRNodeState _state = DRNodeState::kNone; DRNode* _parent_node = nullptr; diff --git a/src/operation/iRT/source/module/topology_generator/TopologyGenerator.cpp b/src/operation/iRT/source/module/topology_generator/TopologyGenerator.cpp index 629f11c2b..b1cd31e28 100644 --- a/src/operation/iRT/source/module/topology_generator/TopologyGenerator.cpp +++ b/src/operation/iRT/source/module/topology_generator/TopologyGenerator.cpp @@ -260,21 +260,31 @@ std::vector> TopologyGenerator::getRoutingSegmentList(TGMod std::vector tg_candidate_list; for (size_t i = 0; i < planar_topo_list.size(); i++) { for (std::vector> routing_segment_list : getRoutingSegmentListList(tg_model, planar_topo_list[i])) { - tg_candidate_list.emplace_back(i, routing_segment_list, 0); + tg_candidate_list.emplace_back(i, routing_segment_list, 0, false, 0); } } #pragma omp parallel for for (TGCandidate& tg_candidate : tg_candidate_list) { - tg_candidate.set_cost(getNodeCost(tg_model, tg_candidate.get_routing_segment_list())); + updateTGCandidate(tg_model, tg_candidate); } std::map topo_candidate_map; for (TGCandidate& tg_candidate : tg_candidate_list) { int32_t topo_idx = tg_candidate.get_topo_idx(); if (!RTUTIL.exist(topo_candidate_map, topo_idx)) { topo_candidate_map[topo_idx] = &tg_candidate; + continue; } - if (tg_candidate.get_cost() < topo_candidate_map[topo_idx]->get_cost()) { + TGCandidate* current_best = topo_candidate_map[topo_idx]; + if (!tg_candidate.get_is_blocked() && current_best->get_is_blocked()) { topo_candidate_map[topo_idx] = &tg_candidate; + } else if (!tg_candidate.get_is_blocked() && !current_best->get_is_blocked()) { + if (tg_candidate.get_total_length() < current_best->get_total_length()) { + topo_candidate_map[topo_idx] = &tg_candidate; + } + } else if (tg_candidate.get_is_blocked() && current_best->get_is_blocked()) { + if (tg_candidate.get_total_cost() < current_best->get_total_cost()) { + topo_candidate_map[topo_idx] = &tg_candidate; + } } } std::vector> routing_segment_list; @@ -684,14 +694,19 @@ std::vector>> TopologyGenerator::getRoutingSegm return routing_segment_list_list; } -double TopologyGenerator::getNodeCost(TGModel& tg_model, std::vector>& routing_segment_list) +void TopologyGenerator::updateTGCandidate(TGModel& tg_model, TGCandidate& tg_candidate) { double overflow_unit = tg_model.get_tg_com_param().get_overflow_unit(); GridMap& tg_node_map = tg_model.get_tg_node_map(); int32_t curr_net_idx = tg_model.get_curr_tg_task()->get_net_idx(); - double node_cost = 0; - for (Segment& coord_segment : routing_segment_list) { + int32_t total_length = 0; + for (Segment& coord_segment : tg_candidate.get_routing_segment_list()) { + total_length += RTUTIL.getManhattanDistance(coord_segment.get_first(), coord_segment.get_second()); + } + bool is_blocked = false; + double total_cost = 0; + for (Segment& coord_segment : tg_candidate.get_routing_segment_list()) { PlanarCoord& first_coord = coord_segment.get_first(); PlanarCoord& second_coord = coord_segment.get_second(); if (!RTUTIL.isRightAngled(first_coord, second_coord)) { @@ -706,11 +721,17 @@ double TopologyGenerator::getNodeCost(TGModel& tg_model, std::vector 1) { + is_blocked = true; + } + total_cost += overflow_cost; } } } - return node_cost; + tg_candidate.set_total_length(total_length); + tg_candidate.set_is_blocked(is_blocked); + tg_candidate.set_total_cost(total_cost); } MTree TopologyGenerator::getCoordTree(TGModel& tg_model, std::vector>& routing_segment_list) diff --git a/src/operation/iRT/source/module/topology_generator/TopologyGenerator.hpp b/src/operation/iRT/source/module/topology_generator/TopologyGenerator.hpp index 241961faf..e7ce57e55 100644 --- a/src/operation/iRT/source/module/topology_generator/TopologyGenerator.hpp +++ b/src/operation/iRT/source/module/topology_generator/TopologyGenerator.hpp @@ -20,6 +20,7 @@ #include "DataManager.hpp" #include "Database.hpp" #include "Monitor.hpp" +#include "TGCandidate.hpp" #include "TGModel.hpp" namespace irt { @@ -67,7 +68,7 @@ class TopologyGenerator std::vector>> getRoutingSegmentListByUPattern(TGModel& tg_model, Segment& planar_topo); std::vector>> getRoutingSegmentListByInner3Bends(TGModel& tg_model, Segment& planar_topo); std::vector>> getRoutingSegmentListByOuter3Bends(TGModel& tg_model, Segment& planar_topo); - double getNodeCost(TGModel& tg_model, std::vector>& routing_segment_list); + void updateTGCandidate(TGModel& tg_model, TGCandidate& tg_candidate); MTree getCoordTree(TGModel& tg_model, std::vector>& routing_segment_list); void uploadNetResult(TGModel& tg_model, MTree& coord_tree); void resetSingleTask(TGModel& tg_model); diff --git a/src/operation/iRT/source/module/topology_generator/tg_data_manager/TGCandidate.hpp b/src/operation/iRT/source/module/topology_generator/tg_data_manager/TGCandidate.hpp index 0462f7f00..134dc20bf 100644 --- a/src/operation/iRT/source/module/topology_generator/tg_data_manager/TGCandidate.hpp +++ b/src/operation/iRT/source/module/topology_generator/tg_data_manager/TGCandidate.hpp @@ -26,27 +26,35 @@ class TGCandidate { public: TGCandidate() = default; - TGCandidate(int32_t topo_idx, const std::vector>& routing_segment_list, double cost) + TGCandidate(int32_t topo_idx, const std::vector>& routing_segment_list, int32_t total_length, bool is_blocked, double total_cost) { _topo_idx = topo_idx; _routing_segment_list = routing_segment_list; - _cost = cost; + _total_length = total_length; + _is_blocked = is_blocked; + _total_cost = total_cost; } ~TGCandidate() = default; // getter int32_t get_topo_idx() const { return _topo_idx; } std::vector>& get_routing_segment_list() { return _routing_segment_list; } - double get_cost() const { return _cost; } + int32_t get_total_length() const { return _total_length; } + bool get_is_blocked() const { return _is_blocked; } + double get_total_cost() const { return _total_cost; } // setter void set_topo_idx(const int32_t topo_idx) { _topo_idx = topo_idx; } void set_routing_segment_list(const std::vector>& routing_segment_list) { _routing_segment_list = routing_segment_list; } - void set_cost(const double cost) { _cost = cost; } + void set_total_length(const int32_t total_length) { _total_length = total_length; } + void set_is_blocked(const bool is_blocked) { _is_blocked = is_blocked; } + void set_total_cost(const double total_cost) { _total_cost = total_cost; } // function private: int32_t _topo_idx = -1; std::vector> _routing_segment_list; - double _cost = 0.0; + int32_t _total_length = 0; + bool _is_blocked = false; + double _total_cost = 0.0; }; } // namespace irt -- Gitee From 24db7920f843c736fb89c204aa3f54962009b475 Mon Sep 17 00:00:00 2001 From: ZhishengZeng Date: Thu, 23 Oct 2025 22:59:14 +0800 Subject: [PATCH 5/7] update io --- .../iFP/source/module/io_placer/io_placer.cpp | 54 +++++++++++++------ 1 file changed, 37 insertions(+), 17 deletions(-) diff --git a/src/operation/iFP/source/module/io_placer/io_placer.cpp b/src/operation/iFP/source/module/io_placer/io_placer.cpp index a7577c2ca..cb318734a 100644 --- a/src/operation/iFP/source/module/io_placer/io_placer.cpp +++ b/src/operation/iFP/source/module/io_placer/io_placer.cpp @@ -97,7 +97,27 @@ bool IoPlacer::autoPlacePins(std::string layer_name, int width, int height, std: auto idb_die = idb_layout->get_die(); auto idb_core = idb_layout->get_core(); - auto layer = idb_layout->get_layers()->find_layer(layer_name); + idb::IdbLayer* left_right_layer = nullptr; + idb::IdbLayer* bottom_top_layer = nullptr; + { + auto curr_layer = idb_layout->get_layers()->find_layer(layer_name); + idb::IdbLayerRouting* curr_routing_layer = dynamic_cast(curr_layer); + + if (curr_routing_layer->get_direction() == idb::IdbLayerDirection::kHorizontal) { + left_right_layer = curr_layer; + } else { + bottom_top_layer = curr_layer; + } + + auto above_layer = idb_layout->get_layers()->find_routing_layer(curr_layer->get_id() + 1); + idb::IdbLayerRouting* above_routing_layer = dynamic_cast(above_layer); + + if (above_routing_layer->get_direction() == idb::IdbLayerDirection::kHorizontal) { + left_right_layer = above_layer; + } else { + bottom_top_layer = above_layer; + } + } auto pin_list = idb_design->get_io_pin_list()->get_pin_list(); /// calculate all the location @@ -117,8 +137,8 @@ bool IoPlacer::autoPlacePins(std::string layer_name, int width, int height, std: break; } - int x = idb_die->get_llx() + width / 2; - int y = idb_core->get_bounding_box()->get_low_y() + i * height_step; + int x = idb_die->get_llx() + height / 2; + int y = idb_core->get_bounding_box()->get_low_y() + i * width_step; auto pin = pin_list[pin_index++]; @@ -135,15 +155,15 @@ bool IoPlacer::autoPlacePins(std::string layer_name, int width, int height, std: shape->set_type_rect(); // Calculate shape coordinates with left-bottom corner aligned to manufacture_grid - int shape_llx = x - width / 2; - int shape_lly = y - height / 2; + int shape_llx = x - height / 2; + int shape_lly = y - width / 2; shape_llx = (shape_llx / manufacture_grid) * manufacture_grid; shape_lly = (shape_lly / manufacture_grid) * manufacture_grid; - int shape_urx = shape_llx + width; - int shape_ury = shape_lly + height; + int shape_urx = shape_llx + height; + int shape_ury = shape_lly + width; shape->add_rect(shape_llx - x, shape_lly - y, shape_urx - x, shape_ury - y); - shape->set_layer(layer); + shape->set_layer(left_right_layer); } } @@ -154,8 +174,8 @@ bool IoPlacer::autoPlacePins(std::string layer_name, int width, int height, std: break; } - int x = idb_die->get_urx() - width / 2; - int y = idb_core->get_bounding_box()->get_low_y() + i * height_step; + int x = idb_die->get_urx() - height / 2; + int y = idb_core->get_bounding_box()->get_low_y() + i * width_step; auto pin = pin_list[pin_index++]; @@ -173,15 +193,15 @@ bool IoPlacer::autoPlacePins(std::string layer_name, int width, int height, std: shape->set_type_rect(); // Calculate shape coordinates with left-bottom corner aligned to manufacture_grid - int shape_llx = x - width / 2; - int shape_lly = y - height / 2; + int shape_llx = x - height / 2; + int shape_lly = y - width / 2; shape_llx = (shape_llx / manufacture_grid) * manufacture_grid; shape_lly = (shape_lly / manufacture_grid) * manufacture_grid; - int shape_urx = shape_llx + width; - int shape_ury = shape_lly + height; + int shape_urx = shape_llx + height; + int shape_ury = shape_lly + width; shape->add_rect(shape_llx - x, shape_lly - y, shape_urx - x, shape_ury - y); - shape->set_layer(layer); + shape->set_layer(left_right_layer); } } @@ -219,7 +239,7 @@ bool IoPlacer::autoPlacePins(std::string layer_name, int width, int height, std: int shape_ury = shape_lly + height; shape->add_rect(shape_llx - x, shape_lly - y, shape_urx - x, shape_ury - y); - shape->set_layer(layer); + shape->set_layer(bottom_top_layer); } } @@ -258,7 +278,7 @@ bool IoPlacer::autoPlacePins(std::string layer_name, int width, int height, std: int shape_ury = shape_lly + height; shape->add_rect(shape_llx - x, shape_lly - y, shape_urx - x, shape_ury - y); - shape->set_layer(layer); + shape->set_layer(bottom_top_layer); } } -- Gitee From ea0ca3ca6cb10e3be4cb5373af9d40a23aba8e15 Mon Sep 17 00:00:00 2001 From: ZhishengZeng Date: Thu, 23 Oct 2025 23:31:19 +0800 Subject: [PATCH 6/7] update egr --- .../module/early_router/EarlyRouter.cpp | 37 +++++++++++++++---- .../module/early_router/EarlyRouter.hpp | 2 +- .../er_data_manager/ERCandidate.hpp | 18 ++++++--- .../early_router/er_data_manager/ERModel.hpp | 2 +- 4 files changed, 44 insertions(+), 15 deletions(-) diff --git a/src/operation/iRT/source/module/early_router/EarlyRouter.cpp b/src/operation/iRT/source/module/early_router/EarlyRouter.cpp index 0ff65f18a..3ccf4f773 100644 --- a/src/operation/iRT/source/module/early_router/EarlyRouter.cpp +++ b/src/operation/iRT/source/module/early_router/EarlyRouter.cpp @@ -1139,21 +1139,31 @@ std::vector> EarlyRouter::getPlanarRoutingSegmentList(ERMod std::vector er_candidate_list; for (size_t i = 0; i < planar_topo_list.size(); i++) { for (std::vector> routing_segment_list : getRoutingSegmentListList(er_model, planar_topo_list[i])) { - er_candidate_list.emplace_back(i, routing_segment_list, 0); + er_candidate_list.emplace_back(i, routing_segment_list, 0, false, 0); } } #pragma omp parallel for for (ERCandidate& er_candidate : er_candidate_list) { - er_candidate.set_cost(getNodeCost(er_model, er_candidate.get_routing_segment_list())); + updateERCandidate(er_model, er_candidate); } std::map topo_candidate_map; for (ERCandidate& er_candidate : er_candidate_list) { int32_t topo_idx = er_candidate.get_topo_idx(); if (!RTUTIL.exist(topo_candidate_map, topo_idx)) { topo_candidate_map[topo_idx] = &er_candidate; + continue; } - if (er_candidate.get_cost() < topo_candidate_map[topo_idx]->get_cost()) { + ERCandidate* current_best = topo_candidate_map[topo_idx]; + if (!er_candidate.get_is_blocked() && current_best->get_is_blocked()) { topo_candidate_map[topo_idx] = &er_candidate; + } else if (!er_candidate.get_is_blocked() && !current_best->get_is_blocked()) { + if (er_candidate.get_total_length() < current_best->get_total_length()) { + topo_candidate_map[topo_idx] = &er_candidate; + } + } else if (er_candidate.get_is_blocked() && current_best->get_is_blocked()) { + if (er_candidate.get_total_cost() < current_best->get_total_cost()) { + topo_candidate_map[topo_idx] = &er_candidate; + } } } std::vector> routing_segment_list; @@ -1563,14 +1573,19 @@ std::vector>> EarlyRouter::getRoutingSegmentLis return routing_segment_list_list; } -double EarlyRouter::getNodeCost(ERModel& er_model, std::vector>& routing_segment_list) +void EarlyRouter::updateERCandidate(ERModel& er_model, ERCandidate& er_candidate) { double overflow_unit = er_model.get_er_com_param().get_overflow_unit(); GridMap& planar_node_map = er_model.get_planar_node_map(); int32_t curr_net_idx = er_model.get_curr_er_task()->get_net_idx(); - double node_cost = 0; - for (Segment& coord_segment : routing_segment_list) { + int32_t total_length = 0; + for (Segment& coord_segment : er_candidate.get_routing_segment_list()) { + total_length += RTUTIL.getManhattanDistance(coord_segment.get_first(), coord_segment.get_second()); + } + bool is_blocked = false; + double total_cost = 0; + for (Segment& coord_segment : er_candidate.get_routing_segment_list()) { PlanarCoord& first_coord = coord_segment.get_first(); PlanarCoord& second_coord = coord_segment.get_second(); if (!RTUTIL.isRightAngled(first_coord, second_coord)) { @@ -1585,11 +1600,17 @@ double EarlyRouter::getNodeCost(ERModel& er_model, std::vector 1) { + is_blocked = true; + } + total_cost += overflow_cost; } } } - return node_cost; + er_candidate.set_total_length(total_length); + er_candidate.set_is_blocked(is_blocked); + er_candidate.set_total_cost(total_cost); } MTree EarlyRouter::getCoordTree(ERModel& er_model, std::vector>& routing_segment_list) diff --git a/src/operation/iRT/source/module/early_router/EarlyRouter.hpp b/src/operation/iRT/source/module/early_router/EarlyRouter.hpp index 546f6345d..6babf1620 100644 --- a/src/operation/iRT/source/module/early_router/EarlyRouter.hpp +++ b/src/operation/iRT/source/module/early_router/EarlyRouter.hpp @@ -88,7 +88,7 @@ class EarlyRouter std::vector>> getRoutingSegmentListByUPattern(ERModel& er_model, Segment& planar_topo); std::vector>> getRoutingSegmentListByInner3Bends(ERModel& er_model, Segment& planar_topo); std::vector>> getRoutingSegmentListByOuter3Bends(ERModel& er_model, Segment& planar_topo); - double getNodeCost(ERModel& er_model, std::vector>& routing_segment_list); + void updateERCandidate(ERModel& er_model, ERCandidate& er_candidate); MTree getCoordTree(ERModel& er_model, std::vector>& routing_segment_list); void resetSinglePlanarTask(ERModel& er_model); void buildLayerNodeMap(ERModel& er_model); diff --git a/src/operation/iRT/source/module/early_router/er_data_manager/ERCandidate.hpp b/src/operation/iRT/source/module/early_router/er_data_manager/ERCandidate.hpp index e1f1c6a52..10b04459c 100644 --- a/src/operation/iRT/source/module/early_router/er_data_manager/ERCandidate.hpp +++ b/src/operation/iRT/source/module/early_router/er_data_manager/ERCandidate.hpp @@ -26,27 +26,35 @@ class ERCandidate { public: ERCandidate() = default; - ERCandidate(int32_t topo_idx, const std::vector>& routing_segment_list, double cost) + ERCandidate(int32_t topo_idx, const std::vector>& routing_segment_list, int32_t total_length, bool is_blocked, double total_cost) { _topo_idx = topo_idx; _routing_segment_list = routing_segment_list; - _cost = cost; + _total_length = total_length; + _is_blocked = is_blocked; + _total_cost = total_cost; } ~ERCandidate() = default; // getter int32_t get_topo_idx() const { return _topo_idx; } std::vector>& get_routing_segment_list() { return _routing_segment_list; } - double get_cost() const { return _cost; } + int32_t get_total_length() const { return _total_length; } + bool get_is_blocked() const { return _is_blocked; } + double get_total_cost() const { return _total_cost; } // setter void set_topo_idx(const int32_t topo_idx) { _topo_idx = topo_idx; } void set_routing_segment_list(const std::vector>& routing_segment_list) { _routing_segment_list = routing_segment_list; } - void set_cost(const double cost) { _cost = cost; } + void set_total_length(const int32_t total_length) { _total_length = total_length; } + void set_is_blocked(const bool is_blocked) { _is_blocked = is_blocked; } + void set_total_cost(const double total_cost) { _total_cost = total_cost; } // function private: int32_t _topo_idx = -1; std::vector> _routing_segment_list; - double _cost = 0.0; + int32_t _total_length = 0; + bool _is_blocked = false; + double _total_cost = 0.0; }; } // namespace irt diff --git a/src/operation/iRT/source/module/early_router/er_data_manager/ERModel.hpp b/src/operation/iRT/source/module/early_router/er_data_manager/ERModel.hpp index a7d032aea..5d4bd444b 100644 --- a/src/operation/iRT/source/module/early_router/er_data_manager/ERModel.hpp +++ b/src/operation/iRT/source/module/early_router/er_data_manager/ERModel.hpp @@ -16,8 +16,8 @@ // *************************************************************************************** #pragma once -#include "ERConflictGroup.hpp" #include "ERComParam.hpp" +#include "ERConflictGroup.hpp" #include "ERNet.hpp" #include "ERNode.hpp" #include "RTHeader.hpp" -- Gitee From 614b1960300c3aee6f14f65d267f0abd8bf77d5b Mon Sep 17 00:00:00 2001 From: Yell-walkalone <12112088@qq.com> Date: Fri, 24 Oct 2025 14:36:44 +0800 Subject: [PATCH 7/7] fix compile bugs for iGUI --- src/interface/gui/include/guigraphicsscene.h | 4 +- src/interface/gui/interface/gui_io.h | 4 +- src/interface/gui/interface/idrc_io.cpp | 2 +- src/interface/gui/src/guiDB/idbfastsetup.cpp | 8 +-- src/interface/gui/src/guiDB/idbfastsetup.h | 6 +- .../gui/src/guiDB/idbfastsetupdrc.cpp | 63 +++++++++---------- .../gui/src/guicontroltree/guitree.cpp | 4 +- src/interface/gui/src/guigraphicsscene.cpp | 2 +- src/interface/tcl/tcl_gui/tcl_gui.cpp | 7 +-- 9 files changed, 46 insertions(+), 54 deletions(-) diff --git a/src/interface/gui/include/guigraphicsscene.h b/src/interface/gui/include/guigraphicsscene.h index ef1d4c6e4..a5ad40dd1 100644 --- a/src/interface/gui/include/guigraphicsscene.h +++ b/src/interface/gui/include/guigraphicsscene.h @@ -30,7 +30,7 @@ #include "file_placement.h" #include "guiitem.h" #include "guitree.h" -#include "idrc_violation.h" +#include "ids.hpp" #include "line.h" #include "ruler.h" #include "shape.h" @@ -62,7 +62,7 @@ class GuiGraphicsScene : public QGraphicsScene { void createChip(std::map> map); void createChip(std::vector lef_paths, std::string def_path); void createChip(IdbBuilder* builder, std::string type = ""); - void createDrc(std::map>& drc_db, int max_num = -1); + void createDrc(std::map>>& drc_db, int max_num = -1); void createClockTree(std::vector& node_list); void updateInstanceInFastMode(std::vector& file_inst_list); void createGraph(std::map net_map); diff --git a/src/interface/gui/interface/gui_io.h b/src/interface/gui/interface/gui_io.h index a66fecf93..786c6c950 100644 --- a/src/interface/gui/interface/gui_io.h +++ b/src/interface/gui/interface/gui_io.h @@ -21,7 +21,7 @@ #include "builder.h" #include "file_cts.h" -#include "idrc_violation.h" +#include "ids.hpp" #include "mainwindow.h" #include "vec_net.h" @@ -49,7 +49,7 @@ namespace igui { /// data operation- void readDB(std::vector lef_paths, std::string def_path); void readDB(IdbBuilder* _builder); - void readDrcDb(std::map>& drc_db, int max_num = -1); + void readDrcDb(std::map>>& drc_db, int max_num = -1); void readClockTreeDb(std::vector& node_list); void readGraphDb(std::map net_map); diff --git a/src/interface/gui/interface/idrc_io.cpp b/src/interface/gui/interface/idrc_io.cpp index 31852aacd..c780e1ffc 100644 --- a/src/interface/gui/interface/idrc_io.cpp +++ b/src/interface/gui/interface/idrc_io.cpp @@ -23,7 +23,7 @@ namespace igui { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// bool GuiIO::autoRunDrcCheckDef() { return true; } - void GuiIO::readDrcDb(std::map>& drc_db, int max_num) { + void GuiIO::readDrcDb(std::map>>& drc_db, int max_num) { _gui_win->get_scene()->createDrc(drc_db, max_num); } diff --git a/src/interface/gui/src/guiDB/idbfastsetup.cpp b/src/interface/gui/src/guiDB/idbfastsetup.cpp index ed5610b61..075aae8c3 100644 --- a/src/interface/gui/src/guiDB/idbfastsetup.cpp +++ b/src/interface/gui/src/guiDB/idbfastsetup.cpp @@ -1102,10 +1102,10 @@ void IdbSpeedUpSetup::createBlockage() { int urx = 0; int ury = 0; for (auto idb_rect : idb_blockage->get_rect_list()) { - llx = min(llx, idb_rect->get_low_x()); - lly = min(lly, idb_rect->get_low_y()); - urx = max(urx, idb_rect->get_high_x()); - ury = max(ury, idb_rect->get_high_y()); + llx = std::min(llx, idb_rect->get_low_x()); + lly = std::min(lly, idb_rect->get_low_y()); + urx = std::max(urx, idb_rect->get_high_x()); + ury = std::max(ury, idb_rect->get_high_y()); gui_block->set_halo_rect(_transform.db_to_guidb_rect(idb_rect)); } diff --git a/src/interface/gui/src/guiDB/idbfastsetup.h b/src/interface/gui/src/guiDB/idbfastsetup.h index 7cf2b5270..6edffd9c7 100644 --- a/src/interface/gui/src/guiDB/idbfastsetup.h +++ b/src/interface/gui/src/guiDB/idbfastsetup.h @@ -43,7 +43,7 @@ #include "guistandardcell.h" #include "guistring.h" #include "guivia.h" -#include "idrc_violation.h" +#include "ids.hpp" #include "lef_service.h" #include "transform.h" #include "vec_net.h" @@ -75,7 +75,7 @@ class IdbSpeedUpSetup : public DbSetup { void search(std::string search_text); /// drc - void showDrc(std::map>& drc_db, int max_num = -1); + void showDrc(std::map>>& drc_db, int max_num = -1); void showGraph(std::map net_map); @@ -151,7 +151,7 @@ class IdbSpeedUpSetup : public DbSetup { void createBlockage(); /// DRC - void createDrc(GuiSpeedupDrcList* drc_list, idrc::DrcViolation* drc_db); + void createDrc(GuiSpeedupDrcList* drc_list, ids::Violation& drc_db); void createPinPortShape(vector& pin_list, GuiSpeedupItem* item = nullptr); void createLayerShape(IdbLayerShape& layer_shape, GuiSpeedupItem* item = nullptr); diff --git a/src/interface/gui/src/guiDB/idbfastsetupdrc.cpp b/src/interface/gui/src/guiDB/idbfastsetupdrc.cpp index 33830d5c0..1dbd81319 100644 --- a/src/interface/gui/src/guiDB/idbfastsetupdrc.cpp +++ b/src/interface/gui/src/guiDB/idbfastsetupdrc.cpp @@ -18,53 +18,46 @@ #include "idbfastsetup.h" #include "omp.h" -void IdbSpeedUpSetup::showDrc(std::map>& drc_db, int max_num) { - for (auto [rule_type, drc_spot_list] : drc_db) { - std::cout << "drc rule=" << rule_type << " number=" << drc_spot_list.size() << std::endl; +void IdbSpeedUpSetup::showDrc(std::map>>& drc_db, + int max_num) { + for (auto& [rule_type, drc_layers] : drc_db) { + // std::string rule = rule_type; + // if (rule == "Default Spacing") { + // rule = "ParallelRunLength Spacing"; + // } - for (auto [rule_type, drc_spot_list] : drc_db) { - std::string rule = rule_type; - if (rule == "Default Spacing") { - rule = "ParallelRunLength Spacing"; - } + auto container = _gui_design->get_drc_container(rule_type); + if (container != nullptr) { + int DRC_MAX = max_num > 0 ? max_num : INT32_MAX; + for (auto& [layer, violations] : drc_layers) { + auto drc_list = container->findDrcList(layer); - auto container = _gui_design->get_drc_container(rule); - if (container != nullptr) { - if (max_num > 0) { - int size = max_num > drc_spot_list.size() ? drc_spot_list.size() : max_num; - // #pragma omp parallel for - for (int i = 0; i < size; i++) { - /// create drc view - std::string layer = drc_spot_list[i]->get_layer()->get_name(); - auto drc_list = container->findDrcList(layer); - createDrc(drc_list, drc_spot_list[i]); - } - } else { - // #pragma omp parallel for - for (auto drc_spot : drc_spot_list) { - /// create drc view - std::string layer = drc_spot->get_layer()->get_name(); - auto drc_list = container->findDrcList(layer); - createDrc(drc_list, drc_spot); + for (auto violation : violations) { + if (DRC_MAX == 0) { + return; } + + /// process violation + createDrc(drc_list, violation); + + DRC_MAX--; } - } else { - std::cout << "find no drc container view : " << rule << std::endl; } + } else { + std::cout << "find no drc container view : " << rule_type << std::endl; } } } -void IdbSpeedUpSetup::createDrc(GuiSpeedupDrcList* drc_list, idrc::DrcViolation* drc_db) { - if (drc_list == nullptr || drc_db == nullptr) { +void IdbSpeedUpSetup::createDrc(GuiSpeedupDrcList* drc_list, ids::Violation& drc_db) { + if (drc_list == nullptr) { return; } - auto* spot_rect = static_cast(drc_db); - int min_x = spot_rect->get_llx(); - int min_y = spot_rect->get_lly(); - int max_x = spot_rect->get_urx(); - int max_y = spot_rect->get_ury(); + int min_x = drc_db.ll_x; + int min_y = drc_db.ll_y; + int max_x = drc_db.ur_x; + int max_y = drc_db.ur_y; if (min_x == max_x) { max_x += 2; diff --git a/src/interface/gui/src/guicontroltree/guitree.cpp b/src/interface/gui/src/guicontroltree/guitree.cpp index 6261a3226..cfac9a533 100644 --- a/src/interface/gui/src/guicontroltree/guitree.cpp +++ b/src/interface/gui/src/guicontroltree/guitree.cpp @@ -157,8 +157,8 @@ void GuiTree::onItemClicked(QTreeWidgetItem *item, int column) { Qt::CheckState state = item->checkState(column); /// save data - string parent_name = ""; - string node_name = ""; + std::string parent_name = ""; + std::string node_name = ""; /// case 1 : click on the parent node if (item->childCount() > 0) { diff --git a/src/interface/gui/src/guigraphicsscene.cpp b/src/interface/gui/src/guigraphicsscene.cpp index ec0590cb2..b68ce7155 100644 --- a/src/interface/gui/src/guigraphicsscene.cpp +++ b/src/interface/gui/src/guigraphicsscene.cpp @@ -156,7 +156,7 @@ void GuiGraphicsScene::createChip(IdbBuilder* builder, std::string type) { } } -void GuiGraphicsScene::createDrc(std::map>& drc_db, int max_num) { +void GuiGraphicsScene::createDrc(std::map>>& drc_db, int max_num) { ((IdbSpeedUpSetup*)_db_setup)->showDrc(drc_db, max_num); } diff --git a/src/interface/tcl/tcl_gui/tcl_gui.cpp b/src/interface/tcl/tcl_gui/tcl_gui.cpp index ff37671e6..c6e8e5b04 100644 --- a/src/interface/tcl/tcl_gui/tcl_gui.cpp +++ b/src/interface/tcl/tcl_gui/tcl_gui.cpp @@ -25,7 +25,7 @@ #include "tcl_gui.h" #include "gui_io.h" -#include "lm_api.h" +#include "vec_api.h" #include "tool_manager.h" namespace tcl { @@ -243,17 +243,16 @@ unsigned CmdGuiShowGraph::exec() if (!check()) { return 0; } - std::cout << "333" << std::endl; + std::string path = ""; TclOption* path_opt = getOptionOrArg(TCL_PATH); if (path_opt != nullptr) { path = path_opt->getStringVal(); } - std::cout << "2222" << std::endl; + ivec::VectorizationApi lm_api; auto data = lm_api.getGraph(path); - std::cout << "11111" << std::endl; iplf::tmInst->guiShowGraph(data); return 1; -- Gitee