summaryrefslogtreecommitdiff
path: root/src/systemc/tests/systemc/bugs
diff options
context:
space:
mode:
Diffstat (limited to 'src/systemc/tests/systemc/bugs')
-rw-r--r--src/systemc/tests/systemc/bugs/async_reset_init/async_reset_init.cpp135
-rw-r--r--src/systemc/tests/systemc/bugs/async_reset_init/golden/async_reset_init.log30
-rw-r--r--src/systemc/tests/systemc/bugs/bug_147853/bug_147853.cpp34
-rw-r--r--src/systemc/tests/systemc/bugs/bug_147853/golden/bug_147853.log21
-rw-r--r--src/systemc/tests/systemc/bugs/bug_185/bug_185.cpp26
-rw-r--r--src/systemc/tests/systemc/bugs/bug_185/golden/bug_185.log8
-rw-r--r--src/systemc/tests/systemc/bugs/bug_70/bug_70.cpp29
-rw-r--r--src/systemc/tests/systemc/bugs/bug_70/golden/bug_70.log9
-rw-r--r--src/systemc/tests/systemc/bugs/constructor_throw/constructor_throw.cpp86
-rw-r--r--src/systemc/tests/systemc/bugs/constructor_throw/golden/constructor_throw.log4
-rw-r--r--src/systemc/tests/systemc/bugs/instantiation_detection/golden/instantiation_detection.log161
-rw-r--r--src/systemc/tests/systemc/bugs/instantiation_detection/instantiation_detection.cpp113
-rw-r--r--src/systemc/tests/systemc/bugs/sc_bigint_part_select/test01/golden/test01.log10
-rw-r--r--src/systemc/tests/systemc/bugs/sc_bigint_part_select/test01/test01.cpp70
-rw-r--r--src/systemc/tests/systemc/bugs/sc_string_bracket_assign/golden/sc_string_bracket_assign.log3
-rw-r--r--src/systemc/tests/systemc/bugs/sc_string_bracket_assign/sc_string_bracket_assign.cpp17
-rw-r--r--src/systemc/tests/systemc/bugs/sign_extension/golden/sign_extension.log11
-rw-r--r--src/systemc/tests/systemc/bugs/sign_extension/golden/sign_extension.log.bsd6411
-rw-r--r--src/systemc/tests/systemc/bugs/sign_extension/golden/sign_extension.log.cygwin6411
-rw-r--r--src/systemc/tests/systemc/bugs/sign_extension/golden/sign_extension.log.linux6411
-rw-r--r--src/systemc/tests/systemc/bugs/sign_extension/golden/sign_extension.log.linuxaarch6411
-rw-r--r--src/systemc/tests/systemc/bugs/sign_extension/golden/sign_extension.log.macosx6411
-rw-r--r--src/systemc/tests/systemc/bugs/sign_extension/sign_extension.cpp75
-rw-r--r--src/systemc/tests/systemc/bugs/stack_alignment/.notsparcOS51
-rw-r--r--src/systemc/tests/systemc/bugs/stack_alignment/golden/stack_alignment.log6
-rw-r--r--src/systemc/tests/systemc/bugs/stack_alignment/stack_alignment.cpp129
26 files changed, 1033 insertions, 0 deletions
diff --git a/src/systemc/tests/systemc/bugs/async_reset_init/async_reset_init.cpp b/src/systemc/tests/systemc/bugs/async_reset_init/async_reset_init.cpp
new file mode 100644
index 000000000..70455825d
--- /dev/null
+++ b/src/systemc/tests/systemc/bugs/async_reset_init/async_reset_init.cpp
@@ -0,0 +1,135 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ async_reset_init.cpp -- Starting a process in async reset state
+
+ Original Author: Philipp A. Hartmann, Intel Corporation, 2017-07-23
+
+ *****************************************************************************/
+
+#include <systemc>
+#include <iomanip>
+
+SC_MODULE(module)
+{
+ sc_core::sc_in<bool> rst_in;
+ sc_core::sc_event ev;
+
+ SC_CTOR(module)
+ : rst_in("rst_in")
+ , ev("ev")
+ {
+ SC_THREAD(thread0);
+ sensitive << ev;
+ async_reset_signal_is(rst_in,true);
+
+ SC_THREAD(thread1);
+ sensitive << ev;
+ async_reset_signal_is(rst_in,true);
+ dont_initialize();
+
+ SC_METHOD(method0);
+ sensitive << ev;
+ async_reset_signal_is(rst_in,true);
+
+ SC_METHOD(method1);
+ sensitive << ev;
+ async_reset_signal_is(rst_in,true);
+ dont_initialize();
+ }
+
+ void thread0() { do_thread(); }
+ void thread1() { do_thread(); }
+
+ void do_thread()
+ {
+ print( "reset state" );
+ wait();
+ print( "reset done" );
+
+ while(1) // main loop
+ {
+ wait();
+ print( "continuing" );
+ }
+ }
+
+ void method0() { do_method(); }
+ void method1() { do_method(); }
+
+ void do_method()
+ {
+ if( rst_in.read() ) {
+ print("reset state");
+ } else {
+ print("running");
+ }
+ }
+
+ void print(const char* msg)
+ {
+ using namespace sc_core;
+ using namespace std;
+ cout
+ << setw(6) << sc_time_stamp()
+ << " (" << sc_delta_count() << "): "
+ << sc_get_current_process_handle().name() << ": "
+ << msg
+ << endl;
+ }
+}; // SC_MODULE(module)
+
+int sc_main(int argc, char* argv[])
+{
+ using namespace sc_core;
+ using namespace std;
+
+ sc_signal<bool> rst_sig;
+ rst_sig.write(true);
+
+ module top("top");
+ top.rst_in(rst_sig);
+
+ cout << "Starting simulation ... " << endl;
+
+ sc_start(10, SC_NS);
+ top.ev.notify(SC_ZERO_TIME);
+ sc_start(10, SC_NS);
+
+ rst_sig.write(false); // releasing reset
+
+ sc_start(10, SC_NS);
+ top.ev.notify(SC_ZERO_TIME);
+ sc_start(10, SC_NS);
+ top.ev.notify(SC_ZERO_TIME);
+ sc_start(10, SC_NS);
+
+ rst_sig.write(true); // entering reset
+
+ sc_start(10, SC_NS);
+ top.ev.notify(SC_ZERO_TIME);
+ sc_start(10, SC_NS);
+
+ cout << "... done." << endl;
+ sc_stop();
+ return 0;
+}
+
diff --git a/src/systemc/tests/systemc/bugs/async_reset_init/golden/async_reset_init.log b/src/systemc/tests/systemc/bugs/async_reset_init/golden/async_reset_init.log
new file mode 100644
index 000000000..681bfe511
--- /dev/null
+++ b/src/systemc/tests/systemc/bugs/async_reset_init/golden/async_reset_init.log
@@ -0,0 +1,30 @@
+SystemC Simulation
+Starting simulation ...
+ 0 s (0): top.method1: reset state
+ 0 s (0): top.method0: reset state
+ 0 s (0): top.method0: reset state
+ 0 s (0): top.thread0: reset state
+ 0 s (0): top.thread1: reset state
+ 10 ns (1): top.method1: reset state
+ 10 ns (1): top.method0: reset state
+ 10 ns (1): top.thread1: reset state
+ 10 ns (1): top.thread0: reset state
+ 30 ns (2): top.method1: running
+ 30 ns (2): top.method0: running
+ 30 ns (2): top.thread1: reset done
+ 30 ns (2): top.thread0: reset done
+ 40 ns (3): top.method1: running
+ 40 ns (3): top.method0: running
+ 40 ns (3): top.thread1: continuing
+ 40 ns (3): top.thread0: continuing
+ 50 ns (4): top.method1: reset state
+ 50 ns (4): top.method0: reset state
+ 50 ns (4): top.thread0: reset state
+ 50 ns (4): top.thread1: reset state
+ 60 ns (5): top.method1: reset state
+ 60 ns (5): top.method0: reset state
+ 60 ns (5): top.thread1: reset state
+ 60 ns (5): top.thread0: reset state
+... done.
+
+Info: /OSCI/SystemC: Simulation stopped by user.
diff --git a/src/systemc/tests/systemc/bugs/bug_147853/bug_147853.cpp b/src/systemc/tests/systemc/bugs/bug_147853/bug_147853.cpp
new file mode 100644
index 000000000..82c20d6a3
--- /dev/null
+++ b/src/systemc/tests/systemc/bugs/bug_147853/bug_147853.cpp
@@ -0,0 +1,34 @@
+// This tests that sc_clock values are updated during the value update phase
+// not during the execution phase of a delta cycle.
+
+#include "systemc.h"
+
+
+SC_MODULE(Test) {
+ sc_in_clk clk;
+ sc_event e1;
+ sc_time d;
+
+ void main() {
+ cerr << sc_time_stamp() <<" " << name() << " clk = " << clk.read() << "\n";
+ e1.notify(d);
+ }
+ SC_CTOR(Test) :d(5,SC_NS) {
+ SC_METHOD(main);
+ sensitive << e1;
+ }
+};
+
+
+int sc_main(int argc,char *argv[]) {
+
+ Test t1("t1");
+ sc_clock clk("clk",10,SC_NS);
+ Test t2("t2");
+
+ t1.clk(clk);
+ t2.clk(clk);
+
+ sc_start(50,SC_NS);
+ return 0;
+}
diff --git a/src/systemc/tests/systemc/bugs/bug_147853/golden/bug_147853.log b/src/systemc/tests/systemc/bugs/bug_147853/golden/bug_147853.log
new file mode 100644
index 000000000..cb6267fb4
--- /dev/null
+++ b/src/systemc/tests/systemc/bugs/bug_147853/golden/bug_147853.log
@@ -0,0 +1,21 @@
+SystemC Simulation
+0 s t1 clk = 0
+0 s t2 clk = 0
+5 ns t1 clk = 1
+5 ns t2 clk = 1
+10 ns t1 clk = 0
+10 ns t2 clk = 0
+15 ns t1 clk = 1
+15 ns t2 clk = 1
+20 ns t1 clk = 0
+20 ns t2 clk = 0
+25 ns t1 clk = 1
+25 ns t2 clk = 1
+30 ns t1 clk = 0
+30 ns t2 clk = 0
+35 ns t1 clk = 1
+35 ns t2 clk = 1
+40 ns t1 clk = 0
+40 ns t2 clk = 0
+45 ns t1 clk = 1
+45 ns t2 clk = 1
diff --git a/src/systemc/tests/systemc/bugs/bug_185/bug_185.cpp b/src/systemc/tests/systemc/bugs/bug_185/bug_185.cpp
new file mode 100644
index 000000000..d314a3504
--- /dev/null
+++ b/src/systemc/tests/systemc/bugs/bug_185/bug_185.cpp
@@ -0,0 +1,26 @@
+// Bug 185 Test - sc_bv(char) constructor.
+//
+// sc_bv<8> a('1') was yielding an all-zero value rather than all ones.
+
+
+#include "systemc.h"
+
+int sc_main(int argc, char* argv[])
+{
+ sc_bv<8> a('0');
+ sc_bv<9> b('1');
+ sc_bv<11> c(false);
+ sc_bv<11> d(true);
+ sc_bv<11> e(0);
+ sc_bv<11> f(1);
+
+ cout << "a = " << a << endl;
+ cout << "b = " << b << endl;
+ cout << "c = " << c << endl;
+ cout << "d = " << d << endl;
+ cout << "e = " << e << endl;
+ cout << "f = " << f << endl;
+
+ cerr << "Program completed" << endl;
+ return 0;
+}
diff --git a/src/systemc/tests/systemc/bugs/bug_185/golden/bug_185.log b/src/systemc/tests/systemc/bugs/bug_185/golden/bug_185.log
new file mode 100644
index 000000000..e022eb2d5
--- /dev/null
+++ b/src/systemc/tests/systemc/bugs/bug_185/golden/bug_185.log
@@ -0,0 +1,8 @@
+SystemC Simulation
+a = 00000000
+b = 111111111
+c = 00000000000
+d = 11111111111
+e = 00000000000
+f = 00000000001
+Program completed
diff --git a/src/systemc/tests/systemc/bugs/bug_70/bug_70.cpp b/src/systemc/tests/systemc/bugs/bug_70/bug_70.cpp
new file mode 100644
index 000000000..e36a1e57b
--- /dev/null
+++ b/src/systemc/tests/systemc/bugs/bug_70/bug_70.cpp
@@ -0,0 +1,29 @@
+// Bug 70 - Problems with part selections on sc_biguint.
+
+#include "systemc.h"
+//#include "iomanip.h"
+
+int sc_main(int argc, char* argv[])
+{
+ sc_biguint< 16 > a, b, c;
+ //sc_uint< 16 > a, b ;
+
+ a = 0x5A6C ;
+ b = 0 ;
+ c = 0 ;
+
+ cout << "a: " << a.to_string(SC_HEX) << endl ;
+ cout << "b: " << b.to_string(SC_HEX) << " - So far so good" << endl ;
+ cout << "c: " << c.to_string(SC_HEX) << " - So far so good" << endl ;
+
+ b(7,0) = a(15,8) ; // Now b should be "0x005A" or ???
+ c = a(15,8) ; // Now c should be "0x005A" or ???
+
+ cout << "a: " << a.to_string(SC_HEX) << endl ;
+ cout << "b: " << b.to_string(SC_HEX) << endl ;
+ cout << "c: " << c.to_string(SC_HEX) << endl ;
+
+ sc_stop() ;
+ return 0;
+}
+
diff --git a/src/systemc/tests/systemc/bugs/bug_70/golden/bug_70.log b/src/systemc/tests/systemc/bugs/bug_70/golden/bug_70.log
new file mode 100644
index 000000000..d8a7be7f2
--- /dev/null
+++ b/src/systemc/tests/systemc/bugs/bug_70/golden/bug_70.log
@@ -0,0 +1,9 @@
+SystemC Simulation
+a: 0x05a6c
+b: 0x00000 - So far so good
+c: 0x00000 - So far so good
+a: 0x05a6c
+b: 0x0005a
+c: 0x0005a
+
+Info: /OSCI/SystemC: Simulation stopped by user.
diff --git a/src/systemc/tests/systemc/bugs/constructor_throw/constructor_throw.cpp b/src/systemc/tests/systemc/bugs/constructor_throw/constructor_throw.cpp
new file mode 100644
index 000000000..560643bc1
--- /dev/null
+++ b/src/systemc/tests/systemc/bugs/constructor_throw/constructor_throw.cpp
@@ -0,0 +1,86 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ test01.cpp --
+
+ Original Author: Andy Goodrich, Forte Design Systems, 14 March 2006
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ $Log: constructor_throw.cpp,v $
+ Revision 1.1.1.1 2006/12/15 20:25:56 acg
+ systemc_tests-2.3
+
+ Revision 1.1 2006/03/15 00:12:08 acg
+ Andy Goodrich: Forte Design Systems
+ First check in.
+
+ *****************************************************************************/
+
+// This tests a bug when an exception is thrown in
+// sc_module::sc_module() for a dynamically allocated sc_module
+// object. We are calling sc_module::end_module() on a module that has
+// already been deleted. The scenario runs like this:
+//
+// a) the sc_module constructor is entered
+// b) the exception is thrown
+// c) the exception processor deletes the storage for the sc_module
+// d) the stack is unrolled causing the sc_module_name instance to be deleted
+// e) ~sc_module_name() calls end_module() with its pointer to the sc_module
+// f) because the sc_module has been deleted its storage is corrupted,
+// either by linking it to a free space chain, or by reuse of some sort
+// g) the m_simc field is garbage
+// h) the m_object_manager field is also garbage
+// i) an exception occurs
+//
+// This does not happen for automatic sc_module instances since the
+// storage for the module is not reclaimed its just part of the stack.
+//
+// I am fixing this by having the destructor for sc_module clear the
+// module pointer in its sc_module_name instance. That cuts things at
+// step (e) above, since the pointer will be null if the module has
+// already been deleted. To make sure the module stack is okay, I call
+// end-module() in ~sc_module in the case where there is an
+// sc_module_name pointer lying around.
+
+#include "systemc.h"
+
+SC_MODULE(X)
+{
+ SC_CTOR(X)
+ {
+ SC_REPORT_ERROR(SC_ID_SET_TIME_RESOLUTION_,"");
+ }
+};
+
+int sc_main(int argc, char* argv[])
+{
+ sc_module* x_p = new X("x");
+
+ cout << "Program completed" << endl;
+ return 0;
+}
+
diff --git a/src/systemc/tests/systemc/bugs/constructor_throw/golden/constructor_throw.log b/src/systemc/tests/systemc/bugs/constructor_throw/golden/constructor_throw.log
new file mode 100644
index 000000000..6401c8a94
--- /dev/null
+++ b/src/systemc/tests/systemc/bugs/constructor_throw/golden/constructor_throw.log
@@ -0,0 +1,4 @@
+SystemC Simulation
+
+Error: (E514) set time resolution failed
+In file: <removed by verify.pl>
diff --git a/src/systemc/tests/systemc/bugs/instantiation_detection/golden/instantiation_detection.log b/src/systemc/tests/systemc/bugs/instantiation_detection/golden/instantiation_detection.log
new file mode 100644
index 000000000..4ba693b97
--- /dev/null
+++ b/src/systemc/tests/systemc/bugs/instantiation_detection/golden/instantiation_detection.log
@@ -0,0 +1,161 @@
+SystemC Simulation
+
+Error: (E100) port specified outside of module: port 'port_0' (sc_port_base)
+In file: <removed by verify.pl>
+
+Error: (E122) sc_export specified outside of module: export 'export_0' (sc_object)
+In file: <removed by verify.pl>
+
+---8<--- end_of_elaboration ---8<---
+
+Error: (E529) insert module failed: elaboration done
+In file: <removed by verify.pl>
+
+Error: (E110) insert port failed: elaboration done: port 'dut.port_0' (sc_port_base)
+In file: <removed by verify.pl>
+
+Error: (E121) insert sc_export failed: elaboration done: export 'dut.export_0' (sc_object)
+In file: <removed by verify.pl>
+
+Error: (E113) insert primitive channel failed: elaboration done
+In file: <removed by verify.pl>
+
+--->8--- end_of_elaboration --->8---
+
+---8<--- start_of_simulation ---8<---
+
+Error: (E529) insert module failed: elaboration done
+In file: <removed by verify.pl>
+
+Error: (E110) insert port failed: elaboration done: port 'dut.port_1' (sc_port_base)
+In file: <removed by verify.pl>
+
+Error: (E121) insert sc_export failed: elaboration done: export 'dut.export_1' (sc_object)
+In file: <removed by verify.pl>
+
+Error: (E113) insert primitive channel failed: elaboration done
+In file: <removed by verify.pl>
+
+--->8--- start_of_simulation --->8---
+
+Error: (E529) insert module failed: simulation running
+In file: <removed by verify.pl>
+In process: dut.create_things_1 @ 0 s
+
+Error: (E110) insert port failed: simulation running: port 'dut.create_things_1.port_0' (sc_port_base)
+In file: <removed by verify.pl>
+In process: dut.create_things_1 @ 0 s
+
+Error: (E121) insert sc_export failed: simulation running: export 'dut.create_things_1.export_0' (sc_object)
+In file: <removed by verify.pl>
+In process: dut.create_things_1 @ 0 s
+
+Error: (E113) insert primitive channel failed: simulation running
+In file: <removed by verify.pl>
+In process: dut.create_things_1 @ 0 s
+
+Error: (E542) call to SC_THREAD in sc_module while simulation running: dut.create_things_1.create_things
+In file: <removed by verify.pl>
+In process: dut.create_things_1 @ 0 s
+
+Error: (E541) call to SC_METHOD in sc_module while simulation running: dut.create_things_1.create_things
+In file: <removed by verify.pl>
+In process: dut.create_things_1 @ 0 s
+
+Error: (E529) insert module failed: simulation running
+In file: <removed by verify.pl>
+In process: dut.create_things_3 @ 0 s
+
+Error: (E110) insert port failed: simulation running: port 'dut.create_things_3.port_0' (sc_port_base)
+In file: <removed by verify.pl>
+In process: dut.create_things_3 @ 0 s
+
+Error: (E121) insert sc_export failed: simulation running: export 'dut.create_things_3.export_0' (sc_object)
+In file: <removed by verify.pl>
+In process: dut.create_things_3 @ 0 s
+
+Error: (E113) insert primitive channel failed: simulation running
+In file: <removed by verify.pl>
+In process: dut.create_things_3 @ 0 s
+
+Error: (E542) call to SC_THREAD in sc_module while simulation running: dut.create_things_3.create_things
+In file: <removed by verify.pl>
+In process: dut.create_things_3 @ 0 s
+
+Error: (E541) call to SC_METHOD in sc_module while simulation running: dut.create_things_3.create_things
+In file: <removed by verify.pl>
+In process: dut.create_things_3 @ 0 s
+
+Error: (E529) insert module failed: simulation running
+In file: <removed by verify.pl>
+In process: dut.create_things @ 0 s
+
+Error: (E110) insert port failed: simulation running: port 'dut.create_things.port_0' (sc_port_base)
+In file: <removed by verify.pl>
+In process: dut.create_things @ 0 s
+
+Error: (E121) insert sc_export failed: simulation running: export 'dut.create_things.export_0' (sc_object)
+In file: <removed by verify.pl>
+In process: dut.create_things @ 0 s
+
+Error: (E113) insert primitive channel failed: simulation running
+In file: <removed by verify.pl>
+In process: dut.create_things @ 0 s
+
+Error: (E542) call to SC_THREAD in sc_module while simulation running: dut.create_things.create_things
+In file: <removed by verify.pl>
+In process: dut.create_things @ 0 s
+
+Error: (E541) call to SC_METHOD in sc_module while simulation running: dut.create_things.create_things
+In file: <removed by verify.pl>
+In process: dut.create_things @ 0 s
+
+Error: (E529) insert module failed: simulation running
+In file: <removed by verify.pl>
+In process: dut.create_things_0 @ 0 s
+
+Error: (E110) insert port failed: simulation running: port 'dut.create_things_0.port_0' (sc_port_base)
+In file: <removed by verify.pl>
+In process: dut.create_things_0 @ 0 s
+
+Error: (E121) insert sc_export failed: simulation running: export 'dut.create_things_0.export_0' (sc_object)
+In file: <removed by verify.pl>
+In process: dut.create_things_0 @ 0 s
+
+Error: (E113) insert primitive channel failed: simulation running
+In file: <removed by verify.pl>
+In process: dut.create_things_0 @ 0 s
+
+Error: (E542) call to SC_THREAD in sc_module while simulation running: dut.create_things_0.create_things
+In file: <removed by verify.pl>
+In process: dut.create_things_0 @ 0 s
+
+Error: (E541) call to SC_METHOD in sc_module while simulation running: dut.create_things_0.create_things
+In file: <removed by verify.pl>
+In process: dut.create_things_0 @ 0 s
+
+Error: (E529) insert module failed: simulation running
+In file: <removed by verify.pl>
+In process: dut.create_things_2 @ 0 s
+
+Error: (E110) insert port failed: simulation running: port 'dut.create_things_2.port_0' (sc_port_base)
+In file: <removed by verify.pl>
+In process: dut.create_things_2 @ 0 s
+
+Error: (E121) insert sc_export failed: simulation running: export 'dut.create_things_2.export_0' (sc_object)
+In file: <removed by verify.pl>
+In process: dut.create_things_2 @ 0 s
+
+Error: (E113) insert primitive channel failed: simulation running
+In file: <removed by verify.pl>
+In process: dut.create_things_2 @ 0 s
+
+Error: (E542) call to SC_THREAD in sc_module while simulation running: dut.create_things_2.create_things
+In file: <removed by verify.pl>
+In process: dut.create_things_2 @ 0 s
+
+Error: (E541) call to SC_METHOD in sc_module while simulation running: dut.create_things_2.create_things
+In file: <removed by verify.pl>
+In process: dut.create_things_2 @ 0 s
+
+Success
diff --git a/src/systemc/tests/systemc/bugs/instantiation_detection/instantiation_detection.cpp b/src/systemc/tests/systemc/bugs/instantiation_detection/instantiation_detection.cpp
new file mode 100644
index 000000000..b3cd75b6d
--- /dev/null
+++ b/src/systemc/tests/systemc/bugs/instantiation_detection/instantiation_detection.cpp
@@ -0,0 +1,113 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ end_of_elaboration.cpp -- Check instantiation detection
+
+ Original Author: Philipp A. Hartmann, OFFIS, 2011-02-14
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+
+#include <systemc.h>
+
+template< typename T >
+T* create( const char* nm )
+{
+ try {
+ return new T( sc_gen_unique_name(nm) );
+ }
+ catch ( sc_report const & x )
+ {
+ std::cout << "\n" << x.what() << std::endl;
+ }
+ return 0; // error detected, return NULL
+}
+
+SC_MODULE(sub_module)
+{
+ SC_CTOR(sub_module){}
+};
+
+SC_MODULE(top)
+{
+ SC_CTOR(top){
+ SC_THREAD( create_things );
+ }
+
+ void create_things()
+ {
+ sc_assert( create<sub_module>("sub_module") == NULL );
+ sc_assert( create<sc_in<bool> >("port") == NULL );
+ sc_assert( create<sc_export<sc_signal_in_if<bool> > >("export") == NULL );
+ sc_assert( create<sc_signal<bool> >("signal") == NULL );
+
+ try {
+ SC_THREAD(create_things);
+ } catch ( sc_report const & x ) {
+ std::cout << "\n" << x.what() << std::endl;
+ }
+
+ try {
+ SC_METHOD(create_things);
+ } catch ( sc_report const & x ) {
+ std::cout << "\n" << x.what() << std::endl;
+ }
+ }
+
+#if 1
+ void start_of_simulation()
+ {
+ std:: cout << "\n---8<--- start_of_simulation ---8<---\n";
+ create_things();
+ std:: cout << "\n--->8--- start_of_simulation --->8---\n";
+ }
+ void end_of_elaboration()
+ {
+ std:: cout << "\n---8<--- end_of_elaboration ---8<---\n";
+ create_things();
+ std:: cout << "\n--->8--- end_of_elaboration --->8---\n";
+ }
+#endif
+};
+
+int sc_main( int, char*[] )
+{
+ sc_report_handler::set_actions( "object already exists", SC_DO_NOTHING );
+
+ top dut("dut");
+
+ // disallow ports and exports outside of modules
+ sc_assert( create<sc_in<bool> >("port") == NULL );
+ sc_assert( create<sc_export<sc_signal_in_if<bool> > >("export") == NULL );
+
+ sc_start( 1, SC_NS );
+ std::cout << "\nSuccess" << std::endl;
+ return 0;
+}
diff --git a/src/systemc/tests/systemc/bugs/sc_bigint_part_select/test01/golden/test01.log b/src/systemc/tests/systemc/bugs/sc_bigint_part_select/test01/golden/test01.log
new file mode 100644
index 000000000..3c0381b46
--- /dev/null
+++ b/src/systemc/tests/systemc/bugs/sc_bigint_part_select/test01/golden/test01.log
@@ -0,0 +1,10 @@
+SystemC Simulation
+ bw:0x999888fffeeedddcccbbbaaa
+ f0:0x0aaa
+ f1:0x0bbb
+ f2:0x0ccc
+ f3:0x0ddd
+ f4:0x0eee
+ f5:0x0fff
+ f6:0x0888
+ f7:0x0999
diff --git a/src/systemc/tests/systemc/bugs/sc_bigint_part_select/test01/test01.cpp b/src/systemc/tests/systemc/bugs/sc_bigint_part_select/test01/test01.cpp
new file mode 100644
index 000000000..23aca446b
--- /dev/null
+++ b/src/systemc/tests/systemc/bugs/sc_bigint_part_select/test01/test01.cpp
@@ -0,0 +1,70 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ sc_main.cpp --
+
+ Original Author: Ray Ryan, Mentor Graphics, 2002-02-15
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+
+#include "systemc.h"
+
+SC_MODULE(sctop) {
+ SC_CTOR(sctop);
+};
+
+#ifdef MTI_INTEGRATION
+ SC_MODULE_EXPORT(sctop);
+#endif
+
+sctop::sctop(sc_module_name name) : sc_module(name)
+{
+ sc_bigint<96> bigword("0x999888fffeeedddcccbbbaaa");
+
+ cout << " bw:" << bigword.to_string(SC_HEX)
+ << "\n f0:" << bigword.range( 11, 0).to_string(SC_HEX)
+ << "\n f1:" << bigword.range( 23, 12).to_string(SC_HEX)
+ << "\n f2:" << bigword.range( 35, 24).to_string(SC_HEX)
+ << "\n f3:" << bigword.range( 47, 36).to_string(SC_HEX)
+ << "\n f4:" << bigword.range( 59, 48).to_string(SC_HEX)
+ << "\n f5:" << bigword.range( 71, 60).to_string(SC_HEX)
+ << "\n f6:" << bigword.range( 83, 72).to_string(SC_HEX)
+ << "\n f7:" << bigword.range( 95, 84).to_string(SC_HEX)
+ << endl;
+
+}
+int sc_main(int argc, char** argv) {
+ sctop top("top");
+ sc_start(1, SC_NS);
+ return 0;
+}
+
+
diff --git a/src/systemc/tests/systemc/bugs/sc_string_bracket_assign/golden/sc_string_bracket_assign.log b/src/systemc/tests/systemc/bugs/sc_string_bracket_assign/golden/sc_string_bracket_assign.log
new file mode 100644
index 000000000..4811e4392
--- /dev/null
+++ b/src/systemc/tests/systemc/bugs/sc_string_bracket_assign/golden/sc_string_bracket_assign.log
@@ -0,0 +1,3 @@
+SystemC Simulation
+s5: abc
+s6: aXc
diff --git a/src/systemc/tests/systemc/bugs/sc_string_bracket_assign/sc_string_bracket_assign.cpp b/src/systemc/tests/systemc/bugs/sc_string_bracket_assign/sc_string_bracket_assign.cpp
new file mode 100644
index 000000000..8014fb07f
--- /dev/null
+++ b/src/systemc/tests/systemc/bugs/sc_string_bracket_assign/sc_string_bracket_assign.cpp
@@ -0,0 +1,17 @@
+
+#if !defined(SC_USE_SC_STRING_OLD) && !defined(SC_USE_STD_STRING)
+# define SC_USE_SC_STRING_OLD
+//# define SC_USE_STD_STRING
+#endif //SC_USE_STRING_*
+
+#include "systemc.h"
+
+int sc_main(int argc, char* argv[])
+{
+ sc_string s5 = "abc";
+ sc_string s6 = s5;
+
+ s6[1] ='X';
+ cout << "s5: " << s5 << endl << "s6: " << s6 << endl;
+ return 0;
+}
diff --git a/src/systemc/tests/systemc/bugs/sign_extension/golden/sign_extension.log b/src/systemc/tests/systemc/bugs/sign_extension/golden/sign_extension.log
new file mode 100644
index 000000000..233ac07ad
--- /dev/null
+++ b/src/systemc/tests/systemc/bugs/sign_extension/golden/sign_extension.log
@@ -0,0 +1,11 @@
+SystemC Simulation
+v_sc_int_31_min=0b1000000000000000000000000000000
+v_sc_bigint_31_min=0b1000000000000000000000000000000
+v_sc_uint32_max=0b011111111111111111111111111111111
+v_sc_biguint_32_max=0b011111111111111111111111111111111
+v_sc_bigint_31_min & v_uint_max=0b11000000000000000000000000000000
+v_sc_bigint_31_min & v_sc_biguint_32_max=0b011000000000000000000000000000000
+int31_uint=0b0000000000000000000000000000000011000000000000000000000000000000
+bigint31_uint=0b1111111111111111111111111111111111000000000000000000000000000000
+bigint31_uint32=0b0000000000000000000000000000000011000000000000000000000000000000
+bigint31_biguint32=0b0000000000000000000000000000000011000000000000000000000000000000
diff --git a/src/systemc/tests/systemc/bugs/sign_extension/golden/sign_extension.log.bsd64 b/src/systemc/tests/systemc/bugs/sign_extension/golden/sign_extension.log.bsd64
new file mode 100644
index 000000000..3d7ccbcae
--- /dev/null
+++ b/src/systemc/tests/systemc/bugs/sign_extension/golden/sign_extension.log.bsd64
@@ -0,0 +1,11 @@
+SystemC Simulation
+v_sc_int_31_min=0b1000000000000000000000000000000
+v_sc_bigint_31_min=0b1000000000000000000000000000000
+v_sc_uint32_max=0b011111111111111111111111111111111
+v_sc_biguint_32_max=0b011111111111111111111111111111111
+v_sc_bigint_31_min & v_uint_max=0b0000000000000000000000000000000011000000000000000000000000000000
+v_sc_bigint_31_min & v_sc_biguint_32_max=0b011000000000000000000000000000000
+int31_uint=0b0000000000000000000000000000000011000000000000000000000000000000
+bigint31_uint=0b0000000000000000000000000000000011000000000000000000000000000000
+bigint31_uint32=0b0000000000000000000000000000000011000000000000000000000000000000
+bigint31_biguint32=0b0000000000000000000000000000000011000000000000000000000000000000
diff --git a/src/systemc/tests/systemc/bugs/sign_extension/golden/sign_extension.log.cygwin64 b/src/systemc/tests/systemc/bugs/sign_extension/golden/sign_extension.log.cygwin64
new file mode 100644
index 000000000..3d7ccbcae
--- /dev/null
+++ b/src/systemc/tests/systemc/bugs/sign_extension/golden/sign_extension.log.cygwin64
@@ -0,0 +1,11 @@
+SystemC Simulation
+v_sc_int_31_min=0b1000000000000000000000000000000
+v_sc_bigint_31_min=0b1000000000000000000000000000000
+v_sc_uint32_max=0b011111111111111111111111111111111
+v_sc_biguint_32_max=0b011111111111111111111111111111111
+v_sc_bigint_31_min & v_uint_max=0b0000000000000000000000000000000011000000000000000000000000000000
+v_sc_bigint_31_min & v_sc_biguint_32_max=0b011000000000000000000000000000000
+int31_uint=0b0000000000000000000000000000000011000000000000000000000000000000
+bigint31_uint=0b0000000000000000000000000000000011000000000000000000000000000000
+bigint31_uint32=0b0000000000000000000000000000000011000000000000000000000000000000
+bigint31_biguint32=0b0000000000000000000000000000000011000000000000000000000000000000
diff --git a/src/systemc/tests/systemc/bugs/sign_extension/golden/sign_extension.log.linux64 b/src/systemc/tests/systemc/bugs/sign_extension/golden/sign_extension.log.linux64
new file mode 100644
index 000000000..3d7ccbcae
--- /dev/null
+++ b/src/systemc/tests/systemc/bugs/sign_extension/golden/sign_extension.log.linux64
@@ -0,0 +1,11 @@
+SystemC Simulation
+v_sc_int_31_min=0b1000000000000000000000000000000
+v_sc_bigint_31_min=0b1000000000000000000000000000000
+v_sc_uint32_max=0b011111111111111111111111111111111
+v_sc_biguint_32_max=0b011111111111111111111111111111111
+v_sc_bigint_31_min & v_uint_max=0b0000000000000000000000000000000011000000000000000000000000000000
+v_sc_bigint_31_min & v_sc_biguint_32_max=0b011000000000000000000000000000000
+int31_uint=0b0000000000000000000000000000000011000000000000000000000000000000
+bigint31_uint=0b0000000000000000000000000000000011000000000000000000000000000000
+bigint31_uint32=0b0000000000000000000000000000000011000000000000000000000000000000
+bigint31_biguint32=0b0000000000000000000000000000000011000000000000000000000000000000
diff --git a/src/systemc/tests/systemc/bugs/sign_extension/golden/sign_extension.log.linuxaarch64 b/src/systemc/tests/systemc/bugs/sign_extension/golden/sign_extension.log.linuxaarch64
new file mode 100644
index 000000000..3d7ccbcae
--- /dev/null
+++ b/src/systemc/tests/systemc/bugs/sign_extension/golden/sign_extension.log.linuxaarch64
@@ -0,0 +1,11 @@
+SystemC Simulation
+v_sc_int_31_min=0b1000000000000000000000000000000
+v_sc_bigint_31_min=0b1000000000000000000000000000000
+v_sc_uint32_max=0b011111111111111111111111111111111
+v_sc_biguint_32_max=0b011111111111111111111111111111111
+v_sc_bigint_31_min & v_uint_max=0b0000000000000000000000000000000011000000000000000000000000000000
+v_sc_bigint_31_min & v_sc_biguint_32_max=0b011000000000000000000000000000000
+int31_uint=0b0000000000000000000000000000000011000000000000000000000000000000
+bigint31_uint=0b0000000000000000000000000000000011000000000000000000000000000000
+bigint31_uint32=0b0000000000000000000000000000000011000000000000000000000000000000
+bigint31_biguint32=0b0000000000000000000000000000000011000000000000000000000000000000
diff --git a/src/systemc/tests/systemc/bugs/sign_extension/golden/sign_extension.log.macosx64 b/src/systemc/tests/systemc/bugs/sign_extension/golden/sign_extension.log.macosx64
new file mode 100644
index 000000000..3d7ccbcae
--- /dev/null
+++ b/src/systemc/tests/systemc/bugs/sign_extension/golden/sign_extension.log.macosx64
@@ -0,0 +1,11 @@
+SystemC Simulation
+v_sc_int_31_min=0b1000000000000000000000000000000
+v_sc_bigint_31_min=0b1000000000000000000000000000000
+v_sc_uint32_max=0b011111111111111111111111111111111
+v_sc_biguint_32_max=0b011111111111111111111111111111111
+v_sc_bigint_31_min & v_uint_max=0b0000000000000000000000000000000011000000000000000000000000000000
+v_sc_bigint_31_min & v_sc_biguint_32_max=0b011000000000000000000000000000000
+int31_uint=0b0000000000000000000000000000000011000000000000000000000000000000
+bigint31_uint=0b0000000000000000000000000000000011000000000000000000000000000000
+bigint31_uint32=0b0000000000000000000000000000000011000000000000000000000000000000
+bigint31_biguint32=0b0000000000000000000000000000000011000000000000000000000000000000
diff --git a/src/systemc/tests/systemc/bugs/sign_extension/sign_extension.cpp b/src/systemc/tests/systemc/bugs/sign_extension/sign_extension.cpp
new file mode 100644
index 000000000..c51fde25a
--- /dev/null
+++ b/src/systemc/tests/systemc/bugs/sign_extension/sign_extension.cpp
@@ -0,0 +1,75 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ sign_extension.cpp --
+
+ Original Author: Philipp A. Hartmann, OFFIS, 2012-07-17
+
+ -----------------------------------------------------------------------------
+
+ This test demonatrates a bug in the sc_biguint constructor(?), where
+ construction from bit-wise expressions with "unsigned int" and sc_bigint
+ may lead to wrongly sign-extended values (at least on 32-bit machines) when
+ the destination size is bigger than the source size.
+
+ *****************************************************************************/
+
+#include <systemc>
+using sc_dt::sc_int;
+using sc_dt::sc_uint;
+using sc_dt::sc_bigint;
+using sc_dt::sc_biguint;
+using sc_dt::SC_BIN;
+
+#define DUMP_VAR( Var ) \
+ std::cout << #Var "=" << (Var).to_string(SC_BIN) << "\n"
+
+int sc_main(int, char*[])
+{
+
+ sc_int<31> v_sc_int_31_min = (1<<30); // 010...0 (31 bit)
+ sc_bigint<31> v_sc_bigint_31_min = (1<<30); // 010...0
+ unsigned int v_uint_max = ~0; // 11....1 (32-bit)
+ sc_uint<32> v_sc_uint32_max = ~0; // 11....1 (32-bit)
+ sc_biguint<32> v_sc_biguint_32_max = -1; // 11....1 (32-bit)
+
+ DUMP_VAR( v_sc_int_31_min );
+ DUMP_VAR( v_sc_bigint_31_min );
+ DUMP_VAR( v_sc_uint32_max );
+ DUMP_VAR( v_sc_biguint_32_max );
+
+ sc_bigint<64> int31_uint = (v_sc_int_31_min & v_uint_max);
+ // the following expression yields 0b1....10...0 on 32-bit machines
+ sc_bigint<64> bigint31_uint = (v_sc_bigint_31_min & v_uint_max);
+ sc_bigint<64> bigint31_uint32 = (v_sc_bigint_31_min & v_sc_uint32_max);
+ sc_bigint<64> bigint31_biguint32 = (v_sc_bigint_31_min & v_sc_biguint_32_max);
+
+ DUMP_VAR( v_sc_bigint_31_min & v_uint_max );
+ DUMP_VAR( v_sc_bigint_31_min & v_sc_biguint_32_max );
+
+ DUMP_VAR(int31_uint);
+ DUMP_VAR(bigint31_uint); // <--
+ DUMP_VAR(bigint31_uint32);
+ DUMP_VAR(bigint31_biguint32);
+
+ return 0;
+}
+
diff --git a/src/systemc/tests/systemc/bugs/stack_alignment/.notsparcOS5 b/src/systemc/tests/systemc/bugs/stack_alignment/.notsparcOS5
new file mode 100644
index 000000000..f40b3ddeb
--- /dev/null
+++ b/src/systemc/tests/systemc/bugs/stack_alignment/.notsparcOS5
@@ -0,0 +1 @@
+# This bug is assumed not to affect the 32-bit SPARC architecture.
diff --git a/src/systemc/tests/systemc/bugs/stack_alignment/golden/stack_alignment.log b/src/systemc/tests/systemc/bugs/stack_alignment/golden/stack_alignment.log
new file mode 100644
index 000000000..fcb395ef9
--- /dev/null
+++ b/src/systemc/tests/systemc/bugs/stack_alignment/golden/stack_alignment.log
@@ -0,0 +1,6 @@
+SystemC Simulation
+Inside sc_main()
+Inside C::run()
+Between C::run()
+Out of C::run()
+Out of sc_main()
diff --git a/src/systemc/tests/systemc/bugs/stack_alignment/stack_alignment.cpp b/src/systemc/tests/systemc/bugs/stack_alignment/stack_alignment.cpp
new file mode 100644
index 000000000..e20395e2f
--- /dev/null
+++ b/src/systemc/tests/systemc/bugs/stack_alignment/stack_alignment.cpp
@@ -0,0 +1,129 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ stack_alignment.cpp -- This example shows the crash of an fxsave instruction
+ in the sc_thread stack environment, but not in the
+ original linux process stack, which is correctly
+ aligned on first function.
+
+ Please note that this test probably runs OK on a faulty implementation in
+ 64-bit in general (depending on your libc implementation), but will crash
+ for sure in 32-bit.
+
+ Original Author: Eric Paire, STMicroelectronics
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+
+#include "systemc.h"
+
+/*
+ * This program exhibits a bug in the management by QT of the stack of each
+ * SystemC process. At least on i686 & x86_64, GCC makes the assumption that
+ * the stack is aligned on a 16-byte boundary on each C/C++ function entry.
+ * This convention allows GCC to respects constraints of automatic (stack)
+ * variable alignment, using the __attribute)__ ((align(X))) GCC extension.
+ *
+ * The X is known to be 16 for i686 & x86_64, as this is the largest alignment
+ * required by instructions operands, actually used by fxsave instruction.
+ *
+ * The attached code shows up the problem by crashing when fxsave is executed
+ * in a SystemC thread, and executing correctly the *same* code on the initial
+ * process stack, as initialized by the libc runtime.
+ *
+ * This misbehavior does not occur systematically for x86_64 (no crash,
+ * or crash difficult to reproduce with standard malloc()), but often does
+ * with i686. Notice that the instruction with the right alignment is shown
+ * when using the myfpxregs address which is aligned on 16-byte boundary.
+ */
+
+#if defined(__x86_64__)
+# define FXSAVE "fxsaveq"
+#else
+# define FXSAVE "fxsave"
+#endif
+
+#if defined(__GNUC__)
+# define ALIGNED_ARRAY( Type, Name, Size, Align ) \
+ Type Name[Size] __attribute__((aligned(Align)))
+#elif defined(_MSC_VER)
+# define ALIGNED_ARRAY( Type, Name, Size, Align ) \
+ __declspec(align(Align)) Type Name[Size]
+#endif
+
+#if defined(__GNUC__) && ( defined(__x86_64__) || defined(__i386__) )
+# define ASM( Assembly ) __asm__ __volatile__( Assembly )
+#else
+# define ASM( Assembly ) /* not implemented */
+#endif
+
+// Class
+SC_MODULE(C)
+{
+public:
+ SC_CTOR(C) {
+ SC_THREAD(run);
+ }
+ void run(void)
+ {
+ ALIGNED_ARRAY( char, fpxregs64, 512+15, 16 );
+
+ cout << "Inside C::run() " << endl;
+
+ // manually enforce alignment (volatile to avoid optmizations)
+ char * volatile myfpxregs = fpxregs64;
+ while ((uintptr_t)myfpxregs & 0xF)
+ myfpxregs++;
+
+ // the "real" requirement: enforced alignment works
+ sc_assert( !((uintptr_t)fpxregs64 & 0xF) );
+ sc_assert( !((uintptr_t)myfpxregs & 0xF) );
+ sc_assert( myfpxregs == fpxregs64 );
+
+ // test assembly on supported platforms
+ ASM( FXSAVE " (%0)" :: "r"(myfpxregs) );
+ cout << "Between C::run() " << endl;
+ ASM( FXSAVE " %0" : "=m"(fpxregs64) );
+
+ cout << "Out of C::run() " << endl;
+ }
+};
+
+int sc_main(int , char** ) {
+ C the_C("C");
+
+ ALIGNED_ARRAY( char, fpxregs64, 512, 16 );
+
+ cout << "Inside sc_main() " << endl;
+ ASM( FXSAVE " %0" : "=m"(fpxregs64) );
+ sc_start(1, SC_NS);
+ cout << "Out of sc_main() " << endl;
+ return 0;
+}