Skip to content

Commit 9387f13

Browse files
committed
Add Vivado
1 parent 9622e49 commit 9387f13

File tree

3 files changed

+37
-4
lines changed

3 files changed

+37
-4
lines changed

README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,20 @@ Install:
99
pip install edalogparser
1010
```
1111

12-
Pipe Verilator output through it to generate json:
12+
Example: Pipe Verilator output through it to generate json:
1313

1414
```bash
1515
verilator ... 2>&1 | eda-log-parser -t verilator -f json
1616
```
1717

18-
Other targets:
18+
Supported tools:
19+
20+
- `verilator`: Verilator
21+
- `vivado`: Xilinx Vivado
22+
23+
Supported targets:
1924

2025
- `azure`: LogIssue commands for Azure Pipelines
26+
- `dict`: Plain Python dict
2127
- `ghactions`: Log commands for GitHub Actions
28+
- `json`: JSON file (difference to dict: JSON strings)

edalogparser/main.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
import argparse
33

44
from .verilator import VerilatorLogParser
5+
from .vivado import VivadoLogParser
56

6-
tools = { "verilator": VerilatorLogParser }
7+
tools = { "verilator": VerilatorLogParser, "vivado": VivadoLogParser }
78

89
def main():
910
parser = argparse.ArgumentParser()
10-
parser.add_argument("-t", "--tool", required=True, choices=["verilator"])
11+
parser.add_argument("-t", "--tool", required=True, choices=tools.keys())
1112
parser.add_argument("-f", "--format", choices=["json", "azure", "ghaction"], default="json")
1213
parser.add_argument("input", nargs='?', help="", type=argparse.FileType('r'),
1314
default=sys.stdin)

edalogparser/vivado.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from .base import LogParser, LogEntry, Log
2+
import re
3+
4+
class VivadoLogParser(LogParser):
5+
regex = re.compile(r"^((INFO|WARNING|ERROR): \[(.*?)\] (.*?)( \[(.*?)\])?)\n$")
6+
7+
def __init__(self):
8+
super().__init__()
9+
10+
def parse(self, log):
11+
entries = Log()
12+
for line in log:
13+
m = self.regex.match(line)
14+
if m:
15+
severity = m.group(2).lower()
16+
msg = m.group(4)
17+
file = None
18+
line = None
19+
if m.group(6):
20+
colon = m.group(6).rfind(":")
21+
file = m.group(6)[0:colon]
22+
line = m.group(6)[colon+1:]
23+
entries.append(LogEntry(severity, msg, file, line, None))
24+
return entries
25+

0 commit comments

Comments
 (0)