-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #238 from chipsalliance/main
Reintegrate main -> dev-public
- Loading branch information
Showing
867 changed files
with
73,716 additions
and
231,626 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
#!/bin/bash | ||
# | ||
# This script runs Verilator RTL simulation and OpenOCD in background, invokes | ||
# the supplied test command and shuts everything down. | ||
|
||
SIM_LOG=`realpath sim.log` | ||
OPENOCD_LOG=`realpath openocd.log` | ||
|
||
set +e | ||
|
||
if [ "$#" -lt 1 ]; then | ||
echo "Usage: gdb_test.sh <command> [args ...]" | ||
exit 1 | ||
fi | ||
|
||
# Utils | ||
source `dirname ${BASH_SOURCE[0]}`/utils.sh | ||
|
||
terminate_all () { | ||
terminate ${OPENOCD_PID} | ||
terminate ${SIM_PID} | ||
} | ||
|
||
print_logs () { | ||
echo -e "${COLOR_WHITE}======== Simulation log ========${COLOR_OFF}" | ||
cat ${SIM_LOG} || true | ||
echo -e "${COLOR_WHITE}======== OpenOCD log ========${COLOR_OFF}" | ||
cat ${OPENOCD_LOG} || true | ||
} | ||
|
||
echo -e "${COLOR_WHITE}======== Launching interactive simulation ========${COLOR_OFF}" | ||
|
||
# Start the simulation | ||
echo -e "Starting simulation..." | ||
obj_dir/Vcaliptra_top_tb >"${SIM_LOG}" 2>&1 & | ||
SIM_PID=$! | ||
|
||
# Wait | ||
wait_for_phrase "${SIM_LOG}" "CLP: ROM Flow in progress..." | ||
if [ $? -ne 0 ]; then | ||
echo -e "${COLOR_RED}Failed to start the simulation!${COLOR_OFF}" | ||
print_logs | ||
terminate_all; exit -1 | ||
fi | ||
echo -e "Simulation running and ready (pid=${SIM_PID})" | ||
|
||
# Launch OpenOCD | ||
echo -e "Launching OpenOCD..." | ||
cd ${CALIPTRA_ROOT}/tools/scripts/openocd && openocd -d2 -f board/caliptra-verilator.cfg >"${OPENOCD_LOG}" 2>&1 & | ||
OPENOCD_PID=$! | ||
|
||
# Wait | ||
wait_for_phrase "${OPENOCD_LOG}" "Listening on port 3333 for gdb connections" | ||
if [ $? -ne 0 ]; then | ||
echo -e "${COLOR_RED}Failed to start OpenOCD!${COLOR_OFF}" | ||
print_logs | ||
terminate_all; exit -1 | ||
fi | ||
echo -e "OpenOCD running and ready (pid=${OPENOCD_PID})" | ||
|
||
# Wait a bit | ||
sleep 1s | ||
|
||
# Run the test | ||
echo -e "${COLOR_WHITE}======== Running test '$@' ========${COLOR_OFF}" | ||
|
||
bash -c "$(printf ' %q' "$@")" | ||
EXITCODE=$? | ||
|
||
if [ ${EXITCODE} -eq 0 ]; then | ||
echo -e "${COLOR_GREEN}[PASSED]${COLOR_OFF}" | ||
else | ||
echo -e "${COLOR_RED}[FAILED]${COLOR_OFF}" | ||
fi | ||
|
||
sleep 1s | ||
|
||
# Terminate | ||
echo -e "${COLOR_WHITE}Terminating...${COLOR_OFF}" | ||
terminate_all | ||
|
||
# Display logs | ||
print_logs | ||
|
||
# Honor the exitcode | ||
exit ${EXITCODE} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#!/bin/bash | ||
# | ||
# This script runs Verilator RTL simulation in background and invokes OpenOCD | ||
# to perform JTAG access test | ||
|
||
SIM_LOG=`realpath sim.log` | ||
OPENOCD_LOG=`realpath openocd.log` | ||
|
||
set +e | ||
|
||
if [ "$#" -lt 1 ]; then | ||
echo "Usage: openocd_test.sh [openocd args ...]" | ||
exit 1 | ||
fi | ||
OPENOCD_ARGS=$@ | ||
|
||
# Utils | ||
source `dirname ${BASH_SOURCE[0]}`/utils.sh | ||
|
||
print_logs () { | ||
echo -e "${COLOR_WHITE}======== Simulation log ========${COLOR_OFF}" | ||
cat ${SIM_LOG} || true | ||
echo -e "${COLOR_WHITE}======== OpenOCD log ========${COLOR_OFF}" | ||
cat ${OPENOCD_LOG} || true | ||
} | ||
|
||
echo -e "${COLOR_WHITE}======== Launching interactive simulation ========${COLOR_OFF}" | ||
|
||
# Start the simulation | ||
echo -e "Starting simulation..." | ||
obj_dir/Vcaliptra_top_tb >"${SIM_LOG}" 2>&1 & | ||
SIM_PID=$! | ||
|
||
# Wait | ||
wait_for_phrase "${SIM_LOG}" "CLP: ROM Flow in progress..." | ||
if [ $? -ne 0 ]; then | ||
echo -e "${COLOR_RED}Failed to start the simulation!${COLOR_OFF}" | ||
print_logs | ||
terminate ${SIM_PID}; exit -1 | ||
fi | ||
echo -e "Simulation running and ready (pid=${SIM_PID})" | ||
|
||
# Wait a bit | ||
sleep 5s | ||
|
||
# Run the test | ||
echo -e "${COLOR_WHITE}======== Running OpenOCD test '$@' ========${COLOR_OFF}" | ||
cd ${CALIPTRA_ROOT}/tools/scripts/openocd && openocd -d2 ${OPENOCD_ARGS} >"${OPENOCD_LOG}" 2>&1 | ||
EXITCODE=$? | ||
|
||
if [ ${EXITCODE} -eq 0 ]; then | ||
echo -e "${COLOR_GREEN}[PASSED]${COLOR_OFF}" | ||
else | ||
echo -e "${COLOR_RED}[FAILED]${COLOR_OFF}" | ||
fi | ||
|
||
sleep 1s | ||
|
||
# Terminate | ||
echo -e "${COLOR_WHITE}Terminating...${COLOR_OFF}" | ||
terminate ${SIM_PID} | ||
|
||
# Display logs | ||
print_logs | ||
|
||
# Honor the exitcode | ||
exit ${EXITCODE} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/bin/bash | ||
|
||
# Colors | ||
COLOR_OFF='\033[0m' | ||
COLOR_RED='\033[31m' | ||
COLOR_GREEN='\033[32m' | ||
COLOR_WHITE='\033[1;37m' | ||
|
||
# Waits until the given phrase appears in a log file (actively written to) | ||
# Usage: wait_for_phrase <log_file> <phrase> | ||
wait_for_phrase () { | ||
|
||
# Check if the log exists | ||
sleep 1s | ||
if ! [ -f "$1" ]; then | ||
echo -e "${COLOR_RED}Log file '$1' not found!${COLOR_OFF}" | ||
return -1 | ||
fi | ||
|
||
# Wait for the phrase | ||
DEADLINE=$((${EPOCHSECONDS} + 30)) | ||
while [ ${EPOCHSECONDS} -lt ${DEADLINE} ] | ||
do | ||
# Check for the phrase | ||
grep "$2" "$1" >/dev/null | ||
if [ $? -eq 0 ]; then | ||
return 0 | ||
fi | ||
|
||
# Sleep and retry | ||
sleep 1s | ||
done | ||
|
||
# Timeout | ||
return -1 | ||
} | ||
|
||
# Terminates a process. First via SIGINT and if this doesn't work after 10s | ||
# retries with SIGKILL | ||
# Usage: terminate <pid> | ||
terminate () { | ||
|
||
local PID=$1 | ||
|
||
# Gently interrupt, wait some time and then kill | ||
/bin/kill -s SIGINT ${PID} || true | ||
sleep 10s | ||
/bin/kill -s SIGKILL ${PID} || true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.