Jump to content

Building an Executable in AMS

Recommended Posts

Hey everybody,


I'm now working with the new systemc-ams-2.1 on Linux.

I had problems to generate a correct executable.

Can I still use the following to compile a cpp file?

<user_system_prompt> g++ -I. -I/<directory_path_to_SystemC_2.3.0>/include
–I<directory_path_to_SystemC_AMS 1.0>/include -L.
–L/<directory_path_to_SystemC_2.3.0>/lib-linux -L/<directory_path_to_SystemC_AMS
1.0>/lib-linux -o sim text.cpp -lsystemc-ams -lsystemc -lm


Or do you have already written a general makefile appropriate for the use with AMS?


Thanks for answers in advance.




Share this post

Link to post
Share on other sites

The compilation command is correct except for the SystemC AMS version. You also have to check that you have chosen the appropriate lib directory for your target platform (e.g., "linux" signifies a 32-bit i686 Linux platform, "linux64" a 64-bit x86_64 Linux platform).

You can try to adapt the following Makefile snippet as a starting point:

# Compiler and linker flags

–I<directory_path_to_SystemC_AMS 2.1>/include

SYSTEMC_LIBRARY_DIRS?=–L/<directory_path_to_SystemC_2.3.0>/lib-${SYSTEMC_ARCHITECTURE} -L/<directory_path_to_SystemC_AMS 2.1>/lib-${SYSTEMC_ARCHITECTURE}


# List of all ecutables to be compiled
EXECUTABLES = sim01_tb sim02_tb

# .PHONY targets don't generate files
.PHONY:	all clean

# Default targets

# Rules defining the targets and their dependencies and how to generate
# the first from the latter.

# 1st example can be directly compiled, as it only depends on one
# CPP file and the headers of th source and the sink, which also
# include their implementation.
sim01_tb: sim01_tb.cpp source.h sink.h
	$(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $< -lsystemc-ams -lsystemc | c++filt

# 2nd example is constituted of two CPP implementation files, which have
# to be first compiled to object files before being linked. For
# big models, this is preferable, as the object files can be selectively
# updated after individual modifications.
sim02_tb: sim02_tb.o my_module.o
	$(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $^ -lsystemc-ams -lsystemc | c++filt

# GNU make knows how to compile a CPP file using compiler $(CXX) and
# the flags $(CXXFLAGS).
sim02_tb.o: sim02_tb.cpp source.h my_module.h sink.h

my_module.o: my_module.cpp my_module.h

# Clean rule to delete temporary and generated files
	rm -rf *~ *.o *.dat *.vcd *.dSYM $(EXECUTABLES)

It compiles two test benches sim01_tb and sim02_tb.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now