mirror of https://github.com/VLSIDA/OpenRAM.git
Added graph store and read functionality
This commit is contained in:
parent
d3753556c1
commit
05ab45f39b
|
|
@ -1,6 +1,7 @@
|
||||||
import copy
|
import copy
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
import debug
|
import debug
|
||||||
|
import json
|
||||||
|
|
||||||
|
|
||||||
class timing_graph():
|
class timing_graph():
|
||||||
|
|
@ -139,6 +140,35 @@ class timing_graph():
|
||||||
|
|
||||||
return [self.edge_mods[(path[i], path[i+1])] for i in range(len(path)-1)]
|
return [self.edge_mods[(path[i], path[i+1])] for i in range(len(path)-1)]
|
||||||
|
|
||||||
|
def write(self, filename):
|
||||||
|
"""
|
||||||
|
Export graph to a JSON file
|
||||||
|
"""
|
||||||
|
# TODO: Find a proper way to store edge_mods values
|
||||||
|
with open(filename, 'w') as f:
|
||||||
|
f.write(
|
||||||
|
json.dumps(
|
||||||
|
{
|
||||||
|
'graph':
|
||||||
|
{key: list(val) for key, val in self.graph.items()},
|
||||||
|
'edge_mods':
|
||||||
|
{
|
||||||
|
', '.join(key): str(value)
|
||||||
|
for key, value in self.edge_mods.items()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
def read(self, filename):
|
||||||
|
"""
|
||||||
|
Read graph from JSON file
|
||||||
|
"""
|
||||||
|
with open(filename, 'r') as f:
|
||||||
|
d = json.loads(f.read())
|
||||||
|
self.graph = {key: set(value) for key, value in d['graph'].items()}
|
||||||
|
self.edge_mods = {tuple(key.split(', ')): value for key, value in d['edge_mods'].items()}
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
""" override print function output """
|
""" override print function output """
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,9 @@ s.setup_multiport_constants()
|
||||||
OPTS.netlist_only = True
|
OPTS.netlist_only = True
|
||||||
OPTS.check_lvsdrc = False
|
OPTS.check_lvsdrc = False
|
||||||
|
|
||||||
|
# TODO: remove this after adding trimmed netlist gen to sram run
|
||||||
|
OPTS.trim_netlist = False
|
||||||
|
|
||||||
# Characterize the design
|
# Characterize the design
|
||||||
start_time = datetime.datetime.now()
|
start_time = datetime.datetime.now()
|
||||||
from characterizer import lib
|
from characterizer import lib
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import datetime
|
||||||
import os
|
import os
|
||||||
import debug
|
import debug
|
||||||
from characterizer import functional
|
from characterizer import functional
|
||||||
|
from base import timing_graph
|
||||||
from globals import OPTS, print_time
|
from globals import OPTS, print_time
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
|
|
@ -187,3 +188,13 @@ class sram():
|
||||||
debug.print_raw("Extended Config: Writing to {0}".format(oname))
|
debug.print_raw("Extended Config: Writing to {0}".format(oname))
|
||||||
self.extended_config_write(oname)
|
self.extended_config_write(oname)
|
||||||
print_time("Extended Config", datetime.datetime.now(), start_time)
|
print_time("Extended Config", datetime.datetime.now(), start_time)
|
||||||
|
|
||||||
|
# Write the graph if specified
|
||||||
|
if OPTS.write_graph:
|
||||||
|
start_time = datetime.datetime.now()
|
||||||
|
oname = OPTS.output_path + OPTS.output_name + "_graph.json"
|
||||||
|
debug.print_raw("Graph: Writing to {0}".format(oname))
|
||||||
|
graph = timing_graph()
|
||||||
|
self.s.build_graph(graph, self.name, self.s.pins)
|
||||||
|
graph.write(oname)
|
||||||
|
print_time("Graph", datetime.datetime.now(), start_time)
|
||||||
|
|
|
||||||
|
|
@ -119,6 +119,8 @@ class options(optparse.Values):
|
||||||
# Determines which analytical model to use.
|
# Determines which analytical model to use.
|
||||||
# Available Models: elmore, linear_regression
|
# Available Models: elmore, linear_regression
|
||||||
model_name = "elmore"
|
model_name = "elmore"
|
||||||
|
# Write graph to a file
|
||||||
|
write_graph = False
|
||||||
|
|
||||||
###################
|
###################
|
||||||
# Tool options
|
# Tool options
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue