Skip to content

Commit

Permalink
feat: add verilator as a linter tool
Browse files Browse the repository at this point in the history
  • Loading branch information
esynr3z committed Jun 8, 2024
1 parent 5a4e279 commit 0f2710d
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 7 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,13 @@ jobs:
echo "${{ env.VERILATOR_INSTALL }}/bin" >> $GITHUB_PATH
echo "${{ github.workspace }}/contrib/svunit/bin" >> $GITHUB_PATH
- name: Run tests for package
- name: Lint the package
run: make lint_verilator

- name: Test the package
run: make -C tests test_verilator

- name: Run tests for examples
- name: Test documentation examples
run: make -C docs/modules/ROOT/examples/selftest test_verilator

- name: Parse test results
Expand Down
19 changes: 16 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
.PHONY: all test test_src test_examples
.PHONY: all lint lint_verilator test test_src test_examples

all: test
export SVJSON_ROOT := $(realpath .)

all: lint test

lint: lint_verilator

# VARHIDDEN - too strict, method arguments may overlap with class property names
# UNDRIVEN - has false positives on interface classes and custom constructors
lint_verilator:
@echo "Lint sources with Verilator"
verilator --lint-only -f $(SVJSON_ROOT)/src/filelist.f \
-Wall -Wno-VARHIDDEN -Wno-UNDRIVEN

test: test_src test_examples

test_src:
@echo "Run tests for main sources"
make -C tests test

test_examples:
@echo "Run tests for documentation example snippets"
make -C docs/modules/ROOT/examples/selftest test

clean:
make -C tests clean
make -C docs/modules/ROOT/examples/selftest clean
make -C docs/modules/ROOT/examples/selftest clean
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/changelog.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to {url-semantic-versioning}[Semantic Versioning].
=== Added

* Add a table of supported EDA tools
* Add Verilator as a linter

=== Fixed
=== Changed
Expand Down
3 changes: 1 addition & 2 deletions src/json_decoder.sv
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,8 @@ function json_result json_decoder::load_string(string str);
case (1)
result.matches_ok(parsed): begin
parser_result check_result = decoder.check_trailing_chars(str, parsed.end_pos + 1);
parsed_s ok;
case (1)
check_result.matches_ok(ok): return json_result#()::ok(parsed.value);
check_result.is_ok(): return json_result#()::ok(parsed.value);
check_result.matches_err(error): return json_result#()::err(error);
endcase
end
Expand Down
1 change: 1 addition & 0 deletions tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ all: test
test: test_verilator

test_verilator:
@echo Test sources with Verilator
runSVUnit \
-s verilator \
-l run.log \
Expand Down

0 comments on commit 0f2710d

Please sign in to comment.