Plumb distdir/cachedir to dvsim

Bypass-Presubmit-Reason: manual test passes with full topic.
Change-Id: I96c2c6c3b2e7669a6fb69a375aed7eb73c679cf4
diff --git a/hw/dv/tools/dvsim/common_sim_cfg.hjson b/hw/dv/tools/dvsim/common_sim_cfg.hjson
index 38c52ac..e07eb31 100644
--- a/hw/dv/tools/dvsim/common_sim_cfg.hjson
+++ b/hw/dv/tools/dvsim/common_sim_cfg.hjson
@@ -83,6 +83,8 @@
     { DUT_TOP: "{dut}" },
     { TB_TOP: "{tb}" },
     { dut_instance: "{dut_instance}" }
+    { BAZEL_DISTDIR: "{bazel_distdir}" }
+    { BAZEL_CACHEDIR: "{bazel_cachedir}" }
   ]
 
   // Build modes are collection of build_opts and run_opts
diff --git a/util/dvsim_matcha/CfgFactory.py b/util/dvsim_matcha/CfgFactory.py
index 18822aa..4e6c1b7 100644
--- a/util/dvsim_matcha/CfgFactory.py
+++ b/util/dvsim_matcha/CfgFactory.py
@@ -97,7 +97,7 @@
     return cls(path, hjson_data, args, None)
 
 
-def make_cfg(path, args, proj_root, titan_root):
+def make_cfg(path, args, proj_root, titan_root, bazel_distdir, bazel_cachedir):
     '''Make a flow config by loading the config file at path
 
     args is the arguments passed to the dvsim.py tool and proj_root is the top
@@ -109,6 +109,11 @@
         'titan_root': titan_root,
         'self_dir': os.path.dirname(path),
     }
+    if args.bazel_distdir:
+        initial_values['bazel_distdir'] = bazel_distdir
+    if args.bazel_cachedir:
+        initial_values['bazel_cachedir'] = bazel_cachedir
+
     if args.tool is not None:
         initial_values['tool'] = args.tool
 
diff --git a/util/dvsim_matcha/dvsim.py b/util/dvsim_matcha/dvsim.py
index 23a2181..b95140f 100755
--- a/util/dvsim_matcha/dvsim.py
+++ b/util/dvsim_matcha/dvsim.py
@@ -389,6 +389,14 @@
                        "-tr",
                        metavar="PATH",
                        help=('The root directory of the opentitan repo'))
+    pathg.add_argument("--bazel-distdir",
+                       "-bd",
+                       metavar="PATH",
+                       help=('The BAZEL_DISTDIR'))
+    pathg.add_argument("--bazel-cachedir",
+                       "-bc",
+                       metavar="PATH",
+                        help=('The BAZEL_CACHEDIR'))
 
     pathg.add_argument("--branch",
                        "-br",
@@ -752,7 +760,7 @@
     # Build infrastructure from hjson file and create the list of items to
     # be deployed.
     global cfg
-    cfg = make_cfg(args.cfg, args, proj_root, args.titan_root)
+    cfg = make_cfg(args.cfg, args, proj_root, args.titan_root, args.bazel_distdir, args.bazel_cachedir)
 
     # List items available for run if --list switch is passed, and exit.
     if args.list is not None: