From 080d21c9f1e3cef07805387dc2c62d3d37a392bc Mon Sep 17 00:00:00 2001 From: Ganesh Gore Date: Sun, 7 Feb 2021 22:35:13 -0700 Subject: [PATCH 1/6] [Flow] Updated shortcuts shell script --- openfpga.sh | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/openfpga.sh b/openfpga.sh index 690a7b9b9..88eaed7c2 100755 --- a/openfpga.sh +++ b/openfpga.sh @@ -5,9 +5,9 @@ #author : Ganesh Gore #============================================================================== -export OPENFPGA_PATH="$(pwd)" -export OPENFPGA_SCRIPT_PATH="$(pwd)/openfpga_flow/scripts" -export OPENFPGA_TASK_PATH="$(pwd)/openfpga_flow/tasks" +export OPENFPGA_PATH=$(dirname $(readlink -f $0)) +export OPENFPGA_SCRIPT_PATH="${OPENFPGA_PATH}/openfpga_flow/scripts" +export OPENFPGA_TASK_PATH="${OPENFPGA_PATH}/openfpga_flow/tasks" if [ -z $PYTHON_EXEC ]; then export PYTHON_EXEC="python3"; fi # This function checks the path and @@ -44,7 +44,7 @@ run-flow () { # lists all the configure task in task directory list-tasks () { check_execution_path "$(pwd)" - ls -tdalh ${OPENFPGA_TASK_PATH}/* | awk '{printf("%-4s | %s %-3s | ", $5, $6, $7) ;system("basename " $9)}' + tree -P 'task.conf' --prune | sed "/.* task.conf/d" | sed "/.* config/d" | sed '$d' } # Switch directory to root of OpenFPGA @@ -58,15 +58,6 @@ run-regression-local () { bash .github/workflows/*reg_test.sh } -# Run regression test locally -run-regression-local-docker () { - cd ${OPENFPGA_PATH} - docker run \ - -v $(pwd)/openfpga_flow:/opt/openfpga/ \ - -v $(pwd)/.github:/opt/openfpga/ \ - ghcr.io/lnis-uofu/openfpga-master:latest "bash .github/workflows/*reg_test.sh" -} - # Changes directory to task directory [goto_task ] goto-task () { if [ -z $1 ]; then @@ -105,7 +96,12 @@ unset-openfpga (){ if [[ $(ps -p $$ -oargs=) == *"zsh"* ]]; then autoload -U +X bashcompinit; bashcompinit; fi -TaskList=$(ls -tdalh ${OPENFPGA_TASK_PATH}/* | awk '{system("basename " $9)}' | awk '{printf("%s ",$1)}') +# TaskList=$(ls -tdalh ${OPENFPGA_TASK_PATH}/* | awk '{system("basename " $9)}' | awk '{printf("%s ",$1)}') +TaskList=$(ls -tdalh ${OPENFPGA_TASK_PATH}/**/task.conf | +awk '{print $9}' | sed -e "s/\/config\/task.conf//" | +sed -e "s/${OPENFPGA_PATH//\//\\/}\/openfpga_flow\/tasks\///" | +awk '{printf("%s ",$1)}') + complete -W "${TaskList}" goto-task complete -W "${TaskList}" run-task complete -W "${TaskList}" run-shell-task From cbd2064f59465a5d01663a10291e9a69bdf077f1 Mon Sep 17 00:00:00 2001 From: Ganesh Gore Date: Sun, 7 Feb 2021 23:33:25 -0700 Subject: [PATCH 2/6] [Docs] Updated docker based run documentation --- docs/source/tutorials/compile.rst | 37 +++++++++++++++++-------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/docs/source/tutorials/compile.rst b/docs/source/tutorials/compile.rst index 1a5c5a216..8b95c995d 100644 --- a/docs/source/tutorials/compile.rst +++ b/docs/source/tutorials/compile.rst @@ -49,28 +49,31 @@ In particular, OpenFPGA requires specific versions for the following dependencie .. _install_dependencies_build: https://github.com/lnis-uofu/OpenFPGA/blob/master/.github/workflows/install_dependencies_build.sh -Docker -~~~~~~ -If some of these dependencies are not installed on your machine, you can choose to use a Docker (the Docker tool needs to be installed). -For the ease of the customer first experience, a Dockerfile is provided in the OpenFPGA folder. A container ready to use can be created with the following command -.. code-block:: shell +Running with the docker image +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - docker run lnis/open_fpga:release +Users can skip the traditional installation process by using Dockerized version +of the OpenFPGA tool. OpenFPGA project maintains the docker image/Github package of +the latest stable version of OpenFPGA in the following repository +`openfpga-master `_. +This image contains precompiled OpenFPGA binaries with all prerequisites installed. -.. note:: This command is for quick testing. If you want to conserve your work, you should certainly use other options, such as ``-v``. +.. code-block:: bash -Otherwise, a container where you can build OpenFPGA yourself can be created with the following commands + # To get the docker image from the repository, docker pull ghcr.io/lnis-uofu/openfpga-master:latest -.. code-block:: shell + # To invoke openfpga_shell + docker run -it ghcr.io/lnis-uofu/openfpga-master:latest openfpga/openfpga -i - docker build . -t open_fpga - docker run -it --rm -v $PWD:/localfile/OpenFPGA -w="/localfile/OpenFPGA" open_fpga bash + # To run the task that already exists in the repository. + docker run -it ghcr.io/lnis-uofu/openfpga-master:latest bash -c "source openfpga.sh && run-task compilation_verification" -For more information about dock, see dock_download_link_ + # To run a task from a local machine + mkdir <>/config + vi <>/config/task.config # Create your task configuration + TASK_NAME=<> docker run -it -v ${PWD}/${TASK_NAME}:/opt/openfpga/openfpga_flow/tasks/${TASK_NAME} ghcr.io/lnis-uofu/openfpga-master:latest bash -c "source openfpga.sh && run-task ${TASK_NAME}" -.. _dock_download_link: https://www.docker.com/products/docker-desktop - -To build the tool, go in the OpenFPGA folder and follow the compilation steps - -.. note:: Using docker, you cannot use ``make -j``, errors will happen +.. note:: + While running local task using docker, make sure all the additional files + are maintained in the task_directory and reference using variable ${TASK_DIR} \ No newline at end of file From c35cf72489833304e5dce0d15b6a511df15df3bb Mon Sep 17 00:00:00 2001 From: Ganesh Gore Date: Sun, 7 Feb 2021 23:42:05 -0700 Subject: [PATCH 3/6] [Docs] Added OpenFPGA shortcut commands docs --- docs/source/tutorials/index.rst | 4 ++- docs/source/tutorials/shell_shortcuts.rst | 42 +++++++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 docs/source/tutorials/shell_shortcuts.rst diff --git a/docs/source/tutorials/index.rst b/docs/source/tutorials/index.rst index eb1adccf6..53421eb5a 100644 --- a/docs/source/tutorials/index.rst +++ b/docs/source/tutorials/index.rst @@ -1,11 +1,13 @@ .. _tutorials: Tutorials - + .. toctree:: :maxdepth: 2 compile + shell_shortcuts + tools design_flow/index diff --git a/docs/source/tutorials/shell_shortcuts.rst b/docs/source/tutorials/shell_shortcuts.rst new file mode 100644 index 000000000..d8b8369e3 --- /dev/null +++ b/docs/source/tutorials/shell_shortcuts.rst @@ -0,0 +1,42 @@ +OpenFPGA shortcuts +------------------ + +OpenFPGA provides bash/zsh shell-based shortcuts to perform all essential functions and navigating through the directories. Go to the OpenFPGA directory and source ``openfpga.sh`` + +.. code-block:: bash + + cd ${OPENFPGA_PATH} && source openfpga.sh + +.. note:: + The OpenFPGA shortcuts are designed to work with only bash based shells. e.g. bash/zsh/fish etc. + +Shortcut Commands +^^^^^^^^^^^^^^^^^ + +Once the ``openfpga.sh`` script is sourced, you can run any of the following commands directly in the terminal. + +.. option:: list-tasks + + This command lists all the OpenFPGA tasks from the current task directory. + default task directory is considered as ``${OPENFPGA_PATH}/openfpga_flow/tasks`` + +.. option:: run-task **kwarags + + This command runs the specified task listed from the ``list-task`` command or from the existing directory. The command name is relative to the ``TASK_DIRECTORY``. User can provide any additional arguments which are listed `here <_openfpga_task_args>`_ to this command. + +.. option:: run-modelsim + + This command runs the verification using ModelSim. + The test benches are generated during the OpenFPGA run. + **Note**: user need to have ``VSIM`` install and configured + + +.. option:: run-regression-local + + This script runs the regression test locally using the current version of OpenFPGA. + **NOTE** Important before making a pull request to the master + +.. option:: unset-openfpga + + Unregisters all the shortcuts and commands from the current shell session + From 12e4fa07a23e516c6531b726c180b3cd3f0ebbf1 Mon Sep 17 00:00:00 2001 From: Ganesh Gore Date: Mon, 8 Feb 2021 11:57:15 -0700 Subject: [PATCH 4/6] [bugfix] OPENFPGA_PATH location --- openfpga.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/openfpga.sh b/openfpga.sh index 88eaed7c2..9a2c80942 100755 --- a/openfpga.sh +++ b/openfpga.sh @@ -5,7 +5,13 @@ #author : Ganesh Gore #============================================================================== -export OPENFPGA_PATH=$(dirname $(readlink -f $0)) +if [ -z $OPENFPGA_PATH ]; then + echo "OPENFPGA_PATH variable not found" + export OPENFPGA_PATH=$(pwd); + echo "Setting OPENFPGA_PATH=${OPENFPGA_PATH}" +else + echo "OPENFPGA_PATH=${OPENFPGA_PATH}" +fi export OPENFPGA_SCRIPT_PATH="${OPENFPGA_PATH}/openfpga_flow/scripts" export OPENFPGA_TASK_PATH="${OPENFPGA_PATH}/openfpga_flow/tasks" if [ -z $PYTHON_EXEC ]; then export PYTHON_EXEC="python3"; fi From 6761df6d9d173478d058999faee35f5c12d174ba Mon Sep 17 00:00:00 2001 From: Ganesh Gore Date: Mon, 8 Feb 2021 12:36:50 -0700 Subject: [PATCH 5/6] [Bugfix] Reverted setting OPENFPGA_PATH --- openfpga.sh | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/openfpga.sh b/openfpga.sh index 9a2c80942..c8275b6dc 100755 --- a/openfpga.sh +++ b/openfpga.sh @@ -5,13 +5,7 @@ #author : Ganesh Gore #============================================================================== -if [ -z $OPENFPGA_PATH ]; then - echo "OPENFPGA_PATH variable not found" - export OPENFPGA_PATH=$(pwd); - echo "Setting OPENFPGA_PATH=${OPENFPGA_PATH}" -else - echo "OPENFPGA_PATH=${OPENFPGA_PATH}" -fi +export OPENFPGA_PATH="$(pwd)" export OPENFPGA_SCRIPT_PATH="${OPENFPGA_PATH}/openfpga_flow/scripts" export OPENFPGA_TASK_PATH="${OPENFPGA_PATH}/openfpga_flow/tasks" if [ -z $PYTHON_EXEC ]; then export PYTHON_EXEC="python3"; fi From c2b68606c99b005c0cc214c42438ee7afe24d8e6 Mon Sep 17 00:00:00 2001 From: Ganesh Gore Date: Mon, 8 Feb 2021 14:07:01 -0700 Subject: [PATCH 6/6] [Bugfix] Added shell globstar --- openfpga.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/openfpga.sh b/openfpga.sh index c8275b6dc..f0ab701ee 100755 --- a/openfpga.sh +++ b/openfpga.sh @@ -5,7 +5,13 @@ #author : Ganesh Gore #============================================================================== -export OPENFPGA_PATH="$(pwd)" +if [ -z $OPENFPGA_PATH ]; then + echo "OPENFPGA_PATH variable not found" + export OPENFPGA_PATH=$(pwd); + echo "Setting OPENFPGA_PATH=${OPENFPGA_PATH}" +else + echo "OPENFPGA_PATH=${OPENFPGA_PATH}" +fi export OPENFPGA_SCRIPT_PATH="${OPENFPGA_PATH}/openfpga_flow/scripts" export OPENFPGA_TASK_PATH="${OPENFPGA_PATH}/openfpga_flow/tasks" if [ -z $PYTHON_EXEC ]; then export PYTHON_EXEC="python3"; fi @@ -96,6 +102,8 @@ unset-openfpga (){ if [[ $(ps -p $$ -oargs=) == *"zsh"* ]]; then autoload -U +X bashcompinit; bashcompinit; fi + +command -v shopt && shopt -s globstar # TaskList=$(ls -tdalh ${OPENFPGA_TASK_PATH}/* | awk '{system("basename " $9)}' | awk '{printf("%s ",$1)}') TaskList=$(ls -tdalh ${OPENFPGA_TASK_PATH}/**/task.conf | awk '{print $9}' | sed -e "s/\/config\/task.conf//" |