Commit 347de1d1 by sakundu

Updated CodeElement formatTranslators and added Ariane133-NG45 clustered netlist

Signed-off-by: sakundu <sakundu@ucsd.edu>
parent ededa3b5
...@@ -13,7 +13,8 @@ from FormatTranslators import MacroPin ...@@ -13,7 +13,8 @@ from FormatTranslators import MacroPin
class Clustering: class Clustering:
def __init__(self, design, src_dir, fixed_file, step_threshold = 100.6, distance = 1000.0, def __init__(self, design, src_dir, fixed_file, step_threshold = 100.6, distance = 1000.0,
grid_width = 30.0, max_num_vertices = 1000000, net_size_threshold = 300, grid_width = 30.0, max_num_vertices = 1000000, net_size_threshold = 300,
Nparts = 500, setup_file = "setup.tcl", RePlace = True, placement_density = 0.7, GUI = True): Nparts = 500, setup_file = "setup.tcl", result_dir = "./results",
RePlace = True, placement_density = 0.7, GUI = True):
""" """
parameter: design, help="design_name: ariane, MegaBoom_x2 ", type = str parameter: design, help="design_name: ariane, MegaBoom_x2 ", type = str
parameter: src_dir, help="directory for source codes", type = str parameter: src_dir, help="directory for source codes", type = str
...@@ -67,7 +68,6 @@ class Clustering: ...@@ -67,7 +68,6 @@ class Clustering:
self.net_file = self.hypergraph_file + ".net" self.net_file = self.hypergraph_file + ".net"
# set up result directories # set up result directories
result_dir = "./results"
if not os.path.exists(result_dir): if not os.path.exists(result_dir):
os.mkdir(result_dir) os.mkdir(result_dir)
...@@ -764,12 +764,14 @@ class ProBufFormat: ...@@ -764,12 +764,14 @@ class ProBufFormat:
if (len(adj_list[macro_pin]) == 0): if (len(adj_list[macro_pin]) == 0):
offset = self.macro_pin_offset[macro_pin] offset = self.macro_pin_offset[macro_pin]
inst_name = self.macro_pin_map[macro_pin] inst_name = self.macro_pin_map[macro_pin]
macro_type = self.insts[inst_name].GetType()
self.insts[inst_name].AddInputPin(MacroPin(macro_pin, inst_name, \ self.insts[inst_name].AddInputPin(MacroPin(macro_pin, inst_name, \
offset[0], offset[1])) offset[0], offset[1], macro_type))
else: else:
offset = self.macro_pin_offset[macro_pin] offset = self.macro_pin_offset[macro_pin]
inst_name = self.macro_pin_map[macro_pin] inst_name = self.macro_pin_map[macro_pin]
Pin = MacroPin(macro_pin, inst_name, offset[0], offset[1]) macro_type = self.insts[inst_name].GetType()
Pin = MacroPin(macro_pin, inst_name, offset[0], offset[1], macro_type)
Pin.AddSinks(adj_list[macro_pin].keys()) Pin.AddSinks(adj_list[macro_pin].keys())
self.insts[inst_name].AddOutputPin(Pin) self.insts[inst_name].AddOutputPin(Pin)
...@@ -777,12 +779,13 @@ class ProBufFormat: ...@@ -777,12 +779,13 @@ class ProBufFormat:
# add input pin # add input pin
inst_name = "Grp_" + str(i) inst_name = "Grp_" + str(i)
macro_pin = inst_name + "/Input" macro_pin = inst_name + "/Input"
self.insts[inst_name].AddInputPin(MacroPin(macro_pin, inst_name, 0.0, 0.0)) macro_type = self.insts[inst_name].GetType()
self.insts[inst_name].AddInputPin(MacroPin(macro_pin, inst_name, macro_type, 0.0, 0.0))
output_idx = 1 output_idx = 1
for key, weight in adj_list[inst_name].items(): for key, weight in adj_list[inst_name].items():
macro_pin = inst_name + "/Output_" + str(output_idx) macro_pin = inst_name + "/Output_" + str(output_idx)
output_idx += 1 output_idx += 1
Pin = MacroPin(macro_pin, inst_name, 0.0, 0.0) Pin = MacroPin(macro_pin, inst_name, macro_type, 0.0, 0.0)
Pin.AddSink(key) Pin.AddSink(key)
if key not in self.ios or key not in self.macro_pin_map: if key not in self.ios or key not in self.macro_pin_map:
Pin.SpecifyWeight(weight) Pin.SpecifyWeight(weight)
...@@ -794,7 +797,7 @@ class ProBufFormat: ...@@ -794,7 +797,7 @@ class ProBufFormat:
f = open(self.pbf_file, "w") f = open(self.pbf_file, "w")
for inst_name, inst in self.insts.items(): for inst_name, inst in self.insts.items():
f.write(str(inst)) f.write(str(inst))
if (inst.GetType() == "MACRO"): if inst.GetType() in ["MACRO","macro"]:
for macro_pin in inst.GetPins(): for macro_pin in inst.GetPins():
f.write(str(macro_pin)) f.write(str(macro_pin))
f.close() f.close()
......
...@@ -9,6 +9,24 @@ import shutil ...@@ -9,6 +9,24 @@ import shutil
import sys import sys
sys.path.append('./utils') sys.path.append('./utils')
# String Helper #
def print_placeholder(key, value):
line = " attr {\n"
line += f' key: "{key}"\n'
line += ' value {\n'
line += f' placeholder: "{value}"\n'
line += ' }\n'
line += ' }\n'
return line
def print_float(key, value):
line = " attr {\n"
line += f' key: "{key}"\n'
line += ' value {\n'
line += f' f: {value}\n'
line += ' }\n'
line += ' }\n'
return line
# Port # Port
class Port: class Port:
...@@ -48,6 +66,7 @@ class Port: ...@@ -48,6 +66,7 @@ class Port:
else: else:
name += char name += char
self.str += ' name: "' + name + '"\n' self.str += ' name: "' + name + '"\n'
for sink in self.sinks: for sink in self.sinks:
sink_new = '' sink_new = ''
for char in sink: for char in sink:
...@@ -57,30 +76,11 @@ class Port: ...@@ -57,30 +76,11 @@ class Port:
sink_new += char sink_new += char
sink = sink_new sink = sink_new
self.str += ' input: "' + sink + '"\n' self.str += ' input: "' + sink + '"\n'
self.str += " attr {\n"
self.str += ' key: "type"\n' self.str += print_placeholder('type', 'PORT')
self.str += ' value {\n' self.str += print_placeholder('side', self.side)
self.str += ' placeholder: "PORT"\n' self.str += print_float('x', self.x)
self.str += ' }\n' self.str += print_float('y', self.y)
self.str += ' }\n'
self.str += " attr {\n"
self.str += ' key: "side"\n'
self.str += ' value {\n'
self.str += ' placeholder: "' + self.side + '"\n'
self.str += ' }\n'
self.str += ' }\n'
self.str += " attr {\n"
self.str += ' key: "x"\n'
self.str += ' value {\n'
self.str += ' f: ' + str(self.x) + "\n"
self.str += ' }\n'
self.str += ' }\n'
self.str += " attr {\n"
self.str += ' key: "y"\n'
self.str += ' value {\n'
self.str += ' f: ' + str(self.y) + "\n"
self.str += ' }\n'
self.str += ' }\n'
self.str += "}\n" self.str += "}\n"
return self.str return self.str
...@@ -135,36 +135,12 @@ class StandardCell: ...@@ -135,36 +135,12 @@ class StandardCell:
sink_new += char sink_new += char
sink = sink_new sink = sink_new
self.str += ' input: "' + sink + '"\n' self.str += ' input: "' + sink + '"\n'
self.str += " attr {\n"
self.str += ' key: "type"\n' self.str += print_placeholder('type', 'STDCELL')
self.str += ' value {\n' self.str += print_float('height', self.height)
self.str += ' placeholder: "STDCELL"\n' self.str += print_float('width', self.width)
self.str += ' }\n' self.str += print_float('x', self.x)
self.str += ' }\n' self.str += print_float('y', self.y)
self.str += " attr {\n"
self.str += ' key: "height"\n'
self.str += ' value {\n'
self.str += ' f: ' + str(self.height) + "\n"
self.str += ' }\n'
self.str += ' }\n'
self.str += " attr {\n"
self.str += ' key: "width"\n'
self.str += ' value {\n'
self.str += ' f: ' + str(self.width) + "\n"
self.str += ' }\n'
self.str += ' }\n'
self.str += " attr {\n"
self.str += ' key: "x"\n'
self.str += ' value {\n'
self.str += ' f: ' + str(self.x) + "\n"
self.str += ' }\n'
self.str += ' }\n'
self.str += " attr {\n"
self.str += ' key: "y"\n'
self.str += ' value {\n'
self.str += ' f: ' + str(self.y) + "\n"
self.str += ' }\n'
self.str += ' }\n'
self.str += "}\n" self.str += "}\n"
return self.str return self.str
...@@ -228,50 +204,22 @@ class Macro: ...@@ -228,50 +204,22 @@ class Macro:
else: else:
name += char name += char
self.str += ' name: "' + name + '"\n' self.str += ' name: "' + name + '"\n'
self.str += " attr {\n" self.str += print_placeholder('type', self.GetType())
self.str += ' key: "type"\n' self.str += print_placeholder('orientation', self.orientation)
self.str += ' value {\n' self.str += print_float('height', self.height)
self.str += ' placeholder: "' + self.GetType() + '\n' self.str += print_float('width', self.width)
self.str += ' }\n' self.str += print_float('x', self.x)
self.str += ' }\n' self.str += print_float('y', self.y)
self.str += " attr {\n"
self.str += ' key: "orientation"\n'
self.str += ' value {\n'
self.str += ' placeholder: "' + self.orientation + '"\n'
self.str += ' }\n'
self.str += ' }\n'
self.str += " attr {\n"
self.str += ' key: "height"\n'
self.str += ' value {\n'
self.str += ' f: ' + str(self.height) + "\n"
self.str += ' }\n'
self.str += ' }\n'
self.str += " attr {\n"
self.str += ' key: "width"\n'
self.str += ' value {\n'
self.str += ' f: ' + str(self.width) + "\n"
self.str += ' }\n'
self.str += ' }\n'
self.str += " attr {\n"
self.str += ' key: "x"\n'
self.str += ' value {\n'
self.str += ' f: ' + str(self.x) + "\n"
self.str += ' }\n'
self.str += ' }\n'
self.str += " attr {\n"
self.str += ' key: "y"\n'
self.str += ' value {\n'
self.str += ' f: ' + str(self.y) + "\n"
self.str += ' }\n'
self.str += ' }\n'
self.str += "}\n" self.str += "}\n"
return self.str return self.str
# Macro pin # Macro pin
class MacroPin: class MacroPin:
def __init__(self, name, macro_name, x_offset, y_offset, x = 0.0, y = 0.0): def __init__(self, name, macro_name, x_offset, y_offset, macro_type,
x = 0.0, y = 0.0):
self.name = name self.name = name
self.macro_name = macro_name self.macro_name = macro_name
self.macro_type = macro_type
self.x_offset = x_offset self.x_offset = x_offset
self.y_offset = y_offset self.y_offset = y_offset
self.x = x self.x = x
...@@ -316,55 +264,25 @@ class MacroPin: ...@@ -316,55 +264,25 @@ class MacroPin:
sink_new += char sink_new += char
sink = sink_new sink = sink_new
self.str += ' input: "' + sink + '"\n' self.str += ' input: "' + sink + '"\n'
self.str += " attr {\n"
self.str += ' key: "macro_name"\n'
self.str += ' value {\n'
macro_name = '' macro_name = ''
for char in self.macro_name: for char in self.macro_name:
if char == '\\': if char == '\\':
macro_name += '\\\\' macro_name += '\\\\'
else: else:
macro_name += char macro_name += char
self.str += ' placeholder: "' + str(macro_name) + '"\n' self.str += print_placeholder('macro_name', str(macro_name))
self.str += ' }\n' if self.macro_type == "MACRO":
self.str += ' }\n' self.str += print_placeholder('type', 'MACRO_PIN')
self.str += " attr {\n" else:
self.str += ' key: "type"\n' self.str += print_placeholder('type', 'macro_pin')
self.str += ' value {\n'
self.str += ' placeholder: "macro_pin"\n'
self.str += ' }\n'
self.str += ' }\n'
if (self.weight > 1): if (self.weight > 1):
self.str += " attr {\n" self.str += print_float('weight', self.weight)
self.str += ' key: "weight"\n'
self.str += ' value {\n' self.str += print_float('x_offset', self.x_offset)
self.str += ' f: ' + str(self.weight) + "\n" self.str += print_float('y_offset', self.y_offset)
self.str += ' }\n' self.str += print_float('x', self.x)
self.str += ' }\n' self.str += print_float('y', self.y)
self.str += " attr {\n"
self.str += ' key: "x_offset"\n'
self.str += ' value {\n'
self.str += ' f: ' + str(self.x_offset) + "\n"
self.str += ' }\n'
self.str += ' }\n'
self.str += " attr {\n"
self.str += ' key: "y_offset"\n'
self.str += ' value {\n'
self.str += ' f: ' + str(self.y_offset) + "\n"
self.str += ' }\n'
self.str += ' }\n'
self.str += " attr {\n"
self.str += ' key: "x"\n'
self.str += ' value {\n'
self.str += ' f: ' + str(self.x) + "\n"
self.str += ' }\n'
self.str += ' }\n'
self.str += " attr {\n"
self.str += ' key: "y"\n'
self.str += ' value {\n'
self.str += ' f: ' + str(self.y) + "\n"
self.str += ' }\n'
self.str += ' }\n'
self.str += "}\n" self.str += "}\n"
return self.str return self.str
...@@ -646,7 +564,8 @@ class BookShelf2ProBufFormat: ...@@ -646,7 +564,8 @@ class BookShelf2ProBufFormat:
# We use the OpenDB database in OpenROAD to read lef/def files # We use the OpenDB database in OpenROAD to read lef/def files
# We have provided an openroad exe # We have provided an openroad exe
class ODB2ProBufFormat: class ODB2ProBufFormat:
def __init__(self, file_dir, design, output_file, openroad_exe, net_size_threshold): def __init__(self, file_dir, design, output_file, openroad_exe,
net_size_threshold):
self.design = design self.design = design
self.file_dir = file_dir self.file_dir = file_dir
self.db_file = file_dir + "/" + design + ".odb" self.db_file = file_dir + "/" + design + ".odb"
...@@ -668,7 +587,6 @@ class ODB2ProBufFormat: ...@@ -668,7 +587,6 @@ class ODB2ProBufFormat:
self.fp_ux = 0.0 self.fp_ux = 0.0
self.fp_uy = 0.0 self.fp_uy = 0.0
# functions # functions
self.CheckFiles() self.CheckFiles()
self.ReadOutlineFile() self.ReadOutlineFile()
...@@ -720,7 +638,8 @@ class ODB2ProBufFormat: ...@@ -720,7 +638,8 @@ class ODB2ProBufFormat:
print('*'*80) print('*'*80)
print("Outline Information") print("Outline Information")
print("[INFO] Core Size : ", self.fp_lx, self.fp_ly, self.fp_ux, self.fp_uy) print("[INFO] Core Size : ", self.fp_lx, self.fp_ly, self.fp_ux,
self.fp_uy)
print("\n\n") print("\n\n")
......
This source diff could not be displayed because it is too large. You can view the blob instead.
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