Coder Social home page Coder Social logo

accellera-official / systemc Goto Github PK

View Code? Open in Web Editor NEW
447.0 45.0 142.0 80.33 MB

SystemC Reference Implementation

Home Page: https://systemc.org/overview/systemc/

License: Apache License 2.0

CMake 0.62% Makefile 0.19% M4 0.31% Shell 0.15% C++ 78.23% C 18.28% Assembly 1.00% Awk 0.03% Dockerfile 0.01% Python 0.21% Perl 0.79% Batchfile 0.05% Fortran 0.13% Forth 0.01%
cpp systemc tlm

systemc's People

Contributors

andreashedstrom-intel avatar andrewgoodrich avatar aut0 avatar barnasc avatar basarts avatar dcblack avatar e6danielhuawei avatar eactor avatar einwich avatar frdoucet avatar guillaumeaudeon avatar hz-hz avatar jeromecornetst avatar joshualandau-arm avatar lmailletcontoz avatar maehne avatar markfoodyburton avatar mohamed avatar pah avatar paulfloyd avatar peterdejager-github avatar ralphg avatar richardxia avatar ripopov avatar schulzst avatar sonalpoddar avatar twieman avatar uhle avatar veeyceey avatar voertler avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

systemc's Issues

problems with RAII in C++ >= 11

I have a project in work where we manage some objects using fifo and because systemc API does not support move operations there is a problem with expensive and/or move-only objects.

Currently the issue is resolved by very ugly code like:

// producer place
fifo.write(new T(...));

// consumer place
auto ptr = fifo.read();
// use ptr...
delete ptr;

I would like to avoid pointer/lifetime issues yet I know that API is designed only with C++98/03 in mind. So I tried to use smart pointers which should keep any resources correctly managed.

I have made a reproducible example based on http://learnsystemc.com/basic/channel_fifo which showcases leaks - 4 objects remain even though I used only smart pointers:

#include <systemc>
#include <memory>
#include <utility>
using namespace sc_core;
using std::cout;

class blabber
{
public:
	blabber(int x): x(x)
	{
		cout << "ctor: " << x << "\n";
		++instances;
	}

	blabber(const blabber& other)
	: x(other.x)
	{
		cout << "copy ctor: " << x << "\n";
		++instances;
	}
	
	blabber(blabber&& other) noexcept
	: x(std::exchange(other.x, -1))
	{
		cout << "move ctor: " << x << "\n";
		++instances;
	}
	
	blabber& operator=(blabber other) noexcept
	{
		std::swap(x, other.x);
		cout << "assignment: " << x << "\n";
		return *this;
	}
	
	~blabber()
	{
		cout << "dtor: " << x << "\n";
		--instances;
	}

	operator int() { return x; }
	
	static int get_num_instances() { return instances; }
	
private:
	int x = -1;
	static int instances;
};

int blabber::instances = 0;

SC_MODULE(FIFO) {
	sc_fifo<std::shared_ptr<blabber>> f1, f2, f3;
	SC_CTOR(FIFO) : f1(2), f2(2), f3(2) { // fifo with size 2
		SC_THREAD(generator1);
		SC_THREAD(consumer1);

		SC_THREAD(generator2);
		SC_THREAD(consumer2);

		SC_THREAD(generator3);
		SC_THREAD(consumer3);
	}
	void generator1() { // blocking write
		int v = 10;
		while (true) {
			f1.write(std::make_shared<blabber>(v)); // same as f = v, which is not recommended.
			std::cout << sc_time_stamp() << ": generator1 writes " << v++ << std::endl;
			wait(1, SC_SEC); // write every 1 s
		}
	}
	void consumer1() { // blocking read
		while (true) {
			auto ptr = f1.read();
			std::cout << sc_time_stamp() << ": consumer1 reads " << *ptr << std::endl;
			wait(3, SC_SEC); // read every 3 s, fifo will fill up soon
		}
	}
	void generator2() { // non-blocking write
		int v = 20;
		while (true) {
			auto ptr = std::make_shared<blabber>(v);
			while (f2.nb_write(ptr) == false ) { // nb write until succeeded
				wait(f2.data_read_event()); // if not successful, wait for data read (a fifo slot becomes available)
			}
			std::cout << sc_time_stamp() << ": generator2 writes " << v++ << std::endl;
			wait(1, SC_SEC); // write every 1 s
		}
	}
	void consumer2() { // non-blocking read
		while (true) {
			std::shared_ptr<blabber> ptr;
			while (f2.nb_read(ptr) == false) {
				wait(f2.data_written_event());
			}
			std::cout << sc_time_stamp() << ": consumer2 reads " << *ptr << std::endl;
			wait(3, SC_SEC); // read every 3 s, fifo will fill up soon
		}
	}
	void generator3() { // free/available slots before/after write
		int v = 30;
		while (true) {
			std::cout << sc_time_stamp() << ": generator3, before write, #free/#available=" << f3.num_free() << "/" << f3.num_available() << std::endl;
			f3.write(std::make_shared<blabber>(v++));
			std::cout << sc_time_stamp() << ": generator3, after write, #free/#available=" << f3.num_free() << "/" << f3.num_available() << std::endl;
			wait(1, SC_SEC);
		}
	}
	void consumer3() { // free/available slots before/after read
		while (true) {
			std::cout << sc_time_stamp() << ": consumer3, before read, #free/#available=" << f3.num_free() << "/" << f3.num_available() << std::endl;
			auto ptr = f3.read();
			std::cout << sc_time_stamp() << ": consumer3, after read, #free/#available=" << f3.num_free() << "/" << f3.num_available() << std::endl;
			wait(3, SC_SEC); // read every 3 s, fifo will fill up soon
		}
	}
};

int sc_main(int, char*[]) {
	{
		FIFO fifo("fifo");
		sc_start(10, SC_SEC);
	}
	
	cout << "instances: " << blabber::get_num_instances() << "\n";
	return 0;
}

execution log:


        SystemC 2.3.4_pub_rev_20191203-Accellera --- Mar  7 2022 16:00:29
        Copyright (c) 1996-2019 by all Contributors,
        ALL RIGHTS RESERVED
ctor: 10
0 s: generator1 writes 10
ctor: 20
0 s: generator2 writes 20
0 s: generator3, before write, #free/#available=2/0
ctor: 30
0 s: generator3, after write, #free/#available=1/0
0 s: consumer3, before read, #free/#available=1/0
0 s: consumer1 reads 10
0 s: consumer2 reads 20
0 s: consumer3, after read, #free/#available=1/0
ctor: 11
1 s: generator1 writes 11
ctor: 21
1 s: generator2 writes 21
1 s: generator3, before write, #free/#available=2/0
ctor: 31
1 s: generator3, after write, #free/#available=1/0
ctor: 12
2 s: generator1 writes 12
ctor: 22
2 s: generator2 writes 22
2 s: generator3, before write, #free/#available=1/1
ctor: 32
2 s: generator3, after write, #free/#available=0/1
dtor: 30
3 s: consumer3, before read, #free/#available=0/2
3 s: consumer3, after read, #free/#available=0/1
3 s: generator3, before write, #free/#available=0/1
ctor: 33
ctor: 23
ctor: 13
dtor: 10
3 s: consumer1 reads 11
dtor: 20
3 s: consumer2 reads 21
3 s: generator3, after write, #free/#available=0/1
3 s: generator1 writes 13
3 s: generator2 writes 23
4 s: generator3, before write, #free/#available=0/2
ctor: 34
ctor: 14
ctor: 24
dtor: 11
6 s: consumer1 reads 12
dtor: 31
6 s: consumer3, before read, #free/#available=0/2
6 s: consumer3, after read, #free/#available=0/1
dtor: 21
6 s: consumer2 reads 22
6 s: generator1 writes 14
6 s: generator3, after write, #free/#available=0/1
6 s: generator2 writes 24
ctor: 15
7 s: generator3, before write, #free/#available=0/2
ctor: 35
ctor: 25
dtor: 32
9 s: consumer3, before read, #free/#available=0/2
9 s: consumer3, after read, #free/#available=0/1
dtor: 12
9 s: consumer1 reads 13
dtor: 22
9 s: consumer2 reads 23
9 s: generator3, after write, #free/#available=0/1
9 s: generator1 writes 15
9 s: generator2 writes 25
dtor: 35
dtor: 34
dtor: 24
dtor: 15
dtor: 14
instances: 4

Using GCC Ubuntu 9.4.0-1ubuntu1~20.04.1

How to link systemc with CMake?

There is no include directory in the project, so my hello world demo in another directory can't find header files using CMake. How do l link systemc with CMake in other directory.

Tests fail to run with: string sub-command REGEX, mode REPLACE needs at least 6 arguments total to command

Build is fine once inclusion of qt.h is fixed, but all tests fail, almost all identically with run_test.cmake:104 (string): string sub-command REGEX, mode REPLACE needs at least 6 arguments total to command:

Start testing: Jun 19 02:44 MYT
----------------------------------------------------------
1/33 Testing: examples/sysc/2.1/dpipe/dpipe
1/33 Test: examples/sysc/2.1/dpipe/dpipe
Command: "/opt/local/bin/cmake" "-DTEST_EXE=/opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_systemc/systemc/work/build/examples/sysc/2.1/dpipe/dpipe" "-DTEST_DIR=/opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_systemc/systemc/work/build/examples/sysc/2.1/dpipe" "-DTEST_INPUT=" "-DTEST_GOLDEN=/opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_systemc/systemc/work/systemc-2.3.4/examples/sysc/2.1/dpipe/golden.log" "-DTEST_FILTER=" "-DDIFF_COMMAND=/usr/bin/diff" "-DDIFF_OPTIONS=-u" "-P" "/opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_systemc/systemc/work/systemc-2.3.4/cmake/run_test.cmake"
Directory: /opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_systemc/systemc/work/build/examples/sysc/2.1/dpipe
"examples/sysc/2.1/dpipe/dpipe" start time: Jun 19 02:44 MYT
Output:
----------------------------------------------------------
CMake Deprecation Warning at /opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_systemc/systemc/work/systemc-2.3.4/cmake/run_test.cmake:41 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


