Skip to content

added up-to-date CRAVE with crave-layer and candy lover example #335

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
23 changes: 23 additions & 0 deletions contrib/crave/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
project ( crave2uvm )
cmake_minimum_required(VERSION 2.8)

set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/build/bin)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/build/lib)
set (CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)

#SystemC
find_package(SystemC REQUIRED)

#CRAVE
find_package(CRAVE REQUIRED)

#UVM-SystemC
find_package(UVM-SystemC REQUIRED)

#Includes setzen
include_directories (${SystemC_INCLUDE_DIRS} ${CRAVE_INCLUDE_DIRS} ${UVM_SystemC_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/src/include)

#Compiler flags
SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -g -ggdb")

add_subdirectory (examples)
45 changes: 45 additions & 0 deletions contrib/crave/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# CRAVE2UVM prototype

This projects contains a prototypical integration of CRAVE with UVM-SystemC to provide access to constrained randomization and coverage.
For demonstration, we ported the SystemVerilog example CandyLovers (UVM Tutorial for CandyLovers, see http://cluelogic.com/2011/07/uvm-tutorial-for-candy-lovers-overview/) to UVM-SystemC and included it in this distribution.

## Requirements

Make sure all pre-install requirements of CRAVE and UVM-SystemC are met:

* CMake (at least v2.8.9)
* GNU Make
* g++ (at least v4.7.2)
* SystemC (the environment variable SYSTEMC_HOME must be set accordingly)
* Boost (at least v1.50.0 and the environment variable BOOST_ROOT must be set accordingly, e.g. BOOST_ROOT=/usr)
* zlib development libraries (e.g. zlib1g-dev).

The version of CRAVE included in this distribution by default will build a minimal configuration (Glog and 2 solver backends: CUDD and SWORD).
The pre-compiled SWORD library does not work on some platforms.
In this case, the user can replace SWORD with STP by setting the environment variable CRAVE_USE_STP to ON.
If download is permitted, CRAVE can automatically download and build these backends.
Otherwise, these will be unpacked from pre-packaged archives.
Other configurations with additional backends (e.g. Boolector, Z3, CVC4, etc.) are also possible.
For more detailed instructions , please refer to the CRAVE README or contact us.

## Installation

To install and run the example, use the buildscript on the top-level of this repository. It currently executes three common tasks:

1. ./buildscript install: this will install CRAVE (shipped with this distribution) into ./crave, locally compiles UVM-SystemC into ../.. and setup the Makefile for the example "CandyLovers".

2. ./buildscript compile: this will compile the example and put the executables into build/bin.

3. ./buildscript run: this will run the CandyLovers example.

## Tested OS

This distribution has been tested on the following 64-bit Linux (x86_64) systems:

* Fedora 22 with g++-5.3.1
* Ubuntu 14.04.4 LTS with g++-4.8.4
* Debian 7.0 with g++-4.7.2

## Contact
For bug report and feedback: [email protected]

167 changes: 167 additions & 0 deletions contrib/crave/buildscript
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
#!/bin/bash

NUM_THREADS=1

install_dependencies () {
echo "Install dependencies using $NUM_THREADS thread(s)"

#SystemC
echo -n "SystemC: "
if [ -z "$SYSTEMC_HOME" ]
then
echo "NOT FOUND - Please set SYSTEMC_HOME to a valid SystemC installation"
echo -n "Type "y" to install SystemC now: "
read line
if [ "$line" = "y" ]
then
echo "Installing SystemC (or just setting the SYSTEMC_HOME variable for installation)"
if [ ! -d systemc-2.3.1 ]
then
wget http://accellera.org/images/downloads/standards/systemc/systemc-2.3.1.tgz
mv systemc-2.3.1.tgz systemc-2.3.1.tar
tar xvf systemc-2.3.1.tar
cd systemc-2.3.1
mkdir objdir
cd objdir
../configure
make
make install
cd ../..
fi
cd systemc-2.3.1
export SYSTEMC_HOME=`pwd`
cd ..
else
exit 1
fi
else
echo "found"
fi

#crave
echo -n "CRAVE: "
if [ ! -d crave ]
then
: ${CRAVE_USE_STP:=OFF}
if [ "$CRAVE_USE_STP" = "ON" ]; then
CRAVE_DEPS_ARCHIVE=crave_package_deps_stp.tar.gz
export CRAVE_SOLVERS='cudd stp'
else
CRAVE_DEPS_ARCHIVE=crave_package_deps.tar.gz
export CRAVE_SOLVERS='cudd sword'
fi
echo "install"
CRAVE_ARCHIVE=`ls ./crave-*.tar.gz -t | head -1`
echo "Extract CRAVE from $CRAVE_ARCHIVE"
tar -xzf $CRAVE_ARCHIVE
CRAVE_DIR=`basename $CRAVE_ARCHIVE .tar.gz`
mv $CRAVE_DIR crave
cd crave
echo -n "Type "y" to install CRAVE in offline mode, anything else for online mode. "
echo -n "Make sure "$CRAVE_DEPS_ARCHIVE" is in "contrib/crave" in case of offline build: "
read line
if [ "$line" = "y" ]
then
echo "Build CRAVE offline using $NUM_THREADS thread(s)"
cp ../$CRAVE_DEPS_ARCHIVE crave_package_deps.tar.gz
if ! CRAVE_OFFLINE_BUILD=ON make -j $NUM_THREADS; then
echo "Building CRAVE failed. Please see above for error"
exit 3
fi
else
echo "Build CRAVE online using $NUM_THREADS thread(s)"
if ! make -j $NUM_THREADS; then
echo "Building CRAVE failed. Please see above for error"
exit 3
fi
fi
make install -j $NUM_THREADS
cd ..
else
echo "found"
fi

#uvm-systemc
echo -n "uvm-systemc-1.0-alpha1: "
if [ ! -d ../../include ]
then
echo "install"
cd ../..
#sudo apt-get install automake autoconf libtool
config/bootstrap
mkdir objdir
cd objdir
../configure --enable-debug
echo "Build UVM-SystemC using $NUM_THREADS thread(s)"
make -j $NUM_THREADS
make install -j $NUM_THREADS
cd ..
#rm -rf objdir
cd contrib/crave
else
echo "found"
fi

}

if [ "$1" = '' ]
then
echo " Usage: ./buildscript <task> [Options]"
echo " Tasks: "
echo -e " install [-j n]\t - Install the CandyLovers example and all dependencies"
echo -e " compile [-j n]\t - (Re)compile the example after changes (You may use -j n to be faster with make)"
echo -e " run \t - Run the CandyLovers example"
echo -e " tarball \t - Create a tarball of the repository"
else
if [ "$2" == "-j" ]
then
case $3 in
''|*[!0-9]*) ;;
*) NUM_THREADS=$3 ;;
esac
fi
case "$1" in
install)
install_dependencies
if [ -d build ]
then
rm -r build
fi
mkdir build
cd build
cmake -G "Unix Makefiles" ..
cd ..
;;
compile)
cd build
make -j $NUM_THREADS
cd ..
;;
run)
build/bin/CandyLovers
;;
tarball)
name_date=crave2uvm_$(date +"%Y%m%d_%H%M")
name=contrib/crave
mkdir -p $name
mkdir -p $name/cmake
mkdir -p $name/examples
mkdir -p $name/src
mkdir -p $name/presentation

