Skip to content

Commit ee97594

Browse files
authored
Merge pull request #8222 from hongted/mbff
gpl: Allow for MBFF tray identification on flops that have scan, preset, and clear pins.
2 parents 7e3676e + 6ce01e7 commit ee97594

File tree

11 files changed

+1490
-8
lines changed

11 files changed

+1490
-8
lines changed

MODULE.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ git_override(
112112

113113
bazel_dep(name = "googletest", version = "1.17.0", dev_dependency = True)
114114

115+
bazel_dep(name = "abseil-cpp", version = "20240722.0", repo_name = "com_google_absl")
116+
115117
# Dependencies needed by one of the rules_hdl repos. Once they are on
116118
# BCR, they should depend on their own version.
117119
bazel_dep(name = "glpk", version = "5.0.bcr.3", repo_name = "org_gnu_glpk")

src/gpl/BUILD

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,9 @@ cc_library(
2323
"src/graphicsImpl.cpp",
2424
"src/graphicsImpl.h",
2525
"src/graphicsNone.cpp",
26-
"src/graphicsNone.h",
2726
"src/initialPlace.cpp",
2827
"src/initialPlace.h",
2928
"src/mbff.cpp",
30-
"src/mbff.h",
3129
"src/nesterovBase.cpp",
3230
"src/nesterovBase.h",
3331
"src/nesterovPlace.cpp",
@@ -49,6 +47,8 @@ cc_library(
4947
"include/gpl/AbstractGraphics.h",
5048
"include/gpl/MakeReplace.h",
5149
"include/gpl/Replace.h",
50+
"src/graphicsNone.h",
51+
"src/mbff.h",
5252
],
5353
copts = [
5454
"-fopenmp",

src/gpl/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ target_include_directories(gpl_lib
6262
)
6363

6464
target_link_libraries(gpl_lib
65-
PRIVATE
6665
utl_lib
6766
Eigen3::Eigen
6867
odb

src/gpl/src/mbff.cpp

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,6 @@ bool MBFF::IsClearPin(dbITerm* iterm)
352352
{
353353
dbInst* inst = iterm->getInst();
354354
const sta::Cell* cell = network_->dbToSta(inst->getMaster());
355-
const sta::LibertyCell* lib_cell = getLibertyCell(cell);
356355
const sta::Pin* pin = network_->dbToSta(iterm);
357356
if (pin == nullptr) {
358357
return false;
@@ -361,11 +360,41 @@ bool MBFF::IsClearPin(dbITerm* iterm)
361360
if (lib_port == nullptr) {
362361
return false;
363362
}
363+
364+
const sta::LibertyCell* lib_cell = network_->libertyCell(cell);
365+
if (lib_cell == nullptr) {
366+
return false;
367+
}
368+
369+
// Check the lib cell if the port is a clear.
364370
for (const sta::Sequential* seq : lib_cell->sequentials()) {
365371
if (seq->clear() && seq->clear()->hasPort(lib_port)) {
366372
return true;
367373
}
368374
}
375+
376+
// If it exists, check the test lib cell if the port is a clear.
377+
const sta::LibertyCell* test_cell = lib_cell->testCell();
378+
if (test_cell == nullptr) {
379+
return false;
380+
}
381+
382+
// Find the equivalent lib_port on the test cell by name.
383+
//
384+
// TODO: NA - Make retrieving the port on the lib cell possible without doing
385+
// a name match each time
386+
const sta::LibertyPort* test_lib_port
387+
= test_cell->findLibertyPort(lib_port->name());
388+
if (test_lib_port == nullptr) {
389+
return false;
390+
}
391+
392+
for (const sta::Sequential* seq : test_cell->sequentials()) {
393+
if (seq->clear() && seq->clear()->hasPort(test_lib_port)) {
394+
return true;
395+
}
396+
}
397+
369398
return false;
370399
}
371400

@@ -385,7 +414,6 @@ bool MBFF::IsPresetPin(dbITerm* iterm)
385414
{
386415
dbInst* inst = iterm->getInst();
387416
const sta::Cell* cell = network_->dbToSta(inst->getMaster());
388-
const sta::LibertyCell* lib_cell = getLibertyCell(cell);
389417
const sta::Pin* pin = network_->dbToSta(iterm);
390418
if (pin == nullptr) {
391419
return false;
@@ -394,11 +422,41 @@ bool MBFF::IsPresetPin(dbITerm* iterm)
394422
if (lib_port == nullptr) {
395423
return false;
396424
}
425+
426+
const sta::LibertyCell* lib_cell = network_->libertyCell(cell);
427+
if (lib_cell == nullptr) {
428+
return false;
429+
}
430+
431+
// Check the lib cell if the port is a preset.
397432
for (const sta::Sequential* seq : lib_cell->sequentials()) {
398433
if (seq->preset() && seq->preset()->hasPort(lib_port)) {
399434
return true;
400435
}
401436
}
437+
438+
// If it exists, check the test lib cell if the port is a preset.
439+
const sta::LibertyCell* test_cell = lib_cell->testCell();
440+
if (test_cell == nullptr) {
441+
return false;
442+
}
443+
444+
// Find the equivalent lib_port on the test cell by name.
445+
//
446+
// TODO: NA - Make retrieving the port on the lib cell possible without doing
447+
// a name match each time
448+
const sta::LibertyPort* test_lib_port
449+
= test_cell->findLibertyPort(lib_port->name());
450+
if (test_lib_port == nullptr) {
451+
return false;
452+
}
453+
454+
for (const sta::Sequential* seq : test_cell->sequentials()) {
455+
if (seq->preset() && seq->preset()->hasPort(test_lib_port)) {
456+
return true;
457+
}
458+
}
459+
402460
return false;
403461
}
404462

src/gpl/src/mbff.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@
33

44
#pragma once
55

6-
#include <fstream>
76
#include <map>
87
#include <memory>
9-
#include <set>
108
#include <string>
119
#include <utility>
1210
#include <vector>
@@ -54,6 +52,8 @@ enum PortName
5452

5553
class MBFF
5654
{
55+
friend class MBFFTestPeer;
56+
5757
public:
5858
MBFF(odb::dbDatabase* db,
5959
sta::dbSta* sta,

src/gpl/test/BUILD

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,3 +152,31 @@ cc_test(
152152
"@spdlog",
153153
],
154154
)
155+
156+
cc_test(
157+
name = "mbff_test",
158+
srcs = ["mbff_test.cpp"],
159+
data = [
160+
"library/test/test0.lef",
161+
"library/test/test0.lib",
162+
],
163+
deps = [
164+
"//:openroad_lib",
165+
"//bazel:runfiles",
166+
"//src/ant",
167+
"//src/dbSta",
168+
"//src/dbSta:dbReadVerilog",
169+
"//src/dpl",
170+
"//src/est",
171+
"//src/gpl",
172+
"//src/grt",
173+
"//src/odb",
174+
"//src/rsz",
175+
"//src/stt",
176+
"//src/tst",
177+
"//src/utl",
178+
"@com_google_absl//absl/strings",
179+
"@googletest//:gtest",
180+
"@googletest//:gtest_main",
181+
],
182+
)

src/gpl/test/CMakeLists.txt

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,5 +66,30 @@ target_sources(fft_test
6666
../src/fftsg2d.cpp
6767
)
6868

69+
add_executable(mbff_test
70+
mbff_test.cpp
71+
)
72+
73+
target_include_directories(mbff_test
74+
PRIVATE
75+
${PROJECT_SOURCE_DIR}
76+
)
77+
78+
target_link_libraries(mbff_test PUBLIC
79+
absl::strings
80+
GTest::gtest
81+
GTest::gtest_main
82+
gpl_lib
83+
tst
84+
)
85+
86+
gtest_discover_tests(mbff_test
87+
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
88+
)
89+
90+
target_sources(mbff_test
91+
PRIVATE
92+
mbff_test.cpp
93+
)
6994

70-
add_dependencies(build_and_test fft_test)
95+
add_dependencies(build_and_test fft_test mbff_test)

0 commit comments

Comments
 (0)