CMake Error at /opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_systemc/systemc/work/systemc-2.3.4/cmake/run_test.cmake:104 (string):
  string sub-command REGEX, mode REPLACE needs at least 6 arguments total to
  command.


<end of output>
Test time =   0.24 sec
----------------------------------------------------------
Test Failed.
"examples/sysc/2.1/dpipe/dpipe" end time: Jun 19 02:44 MYT
"examples/sysc/2.1/dpipe/dpipe" time elapsed: 00:00:00
----------------------------------------------------------

2/33 Testing: examples/sysc/2.1/forkjoin/forkjoin
2/33 Test: examples/sysc/2.1/forkjoin/forkjoin
Command: "/opt/local/bin/cmake" "-DTEST_EXE=/opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_systemc/systemc/work/build/examples/sysc/2.1/forkjoin/forkjoin" "-DTEST_DIR=/opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_systemc/systemc/work/build/examples/sysc/2.1/forkjoin" "-DTEST_INPUT=" "-DTEST_GOLDEN=/opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_systemc/systemc/work/systemc-2.3.4/examples/sysc/2.1/forkjoin/golden.log" "-DTEST_FILTER=" "-DDIFF_COMMAND=/usr/bin/diff" "-DDIFF_OPTIONS=-u" "-P" "/opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_systemc/systemc/work/systemc-2.3.4/cmake/run_test.cmake"
Directory: /opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_systemc/systemc/work/build/examples/sysc/2.1/forkjoin
"examples/sysc/2.1/forkjoin/forkjoin" start time: Jun 19 02:44 MYT
Output:
----------------------------------------------------------
CMake Deprecation Warning at /opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_systemc/systemc/work/systemc-2.3.4/cmake/run_test.cmake:41 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


CMake Error at /opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_systemc/systemc/work/systemc-2.3.4/cmake/run_test.cmake:104 (string):
  string sub-command REGEX, mode REPLACE needs at least 6 arguments total to
  command.


<end of output>
Test time =   0.21 sec
----------------------------------------------------------
Test Failed.
"examples/sysc/2.1/forkjoin/forkjoin" end time: Jun 19 02:44 MYT
"examples/sysc/2.1/forkjoin/forkjoin" time elapsed: 00:00:00
----------------------------------------------------------
. . .
28/33 Testing: examples/tlm/at_ooo/at_ooo
28/33 Test: examples/tlm/at_ooo/at_ooo
Command: "/opt/local/bin/cmake" "-DTEST_EXE=/opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_systemc/systemc/work/build/examples/tlm/at_ooo/at_ooo" "-DTEST_DIR=/opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_systemc/systemc/work/build/examples/tlm/at_ooo" "-DTEST_INPUT=" "-DTEST_GOLDEN=/opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_systemc/systemc/work/systemc-2.3.4/examples/tlm/at_ooo/results/expected.log" "-DTEST_FILTER=" "-DDIFF_COMMAND=/usr/bin/diff" "-DDIFF_OPTIONS=-u" "-P" "/opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_systemc/systemc/work/systemc-2.3.4/cmake/run_test.cmake"
Directory: /opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_systemc/systemc/work/build/examples/tlm/at_ooo
"examples/tlm/at_ooo/at_ooo" start time: Jun 19 02:44 MYT
Output:
----------------------------------------------------------
CMake Deprecation Warning at /opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_systemc/systemc/work/systemc-2.3.4/cmake/run_test.cmake:41 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


CMake Error at /opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_systemc/systemc/work/systemc-2.3.4/cmake/run_test.cmake:104 (string):
  string sub-command REGEX, mode REPLACE needs at least 6 arguments total to
  command.


<end of output>
Test time =   0.21 sec
----------------------------------------------------------
Test Failed.
"examples/tlm/at_ooo/at_ooo" end time: Jun 19 02:44 MYT
"examples/tlm/at_ooo/at_ooo" time elapsed: 00:00:00
----------------------------------------------------------

29/33 Testing: examples/tlm/lt/lt
29/33 Test: examples/tlm/lt/lt
Command: "/opt/local/bin/cmake" "-DTEST_EXE=/opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_systemc/systemc/work/build/examples/tlm/lt/lt" "-DTEST_DIR=/opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_systemc/systemc/work/build/examples/tlm/lt" "-DTEST_INPUT=" "-DTEST_GOLDEN=/opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_systemc/systemc/work/systemc-2.3.4/examples/tlm/lt/results/expected.log" "-DTEST_FILTER=" "-DDIFF_COMMAND=/usr/bin/diff" "-DDIFF_OPTIONS=-u" "-P" "/opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_systemc/systemc/work/systemc-2.3.4/cmake/run_test.cmake"
Directory: /opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_systemc/systemc/work/build/examples/tlm/lt
"examples/tlm/lt/lt" start time: Jun 19 02:44 MYT
Output:
----------------------------------------------------------
CMake Deprecation Warning at /opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_systemc/systemc/work/systemc-2.3.4/cmake/run_test.cmake:41 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


CMake Error at /opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_systemc/systemc/work/systemc-2.3.4/cmake/run_test.cmake:104 (string):
  string sub-command REGEX, mode REPLACE needs at least 6 arguments total to
  command.


<end of output>
Test time =   0.23 sec
----------------------------------------------------------
Test Failed.
"examples/tlm/lt/lt" end time: Jun 19 02:44 MYT
"examples/tlm/lt/lt" time elapsed: 00:00:00
----------------------------------------------------------

30/33 Testing: examples/tlm/lt_dmi/lt_dmi
30/33 Test: examples/tlm/lt_dmi/lt_dmi
Command: "/opt/local/bin/cmake" "-DTEST_EXE=/opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_systemc/systemc/work/build/examples/tlm/lt_dmi/lt_dmi" "-DTEST_DIR=/opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_systemc/systemc/work/build/examples/tlm/lt_dmi" "-DTEST_INPUT=" "-DTEST_GOLDEN=/opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_systemc/systemc/work/systemc-2.3.4/examples/tlm/lt_dmi/results/expected.log" "-DTEST_FILTER=" "-DDIFF_COMMAND=/usr/bin/diff" "-DDIFF_OPTIONS=-u" "-P" "/opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_systemc/systemc/work/systemc-2.3.4/cmake/run_test.cmake"
Directory: /opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_systemc/systemc/work/build/examples/tlm/lt_dmi
"examples/tlm/lt_dmi/lt_dmi" start time: Jun 19 02:44 MYT
Output:
----------------------------------------------------------
CMake Deprecation Warning at /opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_systemc/systemc/work/systemc-2.3.4/cmake/run_test.cmake:41 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


CMake Error at /opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_systemc/systemc/work/systemc-2.3.4/cmake/run_test.cmake:104 (string):
  string sub-command REGEX, mode REPLACE needs at least 6 arguments total to
  command.


<end of output>
Test time =   0.21 sec
----------------------------------------------------------
Test Failed.
"examples/tlm/lt_dmi/lt_dmi" end time: Jun 19 02:44 MYT
"examples/tlm/lt_dmi/lt_dmi" time elapsed: 00:00:00
----------------------------------------------------------

31/33 Testing: examples/tlm/lt_extension_mandatory/lt_extension_mandatory
31/33 Test: examples/tlm/lt_extension_mandatory/lt_extension_mandatory
Command: "/opt/local/bin/cmake" "-DTEST_EXE=/opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_systemc/systemc/work/build/examples/tlm/lt_extension_mandatory/lt_extension_mandatory" "-DTEST_DIR=/opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_systemc/systemc/work/build/examples/tlm/lt_extension_mandatory" "-DTEST_INPUT=" "-DTEST_GOLDEN=/opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_systemc/systemc/work/systemc-2.3.4/examples/tlm/lt_extension_mandatory/results/expected.log" "-DTEST_FILTER=" "-DDIFF_COMMAND=/usr/bin/diff" "-DDIFF_OPTIONS=-u" "-P" "/opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_systemc/systemc/work/systemc-2.3.4/cmake/run_test.cmake"
Directory: /opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_systemc/systemc/work/build/examples/tlm/lt_extension_mandatory
"examples/tlm/lt_extension_mandatory/lt_extension_mandatory" start time: Jun 19 02:44 MYT
Output:
----------------------------------------------------------
CMake Deprecation Warning at /opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_systemc/systemc/work/systemc-2.3.4/cmake/run_test.cmake:41 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


CMake Error at /opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_systemc/systemc/work/systemc-2.3.4/cmake/run_test.cmake:104 (string):
  string sub-command REGEX, mode REPLACE needs at least 6 arguments total to
  command.


<end of output>
Test time =   0.23 sec
----------------------------------------------------------
Test Failed.
"examples/tlm/lt_extension_mandatory/lt_extension_mandatory" end time: Jun 19 02:44 MYT
"examples/tlm/lt_extension_mandatory/lt_extension_mandatory" time elapsed: 00:00:00
----------------------------------------------------------

