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

Update spyglass.py #324

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
111 changes: 111 additions & 0 deletions edalize/dc_shell.py
@@ -0,0 +1,111 @@
# Copyright edalize contributors
# Licensed under the 2-Clause BSD License, see LICENSE for details.
# SPDX-License-Identifier: BSD-2-Clause

import logging
import re
from collections import OrderedDict

from edalize.edatool import Edatool

logger = logging.getLogger(__name__)


class Dc_shell(Edatool):

_description = """ Synopsys (formerly Atrenta) DC_shell Backend

This module generates the file list for dc_shell.
"""

tool_options = {
"lists": {
"dc_options": "String",
},
}

argtypes = ["vlogdefine", "vlogparam"]

tool_options_defaults = {
"dc_options": [],
}

def _set_tool_options_defaults(self):
for key, default_value in self.tool_options_defaults.items():
if not key in self.tool_options:
logger.info(
"Set Spyglass tool option %s to default value %s"
% (key, str(default_value))
)
self.tool_options[key] = default_value

def configure_main(self):
"""
Configuration is the first phase of the build.

This writes the project TCL files and Makefile. It first collects all
sources, IPs and constraints and then writes them to the TCL file along
with the build steps.
"""
self._set_tool_options_defaults()

(src_files, incdirs) = self._get_fileset_files(force_slash=True)

self.jinja_env.filters["src_file_filter"] = self.src_file_filter

has_systemVerilog = False
for src_file in src_files:
if src_file.file_type.startswith("systemVerilogSource"):
has_systemVerilog = True
break

# Spyglass expects all parameters in the form module.parameter
# Always prepend the toplevel module name to be consistent with all other
# backends, which do not require this syntax.
vlogparam_spyglass = OrderedDict(
(self.toplevel + "." + p, v) for (p, v) in self.vlogparam.items()
)

template_vars = {
"name": self.name,
"src_files": src_files,
"incdirs": incdirs,
"tool_options": self.tool_options,
"toplevel": self.toplevel,
"vlogparam": vlogparam_spyglass,
"vlogdefine": self.vlogdefine,
"has_systemVerilog": has_systemVerilog,
"sanitized_goals": [],
}

self.render_template(
"dc_shell.tcl.j2", "dc.read_design.tcl", template_vars
)

def src_file_filter(self, f):

file_types = {
"verilogSource": "analyze -format sverilog",
"systemVerilogSource": "analyze -format sverilog",
}
_file_type = f.file_type.split("-")[0]
if _file_type in file_types:
return file_types[_file_type] + " " + f.name
elif _file_type == "user":
return ""
else:
_s = "{} has unknown file type '{}'"
logger.warning(_s.format(f.name, f.file_type))
return ""

def run_main(self):
args = ["-i"]

# Set plusargs
if self.plusarg:
plusargs = []
for key, value in self.plusarg.items():
plusargs += ["+{}={}".format(key, self._param_value_str(value))]
args.append("EXTRA_OPTIONS=" + " ".join(plusargs))

self._run_tool("make", args)
12 changes: 12 additions & 0 deletions edalize/spyglass.py
Expand Up @@ -145,3 +145,15 @@ def _vhdl_source(f):
_s = "{} has unknown file type '{}'"
logger.warning(_s.format(f.name, f.file_type))
return ""

def run_main(self):
args = ["-i"]

# Set plusargs
if self.plusarg:
plusargs = []
for key, value in self.plusarg.items():
plusargs += ["+{}={}".format(key, self._param_value_str(value))]
args.append("EXTRA_OPTIONS=" + " ".join(plusargs))

self._run_tool("make", args)
10 changes: 10 additions & 0 deletions edalize/templates/dc_shell/Makefile.j2
@@ -0,0 +1,10 @@
all: {{ name }}

{{ name }}: {{ name }}.scr
vcs -full64 -top {{ toplevel }} -f {{ name }}.scr -o $@ {% for option in vcs_options %} {{ option }}{% endfor %}

run: {{ name }}
./{{ name }} -l vcs.log {% for plusarg in plusargs %} {{ plusarg }} {% endfor %}{% for option in run_options %} {{ option }}{% endfor %}

clean:
$(RM) {{ name }}
16 changes: 16 additions & 0 deletions edalize/templates/dc_shell/dc_shell.tcl.j2
@@ -0,0 +1,16 @@
#################################################################################
## RTL Read
## General read script for Design Compiler Reference Methodology
#################################################################################

{% if incdirs -%}
set_app_var search_path "$search_path {{ incdirs|join(' ') }}"
{%- endif %}

{% for src_file in src_files if src_file|src_file_filter%}
{{ src_file|src_file_filter }}
{% endfor %}

#######################
## end
#######################