Skip to content

Commit 0121c41

Browse files
committed
[Infra]: command arg to run a single benchmark in run_yosys script
Signed-off-by: Seyed Alireza Damghani <[email protected]>
1 parent 5aaf296 commit 0121c41

File tree

1 file changed

+74
-15
lines changed

1 file changed

+74
-15
lines changed

ODIN_II/run_yosys.sh

Lines changed: 74 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ NC=$'\033[0m' # No Color
4141
# defaults
4242
_YOSYS_EXEC="yosys"
4343
_TEST_INPUT_LIST=()
44+
_VERILOG_INPUT_LIST=()
4445
_REGENERATE_BLIF="off"
4546
_SHOW_FAILURE="off"
4647
_CLEAN="off"
@@ -71,11 +72,11 @@ function print_test_stat() {
7172
START_TIME="$2"
7273

7374
if [ _${STAT} == "_E" ]; then
74-
echo "[${BLUE}EXIST${NC}] . . . . . . . . . . . . . . . . . . _BLIF/${TASK_DIR}/${TCL_BLIF_NAME}"
75+
echo "[${BLUE}EXIST${NC}] . . . . . . . . . . . . . . . . . . ${OUTPUT_REALPATH}"
7576
elif [ _${STAT} == "_C" ]; then
76-
echo "[${GREEN}CREATED${NC}] . . . . . . . . . . . . . . . . . _BLIF/${TASK_DIR}/${TCL_BLIF_NAME} - [${GREEN}$(print_time_since "${START_TIME}")${NC}]"
77+
echo "[${GREEN}CREATED${NC}] . . . . . . . . . . . . . . . . . ${OUTPUT_REALPATH} - [${GREEN}$(print_time_since "${START_TIME}")${NC}]"
7778
elif [ _${STAT} == "_F" ]; then
78-
echo "[${RED}FAILED${NC}]${RED} . . . . . . . . . . . . . . . . . ${NC}_BLIF/${TASK_DIR}/${TCL_BLIF_NAME}"
79+
echo "[${RED}FAILED${NC}]${RED} . . . . . . . . . . . . . . . . . ${NC}${OUTPUT_REALPATH}"
7980
fi
8081
}
8182

@@ -128,6 +129,7 @@ function help() {
128129
OPTIONS
129130
-h|--help $(_prt_cur_arg off) print this
130131
-s|--show_failure $(_prt_cur_arg off) show failures in yosys blif generating process
132+
-V|--verilog < test name > A path to a single Verilog file
131133
-t|--test < test name > A path to a single test file
132134
-T|--task Test name is either a absolute or relative path to
133135
a directory containing a task.ycfg, task_list.conf
@@ -198,17 +200,28 @@ function parse_args() {
198200
_TEST_INPUT_LIST+=( "$2" )
199201
shift
200202

201-
;;--regenerate_blif)
202-
_REGENERATE_BLIF="on"
203-
echo "regenerating blifs of benchmark/_BLIF"
204-
205-
;;--show_failure)
206-
_SHOW_FAILURE="on"
207-
echo "show yosys log if a benchmark fails"
203+
;;-V|--verilog)
204+
# this is handled down stream
205+
if [ "_$2" == "_" ]
206+
then
207+
echo "empty argument for $1"
208+
_exit_with_code "-1"
209+
fi
210+
# concat tests
211+
_VERILOG_INPUT_LIST+=( "$2" )
212+
shift
208213

209-
;;--clean)
210-
_CLEAN="on"
211-
echo "clean up yosys generated BLIFs directory if exist"
214+
;;--regenerate_blif)
215+
_REGENERATE_BLIF="on"
216+
echo "regenerating blifs of benchmark/_BLIF"
217+
218+
;;--show_failure)
219+
_SHOW_FAILURE="on"
220+
echo "show yosys log if a benchmark fails"
221+
222+
;;--clean)
223+
_CLEAN="on"
224+
echo "clean up yosys generated BLIFs directory if exist"
212225

213226
esac
214227

@@ -299,6 +312,40 @@ function populate_arg_from_file() {
299312
fi
300313
}
301314

315+
function run_single_files() {
316+
for circuit in "${_VERILOG_INPUT_LIST[@]}"
317+
do
318+
# validate input file
319+
if [ "${circuit: -2}" != ".v" ]; then
320+
echo "Invalid input Verilog file (${circuit})"
321+
_exit_with_code "-1"
322+
fi
323+
324+
export OUTPUT_BLIF_PATH="${ODIN_DIR}/yosys"
325+
326+
# run yosys for the current circuit
327+
CIRCUIT_FILE=$(basename "${circuit}")
328+
329+
CIRCUIT_NAME="${CIRCUIT_FILE%.*}"
330+
331+
# to check the required path and files
332+
check "${OUTPUT_BLIF_PATH}" "${CIRCUIT_NAME}"
333+
334+
export TCL_CIRCUIT="${circuit}"
335+
export TCL_BLIF_NAME="${CIRCUIT_NAME}.blif"
336+
OUTPUT_REALPATH="${ODIN_DIR}/${TCL_BLIF_NAME}"
337+
338+
if [ -f "${OUTPUT_BLIF_PATH}/${TCL_BLIF_NAME}" ]; then
339+
print_test_stat "E"
340+
continue
341+
fi
342+
343+
run_yosys "${ODIN_DIR}/synth.tcl"
344+
done
345+
346+
unset _VERILOG_INPUT_LIST
347+
}
348+
302349
function run_task() {
303350
directory="$1"
304351
if [ "_${_CLEAN}" == "_on" ]; then
@@ -326,12 +373,13 @@ function run_task() {
326373

327374
export TCL_CIRCUIT="${circuit}"
328375
export TCL_BLIF_NAME="${CIRCUIT_NAME}.blif"
376+
OUTPUT_REALPATH="_BLIF/${TASK_DIR}/${TCL_BLIF_NAME}"
329377

330378
if [ -f "${OUTPUT_BLIF_PATH}/${TCL_BLIF_NAME}" ]; then
331379
print_test_stat "E"
332380
continue
333381
fi
334-
382+
335383

336384
run_yosys "${ODIN_DIR}/synth.tcl"
337385
done
@@ -394,6 +442,17 @@ function run_suite() {
394442
fi
395443
}
396444

445+
function run() {
446+
# run single verilog file
447+
if [ ${#_VERILOG_INPUT_LIST[@]} -gt 0 ]; then
448+
run_single_files
449+
elif [ ${#_TEST_INPUT_LIST[@]} -gt 0 ]; then
450+
run_suite
451+
else
452+
echo "No test is passed it must pass a verilog file or test directory containing either a task_list.conf or a task.ycfg, see --help"
453+
_exit_with_code "-1"
454+
fi
455+
}
397456

398457
##############################################################################################
399458
######################################### START HERE #########################################
@@ -403,4 +462,4 @@ init
403462

404463
parse_args "$@"
405464

406-
run_suite
465+
run

0 commit comments

Comments
 (0)