32/33 Testing: examples/tlm/lt_mixed_endian/lt_mixed_endian
32/33 Test: examples/tlm/lt_mixed_endian/lt_mixed_endian
Command: "/opt/local/bin/cmake" "-DTEST_EXE=/opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_systemc/systemc/work/build/examples/tlm/lt_mixed_endian/lt_mixed_endian" "-DTEST_DIR=/opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_systemc/systemc/work/build/examples/tlm/lt_mixed_endian" "-DTEST_INPUT=/opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_systemc/systemc/work/systemc-2.3.4/examples/tlm/lt_mixed_endian/results/input.txt" "-DTEST_GOLDEN=/opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_systemc/systemc/work/systemc-2.3.4/examples/tlm/lt_mixed_endian/results/expected.log" "-DTEST_FILTER=::" "-DDIFF_COMMAND=/usr/bin/diff" "-DDIFF_OPTIONS=-u" "-P" "/opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_systemc/systemc/work/systemc-2.3.4/cmake/run_test.cmake"
Directory: /opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_systemc/systemc/work/build/examples/tlm/lt_mixed_endian
"examples/tlm/lt_mixed_endian/lt_mixed_endian" start time: Jun 19 02:44 MYT
Output:
----------------------------------------------------------
CMake Deprecation Warning at /opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_systemc/systemc/work/systemc-2.3.4/cmake/run_test.cmake:41 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


DIFF_EXIT_CODE = 1
CMake Error at /opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_systemc/systemc/work/systemc-2.3.4/cmake/run_test.cmake:128 (message):
  ***ERROR:

  --- run_trimmed.log	2023-06-19 02:44:29.000000000 +0800

  +++ expected_trimmed.log	2023-06-19 02:44:29.000000000 +0800

  @@ -1 +1,96 @@

  -

  +101 BE32 :: cmd: s8 0 0 1 2 3 4 5 6 7

  +101 BE32 :: write transaction length 8 (10) x 8-bit completed

  +101 BE32 :: cmd: l8 0 8

  +101 BE32 :: read transaction length 8 (10) x 8-bit completed, returning:

  +101 BE32 :: 0 1 2 3 4 5 6 7

  +101 BE32 :: cmd: l8 1 7

  +101 BE32 :: read transaction length 7 (10) x 8-bit completed, returning:

  +101 BE32 :: 1 2 3 4 5 6 7

  +101 BE32 :: cmd: l8 5 3

  +101 BE32 :: read transaction length 3 (10) x 8-bit completed, returning:

  +101 BE32 :: 5 6 7

  +101 BE32 :: cmd: l16 0 4

  +101 BE32 :: read transaction length 4 (10) x 16-bit completed, returning:

  +101 BE32 :: 1 203 405 607

  +101 BE32 :: cmd: l16 2 3

  +101 BE32 :: read transaction length 3 (10) x 16-bit completed, returning:

  +101 BE32 :: 203 405 607

  +101 BE32 :: cmd: l16 4 1

  +101 BE32 :: read transaction length 1 (10) x 16-bit completed, returning:

  +101 BE32 :: 405

  +101 BE32 :: cmd: l32 0 2

  +101 BE32 :: read transaction length 2 (10) x 32-bit completed, returning:

  +101 BE32 :: 10203 4050607

  +101 BE32 :: cmd: l32 4 1

  +101 BE32 :: read transaction length 1 (10) x 32-bit completed, returning:

  +101 BE32 :: 4050607

  +102 LE32 :: cmd: s8 0 0 1 2 3 4 5 6 7

  +102 LE32 :: write transaction length 8 (10) x 8-bit completed

  +102 LE32 :: cmd: l8 0 8

  +102 LE32 :: read transaction length 8 (10) x 8-bit completed, returning:

  +102 LE32 :: 0 1 2 3 4 5 6 7

  +102 LE32 :: cmd: l8 1 7

  +102 LE32 :: read transaction length 7 (10) x 8-bit completed, returning:

  +102 LE32 :: 1 2 3 4 5 6 7

  +102 LE32 :: cmd: l8 5 3

  +102 LE32 :: read transaction length 3 (10) x 8-bit completed, returning:

  +102 LE32 :: 5 6 7

  +102 LE32 :: cmd: l16 0 4

  +102 LE32 :: read transaction length 4 (10) x 16-bit completed, returning:

  +102 LE32 :: 100 302 504 706

  +102 LE32 :: cmd: l16 2 3

  +102 LE32 :: read transaction length 3 (10) x 16-bit completed, returning:

  +102 LE32 :: 302 504 706

  +102 LE32 :: cmd: l16 4 1

  +102 LE32 :: read transaction length 1 (10) x 16-bit completed, returning:

  +102 LE32 :: 504

  +102 LE32 :: cmd: l32 0 2

  +102 LE32 :: read transaction length 2 (10) x 32-bit completed, returning:

  +102 LE32 :: 3020100 7060504

  +102 LE32 :: cmd: l32 4 1

  +102 LE32 :: read transaction length 1 (10) x 32-bit completed, returning:

  +102 LE32 :: 7060504

  +101 BE32 :: cmd: l8 0 8

  +101 BE32 :: read transaction length 8 (10) x 8-bit completed, returning:

  +101 BE32 :: 3 2 1 0 7 6 5 4

  +101 BE32 :: cmd: l8 1 7

  +101 BE32 :: read transaction length 7 (10) x 8-bit completed, returning:

  +101 BE32 :: 2 1 0 7 6 5 4

  +101 BE32 :: cmd: l8 5 3

  +101 BE32 :: read transaction length 3 (10) x 8-bit completed, returning:

  +101 BE32 :: 6 5 4

  +101 BE32 :: cmd: l16 0 4

  +101 BE32 :: read transaction length 4 (10) x 16-bit completed, returning:

  +101 BE32 :: 302 100 706 504

  +101 BE32 :: cmd: l16 2 3

  +101 BE32 :: read transaction length 3 (10) x 16-bit completed, returning:

  +101 BE32 :: 100 706 504

  +101 BE32 :: cmd: l32 0 2

  +101 BE32 :: read transaction length 2 (10) x 32-bit completed, returning:

  +101 BE32 :: 3020100 7060504

  +101 BE32 :: cmd: l32 4 1

  +101 BE32 :: read transaction length 1 (10) x 32-bit completed, returning:

  +101 BE32 :: 7060504

  +101 BE32 :: cmd: s32 20 13579bdf

  +101 BE32 :: write transaction length 1 (10) x 32-bit completed

  +102 LE32 :: cmd: l32 20 1

  +102 LE32 :: read transaction length 1 (10) x 32-bit completed, returning:

  +102 LE32 :: 13579bdf

  +102 LE32 :: cmd: s32 30 00000000

  +102 LE32 :: write transaction length 1 (10) x 32-bit completed

  +102 LE32 :: cmd: s16 30 ea62

  +102 LE32 :: write transaction length 1 (10) x 16-bit completed

  +101 BE32 :: cmd: l16 30 1

  +101 BE32 :: read transaction length 1 (10) x 16-bit completed, returning:

  +101 BE32 :: 0

  +101 BE32 :: cmd: l16 32 1

  +101 BE32 :: read transaction length 1 (10) x 16-bit completed, returning:

  +101 BE32 :: ea62

  +101 BE32 :: cmd: s8 42 5a

  +101 BE32 :: write transaction length 1 (10) x 8-bit completed

  +102 LE32 :: cmd: l8 42 1

  +102 LE32 :: read transaction length 1 (10) x 8-bit completed, returning:

  +102 LE32 :: 0

  +102 LE32 :: cmd: l8 41 1

  +102 LE32 :: read transaction length 1 (10) x 8-bit completed, returning:

  +102 LE32 :: 5a



<end of output>
Test time =   0.23 sec
----------------------------------------------------------
Test Failed.
"examples/tlm/lt_mixed_endian/lt_mixed_endian" end time: Jun 19 02:44 MYT
"examples/tlm/lt_mixed_endian/lt_mixed_endian" time elapsed: 00:00:00
----------------------------------------------------------

33/33 Testing: examples/tlm/lt_temporal_decouple/lt_temporal_decouple
33/33 Test: examples/tlm/lt_temporal_decouple/lt_temporal_decouple
Command: "/opt/local/bin/cmake" "-DTEST_EXE=/opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_systemc/systemc/work/build/examples/tlm/lt_temporal_decouple/lt_temporal_decouple" "-DTEST_DIR=/opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_systemc/systemc/work/build/examples/tlm/lt_temporal_decouple" "-DTEST_INPUT=" "-DTEST_GOLDEN=/opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_systemc/systemc/work/systemc-2.3.4/examples/tlm/lt_temporal_decouple/results/expected.log" "-DTEST_FILTER=" "-DDIFF_COMMAND=/usr/bin/diff" "-DDIFF_OPTIONS=-u" "-P" "/opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_systemc/systemc/work/systemc-2.3.4/cmake/run_test.cmake"
Directory: /opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_systemc/systemc/work/build/examples/tlm/lt_temporal_decouple
"examples/tlm/lt_temporal_decouple/lt_temporal_decouple" start time: Jun 19 02:44 MYT
Output:
----------------------------------------------------------
CMake Deprecation Warning at /opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_systemc/systemc/work/systemc-2.3.4/cmake/run_test.cmake:41 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


CMake Error at /opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_systemc/systemc/work/systemc-2.3.4/cmake/run_test.cmake:104 (string):
  string sub-command REGEX, mode REPLACE needs at least 6 arguments total to
  command.


<end of output>
Test time =   0.23 sec
----------------------------------------------------------
Test Failed.
"examples/tlm/lt_temporal_decouple/lt_temporal_decouple" end time: Jun 19 02:44 MYT
"examples/tlm/lt_temporal_decouple/lt_temporal_decouple" time elapsed: 00:00:00
----------------------------------------------------------

End testing: Jun 19 02:44 MYT

Make the docs and examples build optional

Hello, for embedding this library in a larger project, the docs and examples files generate an unnecessary overhead.
There is currently no possibility to make the configure and build skip those folders so it's not possible to remove them without heavy modification of the Makefiles.

I propose to make the configure and build of those folders optional, so that they are only built on demand by the user and that they can be completely removed from the folder if necessary.

macOS build is broken again

Hi all,

I cloned yesterday the repo, I hope it has not been fixed for now. Otherwise, this can be ignore.

the build for macOS for M1-sonomav14.3.1 is broken due to a regression. Funnily enough, the release from last year is still working.

the culprit is the --prefix flag, even with sudo privileges.

sudo ../configure 'CXXFLAGS=-std=c++17' --prefix=/opt/systemc

The above command works with 3.0.0 but with lates on main is not working

kind regards,
Jorge Ventura

SystemC simulations cause signal 11 when run with addresssanitizer

All simulations end with the tracer catching a signal 11 when built and run with the option -fsanitize=address
For example the async_reset test.

        Copyright (c) 1996-2017 by all Contributors,
        ALL RIGHTS RESERVED
SystemC Simulation
==1301179==WARNING: ASan is ignoring requested __asan_handle_no_return: stack top: 0x7fff0c98e000; bottom 0x7fa99d1fe000; size: 0x00556f790000 (366942420992)
False positive error reports may follow
For details see https://github.com/google/sanitizers/issues/189

Success
Tracer caught signal 11: addr=0x7fa99d353000 pc=0x7fa9a07b88b0 sp=0x7fa99c3fdca0
==1301179==LeakSanitizer has encountered a fatal error.
==1301179==HINT: For debugging, try setting environment variable LSAN_OPTIONS=verbosity=1:log_threads=1
==1301179==HINT: LeakSanitizer does not work under ptrace (strace, gdb, etc)
End of SystemC Simulation

I also have -std=c++11 in my ccflags.

Miss Makefile.in in src folder

Hi,

I recently have some problem when I try to install systemC in my machine, when I do "../configure" it will report an error of "cannot fine input file: `src/Makefile.in'.

I noticed that in the newest version, there is no file called "makefile.in", which used to appear in the previous version.

Migrate global sc_event::none and sc_process_handle::non_event to internal fields in sc_simcontext

This issue was originally one raised as a public pull request. However the proposed solution was accessing internal fields in sc_simcontext rather than using access methods. Basically the issue to specified in pull request 9 is:

Remove global sc_events (sc_event::none and sc_process_handle::non_event) by converting them to functions returning a reference to an sc_event in the current simulation context. This eases reset of the simulation context, as discussed in #8, as these sc_events no longer contain any reference to the initial simulation context.

The solution I propose is to move the sc_event locations to sc_simcontext using an internal method.
const sc_event& non_event();
This leads to the following two static methods:

static const sc_event& sc_event::none() { return sc_get_curr_simcontext()->null_event(); }

static const sc_event& sc_process_handle::non_event() { return sc_get_curr_simcontext()->null_event(); }

The "null event" will be a field within sc_simcontext.

no configure file

I'm trying to install 2.3.4 on EDA Playground (in a docker container) and the run is failing because there is no "configure" file. Which, looking at https://github.com/accellera-official/systemc, there isn't. I am following the instructions at https://github.com/accellera-official/systemc/blob/master/INSTALL.md, which is exactly what I did for 2.3.0 to 2.3.3) What am I missing?

Step 13/30 : RUN git clone https://github.com/accellera-official/systemc.git
---> Using cache
---> dd3c9b94d95d
-- snip --
Step 16/30 : RUN ls -l systemc
---> Running in 34525cf7d509
total 196
-rw-r--r-- 1 root root 2195 Jul 30 09:16 AUTHORS.md
-rw-r--r-- 1 root root 38946 Jul 30 09:16 CMakeLists.txt
-rw-r--r-- 1 root root 5640 Jul 30 09:16 CONTRIBUTING.md
-rw-r--r-- 1 root root 30718 Jul 30 09:16 INSTALL.md
-rw-r--r-- 1 root root 11358 Jul 30 09:16 LICENSE
-rw-r--r-- 1 root root 2633 Jul 30 09:16 Makefile.am
-rw-r--r-- 1 root root 3315 Jul 30 09:16 NOTICE
-rw-r--r-- 1 root root 4631 Jul 30 09:16 README.md
-rw-r--r-- 1 root root 34997 Jul 30 09:16 RELEASENOTES
drwxr-xr-x 2 root root 4096 Jul 30 09:16 cmake
drwxr-xr-x 2 root root 4096 Jul 30 09:16 config
-rw-r--r-- 1 root root 22074 Jul 30 09:16 configure.ac
drwxr-xr-x 4 root root 4096 Jul 30 09:16 docs
drwxr-xr-x 6 root root 4096 Jul 30 09:16 examples
drwxr-xr-x 3 root root 4096 Jul 30 09:16 msvc10
drwxr-xr-x 5 root root 4096 Jul 30 09:16 src
Removing intermediate container 34525cf7d509
---> c1df43997ad1
Step 17/30 : RUN mkdir -p systemc/objdir
---> Running in 81a1c130afd4
Removing intermediate container 81a1c130afd4
---> 0215055ffb6d
Step 18/30 : WORKDIR /install_data/systemc/objdir
---> Running in 1e838946a3e2
Removing intermediate container 1e838946a3e2
---> 0d42f997d8ac
Step 19/30 : RUN mkdir -p /playground_lib/systemc-2.3.4
---> Running in 03ac688a2921
Removing intermediate container 03ac688a2921
---> e8455ffdb159
-- snip --
Step 23/30 : RUN ../configure --prefix=/playground_lib/systemc-2.3.4
---> Running in 157f3742ee7a
/bin/sh: 1: ../configure: not found
The command '/bin/sh -c ../configure --prefix=/playground_lib/systemc-2.3.4' returned a non-zero code: 127

Some questions about assignment

Hi, I'm a rookie studying systemc. In systemc, an input is sc_in<sc_uint<8>> a, a local variable is sc_uint<8> b. I want to ask what is the difference between b = a and b = a.read()? Also, if an input is sc_out<sc_uint<8>> a, a local variable is sc_uint<8> b, what is the difference between a = b and a.write(b)? Thank you.

[3.0.0] `cmake_install` points to a non-existing file `DEVELOPMENT.md`, which breaks installation

CMake Error at docs/cmake_install.cmake:41 (file):
  file INSTALL cannot find
  "/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_systemc/systemc/work/systemc-3.0.0_pub_rev_20231129/docs/DEVELOPMENT.md":
  No such file or directory.
Call Stack (most recent call first):
  cmake_install.cmake:91 (include)


make: *** [install/fast] Error 1
make: Leaving directory `/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_systemc/systemc/work/build'
Command failed:  cd "/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_systemc/systemc/work/build" && /usr/bin/make -w install/fast DESTDIR=/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_systemc/systemc/work/destroot 
Exit code: 2

Compilation error with sc_fifo< std::vector<...> >

I want to store std::vector in sc_fifo. But by definining a variable of type

sc_fifo< std::vector<uint16_t> > fifo;

I get the following error:

In file included from /home/gav/SystemC-2.3.4/include/systemc:84,
                 from /home/gav/systemc-test/src/main.cpp:1:
/home/gav/SystemC-2.3.4/include/sysc/communication/sc_fifo.h: In instantiation of ‘void sc_core::sc_fifo<IF>::print(std::ostream&) const [with T = std::vector<short unsigned int>; std::ostream = std::basic_ostream<char>]’:
/home/gav/SystemC-2.3.4/include/sysc/communication/sc_fifo.h:431:12:   required from ‘std::ostream& sc_core::operator<<(std::ostream&, const sc_core::sc_fifo<T>&) [with T = std::vector<short unsigned int>; std::ostream = std::basic_ostream<char>]’
/home/gav/systemc-test/src/main.cpp:28:18:   required from here
/home/gav/SystemC-2.3.4/include/sysc/communication/sc_fifo.h:317:16: error: no match for ‘operator<<’ (operand types are ‘std::ostream’ {aka ‘std::basic_ostream<char>’} and ‘std::vector<short unsigned int>’)
  317 |             os << m_buf[i] << ::std::endl;
      |             ~~~^~~~~~~~~

But actually I have defined operator<< for std::vector<uint16_t>.

Here is the full code of my test program:

#include <systemc>
using namespace sc_core;

#include <vector>
#include <stdint.h>

std::ostream& operator<<(std::ostream& out, const std::vector<uint16_t>& data )
{
    return out;
}

int sc_main(int argc, char* argv[])
{
    sc_fifo< std::vector<uint16_t> > tmp;
    std::cout << tmp;

    std::vector<uint16_t> ddd;          // just for checking operator<< for std::vector<uint16_t> is really defined
    std::cout << ddd << std::endl;

    sc_start(4, SC_SEC);

    return 0;

};

If I comment lines

    sc_fifo< std::vector<uint16_t> > tmp;
    std::cout << tmp;

the compilation finished successfully, but when I uncommnent them then I get the error as provided above.

My OS is Ubuntu 22.04.
Tested on SystemC v2.3.3 and v2.3.4

Make check fails after building with cmake on macOS M1

Hi all,

I'm building systemc with cmake and the process completes with no issues. However I cannot run any test bench:
dyld[89728]: missing symbol called
even make check fails for all tests.
I've compiled with clang:
Apple clang version 12.0.5 (clang-1205.0.22.9)
Target: arm64-apple-darwin22.5.0
Thread model: posix

Any suggestions are more than welcome.

Update: I've made make check to pass by building with shared libraries ON, however when I try to build a systemc-ams test bench I still get the missing symbol called error.

end_of_simulation called only with sc_stop() and not while using sc_start(until)

end_of_simulation() from the name must trigger at the end of simulation. irrespetive of the way in which simulation gracefully exits.
However, the observation is :

  1. When sc_stop() is called, end_of_simulation callbacks are triggered.
  2. When sc_start(until) is given end_of_simulation callbacks are not triggered.

I saw the below piece of code in simcontext.cpp::simulate() function :
exit_time: // final simulation time update, if needed
if ( t > m_curr_time && t <= until_t )
do_timestep(t);

It looks like we are not calling end() function during exit time which would trigger the end_of_simulation callbacks.
Not sure if my understanding is correct.

'specialization': cannot convert from 'int' to 'sc_core::sc_port_policy'

Got the below error while compiling at_mixed_targets example code using CMake for Visual Studio 2017

`============================================================

1>------ Build started: Project: at_mixed_targets, Configuration: Debug Win32 ------
1>Building Custom Rule C:/NoBackup/systemc-2.3.4/examples/tlm/at_mixed_targets/CMakeLists.txt
1>CMake does not need to re-run because C:/NoBackup/systemc-2.3.4/build_32/examples/tlm/at_mixed_targets/CMakeFiles/generate.stamp is up-to-date.
1>at_mixed_targets.cpp
1>at_mixed_targets_top.cpp
1>initiator_top.cpp
1>traffic_generator.cpp
1>c:\nobackup\systemc-2.3.4\src\tlm_core/tlm_2/tlm_sockets/tlm_initiator_socket.h(174): error C2440: 'specialization': cannot convert from 'int' to 'sc_core::sc_port_policy' (compiling source file C:\NoBackup\systemc-2.3.4\examples\tlm\at_mixed_targets\src\initiator_top.cpp)
1>c:\nobackup\systemc-2.3.4\src\tlm_core/tlm_2/tlm_sockets/tlm_initiator_socket.h(174): note: Conversion to enumeration type requires an explicit cast (static_cast, C-style cast or function-style cast) (compiling source file C:\NoBackup\systemc-2.3.4\examples\tlm\at_mixed_targets\src\initiator_top.cpp)
1>c:\nobackup\systemc-2.3.4\src\tlm_core/tlm_2/tlm_sockets/tlm_initiator_socket.h(172): error C2440: 'specialization': cannot convert from 'int' to 'sc_core::sc_port_policy' (compiling source file C:\NoBackup\systemc-2.3.4\examples\tlm\at_mixed_targets\src\initiator_top.cpp)
1>c:\nobackup\systemc-2.3.4\src\tlm_core/tlm_2/tlm_sockets/tlm_initiator_socket.h(172): note: Conversion to enumeration type requires an explicit cast (static_cast, C-style cast or function-style cast) (compiling source file C:\NoBackup\systemc-2.3.4\examples\tlm\at_mixed_targets\src\initiator_top.cpp)
=============================================================`

CMake: `make check` - all tests failing on MacOSX 10.14 (Mojave).

When I attempt to build, using the CMake approach, on a 2018 MacBook Pro running MacOSX 10.14.6 (Mojave), all tests in make check fail, yielding the same error:

CMake Error at /Users/dbanas/Documents/Projects/systemc/cmake/run_test.cmake:104 (string):
  string sub-command REGEX, mode REPLACE needs at least 6 arguments total to
  command.

When I look at line 104 of run_test.cmake, I see:

string(REGEX REPLACE "^.*stopped by user.*$" "" RUN_TRIMMED_LOG ${RUN_LOG})

which certainly seems to be providing 6 arguments to the function, unless either the empty quotation or the ${RUN_LOG} is somehow producing a null argument?

$ cmake --version
cmake version 3.21.0-rc2

powerpc.c: fatal error: qt.h: No such file or directory

Something wrong with headers inclusion here:

[ 96%] Building C object src/CMakeFiles/systemc.dir/sysc/packages/qt/md/powerpc.c.o
cd /opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_systemc/systemc/work/build/src && /opt/local/bin/gcc-mp-12 -DSC_BUILD -DSC_ENABLE_EARLY_MAXTIME_CREATION -DSC_ENABLE_SIMULATION_PHASE_CALLBACKS_TRACING -DSC_HAVE_POSIX_MEMALIGN -DSC_INCLUDE_FX -Dsystemc_EXPORTS -I/opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_systemc/systemc/work/systemc-2.3.4/src -pipe -Os -DNDEBUG -I/opt/local/include -arch ppc -mmacosx-version-min=10.6 -fPIC -Wall -Wextra -Wno-unused-parameter -Wno-unused-variable -MD -MT src/CMakeFiles/systemc.dir/sysc/packages/qt/md/powerpc.c.o -MF CMakeFiles/systemc.dir/sysc/packages/qt/md/powerpc.c.o.d -o CMakeFiles/systemc.dir/sysc/packages/qt/md/powerpc.c.o -c /opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_systemc/systemc/work/systemc-2.3.4/src/sysc/packages/qt/md/powerpc.c
/opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_systemc/systemc/work/systemc-2.3.4/src/sysc/packages/qt/md/powerpc.c:16:10: fatal error: qt.h: No such file or directory
   16 | #include "qt.h"
      |          ^~~~~~
compilation terminated.
make[2]: *** [src/CMakeFiles/systemc.dir/sysc/packages/qt/md/powerpc.c.o] Error 1

[3.0.0] invalid utf8 characters in comments

Using the tarball downloaded from https://github.com/accellera-official/systemc/archive/refs/tags/3.0.0_pub_rev_20231129.tar.gz

Latest versions of clang have a -Winvalid-utf8 warning that complains if comments have invalid utf8 characters in them. When I build on macos using the following versions of things:

Build system Details
Agent name: 'Azure Pipelines 21'
Agent machine name: 'Mac-1703939497278'
Current agent version: '3.232.0'
Operating System
macOS
11.7.10
20G1427
Runner Image
Image: macos-11
Version: 20231216.1
Included Software: https://github.com/actions/runner-images/blob/macOS-11/20231216.1/images/macos/macos-11-Readme.md
Image Release: https://github.com/actions/runner-images/releases/tag/macOS-11%2F20231216.1

## Package Plan ##

  environment location: /Users/runner/miniforge3/conda-bld/systemc-split_1703954718054/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_place


The following NEW packages will be INSTALLED:

    libcxx: 16.0.6-hd57cbcb_0 conda-forge

Preparing transaction: ...working... done
Verifying transaction: ...working... done
Executing transaction: ...working... done
Reloading output folder: /Users/runner/miniforge3/conda-bld
Reloading output folder: /Users/runner/miniforge3/conda-bld



## Package Plan ##

  environment location: /Users/runner/miniforge3/conda-bld/systemc-split_1703954718054/_build_env


The following NEW packages will be INSTALLED:

    autoconf:            2.71-pl5321hed12c24_1     conda-forge
    automake:            1.16.5-pl5321h694c41f_0   conda-forge
    bzip2:               1.0.8-h10d778d_5          conda-forge
    c-ares:              1.24.0-h10d778d_0         conda-forge
    ca-certificates:     2023.11.17-h8857fd0_0     conda-forge
    cctools_osx-64:      973.0.1-ha1c5b94_15       conda-forge
    clang:               16.0.6-hac416ee_3         conda-forge
    clang-16:            16.0.6-default_h6b1ee41_3 conda-forge
    clang_impl_osx-64:   16.0.6-h8787910_7         conda-forge
    clang_osx-64:        16.0.6-hb91bd55_7         conda-forge
    clangxx:             16.0.6-default_h6b1ee41_3 conda-forge
    clangxx_impl_osx-64: 16.0.6-h6d92fbe_7         conda-forge
    clangxx_osx-64:      16.0.6-hb91bd55_7         conda-forge
    cmake:               3.28.1-h7c85d92_0         conda-forge
    compiler-rt:         16.0.6-ha38d28d_2         conda-forge
    compiler-rt_osx-64:  16.0.6-ha38d28d_2         conda-forge
    icu:                 73.2-hf5e326d_0           conda-forge
    krb5:                1.21.2-hb884880_0         conda-forge
    ld64_osx-64:         609-ha20a434_15           conda-forge
    libclang-cpp16:      16.0.6-default_h6b1ee41_3 conda-forge
    libcurl:             8.5.0-h726d00d_0          conda-forge
    libcxx:              16.0.6-hd57cbcb_0         conda-forge
    libedit:             3.1.20191231-h0678c8f_2   conda-forge
    libev:               4.33-h10d778d_2           conda-forge
    libexpat:            2.5.0-hf0c8a7f_1          conda-forge
    libiconv:            1.17-hd75f5a5_2           conda-forge
    libllvm16:           16.0.6-hbedff68_3         conda-forge
    libnghttp2:          1.58.0-h64cf6d3_1         conda-forge
    libssh2:             1.11.0-hd019ec5_0         conda-forge
    libtool:             2.4.7-hf0c8a7f_0          conda-forge
    libuv:               1.46.0-h0c2f820_0         conda-forge
    libxml2:             2.12.3-hc0ae0f7_0         conda-forge
    libzlib:             1.2.13-h8a1eda9_5         conda-forge
    llvm-tools:          16.0.6-hbedff68_3         conda-forge
    m4:                  1.4.18-haf1e3a3_1001      conda-forge
    make:                4.3-h22f3db7_1            conda-forge
    ncurses:             6.4-h93d8f39_2            conda-forge
    openssl:             3.2.0-hd75f5a5_1          conda-forge
    perl:                5.32.1-7_h10d778d_perl5   conda-forge
    rhash:               1.4.4-h0dc2134_0          conda-forge
    sigtool:             0.1.3-h88f4db0_0          conda-forge
    tapi:                1100.0.11-h9ce4665_0      conda-forge
    xz:                  5.2.6-h775f41a_0          conda-forge
    zstd:                1.5.5-h829000d_0          conda-forge

Preparing transaction: ...working... done
Verifying transaction: ...working... done
Executing transaction: ...working... done

The full output of the build will be available for 30 days on Azure.

I run into the following:

x86_64-apple-darwin13.4.0-clang++ -march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -stdlib=libc++ -fvisibility-inlines-hidden -fmessage-length=0 -isystem $PREFIX/include -fdebug-prefix-map=$SRC_DIR=/usr/local/src/conda/systemc-dev-3.0.0dev20231129 -fdebug-prefix-map=$PREFIX=/usr/local/src/conda-prefix -march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -isystem $PREFIX/include -fdebug-prefix-map=$SRC_DIR=/usr/local/src/conda/systemc-dev-3.0.0dev20231129 -fdebug-prefix-map=$PREFIX=/usr/local/src/conda-prefix -g -Wall -pedantic -Wno-long-long -Werror -I../include -I../../common/include -I. -I.. -I$PREFIX/include  -c ../../common/src/traffic_generator.cpp -o traffic_generator.o
../../common/src/traffic_generator.cpp:251:30: error: invalid UTF-8 in comment [-Werror,-Winvalid-utf8]
      // The address for the <93>gp<94> is used as expected data.  The address filed of 
                             ^
../../common/src/traffic_generator.cpp:251:33: error: invalid UTF-8 in comment [-Werror,-Winvalid-utf8]
      // The address for the <93>gp<94> is used as expected data.  The address filed of 
                                   ^
../../common/src/traffic_generator.cpp:252:15: error: invalid UTF-8 in comment [-Werror,-Winvalid-utf8]
      //  the <93>gp<94> is a mutable field and is changed by the SimpleBus interconnect. 
              ^
../../common/src/traffic_generator.cpp:252:18: error: invalid UTF-8 in comment [-Werror,-Winvalid-utf8]
      //  the <93>gp<94> is a mutable field and is changed by the SimpleBus interconnect. 
                    ^

NOTE: this is not an exhaustive list of the failures, there are other files that fail after this first one.

I was able to successfully work around this by adding -Wno-error=invalid-utf8. I was also able to clean individual files by asking Vim to :set fileencoding=utf8 and then writing the files. If a PR would be valuable, just let me know and I'll open one.

It would probably be nice to clean this up before the official 3.0 release as I'm sure more folks will run into clang being annoying as we move into the future.

sc_externs.h signatures do not match standard. add on extern "C"

sc_externs.h forward declares the following functions:

extern "C" int sc_main( int argc, char* argv[] );

namespace sc_core {
	extern "C" int sc_elab_and_sim( int argc, char* argv[] );
	extern "C" int sc_argc();
	extern "C" const char* const* sc_argv();

It appends extern "C" to the signature of the functions, which is not compatible with declarations of these functions in the SystemC LRM sections 4.3.1-4.3.4.

Another source file that declares and defines the functions according to the standard, without extern "C" is unable to link to the systemc library correctly.

Linking SystemC on Windows with MinGW produces Error with QuickThreads

C:\Users\...\systemc\src\sysc\packages\qt\md\iX86_64.s: Assembler messages:
C:\Users\...\systemc\src\sysc\packages\qt\md\iX86_64.s:77: Error: junk at end of line, first unrecognized character is `-'
mingw32-make.exe[2]: *** [...\systemc\src\CMakeFiles\systemc.dir\build.make:1266: .../systemc/src/CMakeFiles/systemc.dir/sysc/packages/qt/md/iX86_64.s.obj] Error 1
mingw32-make.exe[1]: *** [CMakeFiles\Makefile2:1006: .../systemc/src/CMakeFiles/systemc.dir/all] Error 2
mingw32-make.exe: *** [Makefile:129: all] Error 2

SystemC was build with CMAKE in the context of a CMAKE project. Under Linux and macOS its works, but on windows I get this assembler error shown above. It can be fixed by using pthreads but I think qt are much better. 

Any ideas to fix it? 

Global state in SystemC

I am currently working on a specialized SystemC project where I want to restart the SystemC simulation process multiple times. I have a working proof of concept which does this by providing a custom main function in which I reset the global SystemC simulation context (sc_core::sc_curr_simcontext) and call sc_core::sc_elab_and_sim in a loop. As an example, consider the following code:

int main(int argc, char **argv) {
        // …

	for (i = 0; !exit_simulation; i++) {
		printf("\n##\n# %zuth execution\n##\n", i);

		// Reset SystemC simulation context
		if (sc_core::sc_curr_simcontext)
			delete sc_core::sc_curr_simcontext;
		sc_core::sc_curr_simcontext = NULL;

		if ((ret = sc_core::sc_elab_and_sim(argc, argv)))
			return ret;
	}

        // …
}

I am aware that this code relies on specific implementation details of the sc_get_curr_simcontext() function and is thus not conforming to IEEE Std 1666-2001. In fact, the code above only works because sc_get_curr_simcontext() currently creates a new simulation context if the global sc_core::sc_curr_simcontext is NULL:

if( sc_curr_simcontext == 0 ) {
sc_default_global_context = new sc_simcontext;
sc_curr_simcontext = sc_default_global_context;
}

Apart from relying on implementation-defined behaviour, an additional problem with the code above is that SystemC contains global variables which are independent of the simulation context. Some of these variables even hold references to the simulation context which cannot be updated and thus cause a double free on program termination. One example of such variables is the sc_event::none variable which was added in 55da81d:

// never notified event
static const sc_event none;

As sc_event::none is a global variable, it is initialized on program startup and holds a reference to a simulation context (created through the invocation of sc_get_curr_simcontext() by the sc_event constructor). This reference is not updated by the loop from above, in fact in cannot be updated as the m_simc member of sc_event is private. An additional global variable with the same problem is sc_process_handle::non_event:

sc_event sc_process_handle::non_event( sc_event::kernel_event );

I am currently considering working on a modified version of SystemC which addresses issue related to such global variables. I created this issue to figure out if there is an interest in reducing global state in SystemC and if patches in this regard would be accepted.

Undefined Behaviour in sc_int constructor

The following code gives an error when compiled in clang with -fsanitize=undefined:

#include <systemc>

int sc_main(int, char**) {
    sc_dt::sc_int<32> x = -1;
    std::cout << x << std::endl;
    return 0;
}

The output:

        SystemC 2.3.3-Accellera --- May 18 2021 00:00:00
        Copyright (c) 1996-2018 by all Contributors,
        ALL RIGHTS RESERVED
/usr/include/systemc/sysc/datatypes/int/sc_int_base.h:574:22: runtime error: left shift of negative value -1
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/include/systemc/sysc/datatypes/int/sc_int_base.h:574:22 in 
-1

The relevant code:

void extend_sign()
{
#ifdef DEBUG_SYSTEMC
check_value();
#endif
m_val = ( m_val << m_ulen >> m_ulen );
}

The result is correct in this example, however there could be cases where, depending on optimisation level, the compiler could do something unexpected with this code. Perhaps there should be a check for negative values before doing the shift here?

Broken CMake Configuration

It seems the CMake Configuration:
BUILD_SOURCE_DOCUMENTATION is broken.
Even After enabling the said configuration parameter to ON.
I am not able to observe any Doxygen Generated HTML Documentation for the SystemC sources.

./configure script does not work 'out-of-box' with 2.3.4

Hi,
I've noticed that 'out-of-box' a download of 2.3.4, ./configure does not work.

It reports:

configure: creating ./config.status
config.status: creating Makefile
config.status: error: cannot find input file: `src/Makefile.in'

For me, at least. Could this be fixed? (Maybe along with Mac ARM build support :-)

sc_uint constructor from binary string initializes the wrong integer

SystemC version: tested on 2.3.3, 2.3.4 and 3.0.0 (the latter pulled and compiled from main)
Platform: Linux Mint 20.3
Compiler: g++ 9.4.0

Description of the problem:

The sc_uint (and sc_biguint) constructor that takes a binary string as input seems to incorrectly initialize the number. The same number created from an integer number is initialized correctly.

The error seems to depend on the length of the integer, for example:

cout << sc_uint<3>(2);      // prints 2
cout << sc_uint<3>("010");  // prints 2
cout << sc_uint<4>(2);      // prints 2
cout << sc_uint<4>("0010"); // prints 10

Steps to reproduce the problem

To verify the behavior, I've used the following code, that compares all sc_uint created from a binary string of length N and the corresponding integer, with an sc_bv created from the same values.

#include "systemc.h"
#include <iostream>
#include <bitset> // used to print the binary string of an int

// how many bits to test
#define N 4

template <typename T>
void test(T n)
{
    sc_uint<N> integer(n); // create the integer
    sc_bv<N> bitvector(integer); // convert integer to bitvector
    
    // check if the converted number is the same as the original one
    cout << n << " " << bitvector << (n == bitvector ? " OK" : " ERROR") << endl;
}

int sc_main(int argc, char * argv[]) {

    // create sc_uint from integer
	for (int i = 0; i < (1 << N); i++)
	    test(i);

    // create sc_uint from binary string
	for (int i = 0; i < (1 << N); i++)
	    test(std::bitset<N>(i).to_string().c_str());

	return 0;
}

The results with N <= 3 report everything as correct

0 000 OK
1 001 OK
2 010 OK
3 011 OK
4 100 OK
5 101 OK
6 110 OK
7 111 OK
000 000 OK
001 001 OK
010 010 OK
011 011 OK
100 100 OK
101 101 OK
110 110 OK
111 111 OK

However, with N = 4, half of the numbers are wrong

0 0000 OK
1 0001 OK
2 0010 OK
3 0011 OK
4 0100 OK
5 0101 OK
6 0110 OK
7 0111 OK
8 1000 OK
9 1001 OK
10 1010 OK
11 1011 OK
12 1100 OK
13 1101 OK
14 1110 OK
15 1111 OK
0000 0000 OK
0001 0001 OK
0010 1010 ERROR
0011 1011 ERROR
0100 0100 OK
0101 0101 OK
0110 1110 ERROR
0111 1111 ERROR
1000 1000 OK
1001 1001 OK
1010 0010 ERROR
1011 0011 ERROR
1100 1100 OK
1101 1101 OK
1110 0110 ERROR

with N = 6, only 25% of numbers are correct, with N = 7 only 12.5% are correct and so on...

move to cmake, seriously!

Hi,

This is the second time I worked with a synopsis project. I still dunno why make is enforced when in 2024 we have cmake which is a very powerful generator of makefile.

it is always the synopsis makefile's that consume more and more valuable human power. They are convoluted and not very easy to maintain. Last time, it was a makefile for some neural accelerator and now makefile of systemC.

IMHO, I believe that dropping your makefile approach would be beneficial for your company. I keep having a bad after taste when debugging synopsis's makefiles, and I always say to my managers or purchasing department to avoid synopsis tools due to the unreliability.

I hope the feedback is taken as a constructive criticism.

kind regards,
Jorge Ventura

Code format

First of all, clean up mixed use of tabs and space;
Second, will you add a .clang-format?

Undefined behavior sanitizer reports misaligned memory accesses in SystemC library

Hello,
when compiling with -fsanitize=address,undefined, even in empty SystemC projects misaligned memory accesses are detected by the undefined behavior sanitizer.
Can be observed with both GCC and Clang.

This issue is not related to #19 as this can also be observed in the new 2.3.4 version.

GCC output:

        SystemC 2.3.4-Accellera --- Jun  5 2023 09:45:57
        Copyright (c) 1996-2022 by all Contributors,
        ALL RIGHTS RESERVED
/home/derek/sanitize/build/_deps/systemc-src/src/sysc/kernel/sc_method_process.h:286:12: runtime error: member access within misaligned address 0x0000000000db for type 'struct sc_method_process', which requires 8 byte alignment
0x0000000000db: note: pointer points here
<memory cannot be printed>
AddressSanitizer:DEADLYSIGNAL
=================================================================
==3517==ERROR: AddressSanitizer: SEGV on unknown address 0x0000000000db (pc 0x7fb65b11fe8a bp 0x7ffe1045eb80 sp 0x7ffe1045e9e0 T0)
==3517==The signal is caused by a READ memory access.
==3517==Hint: address points to the zero page.
    #0 0x7fb65b11fe8a in sc_core::sc_method_process::next_runnable() /home/derek/sanitize/build/_deps/systemc-src/src/sysc/kernel/sc_method_process.h:286
    #1 0x7fb65b11fe8a in sc_core::sc_runnable::toggle_methods() /home/derek/sanitize/build/_deps/systemc-src/src/sysc/kernel/sc_runnable_int.h:464
    #2 0x7fb65b11fe8a in sc_core::sc_simcontext::crunch(bool) /home/derek/sanitize/build/_deps/systemc-src/src/sysc/kernel/sc_simcontext.cpp:482
    #3 0x7fb65b111a0c in sc_core::sc_simcontext::simulate(sc_core::sc_time const&) /home/derek/sanitize/build/_deps/systemc-src/src/sysc/kernel/sc_simcontext.cpp:887
    #4 0x7fb65b113e57 in sc_core::sc_start(sc_core::sc_time const&, sc_core::sc_starvation_policy) /home/derek/sanitize/build/_deps/systemc-src/src/sysc/kernel/sc_simcontext.cpp:1718
    #5 0x7fb65b11502c in sc_core::sc_start() /home/derek/sanitize/build/_deps/systemc-src/src/sysc/kernel/sc_simcontext.cpp:1752
    #6 0x55fb2e65838c in sc_main /home/derek/sanitize/main.cpp:5
    #7 0x7fb65affbba9 in sc_elab_and_sim /home/derek/sanitize/build/_deps/systemc-src/src/sysc/kernel/sc_main_main.cpp:89
    #8 0x7fb658e6fd8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #9 0x7fb658e6fe3f in __libc_start_main_impl ../csu/libc-start.c:392
    #10 0x55fb2e6582b4 in _start (/home/derek/sanitize/build/sanitize+0x22b4)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /home/derek/sanitize/build/_deps/systemc-src/src/sysc/kernel/sc_method_process.h:286 in sc_core::sc_method_process::next_runnable()
==3517==ABORTING

Clang output:

        SystemC 2.3.4-Accellera --- Jun  5 2023 10:00:10
        Copyright (c) 1996-2022 by all Contributors,
        ALL RIGHTS RESERVED
/home/derek/sanitize/build/_deps/systemc-src/src/sysc/kernel/sc_method_process.h:280:20: runtime error: upcast of misaligned address 0x0000000000db for type 'sc_core::sc_method_process', which requires 8 byte alignment
0x0000000000db: note: pointer points here
<memory cannot be printed>
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /home/derek/sanitize/build/_deps/systemc-src/src/sysc/kernel/sc_method_process.h:280:20 in
/home/derek/sanitize/build/_deps/systemc-src/src/sysc/kernel/sc_thread_process.h:437:20: runtime error: upcast of misaligned address 0x0000000000db for type 'sc_core::sc_thread_process', which requires 8 byte alignment
0x0000000000db: note: pointer points here
<memory cannot be printed>
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /home/derek/sanitize/build/_deps/systemc-src/src/sysc/kernel/sc_thread_process.h:437:20 in
/home/derek/sanitize/build/_deps/systemc-src/src/sysc/kernel/sc_method_process.h:286:12: runtime error: downcast of misaligned address 0x0000000000db for type 'class sc_method_process', which requires 8 byte alignment
0x0000000000db: note: pointer points here
<memory cannot be printed>
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /home/derek/sanitize/build/_deps/systemc-src/src/sysc/kernel/sc_method_process.h:286:12 in
AddressSanitizer:DEADLYSIGNAL
=================================================================
==6136==ERROR: AddressSanitizer: SEGV on unknown address 0x0000000000db (pc 0x7fb1a0d77ebf bp 0x843b6d40b9976ed1 sp 0x7ffe9fb7d9d0 T0)
==6136==The signal is caused by a READ memory access.
==6136==Hint: address points to the zero page.
    #0 0x7fb1a0d77ebf in sc_core::sc_method_process::next_runnable() /home/derek/sanitize/build/_deps/systemc-src/src/sysc/kernel/sc_method_process.h:286:12
    #1 0x7fb1a0dbbf34 in sc_core::sc_runnable::toggle_methods() /home/derek/sanitize/build/_deps/systemc-src/src/sysc/kernel/sc_runnable_int.h:464:39
    #2 0x7fb1a0db6d84 in sc_core::sc_simcontext::crunch(bool) /home/derek/sanitize/build/_deps/systemc-src/src/sysc/kernel/sc_simcontext.cpp:482:18
    #3 0x7fb1a0dae489 in sc_core::sc_simcontext::simulate(sc_core::sc_time const&) /home/derek/sanitize/build/_deps/systemc-src/src/sysc/kernel/sc_simcontext.cpp:887:2
    #4 0x7fb1a0db4408 in sc_core::sc_start(sc_core::sc_time const&, sc_core::sc_starvation_policy) /home/derek/sanitize/build/_deps/systemc-src/src/sysc/kernel/sc_simcontext.cpp:1718:16
    #5 0x7fb1a0db4b7f in sc_core::sc_start() /home/derek/sanitize/build/_deps/systemc-src/src/sysc/kernel/sc_simcontext.cpp:1752:5
    #6 0x55cfd4f9b59d in sc_main /home/derek/sanitize/main.cpp:5:5
    #7 0x7fb1a0d6eb83 in sc_elab_and_sim /home/derek/sanitize/build/_deps/systemc-src/src/sysc/kernel/sc_main_main.cpp:89:18
    #8 0x7fb1a040fd8f in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
    #9 0x7fb1a040fe3f in __libc_start_main csu/../csu/libc-start.c:392:3
    #10 0x55cfd4edb384 in _start (/home/derek/sanitize/build/sanitize+0x1e384) (BuildId: ac89e2b3c78c26cd0d56ce9c1ff8b672cdf0b2ce)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /home/derek/sanitize/build/_deps/systemc-src/src/sysc/kernel/sc_method_process.h:286:12 in sc_core::sc_method_process::next_runnable()
==6136==ABORTING

For completeness, the program:

#include <systemc>

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

Undefined reference to the `sc_core::sc_api_version_2_3_4_XXX` ....

SystemC fails to link.
Platform Linux, G++ 9.3.0
Built with cmake version 3.16.3

Get link error building empty application.

/usr/bin/ld: /tmp/ccVw0j7V.o: in function `__static_initialization_and_destruction_0(int, int)':
sample.cpp:(.text+0x7e): undefined reference to `sc_core::sc_api_version_2_3_4_cxx201402L<&sc_core::SC_DISABLE_VIRTUAL_BIND_UNDEFINED_>::sc_api_version_2_3_4_cxx201402L(sc_core::sc_writer_policy, bool)'
collect2: error: ld returned 1 exit status

Sample code: cmd: g++ sample.cpp -ISYSC_DIR -lsystemc -LSYSC_LIB_DIR

#include "systemc"
#include <iostream>
int main()
{
	std::cout << "Hello world\n";
	return 0;
}

Also mention I have same issue in Windows platform with MinGW.

SystemC fails to build with clang 8 & libc++ 8

  1. SystemC version
    2.3.3
  2. platform, compiler, flags
    2.1. platform: Linux - Ubuntu 18.04.4 LTS
    2.2. compiler: clang 8 + libc++ 8
    2.3. flags: see point 4
  3. description of the problem
    SystemC fails to build with clang 8 and libc++ 8 due to an incorrect include of experimental/string_view in sc_string_view.h
    Note that experimental/string_view is not support anymore form libc++ 7 and onwards
  4. steps to reproduce the problem
    4.1. mkdir build
    4.2. CC=clang-8 CXX=clang++-8 CXXFLAGS="-stdlib=libc++" cmake .. -DCMAKE_CXX_STANDARD=14
    4.3. make
  5. compile/runtime warnings and errors
...
In file included from src/sysc/kernel/sc_simcontext.cpp:57:
In file included from src/sysc/utils/sc_string_view.h:47:
/usr/lib/llvm-8/bin/../include/c++/v1/experimental/string_view:18:3: warning: "<experimental/string_view> has been removed. Use <string_view> instead." [-W#warnings]
# warning "<experimental/string_view> has been removed. Use <string_view> instead."
  ^
...
In file included from src/sysc/kernel/sc_simcontext.cpp:57:
src/sysc/utils/sc_string_view.h:62:9: error: no member named 'experimental' in namespace 'std'
typedef SC_STRING_VIEW_NS_::string_view sc_string_view;
...
  1. code sample, not more than 100 lines to demonstrate the problem
    Not Applicable

Additional information:

Issue is caused at line 41 by the check for c++ version > c++14

#if SC_CPLUSPLUS >= 201402L && defined(__has_include)
# if SC_CPLUSPLUS > 201402L && __has_include(<string_view>) /* since C++17 */
# define SC_STRING_VIEW_NS_ std
# include <string_view>
/* available in Library Fundamentals, ISO/IEC TS 19568:2015 */
# elif __has_include(<experimental/string_view>)
# define SC_STRING_VIEW_NS_ std::experimental
# include <experimental/string_view>
# endif
#else
// TODO: other ways to detect availability of std::(experimental::)string_view?
#endif

Best Regards,
Jan

std::array and sc_core::sc_fifo

"Define a group of FIFOs, std::array<sc_core::sc_fifostd::uint64_t, 6> mCmdFifo.", Unable to change FIFO init, So I suggest adding methods to set FIFO depth and name to sc_fifo class;

Assemby instruction does not assemble correctly with LLVM 13(vanilla, not Apple fork) on macOS/Apple M1

Hi,

We are building LLVM 13 from sources on macOS - arm64 on an Apple M1 computer(from the official repo, not Apple's fork) and building systemc with the resulting compiler.
This leads to an unusual situation:
(running nm -m on the resulting lib)

libsystemc.a(aarch64.s.o):
0000000000000010 (__TEXT,__text) external _qt_abort
0000000000000078 (__TEXT,__text) external _qt_align
0000000000000010 (__TEXT,__text) external _qt_block
0000000000000010 (__TEXT,__text) external _qt_blocki
0000000000000000 (__TEXT,__text) external _qt_start
                 (indirect) non-external br (for qt_error)
0000000000000000 (__TEXT,__text) non-external ltmp0
0000000000000010 (__TEXT,__text) external qt_abort
0000000000000078 (__TEXT,__text) external qt_align
0000000000000010 (__TEXT,__text) external qt_block
0000000000000010 (__TEXT,__text) external qt_blocki
                 (undefined) external qt_error

As you can see it erroneously generates a br indirect symbol - which led lld to report it cannot handle N_INDR symbols when linking the above lib.
If I change this code:
https://github.com/accellera-official/systemc/blob/master/src/sysc/packages/qt/md/aarch64.s#L26
from br =qt_error to

ldr x28, =qt_error
br x28

or just:
b qt_error
then the error goes away.
I suspect the br instruction is misused as it should be used with a register and not an address/label.
P.S.
Another issue is that qt_error is actually exported as _qt_error by the linker when cmake is used to build.

Rust binding?

Hi, we're using systemc a lot and have a large rust codebase. I'd like to ask question about feasibility to make Rust binding for Systemc. Any opinion or prior arts?

SystemC 2.3.3 - Fatal: (F4) assertion failed: iface != 0

Dear all,

Lately, we have been facing a strange issue, causing a "Fatal: (F4) assertion failed: iface != 0" when running our program on a Windows machine.
After removing all functionality and having only the minimum code, we have been able to find out the issue.
The code below is possible to build without any problems.

Screenshot 2024-04-26 at 12 02 16

But once you run it, you get:
Screenshot 2024-04-26 at 12 04 37

Screenshot 2024-04-26 at 12 04 55

Interestingly, if you run this code on a Linux machine using GCC, the code can run without any troubles...

....
After removing the "some_var" in the Utest class, the code is running...

  • It doesn't matter if the "some_var" is private, protected, public... if it's used, initialized in the constructor, etc.
  • Once we create a simple variable (any type), inside of the Utest class, the code fails to run (Fatal: (F4) ... )
  • If you create a function in the Utest class, the code also runs...

To put it simply, creating a single member variable inside of a class has the result of a "Fatal: (F4) assertion failed: iface != 0", but only on Windows (not Linux with GCC)..

Now, we can fix our full code just by removing the variable, but we just don't understand what the problem is...
Is it a bug? Do we do something that is not allowed?...
Maybe you have some more details about this?

Thank You.
Kind Regards,
Milan

Inconsistent build setting between autoconf and cmake builds

  1. SystemC version: 2.3.3 / 2.3.4_pub_rev
    
  2. platform, compiler, flags: all
    
  3. description of the problem:
    

When building SystemC using autoconf/configure the experiental phase callback feature is by default off. Whne building using cmake the option ENABLE_PHASE_CALLBACKS_TRACING is set to ON (https://github.com/accellera-official/systemc/blob/master/CMakeLists.txt#L310). This leads to inconsitency e.g. when building libraries providing their own trace file implementations.
Aside of this inconsistency there os no way to check at model build time what setting has been used used in thsi regard.

configure error on Mac M1/Ventura

I just tried building, following the instructions in INSTALL.md. I get "sorry...architecture not supported". This is with Xcode 14.1 on macOS 13.0.1 on M1 (ARM).

24408 16:15: systemc/ (master) $ config/bootstrap 
configure.ac:110: installing 'config/ar-lib'
configure.ac:95: installing 'config/compile'
configure.ac:59: installing 'config/install-sh'
configure.ac:59: installing 'config/missing'
examples/sysc/Makefile.am: installing 'config/depcomp'
parallel-tests: installing 'config/test-driver'
configure.ac:58: warning: The macro `AC_CANONICAL_SYSTEM' is obsolete.
configure.ac:58: You should run autoupdate.
./lib/autoconf/general.m4:2081: AC_CANONICAL_SYSTEM is expanded from...
configure.ac:58: the top level
configure.ac:270: warning: The macro `AC_PROG_LIBTOOL' is obsolete.
configure.ac:270: You should run autoupdate.
aclocal.m4:122: AC_PROG_LIBTOOL is expanded from...
configure.ac:270: the top level
configure.ac:565: warning: AC_OUTPUT should be used without arguments.
configure.ac:565: You should run autoupdate.
24409 16:15: systemc/ (master) $ autoupdate
24410 16:15: systemc/ (master) $ config/bootstrap 
configure.ac:90: installing 'config/compile'
configure.ac:54: installing 'config/missing'
examples/sysc/Makefile.am: installing 'config/depcomp'
24410 16:15: objdir/ (master) $ ../configure --prefix=/usr/local/systemc
checking build system type... arm-apple-darwin22.1.0
checking host system type... arm-apple-darwin22.1.0
checking target system type... arm-apple-darwin22.1.0
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a race-free mkdir -p... ../config/install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking how to create a pax tar archive... gnutar
checking whether make supports nested variables... (cached) yes
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether the compiler supports GNU C++... yes
checking whether clang++ accepts -g... yes
checking for clang++ option to enable C++11 features... none needed
checking whether make supports the include directive... yes (GNU style)
checking dependency style of clang++... gcc3
checking whether we are using a Clang/LLVM C++ compiler... yes
checking for gcc... clang++
checking whether the compiler supports GNU C... yes
checking whether clang++ accepts -g... yes
checking for clang++ option to enable C11 features... unsupported
checking for clang++ option to enable C99 features... unsupported
checking for clang++ option to enable C89 features... unsupported
checking whether clang++ understands -c and -o together... yes
checking dependency style of clang++... gcc3
checking whether we are using a Clang/LLVM C compiler... yes
checking for ar... ar
checking the archiver (ar) interface... ar
checking dependency style of clang++... gcc3
checking whether ln -s works... yes
configure: error: "sorry...architecture not supported"

The same result came from brew install --build-from-source systemc.

CMake build both static and dynamic library

For context: to support the work I used to do with SystemC as part of my PhD and since then as a "hobby", for a while now I've had a public Fedora/RedHat/CentOS COPR RPM build repository of SystemC [0]. To generate both the dynamic (.so) library as well as the static (.a) library from the same CMake build, I've always relied on a slightly hacked-up CMakeListst.txt. Unfortunately on every rebase I'd have to re-do the hack, which is why up until today I hadn't done so. On the plus-side, SystemC 3.0.0 makes it easier to perform this hack-up.
Attached to this issue I've attached the patch I've used to achieve both my output files. However, it has two main issues:

  1. I probably broke any build that isn't BUILD_SHARED_LIBS on Linux,
  2. It compiles all the source files twice. Which is "good enough" for my purposes but not ideal.

So, to support myself on future rebases as well as other (aspiring) distro packager maintainers, I want to request for the CMake builder to support a mode in which it outputs both the .a and the .so from the same build.

[0] https://copr.fedorainfracloud.org/coprs/rspliet/SystemC/
0001-CMakeLists-build-both-static-and-dynamic.zip

c++ syntax problem for SC_CTOR

Hi~
This is the code after the predefined is expanded:

struct MODULE_B : ::sc_core::sc_module{
typedef MODULE_B SC_CURRENT_USER_MODULE;
MODULE_B( ::sc_core::sc_module_name ) {
{ ::sc_core::sc_process_handle func_b_handle = sc_core::sc_get_curr_simcontext()->create_method_process( "func_b", false, static_cast<sc_core::SC_ENTRY_FUNC>(&SC_CURRENT_USER_MODULE::func_b), this, 0 ); this->sensitive << func_b_handle; this->sensitive_pos << func_b_handle; this->sensitive_neg << func_b_handle; };
}
void func_b();
};

I'm a little curious about the programming syntax of this sentence:“MODULE_B( ::sc_core::sc_module_name ){}".
Why is it possible to use only the name of the class as an argument in the definition of a constructor?
Look forward to your reply, thank you!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.