[topgen] Create directory for top.gen.hjson if it doesn't exist

Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
diff --git a/util/topgen.py b/util/topgen.py
index 8bf597a..f91f3b5 100755
--- a/util/topgen.py
+++ b/util/topgen.py
@@ -1103,9 +1103,9 @@
     top_name = completecfg["name"]
 
     # Generate top.gen.hjson right before rendering
-    hjson_dir = Path(args.topcfg).parent
-    genhjson_path = hjson_dir / ("autogen/top_%s.gen.hjson" %
-                                 completecfg["name"])
+    genhjson_dir = Path(out_path) / "data/autogen"
+    genhjson_dir.mkdir(parents=True, exist_ok=True)
+    genhjson_path = genhjson_dir / ("top_%s.gen.hjson" % completecfg["name"])
 
     # Header for HJSON
     gencmd = '''//