lefdef_to_odb.py 1.46 KB
Newer Older
sakundu committed
1 2 3 4 5 6
'''
This script generates OpenDB database from LEF/DEF 
'''
import odb
import sys
import os
7
import re
sakundu committed
8 9 10 11 12

design = sys.argv[1]
def_file = sys.argv[2]
output_dir = sys.argv[3]

13 14 15 16 17 18
work_dir = re.search(r'(/\S+/MacroPlacement)', os.getcwd()).group(1)
sys.path.append(f'{work_dir}/Flows/util')

from convert_odb2bookshelf import OdbToBookshelf


sakundu committed
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
lef_dir = '../../../../../Enablements/NanGate45/lef'
lef_list = [f'{lef_dir}/NangateOpenCellLibrary.tech.lef',
            f'{lef_dir}/NangateOpenCellLibrary.macro.mod.lef',
            f'{lef_dir}/fakeram45_256x16.lef']

db = odb.dbDatabase.create()
for lef_file in lef_list:
    odb.read_lef(db, lef_file)

odb.read_def(db, def_file)
chip = db.getChip()
tech = db.getTech()
libs = db.getLibs()

if chip is None:
    exit("ERROR: READ DEF Failed")

if not os.path.exists(f'{output_dir}/RePlAce'):
    os.makedirs(f'{output_dir}/RePlAce')

odb_file = f'{output_dir}/RePlAce/{design}.odb'
export_result = odb.write_db(db, odb_file)

if export_result != 1:
    exit("ERROR: Export failed")


new_db = odb.dbDatabase.create()
odb.read_db(new_db, odb_file)

if new_db is None:
    exit("ERROR: Import failed")

if odb.db_diff(db, new_db):
    exit("ERROR: Difference found in exported and imported DB")

55 56 57 58 59 60 61 62 63 64
print(f"Successfully generated ODB format from LEF/DEF for {design}")

bs = OdbToBookshelf(
    opendbpy=odb, 
    opendb=db, 
    cellPadding=0,
    modeFormat="ISPD11",
    layerCapacity='layeradjust_empty.tcl')

bs.WriteBookshelf(f'{design}_pad0_ISPD11')