Skip to main content

CMake Build System

Why Unified CMake?

Traditional Beethoven development required separate steps: run sbt to generate hardware, then separately build C++ testbenches. The unified CMake system combines these into a single build:

cmake .. && make

This workflow:

  • Automatically invokes sbt to generate hardware when Scala sources change
  • Manages dependencies between hardware generation and C++ compilation
  • Keeps generated files in project-local directories (no global BEETHOVEN_PATH pollution)
  • Integrates verilator/icarus/VCS simulation into the build graph

Prerequisites

Install Beethoven software library:

cd Beethoven-Software
mkdir build && cd build
cmake .. -DPLATFORM=discrete -DBEETHOVEN_HARDWARE_PATH=/path/to/Beethoven-Hardware
make -j
sudo make install

This installs CMake modules that provide the beethoven_hardware() and beethoven_testbench() functions.

Basic Usage

Minimal Project

Create CMakeLists.txt:

cmake_minimum_required(VERSION 3.15)
project(my_accelerator)
set(CMAKE_CXX_STANDARD 20)

find_package(beethoven REQUIRED)

# Generate hardware from Scala
beethoven_hardware(my_accel
MAIN_CLASS com.example.MyAccelBuild
PLATFORM discrete
)

# Build testbench
beethoven_testbench(my_test
SOURCES test.cc
HARDWARE my_accel
SIMULATOR verilator
)

Build:

mkdir build && cd build
export BEETHOVEN_HARDWARE_PATH=/path/to/Beethoven-Hardware
cmake ..
make # Generates hardware, builds sim, compiles test
./my_test # Run

Environment Variables

VariablePurposeRequired
BEETHOVEN_HARDWARE_PATHPath to Beethoven-Hardware sbt projectFor unified builds
VCS_HOMESynopsys VCS installationIf using VCS simulator

The system searches for BEETHOVEN_HARDWARE_PATH in order:

  1. Environment variable
  2. Installed config (/usr/local/share/beethoven/beethoven_paths.cmake)
  3. Source tree (${CMAKE_SOURCE_DIR}/build.sbt)

File Locations

Generated Hardware

<source_dir>/build/gen/<target>_HW_DIR/
hw/
*.v # Verilog modules
build/
beethoven_hardware.h # C++ bindings
beethoven_hardware.cc
cmake_srcs.cmake # Source list
.beethoven_generated_<target> # Stamp file

Build Artifacts

<build_dir>/
<target> # Executable
<target>_sim/ # Simulator output
Vobj_dir/ # Verilator objects (if verilator)
sim.vvp # Icarus binary (if icarus)
CMakeFiles/