diff --git a/scripts/build-tests.sh b/scripts/build-tests.sh deleted file mode 100755 index 3967e982f..000000000 --- a/scripts/build-tests.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash - -cmake ./tests/ -S ./tests/ -B ./tests/build/ -D CMAKE_BUILD_TYPE=Debug -cmake --build ./tests/build/ --target all diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index ebe8f3940..7d1898e07 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -4,7 +4,7 @@ # usage: # Edit "VARIABLES"-section to suit project requirements. # Build instructions: -# cmake . -S ./ -B ./build/ -D CMAKE_BUILD_TYPE=Debug +# cmake -S ./ -B ./build/ -D CMAKE_BUILD_TYPE=Debug # cmake --build ./build/ --target all # Cleaning: # cmake --build ./build/ --target clean @@ -88,6 +88,44 @@ add_executable(hello hello.c) add_executable(mt-hello mt-hello.c) add_executable(symmetric symmetric.c) +################################# +# Disassembly +################################# + +# Add a target to generate all disassemblies +add_custom_target(dump ALL) + +# Function to add disassembly target for an executable +function(add_dump_target target_name) + add_custom_target(${target_name}-dump + BYPRODUCTS ${CMAKE_SOURCE_DIR}/${target_name}.dump + COMMAND ${CMAKE_OBJDUMP} -D $ > ${CMAKE_SOURCE_DIR}/${target_name}.dump + DEPENDS ${target_name} + COMMENT "Generating disassembly for ${target_name}" + ) + add_dependencies(${target_name}-dump ${target_name}) + add_dependencies(dump ${target_name}-dump) +endfunction() + +add_dump_target(pwm) +add_dump_target(blkdev) +add_dump_target(accum) +add_dump_target(charcount) +add_dump_target(cpp-hello) +add_dump_target(nic-loopback) +add_dump_target(big-blkdev) +add_dump_target(pingd) +add_dump_target(streaming-passthrough) +add_dump_target(streaming-fir) +add_dump_target(nvdla) +add_dump_target(spiflashread) +add_dump_target(spiflashwrite) +add_dump_target(fft) +add_dump_target(gcd) +add_dump_target(hello) +add_dump_target(mt-hello) +add_dump_target(symmetric) + # Add custom command to generate spiflash.img from spiflash.py add_custom_command( diff --git a/tests/README.md b/tests/README.md new file mode 100644 index 000000000..12317b725 --- /dev/null +++ b/tests/README.md @@ -0,0 +1,69 @@ +# Chipyard Tests + +To build the tests, we do the following procedure. + +## Clean the previous build + +First, we clean the previous build. This step is recommended when any changes are made to the CMake build flow. This is equivalent to running `make clean` to the CMake build system. + +```bash +cd $chipyard/tests/ +rm -rf ./build/ +``` + + +## Configure the CMake build system + +Then, we configure the cmake to build with the following settings. This step only needs to be done once when the build directory is not created. + +```bash +cmake -S ./ -B ./build/ -D CMAKE_BUILD_TYPE=Debug +``` + +`-S` specifies the source directory, which is the current directory. + +`-B` specifies the build directory, which is `./build/`. + +`-D CMAKE_BUILD_TYPE=Debug` specifies the build type, which is debug. + + +## Build the tests + +Then, we build the tests with the following command. + +By default, the target is `all`, which builds all the tests. + +```bash +cmake --build ./build/ --target all +``` + +If only specific tests are needed, we can specify the tests by adding the test name after `--target`. + +For example, to build the `hello` test, we can run the following command. + +```bash +cmake --build ./build/ --target hello +``` + + +## Generating disassembly of the tests + +To dump the disassembly of the tests, we can run the following command. + +```bash +cmake --build ./build/ --target dump +``` + +To dump the disassembly of the `hello` test, we can run the following command. + +```bash +cmake --build ./build/ --target hello_dump +``` + +## Clean the previous build + +To clean the previous build, we can run the following command. + +```bash +cmake --build ./build/ --target clean +``` \ No newline at end of file