Skip to content

Commit

Permalink
add capability to switch linting tools
Browse files Browse the repository at this point in the history
  • Loading branch information
gadfort committed Jul 11, 2024
1 parent 6b3c0ae commit e4c8caf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ jobs:
lint_RTL:
needs: docker_image
name: Check RTL
if: false

runs-on: ubuntu-latest
container:
Expand All @@ -92,7 +93,7 @@ jobs:
strategy:
fail-fast: false
matrix:
tool: ['verilator']
tool: ['verilator', 'slang']

steps:
- name: Check out Git repository
Expand All @@ -104,4 +105,4 @@ jobs:
pip3 install .
- name: Run lint
run: sc-gallery -lint
run: sc-gallery -lint -lint_tool ${{ matrix.tool }}
15 changes: 10 additions & 5 deletions scgallery/gallery.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ def __setup_run_chip(self, chip, name, jobsuffix=None):
chip.set('option', 'entrypoint', chip.design)
chip.set('design', name)

def __lint(self, design):
def __lint(self, design, tool):
chip = design['chip']

if not chip:
Expand All @@ -494,7 +494,7 @@ def __lint(self, design):

if 'lintflow' in chip.getkeys('flowgraph'):
chip.schema.remove('flowgraph', 'lintflow')
chip.use(lintflow)
chip.use(lintflow, tool=tool)

self.__setup_run_chip(chip, design["design"], jobsuffix="_lint")

Expand Down Expand Up @@ -666,7 +666,7 @@ def _run_setup(design, target):
def get_run_report(self):
return self.__report_chips.copy()

def lint(self):
def lint(self, tool):
'''
Run lint on the enabled designs.
'''
Expand All @@ -676,7 +676,7 @@ def lint(self):
error = False
for job in self.__get_runnable_jobs():
print(job['print'])
lint_status = self.__lint(job)
lint_status = self.__lint(job, tool)
if lint_status is not None:
error |= not lint_status

Expand Down Expand Up @@ -898,6 +898,11 @@ def format_list(items, prefix_len, max_len=80):
action='store_true',
help='Run lint only')

parser.add_argument('-lint_tool',
choices=['verilator', 'slang'],
default='verilator',
help='Tool to use for linting')

parser.add_argument('-version', action='version', version=__version__)

args = parser.parse_args()
Expand Down Expand Up @@ -951,7 +956,7 @@ def format_list(items, prefix_len, max_len=80):
return 0

if args.lint:
if gallery.lint():
if gallery.lint(args.lint_tool):
return 0

return 1
Expand Down

0 comments on commit e4c8caf

Please sign in to comment.