[topgen] Stop pretending it's not OpenTitan-specific

Topgen was initially designed to be a rather generic toplevel generation
tool. That's not what it is today: it is heavily biased towards
generating OpenTitan toplevel designs -- which is exactly what we need
in OpenTitan. Instead of trying to keep things generic, this commit goes
the first step towards an "opinionated topgen".

As first step, all templates are stored not in the toplevel that is to
be generated, but next to topgen: other components in OpenTitan expect
files generated from these templates to be around exactly like that, so
we cannot simply modify them at will.

If necessary later we can add an override/extension mechanism of some
sort.

This commit tries to be rather minimal in the changes to topgen.py;
there's more to clean-up, but since we have at least three people
working on the same file at the moment I'm trying to keep the diff to a
minimum.

Signed-off-by: Philipp Wagner <phw@lowrisc.org>
diff --git a/doc/rm/topgen_tool.md b/doc/rm/topgen_tool.md
index f83cf44..74d9814 100644
--- a/doc/rm/topgen_tool.md
+++ b/doc/rm/topgen_tool.md
@@ -84,7 +84,7 @@
 ```console
 $ cd ${REPO_TOP}
 $ ./util/topgen.py -h
-usage: topgen [-h] --topcfg TOPCFG [--tpl TPL] [--outdir OUTDIR] [--verbose] [--no-top]
+usage: topgen [-h] --topcfg TOPCFG [--outdir OUTDIR] [--verbose] [--no-top]
               [--no-xbar] [--no-plic] [--no-gen-hjson] [--top-only] [--xbar-only]
               [--plic-only] [--hjson-only] [--top_ral]
 
@@ -92,8 +92,6 @@
   -h, --help            show this help message and exit
   --topcfg TOPCFG, -t TOPCFG
                         `top_{name}.hjson` file.
-  --tpl TPL, -c TPL     The directory having top_{name}_core.sv.tpl and
-                        top_{name}.tpl.sv.
   --outdir OUTDIR, -o OUTDIR
                         Target TOP directory. Module is created under rtl/. (default:
                         dir(topcfg)/..)
diff --git a/hw/Makefile b/hw/Makefile
index 3f434d1..ff2d2d2 100644
--- a/hw/Makefile
+++ b/hw/Makefile
@@ -108,7 +108,6 @@
 $(tops_gen):
 	$(eval $@_TOP := $(strip $(foreach top,$(TOPS),$(findstring $(top),$@))))
 	${PRJ_DIR}/util/topgen.py -t ${PRJ_DIR}/hw/$($@_TOP)/data/$($@_TOP).hjson \
-		--tpl ${PRJ_DIR}/hw/$($@_TOP)/data/ \
 		-o ${PRJ_DIR}/hw/$($@_TOP)/ ${toolflags}
 
 $(tops_reg): pre_reg
diff --git a/hw/top_earlgrey/_index.md b/hw/top_earlgrey/_index.md
index a069b0d..e50ff36 100644
--- a/hw/top_earlgrey/_index.md
+++ b/hw/top_earlgrey/_index.md
@@ -19,7 +19,7 @@
 is created with below command.
 
 ```console
