Skip to content

Commit

Permalink
feat: parse ghdl output
Browse files Browse the repository at this point in the history
  • Loading branch information
glencoe committed Sep 4, 2023
1 parent c00b76a commit 3f7e05f
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
9 changes: 9 additions & 0 deletions elasticai/creator/nn/fixed_point/mac/ghdl_report_parsing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
def parse(text):
separated = text.split(":")
fields = ("source", "line", "column", "time", "type", "content")
parsed = dict(zip(fields, separated))
parsed["type"] = parsed["type"][1:-1]
parsed["time"] = parsed["time"][1:]
parsed["line"] = int(parsed["line"])
parsed["column"] = int(parsed["column"])
return parsed
27 changes: 27 additions & 0 deletions elasticai/creator/nn/fixed_point/mac/ghdl_report_parsing_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from .ghdl_report_parsing import parse


def test_parse_ghdl_simulation_results_one_liner():
simulation_output = "my_test_bench.vhd:64:17:@4ps:(report note):my report message"
expected = {
"source": "my_test_bench.vhd",
"line": 64,
"column": 17,
"time": "4ps",
"type": "report note",
"content": "my report message",
}
assert expected == parse(simulation_output)


def test_parse_ghdl_another_line():
simulation_output = "A:1:2:@B:(C):D"
expected = {
"source": "A",
"line": 1,
"column": 2,
"time": "B",
"type": "C",
"content": "D",
}
assert expected == parse(simulation_output)

0 comments on commit 3f7e05f

Please sign in to comment.