cp -R cmake/* $name/cmake
cp -R examples/* $name/examples
cp -R src/* $name/src
cp presentation/UVM-CRAVE.pdf $name/presentation/UVM-CRAVE.pdf
cp CMakeLists.txt $name/CMakeLists.txt
CRAVE_ARCHIVE=`ls crave-*.tar.gz -t | head -1`
cp $CRAVE_ARCHIVE $name/$CRAVE_ARCHIVE
cp crave_package_deps*.tar.gz $name
cp buildscript $name/buildscript
cp README.md $name/README.md

tar -cvzf $name_date.tar.gz $name
rm -r $name
;;
esac
fi
29 changes: 29 additions & 0 deletions contrib/crave/cmake/FindCRAVE.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#______________________________________________________________________________
#
# This CMake package creates a CRAVE target with all its dependencies
#______________________________________________________________________________
#
# CRAVE_FOUND - system has CRAVE
# CRAVE_INCLUDE_DIRS - the CRAVE include directory and include directories of all dependencies
# CRAVE_LIBRARIES - Link these to use CRAVE. Contains CRAVE and dependencies

SET(crave_DIR ${PROJECT_SOURCE_DIR}/crave/build/root/share/crave/)
find_package(crave QUIET)
IF(crave_FOUND)
SET(CRAVE_FOUND TRUE)
SET(CRAVE_INCLUDE_DIRS ${crave_INCLUDE_DIR})
SET(CRAVE_LIBRARIES ${crave_LIBRARIES})
ENDIF()

IF(CRAVE_FOUND)
IF(NOT CRAVE_FIND_QUIETLY)
MESSAGE(STATUS "Found CRAVE: ${CRAVE_LIBRARIES}")
ENDIF(NOT CRAVE_FIND_QUIETLY)
ELSE(CRAVE_FOUND)
IF(CRAVE_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find CRAVE")
ENDIF(CRAVE_FIND_REQUIRED)
ENDIF(CRAVE_FOUND)

MARK_AS_ADVANCED(CRAVE_INCLUDE_DIRS CRAVE_LIBRARIES)

55 changes: 55 additions & 0 deletions contrib/crave/cmake/FindSystemC.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#______________________________________________________________________________
#
# This CMake package creates a SystemC target
#______________________________________________________________________________
#
# SystemC_FOUND - system has SystemC
# SystemC_INCLUDE_DIRS - the SystemC include directory
# SystemC_LIBRARIES - Link these to use SystemC

IF(SystemC_LIBRARIES AND SystemC_INCLUDE_DIRS)
SET(SystemC_FOUND TRUE)
ELSE(SystemC_LIBRARIES AND SystemC_INCLUDE_DIRS)
FIND_PATH(SystemC_INCLUDE_DIR
HINTS
${SYSTEMC_HOME}/include
$ENV{SYSTEMC_HOME}/include
NAMES
systemc.h
)

FIND_LIBRARY(SystemC_LIBRARY
HINTS
${SYSTEMC_HOME}/lib
${SYSTEMC_HOME}/lib-linux
${SYSTEMC_HOME}/lib-linux64
${SYSTEMC_HOME}/lib-macos
$ENV{SYSTEMC_HOME}/lib
$ENV{SYSTEMC_HOME}/lib-linux
$ENV{SYSTEMC_HOME}/lib-linux64
$ENV{SYSTEMC_HOME}/lib-macos
NAMES
libsystemc.a
)

SET(SystemC_INCLUDE_DIRS ${SystemC_INCLUDE_DIR})
SET(SystemC_LIBRARIES ${SystemC_LIBRARY})

IF(SystemC_INCLUDE_DIRS AND SystemC_LIBRARIES)
SET(SystemC_FOUND TRUE)
ENDIF(SystemC_INCLUDE_DIRS AND SystemC_LIBRARIES)

IF(SystemC_FOUND)
IF(NOT SystemC_FIND_QUIETLY)
MESSAGE(STATUS "Found SystemC: ${SystemC_LIBRARIES}")
ENDIF(NOT SystemC_FIND_QUIETLY)
ELSE(SystemC_FOUND)
IF(SystemC_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find SystemC")
ENDIF(SystemC_FIND_REQUIRED)
ENDIF(SystemC_FOUND)

# show the SystemC_INCLUDE_DIRS and SystemC_LIBRARIES variables only in the advanced view
MARK_AS_ADVANCED(SystemC_INCLUDE_DIRS SystemC_LIBRARIES)

ENDIF(SystemC_LIBRARIES AND SystemC_INCLUDE_DIRS)
51 changes: 51 additions & 0 deletions contrib/crave/cmake/FindUVM-SystemC.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#______________________________________________________________________________
#
# This CMake package creates a UVM-SystemC target
#______________________________________________________________________________
#
# UVM_SystemC_FOUND - system has UVM-SystemC
# UVM_SystemC_INCLUDE_DIRS - the UVM-SystemC include directory
# UVM_SystemC_LIBRARIES - Link these to use UVM-SystemC

SET(UVM_SYSTEMC_HOME ${PROJECT_SOURCE_DIR}/../../)

IF(UVM_SystemC_LIBRARIES AND UVM_SystemC_INCLUDE_DIRS)
SET(UVM_SystemC_FOUND TRUE)
ELSE(UVM_SystemC_LIBRARIES AND UVM_SystemC_INCLUDE_DIRS)
FIND_PATH(UVM_SystemC_INCLUDE_DIR
HINTS
${UVM_SYSTEMC_HOME}/include
NAMES
uvm.h
)

FIND_LIBRARY(UVM_SystemC_LIBRARY
HINTS
${UVM_SYSTEMC_HOME}/lib
${UVM_SYSTEMC_HOME}/lib-linux
${UVM_SYSTEMC_HOME}/lib-linux64
${UVM_SYSTEMC_HOME}/lib-macos
NAMES
libuvm-systemc.a
)

SET(UVM_SystemC_INCLUDE_DIRS ${UVM_SystemC_INCLUDE_DIR})
SET(UVM_SystemC_LIBRARIES ${UVM_SystemC_LIBRARY})

IF(UVM_SystemC_INCLUDE_DIRS AND UVM_SystemC_LIBRARIES)
SET(UVM_SystemC_FOUND TRUE)
ENDIF(UVM_SystemC_INCLUDE_DIRS AND UVM_SystemC_LIBRARIES)

IF(UVM_SystemC_FOUND)
IF(NOT UVM_SystemC_FIND_QUIETLY)
MESSAGE(STATUS "Found UVM_SystemC: ${UVM_SystemC_LIBRARIES}")
ENDIF(NOT UVM_SystemC_FIND_QUIETLY)
ELSE(UVM_SystemC_FOUND)
IF(UVM_SystemC_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find UVM_SystemC")
ENDIF(UVM_SystemC_FIND_REQUIRED)
ENDIF(UVM_SystemC_FOUND)

MARK_AS_ADVANCED(UVM_SystemC_INCLUDE_DIRS UVM_SystemC_LIBRARIES)

ENDIF(UVM_SystemC_LIBRARIES AND UVM_SystemC_INCLUDE_DIRS)
Binary file added contrib/crave/crave-2017-03-09.tar.gz
Binary file not shown.
Binary file added contrib/crave/crave_package_deps.tar.gz
Binary file not shown.
Binary file added contrib/crave/crave_package_deps_stp.tar.gz
Binary file not shown.
1 change: 1 addition & 0 deletions contrib/crave/examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add_subdirectory(CandyLovers)
5 changes: 5 additions & 0 deletions contrib/crave/examples/CandyLovers/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
add_definitions(-std=c++11)

add_executable(CandyLovers sc_main.cpp verification/subscribers/jelly_bean_sb_subscriber.cpp verification/subscribers/jelly_bean_scoreboard.cpp verification/subscribers/jelly_bean_fc_subscriber.cpp)
target_link_libraries(CandyLovers ${SystemC_LIBRARIES} ${CRAVE_LIBRARIES}
${UVM_SystemC_LIBRARIES} ${SystemC_LIBRARIES})
Loading