From 16b662c6e99266fc897f69cefdc8197517300dbc Mon Sep 17 00:00:00 2001
From: dam1n19 <d.a.mapstone@soton.ac.uk>
Date: Tue, 21 Feb 2023 15:42:21 +0000
Subject: [PATCH] Updated Simulation Scripts

---
 flow/simulators/ivlog_sim.sh |  6 +++---
 flow/socsim                  |  2 +-
 sourceme                     | 33 ++++++++++++++++++++++-----------
 3 files changed, 26 insertions(+), 15 deletions(-)

diff --git a/flow/simulators/ivlog_sim.sh b/flow/simulators/ivlog_sim.sh
index fb36012..674d71e 100755
--- a/flow/simulators/ivlog_sim.sh
+++ b/flow/simulators/ivlog_sim.sh
@@ -11,6 +11,6 @@
 
 #!/usr/bin/env bash
 
-mkdir -p $SHA_2_ACC_DIR/simulate/sim/ 
-iverilog -I $SHA_2_ACC_DIR/hdl/verif/ -I $SHA_2_ACC_DIR/hdl/src/ -g2012 -o $SHA_2_ACC_DIR/simulate/sim/$1.vvp $SHA_2_ACC_DIR/hdl/verif/tb_$1.sv
-cd $SHA_2_ACC_DIR/simulate/sim/ && vvp $1.vvp $2
\ No newline at end of file
+mkdir -p $SOC_TOP/simulate/sim/ 
+iverilog -I $SOC_TOP/hdl/verif/ -I $SOC_TOP/hdl/src/ -g2012 -o $SOC_TOP/simulate/sim/$1.vvp $SOC_TOP/hdl/verif/tb_$1.sv
+cd $SOC_TOP/simulate/sim/ && vvp $1.vvp $2
\ No newline at end of file
diff --git a/flow/socsim b/flow/socsim
index 4c98dbf..42c6196 100755
--- a/flow/socsim
+++ b/flow/socsim
@@ -15,4 +15,4 @@ DEFAULT_SIMULATOR="ivlog"
 if [[ -z "${SIMULATOR}" ]]; then 
     SIMULATOR=$DEFAULT_SIMULATOR
 fi
-$SHA_2_ACC_DIR"/flow/simulators/"$SIMULATOR"_sim.sh" $@
+$SOC_TOP"/flow/simulators/"$SIMULATOR"_sim.sh" $@
diff --git a/sourceme b/sourceme
index 572358d..febef30 100755
--- a/sourceme
+++ b/sourceme
@@ -15,19 +15,30 @@ if [ -z "$SHA_2_ACC_DIR" ]; then
     # Set environment Variables for Repository
     export SHA_2_ACC_DIR="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
 
-    # Add flow directory to Path
-    export PATH=$PATH:$SHA_2_ACC_DIR/flow
+    if [ -z "$SOC_ENV_SET" ]; then
+        # Add flow directory to Path
+        export PATH=$PATH:$SHA_2_ACC_DIR/flow
 
-    # Set Default Simulator
-    export SIMULATOR="ivlog"
+        # Set Default Simulator
+        export SIMULATOR="ivlog"
 
-    # Source Top-level sourceme
-    for d in $WRAP_ACC_DIR/../* ; do
-        if [ -d "$d" ]; then
-            if test -f "$d/sourceme"; then
-                source $d/sourceme
+        # Set Top-level Directory
+        export SOC_TOP=$SHA_2_ACC_DIR
+
+        # Set flag to say this is top level repo
+        export SOC_ENV_SET="True"
+
+        # Source Top-level sourceme
+        for d in $WRAP_ACC_DIR/../* ; do
+            if [ -d "$d" ]; then
+                if test -f "$d/sourceme"; then
+                    source $d/sourceme
+                fi
             fi
-        fi
-    done
+        done
+
+        # Clear SOC_ENV_SET Variable
+        unset SOC_ENV_SET
+    fi
 fi
 
-- 
GitLab