2019-10-17 23:44:10 +00:00
|
|
|
######################################################################
|
|
|
|
#
|
|
|
|
# DESCRIPTION: Verilator CMake Example: Small CMakeLists.txt with SystemC tracing
|
|
|
|
#
|
|
|
|
# This is an example cmake script to build a verilog to SystemC project
|
|
|
|
# using CMake and Verilator.
|
|
|
|
#
|
2020-05-19 02:23:19 +00:00
|
|
|
# This file ONLY is placed under the Creative Commons Public Domain, for
|
|
|
|
# any use, without warranty, 2020 by Wilson Snyder.
|
|
|
|
# SPDX-License-Identifier: CC0-1.0
|
2019-10-17 23:44:10 +00:00
|
|
|
#
|
|
|
|
######################################################################
|
|
|
|
|
|
|
|
# This example builds the tracing_sc example using CMake
|
|
|
|
# To use it, run the following:
|
|
|
|
|
|
|
|
# cd /path/to/verilator/examples/cmake_tracing_sc
|
|
|
|
# rm -rf build && mkdir build && cd build
|
|
|
|
# cmake ..
|
|
|
|
# cmake --build .
|
|
|
|
|
2023-02-03 22:16:39 +00:00
|
|
|
cmake_minimum_required(VERSION 3.12)
|
|
|
|
cmake_policy(SET CMP0074 NEW)
|
|
|
|
|
2021-05-13 18:26:53 +00:00
|
|
|
project(cmake_tracing_sc_example CXX)
|
2019-10-17 23:44:10 +00:00
|
|
|
|
|
|
|
find_package(verilator HINTS $ENV{VERILATOR_ROOT} ${VERILATOR_ROOT})
|
2024-09-25 00:43:19 +00:00
|
|
|
if(NOT verilator_FOUND)
|
|
|
|
message(
|
|
|
|
FATAL_ERROR
|
|
|
|
"Verilator was not found. Either install it, or set the VERILATOR_ROOT environment variable"
|
|
|
|
)
|
2019-10-17 23:44:10 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# SystemC dependencies
|
|
|
|
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
|
|
|
find_package(Threads REQUIRED)
|
|
|
|
|
|
|
|
# Find SystemC using SystemC's CMake integration
|
|
|
|
find_package(SystemCLanguage QUIET)
|
|
|
|
|
|
|
|
# Create a new executable target that will contain all your sources
|
|
|
|
add_executable(example ../make_tracing_sc/sc_main.cpp)
|
2024-03-16 13:08:03 +00:00
|
|
|
target_compile_features(example PUBLIC cxx_std_14)
|
2019-10-17 23:44:10 +00:00
|
|
|
|
2024-09-25 00:43:19 +00:00
|
|
|
set_property(TARGET example PROPERTY CXX_STANDARD ${SystemC_CXX_STANDARD})
|
2021-05-13 18:26:53 +00:00
|
|
|
|
2019-10-17 23:44:10 +00:00
|
|
|
# Add the Verilated circuit to the target
|
|
|
|
verilate(example SYSTEMC COVERAGE TRACE
|
|
|
|
INCLUDE_DIRS "../make_tracing_sc"
|
2022-06-03 22:45:39 +00:00
|
|
|
VERILATOR_ARGS -f ../make_tracing_sc/input.vc -x-assign fast
|
2024-09-25 00:43:19 +00:00
|
|
|
SOURCES ../make_tracing_sc/top.v
|
|
|
|
)
|
2019-10-17 23:44:10 +00:00
|
|
|
|
|
|
|
verilator_link_systemc(example)
|