-../../util/topgen.py -t data/top_earlgrey.hjson -c data -o . -v
+../../util/topgen.py -t data/top_earlgrey.hjson -o . -v
 ```
 
 It generates files below:
diff --git a/hw/top_earlgrey/rtl/autogen/top_earlgrey.sv b/hw/top_earlgrey/rtl/autogen/top_earlgrey.sv
index 9c68b2b..70b150a 100644
--- a/hw/top_earlgrey/rtl/autogen/top_earlgrey.sv
+++ b/hw/top_earlgrey/rtl/autogen/top_earlgrey.sv
@@ -6,7 +6,6 @@
 // PLEASE DO NOT HAND-EDIT THIS FILE. IT HAS BEEN AUTO-GENERATED WITH THE FOLLOWING COMMAND:
 //
 // util/topgen.py -t hw/top_earlgrey/data/top_earlgrey.hjson \
-//                --tpl hw/top_earlgrey/data/ \
 //                -o hw/top_earlgrey/ \
 //                --rnd_cnst_seed 4881560218908238235
 
diff --git a/hw/top_earlgrey/rtl/autogen/top_earlgrey_pkg.sv b/hw/top_earlgrey/rtl/autogen/top_earlgrey_pkg.sv
index 630d78f..1760224 100644
--- a/hw/top_earlgrey/rtl/autogen/top_earlgrey_pkg.sv
+++ b/hw/top_earlgrey/rtl/autogen/top_earlgrey_pkg.sv
@@ -6,7 +6,6 @@
 // PLEASE DO NOT HAND-EDIT THIS FILE. IT HAS BEEN AUTO-GENERATED WITH THE FOLLOWING COMMAND:
 //
 // util/topgen.py -t hw/top_earlgrey/data/top_earlgrey.hjson \
-//                --tpl hw/top_earlgrey/data/ \
 //                -o hw/top_earlgrey/ \
 //                --rnd_cnst_seed 4881560218908238235
 
diff --git a/hw/top_earlgrey/rtl/autogen/top_earlgrey_rnd_cnst_pkg.sv b/hw/top_earlgrey/rtl/autogen/top_earlgrey_rnd_cnst_pkg.sv
index 0199241..c0a6739 100644
--- a/hw/top_earlgrey/rtl/autogen/top_earlgrey_rnd_cnst_pkg.sv
+++ b/hw/top_earlgrey/rtl/autogen/top_earlgrey_rnd_cnst_pkg.sv
@@ -6,7 +6,6 @@
 // PLEASE DO NOT HAND-EDIT THIS FILE. IT HAS BEEN AUTO-GENERATED WITH THE FOLLOWING COMMAND:
 //
 // util/topgen.py -t hw/top_earlgrey/data/top_earlgrey.hjson \
-//                --tpl hw/top_earlgrey/data/ \
 //                -o hw/top_earlgrey/ \
 //                --rnd_cnst_seed 4881560218908238235
 
diff --git a/hw/top_englishbreakfast/data/chip_env_pkg__params.sv.tpl b/hw/top_englishbreakfast/data/chip_env_pkg__params.sv.tpl
deleted file mode 120000
index 26c58ff..0000000
--- a/hw/top_englishbreakfast/data/chip_env_pkg__params.sv.tpl
+++ /dev/null
@@ -1 +0,0 @@
-../../top_earlgrey/data/chip_env_pkg__params.sv.tpl
\ No newline at end of file
diff --git a/hw/top_englishbreakfast/data/clang-format b/hw/top_englishbreakfast/data/clang-format
deleted file mode 120000
index 660fef3..0000000
--- a/hw/top_englishbreakfast/data/clang-format
+++ /dev/null
@@ -1 +0,0 @@
-../../top_earlgrey/data/clang-format
\ No newline at end of file
diff --git a/hw/top_englishbreakfast/data/tb__alert_handler_connect.sv.tpl b/hw/top_englishbreakfast/data/tb__alert_handler_connect.sv.tpl
deleted file mode 120000
index e670721..0000000
--- a/hw/top_englishbreakfast/data/tb__alert_handler_connect.sv.tpl
+++ /dev/null
@@ -1 +0,0 @@
-../../top_earlgrey/data/tb__alert_handler_connect.sv.tpl
\ No newline at end of file
diff --git a/hw/top_englishbreakfast/data/tb__xbar_connect.sv.tpl b/hw/top_englishbreakfast/data/tb__xbar_connect.sv.tpl
deleted file mode 120000
index 99790f8..0000000
--- a/hw/top_englishbreakfast/data/tb__xbar_connect.sv.tpl
+++ /dev/null
@@ -1 +0,0 @@
-../../top_earlgrey/data/tb__xbar_connect.sv.tpl
\ No newline at end of file
diff --git a/hw/top_englishbreakfast/data/top_englishbreakfast.c.tpl b/hw/top_englishbreakfast/data/top_englishbreakfast.c.tpl
deleted file mode 120000
index a9f1db5..0000000
--- a/hw/top_englishbreakfast/data/top_englishbreakfast.c.tpl
+++ /dev/null
@@ -1 +0,0 @@
-../../top_earlgrey/data/top_earlgrey.c.tpl
\ No newline at end of file
diff --git a/hw/top_englishbreakfast/data/top_englishbreakfast.h.tpl b/hw/top_englishbreakfast/data/top_englishbreakfast.h.tpl
deleted file mode 120000
index b1b4646..0000000
--- a/hw/top_englishbreakfast/data/top_englishbreakfast.h.tpl
+++ /dev/null
@@ -1 +0,0 @@
-../../top_earlgrey/data/top_earlgrey.h.tpl
\ No newline at end of file
diff --git a/hw/top_englishbreakfast/data/top_englishbreakfast.sv.tpl b/hw/top_englishbreakfast/data/top_englishbreakfast.sv.tpl
deleted file mode 120000
index c44053b..0000000
--- a/hw/top_englishbreakfast/data/top_englishbreakfast.sv.tpl
+++ /dev/null
@@ -1 +0,0 @@
-../../top_earlgrey/data/top_earlgrey.sv.tpl
\ No newline at end of file
diff --git a/hw/top_englishbreakfast/data/top_englishbreakfast_memory.h.tpl b/hw/top_englishbreakfast/data/top_englishbreakfast_memory.h.tpl
deleted file mode 120000
index 9da7d04..0000000
--- a/hw/top_englishbreakfast/data/top_englishbreakfast_memory.h.tpl
+++ /dev/null
@@ -1 +0,0 @@
-../../top_earlgrey/data/top_earlgrey_memory.h.tpl
\ No newline at end of file
diff --git a/hw/top_englishbreakfast/data/top_englishbreakfast_memory.ld.tpl b/hw/top_englishbreakfast/data/top_englishbreakfast_memory.ld.tpl
deleted file mode 120000
index 47f658b..0000000
--- a/hw/top_englishbreakfast/data/top_englishbreakfast_memory.ld.tpl
+++ /dev/null
@@ -1 +0,0 @@
-../../top_earlgrey/data/top_earlgrey_memory.ld.tpl
\ No newline at end of file
diff --git a/hw/top_englishbreakfast/data/top_englishbreakfast_pkg.sv.tpl b/hw/top_englishbreakfast/data/top_englishbreakfast_pkg.sv.tpl
deleted file mode 120000
index 587d97f..0000000
--- a/hw/top_englishbreakfast/data/top_englishbreakfast_pkg.sv.tpl
+++ /dev/null
@@ -1 +0,0 @@
-../../top_earlgrey/data/top_earlgrey_pkg.sv.tpl
\ No newline at end of file
diff --git a/hw/top_englishbreakfast/data/top_englishbreakfast_rnd_cnst_pkg.sv.tpl b/hw/top_englishbreakfast/data/top_englishbreakfast_rnd_cnst_pkg.sv.tpl
deleted file mode 120000
index 050b4df..0000000
--- a/hw/top_englishbreakfast/data/top_englishbreakfast_rnd_cnst_pkg.sv.tpl
+++ /dev/null
@@ -1 +0,0 @@
-../../top_earlgrey/data/top_earlgrey_rnd_cnst_pkg.sv.tpl
\ No newline at end of file
diff --git a/hw/top_englishbreakfast/data/xbar_env_pkg__params.sv.tpl b/hw/top_englishbreakfast/data/xbar_env_pkg__params.sv.tpl
deleted file mode 120000
index 86c5137..0000000
--- a/hw/top_englishbreakfast/data/xbar_env_pkg__params.sv.tpl
+++ /dev/null
@@ -1 +0,0 @@
-../../top_earlgrey/data/xbar_env_pkg__params.sv.tpl
\ No newline at end of file
diff --git a/hw/top_englishbreakfast/util/prepare_sw.py b/hw/top_englishbreakfast/util/prepare_sw.py
index 54bc65a..6e7cf43 100755
--- a/hw/top_englishbreakfast/util/prepare_sw.py
+++ b/hw/top_englishbreakfast/util/prepare_sw.py
@@ -42,7 +42,6 @@
     path_out = path_root + '/hw/' + topname
     cmd = [path_root + '/util/topgen.py',  # "--verbose",
            "-t", path_in + topname + '.hjson',
-           "-c", path_in,
            "-o", path_out]
 
     try:
diff --git a/util/topgen-fusesoc.py b/util/topgen-fusesoc.py
index ba2936b..6f31c79 100644
--- a/util/topgen-fusesoc.py
+++ b/util/topgen-fusesoc.py
@@ -68,7 +68,6 @@
     files_out = os.getcwd()
     cmd = [files_root + "/util/topgen.py",  # "--verbose",
            "-t", files_data + topname + ".hjson",
-           "-c", files_data,
            "-o", files_out]
     try:
         print("Running topgen.")
diff --git a/util/topgen.py b/util/topgen.py
index 88538f5..4a508de 100755
--- a/util/topgen.py
+++ b/util/topgen.py
@@ -43,6 +43,8 @@
 
 SRCTREE_TOP = Path(__file__).parent.parent.resolve()
 
+TOPGEN_TEMPLATE_PATH = Path(__file__).parent / 'topgen/templates'
+
 
 def generate_top(top, name_to_block, tpl_filename, **kwargs):
     top_tpl = Template(filename=tpl_filename)
@@ -988,11 +990,6 @@
                         required=True,
                         help="`top_{name}.hjson` file.")
     parser.add_argument(
-        '--tpl',
-        '-c',
-        help=
-        "The directory having top_{name}_core.sv.tpl and top_{name}.tpl.sv.")
-    parser.add_argument(
         '--outdir',
         '-o',
         help='''Target TOP directory.
@@ -1063,12 +1060,6 @@
             "'no' series options cannot be used with 'only' series options")
         raise SystemExit(sys.exc_info()[1])
 
-    if not (args.top_ral or args.plic_only or args.alert_handler_only or
-            args.tpl):
-        log.error(
-            "Template file can be omitted only if '--hjson-only' is true")
-        raise SystemExit(sys.exc_info()[1])
-
     if args.verbose:
         log.basicConfig(format="%(levelname)s: %(message)s", level=log.DEBUG)
     else:
@@ -1142,7 +1133,7 @@
     top_name = completecfg["name"]
 
     # Generate top.gen.hjson right before rendering
-    genhjson_dir = Path(out_path) / "data/autogen"
+    genhjson_dir = out_path / "data/autogen"
     genhjson_dir.mkdir(parents=True, exist_ok=True)
     genhjson_path = genhjson_dir / ("top_%s.gen.hjson" % completecfg["name"])
 
@@ -1158,46 +1149,41 @@
                              hjson.dumps(completecfg, for_json=True))
 
     if not args.no_top or args.top_only:
-        tpl_path = Path(args.tpl)
-
-        def render_template(out_name_tpl, out_dir, **other_info):
-            top_tplpath = tpl_path / ((out_name_tpl + '.tpl') % (top_name))
+        def render_template(template_path: str, rendered_path: Path, **other_info):
             template_contents = generate_top(completecfg, name_to_block,
-                                             str(top_tplpath), **other_info)
+                                             str(template_path), **other_info)
 
-            rendered_dir = out_path / out_dir
-            rendered_dir.mkdir(parents=True, exist_ok=True)
-            rendered_path = rendered_dir / (out_name_tpl % (top_name))
-
+            rendered_path.parent.mkdir(exist_ok=True, parents=True)
             with rendered_path.open(mode='w', encoding='UTF-8') as fout:
                 fout.write(template_contents)
 
-            return rendered_path.resolve()
-
         # Header for SV files
         gencmd = warnhdr + '''//
 // util/topgen.py -t hw/top_{topname}/data/top_{topname}.hjson \\
-//                --tpl hw/top_{topname}/data/ \\
 //                -o hw/top_{topname}/ \\
 //                --rnd_cnst_seed {seed}
 '''.format(topname=topname, seed=topcfg['rnd_cnst_seed'])
 
         # SystemVerilog Top:
-        render_template('top_%s.sv', 'rtl/autogen', gencmd=gencmd)
-        # 'top_{topname}.sv.tpl' -> 'rtl/autogen/top_{topname}.sv'
+        # 'toplevel.sv.tpl' -> 'rtl/autogen/top_{topname}.sv'
+        render_template(TOPGEN_TEMPLATE_PATH / "toplevel.sv.tpl",
+                        out_path / f"rtl/autogen/top_{topname}.sv",
+                        gencmd=gencmd)
 
         # The C / SV file needs some complex information, so we initialize this
         # object to store it.
         c_helper = TopGenC(completecfg, name_to_block)
 
-        # 'top_{topname}_pkg.sv.tpl' -> 'rtl/autogen/top_{topname}_pkg.sv'
-        render_template('top_%s_pkg.sv',
-                        'rtl/autogen',
+        # 'toplevel_pkg.sv.tpl' -> 'rtl/autogen/top_{topname}_pkg.sv'
+        render_template(TOPGEN_TEMPLATE_PATH / "toplevel_pkg.sv.tpl",
+                        out_path / f"rtl/autogen/top_{topname}_pkg.sv",
                         helper=c_helper,
                         gencmd=gencmd)
 
         # compile-time random netlist constants
-        render_template('top_%s_rnd_cnst_pkg.sv', 'rtl/autogen', gencmd=gencmd)
+        render_template(TOPGEN_TEMPLATE_PATH / "toplevel_rnd_cnst_pkg.sv.tpl",
+                        out_path / f"rtl/autogen/top_{topname}_rnd_cnst_pkg.sv",
+                        gencmd=gencmd)
 
         # C Header + C File + Clang-format file
 
@@ -1206,33 +1192,39 @@
         # twice:
         # - Once under out_path/sw/autogen
         # - Once under hw/top_{topname}/sw/autogen
-        for path in [Path(out_path).resolve(),
+        for path in [out_path.resolve(),
                      (SRCTREE_TOP / 'hw/top_{}/'.format(topname)).resolve()]:
 
             # 'clang-format' -> 'sw/autogen/.clang-format'
-            cformat_tplpath = tpl_path / 'clang-format'
+            cformat_tplpath = TOPGEN_TEMPLATE_PATH / 'clang-format'
             cformat_dir = path / 'sw/autogen'
             cformat_dir.mkdir(parents=True, exist_ok=True)
             cformat_path = cformat_dir / '.clang-format'
             cformat_path.write_text(cformat_tplpath.read_text())
 
             # 'top_{topname}.h.tpl' -> 'sw/autogen/top_{topname}.h'
-            cheader_path = render_template('top_%s.h',
-                                           cformat_dir,
-                                           helper=c_helper)
+            cheader_path = cformat_dir / f"top_{topname}.h"
+            render_template(TOPGEN_TEMPLATE_PATH / "toplevel.h.tpl",
+                            cheader_path,
+                            helper=c_helper)
 
             # Save the relative header path into `c_gen_info`
             rel_header_path = cheader_path.relative_to(path.parents[1])
             c_helper.header_path = str(rel_header_path)
 
-            # 'top_{topname}.c.tpl' -> 'sw/autogen/top_{topname}.c'
-            render_template('top_%s.c', cformat_dir, helper=c_helper)
+            # 'toplevel.c.tpl' -> 'sw/autogen/top_{topname}.c'
+            render_template(TOPGEN_TEMPLATE_PATH / "toplevel.c.tpl",
+                            cformat_dir / f"top_{topname}.c",
+                            helper=c_helper)
 
-            # 'top_{topname}_memory.ld.tpl' -> 'sw/autogen/top_{topname}_memory.ld'
-            render_template('top_%s_memory.ld', cformat_dir)
+            # 'toplevel_memory.ld.tpl' -> 'sw/autogen/top_{topname}_memory.ld'
+            render_template(TOPGEN_TEMPLATE_PATH / "toplevel_memory.ld.tpl",
+                            cformat_dir / f"top_{topname}_memory.ld")
 
-            # 'top_{topname}_memory.h.tpl' -> 'sw/autogen/top_{topname}_memory.h'
-            memory_cheader_path = render_template('top_%s_memory.h', cformat_dir)
+            # 'toplevel_memory.h.tpl' -> 'sw/autogen/top_{topname}_memory.h'
+            memory_cheader_path = cformat_dir / f"top_{topname}_memory.h"
+            render_template(TOPGEN_TEMPLATE_PATH / "toplevel_memory.h.tpl",
+                            memory_cheader_path)
 
             try:
                 cheader_path.relative_to(SRCTREE_TOP)
@@ -1259,11 +1251,11 @@
         ]
         for fname in tb_files:
             tpl_fname = "%s.tpl" % (fname)
-            xbar_chip_data_path = tpl_path / tpl_fname
+            xbar_chip_data_path = TOPGEN_TEMPLATE_PATH / tpl_fname
             template_contents = generate_top(completecfg, name_to_block,
                                              str(xbar_chip_data_path))
 
-            rendered_dir = Path(out_path) / 'dv/autogen'
+            rendered_dir = out_path / 'dv/autogen'
             rendered_dir.mkdir(parents=True, exist_ok=True)
             rendered_path = rendered_dir / fname
 
@@ -1272,11 +1264,11 @@
 
         # generate parameters for chip-level environment package
         tpl_fname = 'chip_env_pkg__params.sv.tpl'
-        alert_handler_chip_data_path = tpl_path / tpl_fname
+        alert_handler_chip_data_path = TOPGEN_TEMPLATE_PATH / tpl_fname
         template_contents = generate_top(completecfg, name_to_block,
                                          str(alert_handler_chip_data_path))
 
-        rendered_dir = Path(out_path) / 'dv/env/autogen'
+        rendered_dir = out_path / 'dv/env/autogen'
         rendered_dir.mkdir(parents=True, exist_ok=True)
         rendered_path = rendered_dir / 'chip_env_pkg__params.sv'
 
diff --git a/util/topgen/templates/README.md b/util/topgen/templates/README.md
new file mode 100644
index 0000000..afd488a
--- /dev/null
+++ b/util/topgen/templates/README.md
@@ -0,0 +1,4 @@
+# OpenTitan topgen templates
+
+This directory contains templates used by topgen to assembly a chip toplevel.
+
diff --git a/hw/top_earlgrey/data/chip_env_pkg__params.sv.tpl b/util/topgen/templates/chip_env_pkg__params.sv.tpl
similarity index 100%
rename from hw/top_earlgrey/data/chip_env_pkg__params.sv.tpl
rename to util/topgen/templates/chip_env_pkg__params.sv.tpl
diff --git a/hw/top_earlgrey/data/clang-format b/util/topgen/templates/clang-format
similarity index 100%
rename from hw/top_earlgrey/data/clang-format
rename to util/topgen/templates/clang-format
diff --git a/hw/top_earlgrey/data/tb__alert_handler_connect.sv.tpl b/util/topgen/templates/tb__alert_handler_connect.sv.tpl
similarity index 100%
rename from hw/top_earlgrey/data/tb__alert_handler_connect.sv.tpl
rename to util/topgen/templates/tb__alert_handler_connect.sv.tpl
diff --git a/hw/top_earlgrey/data/tb__xbar_connect.sv.tpl b/util/topgen/templates/tb__xbar_connect.sv.tpl
similarity index 100%
rename from hw/top_earlgrey/data/tb__xbar_connect.sv.tpl
rename to util/topgen/templates/tb__xbar_connect.sv.tpl
diff --git a/hw/top_earlgrey/data/top_earlgrey.c.tpl b/util/topgen/templates/toplevel.c.tpl
similarity index 100%
rename from hw/top_earlgrey/data/top_earlgrey.c.tpl
rename to util/topgen/templates/toplevel.c.tpl
diff --git a/hw/top_earlgrey/data/top_earlgrey.h.tpl b/util/topgen/templates/toplevel.h.tpl
similarity index 100%
rename from hw/top_earlgrey/data/top_earlgrey.h.tpl
rename to util/topgen/templates/toplevel.h.tpl
diff --git a/hw/top_earlgrey/data/top_earlgrey.sv.tpl b/util/topgen/templates/toplevel.sv.tpl
similarity index 100%
rename from hw/top_earlgrey/data/top_earlgrey.sv.tpl
rename to util/topgen/templates/toplevel.sv.tpl
diff --git a/hw/top_earlgrey/data/top_earlgrey_memory.h.tpl b/util/topgen/templates/toplevel_memory.h.tpl
similarity index 100%
rename from hw/top_earlgrey/data/top_earlgrey_memory.h.tpl
rename to util/topgen/templates/toplevel_memory.h.tpl
diff --git a/hw/top_earlgrey/data/top_earlgrey_memory.ld.tpl b/util/topgen/templates/toplevel_memory.ld.tpl
similarity index 100%
rename from hw/top_earlgrey/data/top_earlgrey_memory.ld.tpl
rename to util/topgen/templates/toplevel_memory.ld.tpl
diff --git a/hw/top_earlgrey/data/top_earlgrey_pkg.sv.tpl b/util/topgen/templates/toplevel_pkg.sv.tpl
similarity index 100%
rename from hw/top_earlgrey/data/top_earlgrey_pkg.sv.tpl
rename to util/topgen/templates/toplevel_pkg.sv.tpl
diff --git a/hw/top_earlgrey/data/top_earlgrey_rnd_cnst_pkg.sv.tpl b/util/topgen/templates/toplevel_rnd_cnst_pkg.sv.tpl
similarity index 100%
rename from hw/top_earlgrey/data/top_earlgrey_rnd_cnst_pkg.sv.tpl
rename to util/topgen/templates/toplevel_rnd_cnst_pkg.sv.tpl
diff --git a/hw/top_earlgrey/data/xbar_env_pkg__params.sv.tpl b/util/topgen/templates/xbar_env_pkg__params.sv.tpl
similarity index 100%
rename from hw/top_earlgrey/data/xbar_env_pkg__params.sv.tpl
rename to util/topgen/templates/xbar_env_pkg__params.sv.tpl