Skip to content

Commit

Permalink
Adding resources to build the SystemC library with Sample example.
Browse files Browse the repository at this point in the history
Adding the build script and Sample example to test the SystemC
environment.
  • Loading branch information
AmeyaVS committed Apr 3, 2016
1 parent a504244 commit b479dd0
Show file tree
Hide file tree
Showing 7 changed files with 142 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@
*.exe
*.out
*.app

# do not add temp backup files
*~
8 changes: 8 additions & 0 deletions resources/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
This folder contains resources for setting up the SystemC library on you system.

File: build.sh
This file contains commands necessary to build and install the SystemC libray on you system.
File: links.txt
This files contains resources pertaining to SystemC library from the Acellera website.
It will be updated to point to other online resources available for the SystemC library.

89 changes: 89 additions & 0 deletions resources/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#!/bin/bash

# This script will download the SystemC library from Accelera website and configure the build and build it for you.
echo "======================================================"
echo "Downloading the SystemC library from accellera website"
echo "======================================================"
wget -c http://www.accellera.org/images/downloads/standards/systemc/systemc-2.3.1.tgz

echo "======================================================"
echo "Extracting the SystemC source code"
echo "======================================================"
tar xf systemc-2.3.1.tgz

pd=$PWD

cd systemc-2.3.1

echo "======================================================"
echo "Creating build directory"
echo "======================================================"
if [ -d "objdir" ]; then
echo "!!!Directory Already Exists!!!"
else
mkdir objdir
fi

cd objdir

# Create Installation Directory
SYSTEMC=$HOME/systemcInstall
mkdir -p $HOME/systemcInstall

# Configure the SystemC library
echo "============================================================================"
echo "Configuring the SystemC library"
echo "SystemC library will be installed in $SYSTEMC"
echo "============================================================================"
../configure --prefix=$HOME/systemcInstall

# Find the Number of CPUS to utilize all the cores to build the SystemC llibrary
CPUS=`nproc`
echo "======================================================"
echo "Using $CPUS Threads to build SystemC"
echo "======================================================"

# Build the SystemC library
echo "======================================================"
echo "Building the SystemC library"
echo "======================================================"
make -j $CPUS

# Check the build SystemC library
echo "==========================================================="
echo "Checking the Built library by building examples application"
echo "==========================================================="
make check

# Do the Installation
echo "======================================================"
echo "SystemC Installation"
echo "======================================================"
make install

cd $pd

echo "====================================================================================================================================================="
echo "Please Add the contents of this SystemC.config to the end of your .bashrc file located in your $HOME folder"
echo "====================================================================================================================================================="

echo "export SYSTEMC=$SYSTEMC" > SystemC.config
echo "export SYSTEMC_HOME=\$SYSTEMC" >> SystemC.config
MACHINE_TYPE=`uname -m`
if [ ${MACHINE_TYPE} = "x86_64" ]; then
echo "export TARGET_ARCH=linux64" >> SystemC.config
else
echo "export TARGET_ARCH=linux" >> SystemC.config
fi

#if [ ${LD_LIBRARY_PATH} == "" ]; then
# echo "export LD_LIBRARY_PATH=\$SYSTEMC/lib-\$TARGET_ARCH" >> SystemC.config
#else
# echo "export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:\$SYSTEMC/lib-\$TARGET_ARCH" >> SystemC.config
#fi

echo "export LD_LIBRARY_PATH=${LD_LIBRARY_PATH:+$LD_LIBRARY_PATH:}\$SYSTEMC/lib-\$TARGET_ARCH" >> SystemC.config

echo "======================================================"
echo "Build and Installation finished"
echo "======================================================"
5 changes: 5 additions & 0 deletions resources/links.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
http://www.accellera.org/images/downloads/standards/systemc/systemc-2.3.1.tgz
http://www.accellera.org/images/downloads/standards/systemc/systemc_regressions-2.3.1.tgz
http://www.accellera.org/images/downloads/standards/systemc/SystemC_AMS_2_0_LRM.pdf
http://www.accellera.org/images/downloads/standards/systemc/scv-2.0.0.tgz

23 changes: 23 additions & 0 deletions src/01_SystemCTest/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
CXX=g++
RM= rm -rf
CXX_FLAGS= -c -g -Wall -I$(SYSTEMC)/include

LD_FLAGS= -L$(SYSTEMC)/lib-$(TARGET_ARCH) -lsystemc

SRCS_CXX= basic.cpp

OBJS_CXX= $(SRCS_CXX:.cpp=.o)

PROJECT=01_SystemCTest

all: $(PROJECT)
./$(PROJECT)

$(PROJECT): $(OBJS_CXX)
$(CXX) -o $@ $< $(LD_FLAGS)

.cpp.o:
$(CXX) $(CXX_FLAGS) $< -o $@

clean:
$(RM) $(OBJS_CXX) $(PROJECT)
8 changes: 8 additions & 0 deletions src/01_SystemCTest/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
This Sample application just checks if the Copyright information is being printed
on the console for proper configuration for building sample SystemC application.

Please add the configuration (SystemC.config) generated by the build.sh script
after the SystemC library has been built by it.

Note: Please restart your shell session or just source the .bashrc file to update
Environment variables.
6 changes: 6 additions & 0 deletions src/01_SystemCTest/basic.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include <systemc.h>

int sc_main(int argc, char *argv[]) {
return 0;
}

0 comments on commit b479dd0

Please sign in to comment.