From 341995f2792589d454d2a7f026a1158e4ba0f063 Mon Sep 17 00:00:00 2001
From: David Mapstone <david@mapstone.me>
Date: Wed, 15 Mar 2023 16:51:40 +0000
Subject: [PATCH] SOC1-124: Updated set_env script

---
 flow/socsim     |  2 +-
 flow/stimgen.py |  6 +++---
 set_env.sh      | 47 +++++++++++++++++++++++++++--------------------
 sourceme        | 10 +++++-----
 4 files changed, 36 insertions(+), 29 deletions(-)

diff --git a/flow/socsim b/flow/socsim
index 42c6196..4b2d7f1 100755
--- a/flow/socsim
+++ b/flow/socsim
@@ -15,4 +15,4 @@ DEFAULT_SIMULATOR="ivlog"
 if [[ -z "${SIMULATOR}" ]]; then 
     SIMULATOR=$DEFAULT_SIMULATOR
 fi
-$SOC_TOP"/flow/simulators/"$SIMULATOR"_sim.sh" $@
+$SOC_TOP_DIR"/flow/simulators/"$SIMULATOR"_sim.sh" $@
diff --git a/flow/stimgen.py b/flow/stimgen.py
index 5e3c556..3b8f1b2 100644
--- a/flow/stimgen.py
+++ b/flow/stimgen.py
@@ -188,15 +188,15 @@ def stimulus_generation(stim_file, ref_file, input_start_address, input_size, ou
 
 
     # Generate ADP Command File with Write Transactions
-    adp_file = os.environ["WRAP_ACC_DIR"] + "/simulate/stimulus/" + "adp_hash_stim.cmd"
+    adp_file = os.environ["ACC_WRAPPER_DIR"] + "/simulate/stimulus/" + "adp_hash_stim.cmd"
     adp_output(adp_file, output_word_list)
 
     # Generate FRI File with Write Transactions
-    fri_file = os.environ["WRAP_ACC_DIR"] + "/simulate/stimulus/" + "ahb_input_hash_stim.fri"
+    fri_file = os.environ["ACC_WRAPPER_DIR"] + "/simulate/stimulus/" + "ahb_input_hash_stim.fri"
     fri_output(fri_file, output_word_list)
 
     # Call fm2conv.pl script
-    m2d_file = os.environ["WRAP_ACC_DIR"] + "/simulate/stimulus/" + "ahb_input_hash_stim.m2d"
+    m2d_file = os.environ["ACC_WRAPPER_DIR"] + "/simulate/stimulus/" + "ahb_input_hash_stim.m2d"
     os.system(f"fm2conv.pl -busWidth=32 -infile={fri_file} -outfile={m2d_file}")
 
 
diff --git a/set_env.sh b/set_env.sh
index 8ce4f80..9ee3471 100644
--- a/set_env.sh
+++ b/set_env.sh
@@ -10,34 +10,41 @@
 #-----------------------------------------------------------------------------
 #!/bin/bash
 
-# Get Root Location of Repository
+# Get Root Location of Design Structure
 if [ -z $DESIGN_ROOT ]; then
     # If $DESIGN_ROOT hasn't been set yet
     DESIGN_ROOT=`git rev-parse --show-superproject-working-tree`
+
     if [ -z $DESIGN_ROOT ]; then
-        # If not in a submodule
+        # If not in a submodule - at root
         DESIGN_ROOT=`git rev-parse --show-toplevel`
     fi
-fi
 
-# Set Environment Variable for this Repository
-export WRAP_ACC_DIR="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
+    # Source Top-Level Sourceme
+    source $DESIGN_ROOT/set_env.sh
+else
+    # Set Environment Variable for this Repository
+    export ACC_WRAPPER_DIR="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
 
-# If this Repo is root of workspace
-if [ $WRAP_ACC_DIR = $DESIGN_ROOT ]; then
-    echo "Design Workspace: $WRAP_ACC_DIR" 
-    export $DESIGN_ROOT
-fi
+    # If this Repo is root of workspace
+    if [ $ACC_WRAPPER_DIR = $DESIGN_ROOT ]; then
+        echo "Design Workspace: $DESIGN_ROOT" 
+        export DESIGN_ROOT
+        # Set Default Simulator
+        export SIMULATOR="ivlog"
+    fi
 
-# Source environment variables for all submodules
-for d in $WRAP_ACC_DIR/* ; do
-    if [ -f "$d/.git" ]; then
-        if [ -f "$d/set_env.sh" ]; then
-        # If .git file exists - submodule
-            source $d/set_env.sh
+    # Source environment variables for all submodules
+    for d in $ACC_WRAPPER_DIR/* ; do
+        if [ -f "$d/.git" ]; then
+            if [ -f "$d/set_env.sh" ]; then
+            # If .git file exists - submodule
+                source $d/set_env.sh
+            fi
         fi
-    fi
-done
+    done
+
+    # Add Scripts to Path
+    export PATH="$PATH:/$ACC_WRAPPER_DIR/flow"
+fi
 
-# Add Flow directory to Path
-export PATH="$PATH:/$WRAP_ACC_DIR/flow"
\ No newline at end of file
diff --git a/sourceme b/sourceme
index 76b9c89..12e0c2a 100755
--- a/sourceme
+++ b/sourceme
@@ -11,25 +11,25 @@
 
 #!/usr/bin/env bash
 
-if [ -z "$WRAP_ACC_DIR" ]; then
+if [ -z "$ACC_WRAPPER_DIR" ]; then
     # Set environment Variables for Repository
-    export WRAP_ACC_DIR="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
+    export ACC_WRAPPER_DIR="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
 
     if [ -z "$SOC_ENV_SET" ]; then
         # Add flow directory to Path
-        export PATH=$PATH:$WRAP_ACC_DIR/flow
+        export PATH=$PATH:$ACC_WRAPPER_DIR/flow
 
         # Set Default Simulator
         export SIMULATOR="ivlog"
 
         # Set Top-level Directory
-        export SOC_TOP=$WRAP_ACC_DIR
+        export SOC_TOP=$ACC_WRAPPER_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
+        for d in $ACC_WRAPPER_DIR/../* ; do
             if [ -d "$d" ]; then
                 if test -f "$d/sourceme"; then
                     source $d/sourceme
-- 
GitLab