Skip to content

Commit

Permalink
hotfix: logical errors in Odb.ReportDisconnectedPins (#455)
Browse files Browse the repository at this point in the history
## Steps

* `Odb.ReportDisconnectedPins`
  * Fixed bug with improper table widths in step directories
  * Fixed a bug where pins with `USE SIGNAL` would be considered power
pins
  • Loading branch information
kareefardi authored Apr 23, 2024
1 parent 1c3e106 commit 7a0a73c
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 15 deletions.
8 changes: 8 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@
## API Breaks
## Documentation
-->
# 2.0.2

## Steps

* `Odb.ReportDisconnectedPins`
* Fixed table not being written to step directory
* Fixed bug where table widths were not being set properly
* Fixed bug where pins with `USE SIGNAL` would be considered power pins

# 2.0.1

Expand Down
2 changes: 1 addition & 1 deletion openlane/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
__version__ = "2.0.1"
__version__ = "2.0.2"

if __name__ == "__main__":
print(__version__, end="")
44 changes: 30 additions & 14 deletions openlane/scripts/odbpy/disconnected_pins.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from reader import click, click_odb, OdbReader
from reader import rich
from reader import Table
from rich.console import Console


def is_connected(term: Union[odb.dbITerm, odb.dbBTerm]) -> bool:
Expand All @@ -38,7 +39,7 @@ def is_connected(term: Union[odb.dbITerm, odb.dbBTerm]) -> bool:
@dataclass
class Port:
polarity: Literal["INPUT", "OUTPUT", "INOUT"]
pg: Optional[Literal["POWER", "GROUND"]]
signal_type: Optional[Literal["POWER", "GROUND", "SIGNAL"]]
connected: bool = False


Expand All @@ -62,7 +63,7 @@ def from_object(
module: "Module",
):
result = Self()
for terminal in module.ports.values():
for name, terminal in module.ports.items():
if terminal.polarity == "INPUT":
result.inputs += 1
if terminal.connected:
Expand All @@ -72,11 +73,11 @@ def from_object(
if terminal.connected:
result.outputs_connected += 1
elif terminal.polarity == "INOUT":
if terminal.pg == "POWER":
if terminal.signal_type == "POWER":
result.power_inouts += 1
if terminal.connected:
result.power_inouts_connected += 1
elif terminal.pg == "GROUND":
elif terminal.signal_type == "GROUND":
result.ground_inouts += 1
if terminal.connected:
result.ground_inouts_connected += 1
Expand Down Expand Up @@ -140,14 +141,14 @@ def __init__(self, object: Union[odb.dbBlock, odb.dbInst]) -> None:
power_found = False
ground_found = True
for terminal in terminals:
pg = terminal.getSigType()
if pg == "POWER":
signal_type = terminal.getSigType()
if signal_type == "POWER":
power_found = True
elif pg == "GROUND":
elif signal_type == "GROUND":
ground_found = True
self.ports[terminal.getName()] = Port(
terminal.getIoType(),
pg=terminal.getSigType(),
signal_type=terminal.getSigType(),
connected=is_connected(terminal),
)
if not power_found:
Expand Down Expand Up @@ -189,20 +190,32 @@ def write_disconnected_pins(self, full_table: Table, critical_table: Table):
row = (
self.name,
"\n".join(
[k for k, v in self.ports.items() if v.pg is not None and v.connected]
[
k
for k, v in self.ports.items()
if v.signal_type in ["POWER", "GROUND"] and v.connected
]
),
"\n".join(
[
k
for k, v in self.ports.items()
if v.pg is not None and not v.connected
if v.signal_type in ["POWER", "GROUND"] and not v.connected
]
),
"\n".join(
[k for k, v in self.ports.items() if v.pg is None and v.connected]
[
k
for k, v in self.ports.items()
if v.signal_type == "SIGNAL" and v.connected
]
),
"\n".join(
[k for k, v in self.ports.items() if v.pg is None and not v.connected]
[
k
for k, v in self.ports.items()
if v.signal_type == "SIGNAL" and not v.connected
]
),
)
full_table.add_row(*row)
Expand Down Expand Up @@ -242,6 +255,7 @@ def main(
"Signal Pins",
"Disconnected",
title="",
show_lines=True,
)
critical_table = Table(
"Macro/Instance",
Expand Down Expand Up @@ -277,8 +291,10 @@ def main(
rich.print(critical_table)
if full_table.row_count > 0:
if full_table_path := write_full_table_to:
full_table.width = 160
rich.print(full_table, file=open(full_table_path, "w", encoding="utf8"))
console = Console(
file=open(full_table_path, "w", encoding="utf8"), width=160
)
console.print(full_table)

utl.metric_integer("design__disconnected_pin__count", disconnected_pin_count)
utl.metric_integer(
Expand Down
2 changes: 2 additions & 0 deletions openlane/steps/odb.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,8 @@ def get_command(self) -> List[str]:
for module in ignored_modules:
command.append("--ignore-module")
command.append(module)
command.append("--write-full-table-to")
command.append(os.path.join(self.step_dir, "full_disconnected_pins_table.txt"))
return command


Expand Down

0 comments on commit 7a0a73c

Please sign in to comment.