From 74a96fd8b398808568a8cda23f28497f28ef1748 Mon Sep 17 00:00:00 2001 From: Amal Araweelo Almis <124199007+amal-araweelo@users.noreply.github.com> Date: Fri, 1 Nov 2024 10:55:57 +0100 Subject: [PATCH 1/4] Update spyglass.py Added new tool_option (goal_options) --- edalize/spyglass.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/edalize/spyglass.py b/edalize/spyglass.py index 847b6be5f..5431407f7 100644 --- a/edalize/spyglass.py +++ b/edalize/spyglass.py @@ -14,7 +14,7 @@ class Spyglass(Edatool): - _description = """ Synopsys (formerly Atrenta) Spyglass Backend + _description = """ Synopsys Spyglass Backend (v2023.12) Spyglass performs static source code analysis on HDL code and checks for common coding errors or coding style violations. @@ -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", }, @@ -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": [], } @@ -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 @@ -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: From 3ad3503b379b335917182249bc28f4fe56373236 Mon Sep 17 00:00:00 2001 From: Amal Araweelo Almis <124199007+amal-araweelo@users.noreply.github.com> Date: Fri, 1 Nov 2024 10:58:39 +0100 Subject: [PATCH 2/4] Update spyglass-project.prj.j2 Added goal_options section. Also, in the section where the SystemVerilog (SV09) support is configured, it has been changed to SV for flexibility and generalization --- .../spyglass/spyglass-project.prj.j2 | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/edalize/templates/spyglass/spyglass-project.prj.j2 b/edalize/templates/spyglass/spyglass-project.prj.j2 index 99c8884f3..15adab606 100644 --- a/edalize/templates/spyglass/spyglass-project.prj.j2 +++ b/edalize/templates/spyglass/spyglass-project.prj.j2 @@ -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 -%} @@ -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 %} From 415317a0ffbb30a0a5c274d729417c5c289ef8c6 Mon Sep 17 00:00:00 2001 From: Amal Araweelo Almis <124199007+amal-araweelo@users.noreply.github.com> Date: Mon, 18 Nov 2024 13:47:27 +0100 Subject: [PATCH 3/4] Add support for spyglass as linter --- edalize/flows/lint.py | 60 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 55 insertions(+), 5 deletions(-) diff --git a/edalize/flows/lint.py b/edalize/flows/lint.py index 640d1f0cf..d7a579526 100644 --- a/edalize/flows/lint.py +++ b/edalize/flows/lint.py @@ -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 From 46a82a7f631e1d29b243c88c753d46d1c0047ae6 Mon Sep 17 00:00:00 2001 From: Amal Araweelo Almis <124199007+amal-araweelo@users.noreply.github.com> Date: Mon, 18 Nov 2024 13:48:29 +0100 Subject: [PATCH 4/4] Create spyglass.py --- edalize/tools/spyglass.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 edalize/tools/spyglass.py diff --git a/edalize/tools/spyglass.py b/edalize/tools/spyglass.py new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/edalize/tools/spyglass.py @@ -0,0 +1 @@ +