Setting up SystemC-AMS and Eclipse

SystemC-AMS is a new library that is used to model analog and mixed signal systems in addition to the traditional functionality given by systemC for modeling only digital systems. Currently, I’m using version 2.0 the beta version, which is the latest version as per now. Downloading it from the actual Acellera site was quite a hustle so I downloaded it from the COSEDA Technologies GmbH site.

So firstly,you need to extract the downloaded .zip file to your sources directory (or wherever you choose). Get into the directory where the downloaded file was saved which in my case was the sources directory in my home directory, ~/src

cd ~/src/systemc-ams-2.1 

While still in this directory, make a new directory in the /usr/local called systemc-amsbeta-01 where the installation will be made using the following command

sudo mkdir /usr/local/systemc-ams-2.1

You need to use sudo because you’re going to attempt to create a directory in a restricted area and so you absolutely need some authentication.

Then to run the configuration file which is in the downloaded files enter

./configure --prefix=/usr/local/systemc-ams-2.1/ --with-systemc=/usr/local/systemc-2.3.2/

and to make it run quicker, type

make -j5

If you get errors like memset not defined, add “#include” to the begining of the files indicated to cause the errors: sca_tdf_ltf_ss_proxy.cpp and sca_tdf_ltf_nd_proxy.cpp.
Finally install the library:

sudo make install

So now you have the new library  installed in your computer and all that is left to do is to configure it to work with eclipse, and the procedure is really simple! You just need to follow the same steps as those in the previous post on Setting up SystemC and Eclipse for C++ hardware simulation. BUT in addition to configuring the SystemC library and includes, add those of SystemC-ams as well.

To check whether the libraries have been correctly installed you can build and run this sample code for a simple TDF module implementation that produces a sine wave.


//sin_source.h
#include <systemc-ams.h>

SCA_TDF_MODULE(sin_source)
{
	sca_tdf::sca_out<double> out;

	double ampl;
	double freq;

	void set_attributes()
	{
		out.set_timestep(5, SC_US);
	}

	void processing ()
	{
		double t=out.get_time().to_seconds();
		double x = ampl * std::sin(2.0 * M_PI * freq * t);
		out.write(x);
	}

	SCA_CTOR(sin_source):
		out("out"), ampl(1.0), freq(1e3){}
};

and for the main file


//main.cpp
#include "sin_source.h"
#include <systemc-ams.h>
#include <cmath>

int sc_main (int argc, char* argv[])
{
	sca_tdf::sca_signal <double> out1;

	sin_source mySine("sine1");

	mySine.out(out1);

	sca_util::sca_trace_file *tf1= sca_create_vcd_trace_file("sine_wave");
	sca_util::sca_trace(tf1,out1,"i'm_sine_1");

	sc_core::sc_start(10, SC_MS);
	sca_util::sca_close_vcd_trace_file(tf1);

	return 0;

}

If this builds and runs correctly then voilà! your libraries are good to go.

You may now enjoy the fruits of your labor 🙂

5 responses to “Setting up SystemC-AMS and Eclipse”

  1. Paul Chaffey

    The command line above has a typo: “sudo mkdir /usr/local/systemc-amsbeta-01”

    Also in the header file: “sca_tdf::sca_out&ltdouble&lt out;” should be “sca_tdf::sca_out out;” – typical html gotcha

    This example displays a Sine wave nicely in Impulse

  2. Paul Chaffey

    hmm – my post also had the less than and greater than removed around the “double”

  3. Karibe

    Thanks Paul for pointing it out, fixed.

  4. stephen lohning

    Hi Karibe,
    I have not been able to find the source code at either the Acellera or the Fraunhofer sites, do you know where I can find the it?

    Regards
    Stephen Lohning
    M:stephen.lohning@oxnee.com

    1. Karibe

      Sorry for very late reply, I have updated the post with a working link. Thanks for heads up

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: