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

Updated SpyGlass backend to support features in Synopsys Spyglass v2023.12 #449

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
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
60 changes: 55 additions & 5 deletions edalize/flows/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,65 @@
# Licensed under the 2-Clause BSD License, see LICENSE for details.
# SPDX-License-Identifier: BSD-2-Clause

from edalize.flows.generic import Generic
import os.path
from importlib import import_module

from edalize.flows.edaflow import Edaflow, FlowGraph

class Lint(Generic):
"""Run a linter tool on the design"""
"""Run a lint tool on the design"""

argtypes = ["vlogdefine", "vlogparam"]
argtypes = ["cmdlinearg", "generic", "plusarg", "vlogdefine", "vlogparam"]

FLOW_DEFINED_TOOL_OPTIONS = {
"verilator": {"mode": "lint-only", "exe": "false", "make_options": []},
# verible, spyglass, ascentlint, slang...
"verilator": {
"mode": "lint-only", "exe": "false", "make_options": []
},
"spyglass": {
"methodology": "GuideWare/latest/block/rtl_handoff",
"goals": ["lint/lint_rtl"],
"goal_options": [],
"options": [],
"rule_parameters": [],
},
}

FLOW_OPTIONS = {
"frontends": {
"type": "str",
"desc": "Tools to run before linter (e.g. sv2v)",
"list": True,
},
"tool": {
"type": "str",
"desc": "Select Lint tool",
},
}
# verible, ascentlint, slang...

@classmethod
def get_tool_options(cls, flow_options):
flow = flow_options.get("frontends", []).copy()
tool = flow_options.get("tool")
if not tool:
raise RuntimeError("Flow 'lint' requires flow option 'tool' to be set")
flow.append(tool)
return cls.get_filtered_tool_options(flow, cls.FLOW_DEFINED_TOOL_OPTIONS)

def configure_flow(self, flow_options):
tool = self.flow_options.get("tool", "")
if not tool:
raise RuntimeError("Flow 'lint' requires flow option 'tool' to be set")
fdto = self.FLOW_DEFINED_TOOL_OPTIONS.get(tool, {})
flow = {tool : {"fdto" : fdto}}
deps = []
for frontend in flow_options.get("frontends", []):
flow[frontend] = {"deps" : deps}
deps = [frontend]
flow[tool]["deps"] = deps
return FlowGraph.fromdict(flow)

def configure_tools(self, graph):
super().configure_tools(graph)
tool = self.flow_options.get("tool")
self.commands.default_target = graph.get_node(tool).inst.commands.default_target
17 changes: 11 additions & 6 deletions edalize/spyglass.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

class Spyglass(Edatool):

_description = """ Synopsys (formerly Atrenta) Spyglass Backend
_description = """ Synopsys Spyglass Backend (v2023.12)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the version hardcoded in the description here?


Spyglass performs static source code analysis on HDL code and checks for common
coding errors or coding style violations.
Expand All @@ -27,19 +27,22 @@ class Spyglass(Edatool):
methodology: "GuideWare/latest/block/rtl_handoff"
goals:
- lint/lint_rtl
goal_options:
- addrules { W164c W240 IfWithoutElse-ML } # New fiels
spyglass_options:
# prevent error SYNTH_5273 on generic RAM descriptions
- handlememory yes
rule_parameters:
# Allow localparam to be used in case labels (e.g. in state machines)
- handle_static_caselabels yes
- allow_combo_logic yes

"""

tool_options = {
"members": {"methodology": "String"},
"members": {
"methodology": "String",
},
"lists": {
"goals": "String",
"goal_options": "String", # New field
"spyglass_options": "String",
"rule_parameters": "String",
},
Expand All @@ -50,6 +53,7 @@ class Spyglass(Edatool):
tool_options_defaults = {
"methodology": "GuideWare/latest/block/rtl_handoff",
"goals": ["lint/lint_rtl"],
"goal_options": [], # New field
"spyglass_options": [],
"rule_parameters": [],
}
Expand All @@ -58,7 +62,7 @@ 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"
"Set Spyglass tool option %s to default value %"
% (key, str(default_value))
)
self.tool_options[key] = default_value
Expand Down Expand Up @@ -136,6 +140,7 @@ def _vhdl_source(f):
"tclSource": "source",
"waiver": "read_file -type waiver",
"awl": "read_file -type awl",
"sgdc": "read_file -type sgdc", # Added support for SpyGlass Design Constraint file
}
_file_type = get_file_type(f)
if _file_type in file_types:
Expand Down
23 changes: 13 additions & 10 deletions edalize/templates/spyglass/spyglass-project.prj.j2
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@


set_option projectwdir .
set_option language_mode mixed
set_option designread_enable_synthesis yes
set_option designread_disable_flatten no

### Options ###

# Make no only FATAL messages return a non-zero exit code, but also ERRORs and
# WARNINGs
set_option enable_pass_exit_codes yes

{% for option in tool_options.spyglass_options %}
set_option {{ option }}
{% endfor %}

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


{% if vlogparam -%}
set_option param {
{%- for k, v in vlogparam.items() %}{{ k }}={{ v|param_value_str }} {% endfor -%}
Expand All @@ -42,14 +42,17 @@ set_option incdir [list {{ incdirs|join(' ') }}]
set_option top {{ toplevel }}
{%- endif %}

{% if has_systemVerilog -%}
set_option enableSV09 yes
{%- endif %}

set_option active_methodology $SPYGLASS_HOME/{{ tool_options.methodology }}

current_methodology $SPYGLASS_HOME/{{ tool_options.methodology }}
{% if has_systemVerilog -%} # Modified such that it is not a specifc SV version
set_option enableSV yes
{%- endif %}

### Rule parameters ###
{% for rule_param in tool_options.rule_parameters %}
set_parameter {{ rule_param }}
{% endfor %}

### Goal options ###
{% for goal_option in tool_options.goal_options %}
set_goal_option {{ goal_option }}
{% endfor %}
1 change: 1 addition & 0 deletions edalize/tools/spyglass.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@