Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Path fixes #79

Merged
merged 2 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# 2.3.3

## Common

- Add a new logging system (adopted from OpenLane 2)
- Store output under `run/timestamp/`
- New recommended design directory structure
- Add support for `{cond=value}`

# 2.3.2

## Common
Expand Down
2 changes: 1 addition & 1 deletion cace/__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.3.2'
__version__ = '2.3.3'

if __name__ == '__main__':
print(__version__, end='')
4 changes: 2 additions & 2 deletions cace/cace_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -858,10 +858,10 @@ def save_results(self):
with open(doutfile, 'w') as ofile:
json.dump(
dsheet, ofile, indent=4
) # TODO inside simulation_manager
) # TODO inside parameter_manager
else:
# NOTE: This file contains the run-time settings dictionary
cace_write(dsheet, doutfile) # TODO inside simulation_manager
cace_write(dsheet, doutfile) # TODO inside parameter_manager

self.last_save = os.path.getmtime(doutfile)

Expand Down
24 changes: 21 additions & 3 deletions cace/common/cace_gensim.py
Original file line number Diff line number Diff line change
Expand Up @@ -628,13 +628,18 @@ def get_condition_names_used(testbenchpath, testbench):
# Vectors in name[number|range] format
vectrex = re.compile(r'([^\[]+)\[([0-9:]+)\]')

# List for {cond=value} syntax
default_cond = {}

for line in simlines:
for patmatch in varex.finditer(line):
pattern = patmatch.group(1)

# For condition names in the form {cond=value}, use only the name
if '=' in pattern:
pattern = pattern.split('=')[0]
(pattern, default) = pattern.split('=')
# Add the default value
default_cond[pattern] = default

# For condition names in the form {cond|value}, use only the name
if '|' in pattern:
Expand All @@ -647,7 +652,7 @@ def get_condition_names_used(testbenchpath, testbench):
pattern = pmatch.group(1) + '['
condlist[pattern] = True

return condlist
return (condlist, default_cond)


# -----------------------------------------------------------------------
Expand Down Expand Up @@ -1481,7 +1486,9 @@ def cace_gensim(dataset, param, simfilepath):
# Get the list of parameters that get substituted in the template
condnames = []
for testbench in testbenches:
newnames = get_condition_names_used(testbenchpath, testbench)
(newnames, default_cond) = get_condition_names_used(
testbenchpath, testbench
)
if not newnames:
err('No conditions for testbench ' + testbench)
else:
Expand All @@ -1490,6 +1497,17 @@ def cace_gensim(dataset, param, simfilepath):
if name not in condnames:
condnames.append(name)

# Add new default conditions (if not already exist)
for cond, value in default_cond.items():
if not cond in defcondnames:
defcondnames.append(cond)
defcondlist.append(
{
'name': cond,
'typical': value,
}
)

# Get the list of parameters specific to the electrical parameter
# definition
pcondlist = param['conditions']
Expand Down
14 changes: 9 additions & 5 deletions cace/common/cace_measure.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,13 +223,15 @@ def results_to_json(testbench):
return datfilename


def cace_run_measurement(param, measure, testbench, paths, debug=False):
def cace_run_measurement(
param, measure, testbench, paths, simulation_path, debug=False
):
"""
Execute one measurement on the simulation data
"""

testbench_path = paths.get('testbench', paths['templates'])
simulation_path = paths['simulation']
testbench_path = paths.get('testbench', paths['scripts'])
# simulation_path = paths['simulation']
root_path = paths['root']

testbenchname = param['name']
Expand Down Expand Up @@ -286,7 +288,7 @@ def cace_run_measurement(param, measure, testbench, paths, debug=False):
# ---------------------------------------------------------------------------


