[tool] Add nice debug info for Mako

Debugging Mako template error is quite hard. With this PR, at least it
gives the exact location in the template file when error occurs.

Reference: https://docs.makotemplates.org/en/latest/usage.html#handling-exceptions
diff --git a/util/reggen/gen_rtl.py b/util/reggen/gen_rtl.py
index 3aaa949..14e1475 100644
--- a/util/reggen/gen_rtl.py
+++ b/util/reggen/gen_rtl.py
@@ -9,6 +9,7 @@
 import sys
 
 from mako.template import Template
+from mako import exceptions
 from pkg_resources import resource_filename
 
 from .data import *
@@ -185,17 +186,23 @@
     # Generate pkg.sv with block name
     with open(outdir + "/" + block.name + "_reg_pkg.sv", 'w',
               encoding='UTF-8') as fout:
-        fout.write(
-            reg_pkg_tpl.render(block=block,
-                               HwAccess=HwAccess,
-                               SwRdAccess=SwRdAccess,
-                               SwWrAccess=SwWrAccess))
+        try:
+            fout.write(
+                reg_pkg_tpl.render(block=block,
+                                   HwAccess=HwAccess,
+                                   SwRdAccess=SwRdAccess,
+                                   SwWrAccess=SwWrAccess))
+        except:
+            log.error(exceptions.text_error_template().render())
 
     # Generate top.sv
     with open(outdir + "/" + block.name + "_reg_top.sv", 'w',
               encoding='UTF-8') as fout:
-        fout.write(
-            reg_top_tpl.render(block=block,
-                               HwAccess=HwAccess,
-                               SwRdAccess=SwRdAccess,
-                               SwWrAccess=SwWrAccess))
+        try:
+            fout.write(
+                reg_top_tpl.render(block=block,
+                                   HwAccess=HwAccess,
+                                   SwRdAccess=SwRdAccess,
+                                   SwWrAccess=SwWrAccess))
+        except:
+            log.error(exceptions.text_error_template().render())