Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADD: add dump flow and documentation on tests building #2051

Merged
merged 3 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions scripts/build-tests.sh

This file was deleted.

40 changes: 39 additions & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 $<TARGET_FILE:${target_name}> > ${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(
Expand Down
69 changes: 69 additions & 0 deletions tests/README.md
Original file line number Diff line number Diff line change
@@ -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
```
Loading