def cace_measure(param, testbench, paths, debug=False):
def cace_measure(param, testbench, paths, simulation_path, debug=False):
"""
Main entry point for cace_measure

Expand All @@ -308,7 +310,9 @@ def cace_measure(param, testbench, paths, debug=False):
measurelist = []

for measure in measurelist:
result = cace_run_measurement(param, measure, testbench, paths, debug)
result = cace_run_measurement(
param, measure, testbench, paths, simulation_path, debug
)
if result == 0:
measurements = 0
break
Expand Down
4 changes: 2 additions & 2 deletions cace/common/cace_regenerate.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,8 @@ def check_layout_out_of_date(spicepath, layoutpath, debug=False):
dbg('Layout netlist is older than top-level layout.')
laytime = datetime.fromtimestamp(lay_statbuf.st_mtime)
nettime = datetime.fromtimestamp(spi_statbuf.st_mtime)
dbg('---Layout datestamp = ' + laytime)
dbg('---Netlist datestamp = ' + nettime)
dbg('---Layout datestamp = ' + str(laytime))
dbg('---Netlist datestamp = ' + str(nettime))
need_capture = True
elif os.path.splitext(layoutpath)[1] == '.mag':
# If layoutpath points to a .mag file, then above we only
Expand Down
12 changes: 6 additions & 6 deletions cace/gui/failreport.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,16 +228,16 @@ def table_to_plot(self, condition, pname):
for widget in self.plotframe.winfo_children():
widget.destroy()

dsheet = self.parent.simulation_manager.get_datasheet()
dsheet = self.parent.parameter_manager.get_datasheet()

# Find parameter
if pname:
param = self.parent.simulation_manager.find_parameter(pname)
param = self.parent.parameter_manager.find_parameter(pname)
# Reuse the last parameter
else:
param = self.data

filename = self.parent.simulation_manager.get_runtime_options(
filename = self.parent.parameter_manager.get_runtime_options(
'filename'
)

Expand Down Expand Up @@ -284,16 +284,16 @@ def display(self, pname=None):
# (Diagnostic)
# print('failure report: passed parameter ' + str(param))

dsheet = self.parent.simulation_manager.get_datasheet()
dsheet = self.parent.parameter_manager.get_datasheet()

# Find parameter
if pname:
param = self.parent.simulation_manager.find_parameter(pname)
param = self.parent.parameter_manager.find_parameter(pname)
# Reuse the last parameter
else:
param = self.data

filename = self.parent.simulation_manager.get_runtime_options(
filename = self.parent.parameter_manager.get_runtime_options(
'filename'
)

Expand Down
12 changes: 6 additions & 6 deletions cace/gui/rowwidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ class RowWidget:
redbutton = 'red.TButton'
greenbutton = 'green.TButton'

def __init__(self, param, dframe, netlist_source, row, simulation_manager):
def __init__(self, param, dframe, netlist_source, row, parameter_manager):

self.simulation_manager = simulation_manager
self.parameter_manager = parameter_manager
self.netlist_source = netlist_source

# Set the new parameter
Expand Down Expand Up @@ -582,17 +582,17 @@ def create_widgets(self, dframe, n):
)
# Physical: LVS
elif self.testbench_text() == 'cace_lvs':
filename = self.simulation_manager.get_runtime_options('filename')
filename = self.parameter_manager.get_runtime_options('filename')
dspath = os.path.split(filename)[0]
datasheet = os.path.split(filename)[1]
dsheet = self.simulation_manager.get_datasheet()
dsheet = self.parameter_manager.get_datasheet()
designname = dsheet['name']

root_path = self.simulation_manager.get_path('root')
root_path = self.parameter_manager.get_path('root')

lvs_file = os.path.join(
root_path,
self.simulation_manager.run_dir,
self.parameter_manager.run_dir,
'parameters',
pname,
f'{designname}_comp.out',
Expand Down
26 changes: 10 additions & 16 deletions cace/parameter/electrical_parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ def implementation(self):
if presult:
self.new_testbenches[presult['sequence']] = presult

if self.step_cb:
self.step_cb(self.param)
"""if self.step_cb:
self.step_cb(self.param)"""

dbg(f'Parameter {self.param["name"]}: All tasks done')

Expand All @@ -120,14 +120,7 @@ def implementation(self):
info(
f'Parameter {self.param["name"]}: Starting task with id {job.idx}'
)
jobs.append(
mypool.apply_async(
job.run,
callback=lambda result: self.step_cb(self.param)
if self.step_cb
else None,
)
)
jobs.append(mypool.apply_async(job.run))

# Wait for completion
while 1:
Expand All @@ -145,6 +138,7 @@ def implementation(self):
presult = job.get()

if presult:

# TODO make testbench name the key for easier access
self.new_testbenches[presult['sequence']] = presult

Expand Down Expand Up @@ -219,6 +213,7 @@ def preprocess(self):

alltestbenches = []
results = []
self.new_testbenches = []

for i in range(0, len(testbenches), group_size):
testbenchlist = testbenches[i : i + group_size]
Expand All @@ -232,17 +227,16 @@ def preprocess(self):
self.paths,
self.runtime_options,
self.param_dir,
self.step_cb,
idx,
)
self.add_simulation_job(new_sim_job)

idx += 1
# Create an empty testbench list to hold
# the testbenches that are returned
self.new_testbenches.append([None])

# Create an empty testbench list to hold the testbenches
# that are returned
self.new_testbenches = [None] * (
len(self.param['testbenches']) // group_size
)
idx += 1

def postprocess(self):

Expand Down
13 changes: 9 additions & 4 deletions cace/parameter/parameter_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,15 @@ def save_datasheet(self, path):
# in CACE to work with dictionaries

# Convert dependencies
new_datasheet['dependencies'] = {}
for dependency in self.datasheet['dependencies']:
name = dependency.pop('name')
new_datasheet['dependencies'][name] = dependency
if 'dependencies' in self.datasheet and self.datasheet[
'dependencies'
] != [{}]:
new_datasheet['dependencies'] = {}
for dependency in self.datasheet['dependencies']:
name = dependency.pop('name')
new_datasheet['dependencies'][name] = dependency
else:
new_datasheet.pop('dependencies')

# Convert pins
new_datasheet['pins'] = {}
Expand Down
10 changes: 9 additions & 1 deletion cace/parameter/simulation_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def __init__(
paths,
runtime_options,
param_dir,
step_cb,
idx,
*args,
**kwargs,
Expand All @@ -48,6 +49,7 @@ def __init__(
self.paths = paths
self.runtime_options = runtime_options
self.param_dir = param_dir
self.step_cb = step_cb
self.idx = idx

self.cb = None
Expand Down Expand Up @@ -85,6 +87,10 @@ def run(self):
for i, testbench in enumerate(self.testbenchlist):
simresult += self.simulate(testbench, i)

# Call the step cb -> advance progress bar
if self.step_cb:
self.step_cb(self.param)

self.cancel_point()

debug = (
Expand All @@ -106,7 +112,9 @@ def run(self):

if simresult != 0:
tbzero = self.testbenchlist[0]
simulations = cace_measure(self.param, tbzero, self.paths, debug)
simulations = cace_measure(
self.param, tbzero, self.paths, self.param_dir, debug
)
else:
simulations = 0

Expand Down
Loading