utf-8 decode exception (Vivado 2018.3)
Some verilog files generated by Vivado have encoding errors in the comments. In one of our projects the file axi/mig_7series_v4_2_ddr_a_upsizer.v
was causing trouble (line 85):
parameter integer C_AXI_SUPPORTS_USER_SIGNALS = 0,
// 1 = Propagate all USER signals, 0 = Don<92>t propagate.
Although the issue comes from the Vivado side, I think it is a good idea to make hdlmake more tolerant of such character encoding errors:
diff --git a/hdlmake/sourcefiles/vhdl_parser.py b/hdlmake/sourcefiles/vhdl_parser.py
index e89a2a7..ed35169 100644
--- a/hdlmake/sourcefiles/vhdl_parser.py
+++ b/hdlmake/sourcefiles/vhdl_parser.py
@@ -40,7 +40,7 @@ class VHDLParser(DepParser):
def _preprocess(vhdl_file):
"""Preprocess the supplied VHDL file instance"""
- buf = open(vhdl_file.path, "r").read()
+ buf = open(vhdl_file.path, "r", errors='replace').read()
logging.debug(
"preprocess file %s (of length %d) in library %s",
vhdl_file.path, len(buf), vhdl_file.library)
diff --git a/hdlmake/sourcefiles/vlog_parser.py b/hdlmake/sourcefiles/vlog_parser.py
index 5a728e3..986e031 100644
--- a/hdlmake/sourcefiles/vlog_parser.py
+++ b/hdlmake/sourcefiles/vlog_parser.py
@@ -232,7 +232,7 @@ class VerilogPreprocessor(object):
# assert isinstance(vlog_file, VerilogFile)
# assert isinstance(vlog_file, DepFile)
self.vlog_file = vlog_file
- buf = open(vlog_file.path, "r").read()
+ buf = open(vlog_file.path, "r", errors='replace').read()
return self._preprocess_file(file_content=buf,
file_name=vlog_file.path,
library=vlog_file.library)