Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Kuree committed Dec 4, 2022
1 parent 41db142 commit b1cd4b6
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 2 deletions.
2 changes: 0 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,6 @@ def build_extension(self, ext: CMakeExtension) -> None:
bins = ["hgdb-rtl"]
binaries = [os.path.join(self.build_temp, "hgdb-rtl", "tools", name) for name in bins]
for binary in binaries:
print(binary)
print(extdir)
assert os.path.isfile(binary)
shutil.copy(binary, extdir)

Expand Down
29 changes: 29 additions & 0 deletions tests/test_sv.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import os
import json
import subprocess


def get_vector_file(name):
test_dir = os.path.dirname(os.path.abspath(__file__))
vector_dir = os.path.join(test_dir, "vectors")
path = os.path.join(vector_dir, name + ".sv")
assert os.path.isfile(path)
return path


def get_json(name):
filename = get_vector_file(name)
output = subprocess.check_output(["hgdb-rtl", filename, "-o", "-"]).decode("ascii")
return json.loads(output)


def test_hierarchy():
table = get_json("hierarchy")
top = table["table"][0]
inst = top["instances"][0]
assert inst["name"] == "inst"
assert inst["module"] == "child"


if __name__ == "__main__":
test_hierarchy()
17 changes: 17 additions & 0 deletions tests/vectors/hierarchy.sv
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module child (
input logic a,
input logic b;
);

logic c;

endmodule

module top;

logic a;
logic b;

child inst(.*);

endmodule

0 comments on commit b1cd4b6

Please sign in to comment.