Commit 12d2e715 by sakundu

Updated utility scripts

Signed-off-by: sakundu <sakundu@ucsd.edu>
parent 9435cf9c
......@@ -56,7 +56,7 @@ grouping_src_dir = f'{work_dir}/CodeElements/Grouping/src'
grouping_rpt_dir = f'{output_dir}/grouping_rpt'
K_in = 1
K_out = 1
global_net_threshold = 300
global_net_threshold = 500
grouping = Grouping(design, num_rows, num_cols, K_in, K_out, setup_file, global_net_threshold, grouping_src_dir)
# clean the rpt_dir
......
......@@ -197,16 +197,14 @@ proc write_node_macro_pin { macro_pin_ptr fp } {
### Attribute: type ###
print_placeholder $fp "type" "macro_pin"
set macro_x1 [lindex [dbget ${macro_pin_ptr}.inst.box] 0 0]
set macro_x2 [lindex [dbget ${macro_pin_ptr}.inst.box] 0 2]
set macro_y1 [lindex [dbget ${macro_pin_ptr}.inst.box] 0 1]
set macro_y2 [lindex [dbget ${macro_pin_ptr}.inst.box] 0 3]
set macro_x [expr ($macro_x1 + $macro_x2)/2]
set macro_y [expr ($macro_y1 + $macro_y2)/2]
set X [dbget ${macro_pin_ptr}.pt_x]
set Y [dbget ${macro_pin_ptr}.pt_y]
set x_offset [expr $X - $macro_x]
set y_offset [expr $Y - $macro_y]
set cell_height [dbget ${macro_pin_ptr}.cellTerm.cell.size_y]
set cell_width [dbget ${macro_pin_ptr}.cellTerm.cell.size_x]
set pin_x [dbget ${macro_pin_ptr}.cellTerm.pt_x]
set pin_y [dbget ${macro_pin_ptr}.cellTerm.pt_y]
set x_offset [expr $pin_x - $cell_width/2]
set y_offset [expr $pin_y - $cell_height/2]
### Attribute: x_offset ###
print_float $fp "x_offset" $x_offset
......
......@@ -104,7 +104,9 @@ for node in soft_macro_list:
soft_macro_count += 1
area = area1 + area2
fp.write(f"# HARD MACRO AREA: {area1}\n")
fp.write(f"# SOFT MACRO AREA: {area2}\n")
fp.write(f"# Area: {area}\n")
fp.write(f"# SOFT MACRO COUNT: {soft_macro_count}\n")
fp.write(f"# HARD MACRO COUNT: {hard_macro_count}\n")
fp.close()
\ No newline at end of file
fp.close()
'''
This script generates OpenDB database from LEF/DEF
'''
import odb
import sys
import os
design = sys.argv[1]
def_file = sys.argv[2]
output_dir = sys.argv[3]
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")
print(f"Successfully generated ODB format from LEF/DEF for {design}")
\ No newline at end of file
'''
This script generates bookshelf format from odb format
'''
import os
import odb
import sys
import re
work_dir = re.search(r'(/\S+/MacroPlacement)', os.getcwd()).group(1)
sys.path.append(f'{work_dir}/Flows/util')
from convert_odb2bookshelf import OdbToBookshelf
design = sys.argv[1]
odb_file = sys.argv[2]
output_dir = sys.argv[3]
modeFormat = 'ISPD11'
cellPadding = 0
layerCapacity = 'layeradjust_empty.tcl'
def touch(fname, times=None):
with open(fname, 'a'):
os.utime(fname, times)
if not os.path.exists(layerCapacity):
touch(layerCapacity)
db = odb.dbDatabase.create()
odb.read_db(db, odb_file)
bs = OdbToBookshelf(opendbpy=odb, opendb=db, cellPadding=cellPadding,
modeFormat=modeFormat, layerCapacity=layerCapacity)
if not os.path.exists(f'{output_dir}/RePlAce'):
os.makedirs(f'{output_dir}/RePlAce')
bs.WriteBookshelf(f'{design}.bookshelf')
### Helper to convert Orientation format ###
proc get_orient { tmp_orient } {
set orient "N"
if { $tmp_orient == "N"} {
set orient "R0"
} elseif { $tmp_orient == "S" } {
set orient "R180"
} elseif { $tmp_orient == "W" } {
set orient "R90"
} elseif { $tmp_orient == "E" } {
set orient "R270"
} elseif { $tmp_orient == "FN" } {
set oreint "MY"
} elseif { $tmp_orient == "FS" } {
set oreint "MX"
} elseif { $tmp_orient == "FW" } {
set orient "MX90"
} elseif { $tmp_orient == "FE" } {
set orient "MY90"
}
return $orient
}
proc place_macro_from_pl {file_path} {
set dbu 100
set fp [open $file_path r]
while { [gets $fp line] >= 0} {
if {[llength $line] == 7} {
set inst_name [lindex $line 0]
puts "$inst_name"
set pt_x [expr [lindex $line 1]/$dbu]
set pt_y [expr [lindex $line 2]/$dbu]
set tmp_orient [expr [lindex $line 5]]
set orient [get_orient $tmp_orient]
if {[dbget top.insts.name $inst_name -e] == ""} {
puts "\[ERROR\] $inst_name does not exists."
} else {
placeInstance $inst_name $pt_x $pt_y $orient -fixed
}
}
}
}
\ No newline at end of file
......@@ -9,6 +9,8 @@ plc_file = sys.argv[1]
pb_file = sys.argv[2]
place_tcl = sys.argv[3]
print(f'PLC:\t{plc_file}\nPB:\t{pb_file}\nTCL:\t{place_tcl}')
orientMap = {
"N" : "R0",
"S" : "R180",
......@@ -82,6 +84,7 @@ for line in lines:
node_list[-1].y_offset = words[1]
fp.close()
fp = open(plc_file, "r")
lines = fp.readlines()
fp_out = open(place_tcl, "w")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment