diff options
Diffstat (limited to 'src/systemc/tests/systemc/communication/sc_signal/check_writer')
32 files changed, 1910 insertions, 0 deletions
diff --git a/src/systemc/tests/systemc/communication/sc_signal/check_writer/test01/golden/test01.log b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test01/golden/test01.log new file mode 100644 index 000000000..95d2bcaa2 --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test01/golden/test01.log @@ -0,0 +1,8 @@ +SystemC Simulation + +Error: (E115) sc_signal<T> cannot have more than one driver: + signal `signal_0' (sc_signal) + first driver `a.main_action1' (sc_method_process) + second driver `a.main_action2' (sc_method_process) +In file: <removed by verify.pl> +In process: a.main_action2 @ 500 ps diff --git a/src/systemc/tests/systemc/communication/sc_signal/check_writer/test01/test01.cpp b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test01/test01.cpp new file mode 100644 index 000000000..c6d3c8cc8 --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test01/test01.cpp @@ -0,0 +1,103 @@ +/***************************************************************************** + + 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: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +// test of dynamic design rule checking in signals. + +// #define DEBUG_SYSTEMC +#include "systemc.h" + +SC_MODULE( mod_a ) +{ + sc_in_clk clk; + + sc_out<int> out_int; + sc_out<bool> out_bool; + sc_out<sc_logic> out_logic; + sc_out<int> out_int2; + sc_out_resolved out_resolved; + sc_out_rv<1> out_rv1; + + void main_action1() + { + out_int = 42; + out_bool = true; + out_logic = SC_LOGIC_1; + out_int2 = 1; + out_resolved = SC_LOGIC_1; + out_rv1 = sc_lv<1>( SC_LOGIC_1 ); + } + + void main_action2() + { + out_int = 0; + out_bool = false; + out_logic = SC_LOGIC_0; + out_int2 = 0; + out_resolved = SC_LOGIC_0; + out_rv1 = sc_lv<1>( SC_LOGIC_0 ); + } + + SC_CTOR( mod_a ) + { + SC_METHOD( main_action1 ); + sensitive << clk.pos(); + dont_initialize(); + SC_METHOD( main_action2 ); + sensitive << clk.neg(); + dont_initialize(); + } +}; + +int +sc_main( int, char*[] ) +{ + sc_clock clk; + + sc_signal<int> sig_int; + sc_signal<bool> sig_bool; + sc_signal<sc_logic> sig_logic; + sc_buffer<int> buf_int; + sc_signal_resolved sig_resolved; + sc_signal_rv<1> sig_rv1; + + mod_a a("a"); + a(clk,sig_int,sig_bool,sig_logic,buf_int,sig_resolved,sig_rv1); + + sc_start( 20, SC_NS ); + + return 0; +} diff --git a/src/systemc/tests/systemc/communication/sc_signal/check_writer/test02/golden/test02.log b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test02/golden/test02.log new file mode 100644 index 000000000..95d2bcaa2 --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test02/golden/test02.log @@ -0,0 +1,8 @@ +SystemC Simulation + +Error: (E115) sc_signal<T> cannot have more than one driver: + signal `signal_0' (sc_signal) + first driver `a.main_action1' (sc_method_process) + second driver `a.main_action2' (sc_method_process) +In file: <removed by verify.pl> +In process: a.main_action2 @ 500 ps diff --git a/src/systemc/tests/systemc/communication/sc_signal/check_writer/test02/test02.cpp b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test02/test02.cpp new file mode 100644 index 000000000..ec1d30ed2 --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test02/test02.cpp @@ -0,0 +1,103 @@ +/***************************************************************************** + + 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. + + *****************************************************************************/ + +/***************************************************************************** + + test02.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +// test of dynamic design rule checking in signals. + +#define DEBUG_SYSTEMC +#include "systemc.h" + +SC_MODULE( mod_a ) +{ + sc_in_clk clk; + + sc_out<int> out_int; + sc_out<bool> out_bool; + sc_out<sc_logic> out_logic; + sc_out<int> out_int2; + sc_out_resolved out_resolved; + sc_out_rv<1> out_rv1; + + void main_action1() + { + out_int = 42; + out_bool = true; + out_logic = SC_LOGIC_1; + out_int2 = 1; + out_resolved = SC_LOGIC_1; + out_rv1 = sc_lv<1>( SC_LOGIC_1 ); + } + + void main_action2() + { + out_int = 0; + out_bool = false; + out_logic = SC_LOGIC_0; + out_int2 = 0; + out_resolved = SC_LOGIC_0; + out_rv1 = sc_lv<1>( SC_LOGIC_0 ); + } + + SC_CTOR( mod_a ) + { + SC_METHOD( main_action1 ); + sensitive << clk.pos(); + dont_initialize(); + SC_METHOD( main_action2 ); + sensitive << clk.neg(); + dont_initialize(); + } +}; + +int +sc_main( int, char*[] ) +{ + sc_clock clk; + + sc_signal<int> sig_int; + sc_signal<bool> sig_bool; + sc_signal<sc_logic> sig_logic; + sc_buffer<int> buf_int; + sc_signal_resolved sig_resolved; + sc_signal_rv<1> sig_rv1; + + mod_a a("a"); + a(clk, sig_int, sig_bool, sig_logic, buf_int, sig_resolved, sig_rv1); + + sc_start( 20, SC_NS ); + + return 0; +} diff --git a/src/systemc/tests/systemc/communication/sc_signal/check_writer/test03/golden/test03.log b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test03/golden/test03.log new file mode 100644 index 000000000..5be096a49 --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test03/golden/test03.log @@ -0,0 +1,8 @@ +SystemC Simulation + +Error: (E115) sc_signal<T> cannot have more than one driver: + signal `sig_int' (sc_signal) + first driver `a.main_action1' (sc_method_process) + second driver `a.main_action2' (sc_method_process) +In file: <removed by verify.pl> +In process: a.main_action2 @ 500 ps diff --git a/src/systemc/tests/systemc/communication/sc_signal/check_writer/test03/test03.cpp b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test03/test03.cpp new file mode 100644 index 000000000..553014ff8 --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test03/test03.cpp @@ -0,0 +1,103 @@ +/***************************************************************************** + + 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. + + *****************************************************************************/ + +/***************************************************************************** + + test03.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +// test of dynamic design rule checking in signals. + +#define DEBUG_SYSTEMC +#include "systemc.h" + +SC_MODULE( mod_a ) +{ + sc_in_clk clk; + + sc_out<int> out_int; + sc_out<bool> out_bool; + sc_out<sc_logic> out_logic; + sc_out<int> out_int2; + sc_out_resolved out_resolved; + sc_out_rv<1> out_rv1; + + void main_action1() + { + out_int = 42; + out_bool = true; + out_logic = SC_LOGIC_1; + out_int2 = 1; + out_resolved = SC_LOGIC_1; + out_rv1 = sc_lv<1>( SC_LOGIC_1 ); + } + + void main_action2() + { + out_int = 0; + out_bool = false; + out_logic = SC_LOGIC_0; + out_int2 = 0; + out_resolved = SC_LOGIC_0; + out_rv1 = sc_lv<1>( SC_LOGIC_0 ); + } + + SC_CTOR( mod_a ) + { + SC_METHOD( main_action1 ); + sensitive << clk.pos(); + dont_initialize(); + SC_METHOD( main_action2 ); + sensitive << clk.neg(); + dont_initialize(); + } +}; + +int +sc_main( int, char*[] ) +{ + sc_clock clk; + + sc_signal<int> sig_int("sig_int"); + sc_signal<bool> sig_bool("sig_bool"); + sc_signal<sc_logic> sig_logic("sig_logic"); + sc_buffer<int> buf_int("buf_int"); + sc_signal_resolved sig_resolved("sig_resolved"); + sc_signal_rv<1> sig_rv1("sig_rv1"); + + mod_a a("a"); + a(clk, sig_int, sig_bool, sig_logic, buf_int, sig_resolved, sig_rv1); + + sc_start( 20, SC_NS ); + + return 0; +} diff --git a/src/systemc/tests/systemc/communication/sc_signal/check_writer/test04/golden/test04.log b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test04/golden/test04.log new file mode 100644 index 000000000..7efe9540e --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test04/golden/test04.log @@ -0,0 +1,8 @@ +SystemC Simulation + +Error: (E115) sc_signal<T> cannot have more than one driver: + signal `signal_2' (sc_signal) + first driver `a.main_action1' (sc_method_process) + second driver `a.main_action2' (sc_method_process) +In file: <removed by verify.pl> +In process: a.main_action2 @ 500 ps diff --git a/src/systemc/tests/systemc/communication/sc_signal/check_writer/test04/test04.cpp b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test04/test04.cpp new file mode 100644 index 000000000..af7d991aa --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test04/test04.cpp @@ -0,0 +1,103 @@ +/***************************************************************************** + + 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. + + *****************************************************************************/ + +/***************************************************************************** + + test04.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +// test of dynamic design rule checking in signals. + +#define DEBUG_SYSTEMC +#include "systemc.h" + +SC_MODULE( mod_a ) +{ + sc_in_clk clk; + + sc_out<int> out_int; + sc_out<bool> out_bool; + sc_out<sc_logic> out_logic; + sc_out<int> out_int2; + sc_out_resolved out_resolved; + sc_out_rv<1> out_rv1; + + void main_action1() + { + out_int = 42; + out_bool = true; + out_logic = SC_LOGIC_1; + out_int2 = 1; + out_resolved = SC_LOGIC_1; + out_rv1 = sc_lv<1>( SC_LOGIC_1 ); + } + + void main_action2() + { + // out_int = 0; + // out_bool = false; + out_logic = SC_LOGIC_0; + out_int2 = 0; + out_resolved = SC_LOGIC_0; + out_rv1 = sc_lv<1>( SC_LOGIC_0 ); + } + + SC_CTOR( mod_a ) + { + SC_METHOD( main_action1 ); + sensitive << clk.pos(); + dont_initialize(); + SC_METHOD( main_action2 ); + sensitive << clk.neg(); + dont_initialize(); + } +}; + +int +sc_main( int, char*[] ) +{ + sc_clock clk; + + sc_signal<int> sig_int; + sc_signal<bool> sig_bool; + sc_signal<sc_logic> sig_logic; + sc_buffer<int> buf_int; + sc_signal_resolved sig_resolved; + sc_signal_rv<1> sig_rv1; + + mod_a a("a"); + a(clk, sig_int, sig_bool, sig_logic, buf_int, sig_resolved, sig_rv1); + + sc_start( 20, SC_NS ); + + return 0; +} diff --git a/src/systemc/tests/systemc/communication/sc_signal/check_writer/test05/golden/test05.log b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test05/golden/test05.log new file mode 100644 index 000000000..1e2e6730e --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test05/golden/test05.log @@ -0,0 +1,8 @@ +SystemC Simulation + +Error: (E115) sc_signal<T> cannot have more than one driver: + signal `buffer_0' (sc_buffer) + first driver `a.main_action1' (sc_method_process) + second driver `a.main_action2' (sc_method_process) +In file: <removed by verify.pl> +In process: a.main_action2 @ 500 ps diff --git a/src/systemc/tests/systemc/communication/sc_signal/check_writer/test05/test05.cpp b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test05/test05.cpp new file mode 100644 index 000000000..482de1c2e --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test05/test05.cpp @@ -0,0 +1,103 @@ +/***************************************************************************** + + 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. + + *****************************************************************************/ + +/***************************************************************************** + + test05.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +// test of dynamic design rule checking in signals. + +#define DEBUG_SYSTEMC +#include "systemc.h" + +SC_MODULE( mod_a ) +{ + sc_in_clk clk; + + sc_out<int> out_int; + sc_out<bool> out_bool; + sc_out<sc_logic> out_logic; + sc_out<int> out_int2; + sc_out_resolved out_resolved; + sc_out_rv<1> out_rv1; + + void main_action1() + { + out_int = 42; + out_bool = true; + out_logic = SC_LOGIC_1; + out_int2 = 1; + out_resolved = SC_LOGIC_1; + out_rv1 = sc_lv<1>( SC_LOGIC_1 ); + } + + void main_action2() + { + // out_int = 0; + // out_bool = false; + // out_logic = SC_LOGIC_0; + out_int2 = 0; + out_resolved = SC_LOGIC_0; + out_rv1 = sc_lv<1>( SC_LOGIC_0 ); + } + + SC_CTOR( mod_a ) + { + SC_METHOD( main_action1 ); + sensitive << clk.pos(); + dont_initialize(); + SC_METHOD( main_action2 ); + sensitive << clk.neg(); + dont_initialize(); + } +}; + +int +sc_main( int, char*[] ) +{ + sc_clock clk; + + sc_signal<int> sig_int; + sc_signal<bool> sig_bool; + sc_signal<sc_logic> sig_logic; + sc_buffer<int> buf_int; + sc_signal_resolved sig_resolved; + sc_signal_rv<1> sig_rv1; + + mod_a a("a"); + a(clk, sig_int, sig_bool, sig_logic, buf_int, sig_resolved, sig_rv1); + + sc_start( 20, SC_NS ); + + return 0; +} diff --git a/src/systemc/tests/systemc/communication/sc_signal/check_writer/test06/golden/test06.log b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test06/golden/test06.log new file mode 100644 index 000000000..6d243dcc5 --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test06/golden/test06.log @@ -0,0 +1 @@ +SystemC Simulation diff --git a/src/systemc/tests/systemc/communication/sc_signal/check_writer/test06/test06.cpp b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test06/test06.cpp new file mode 100644 index 000000000..ee6ff58ee --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test06/test06.cpp @@ -0,0 +1,103 @@ +/***************************************************************************** + + 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. + + *****************************************************************************/ + +/***************************************************************************** + + test06.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +// test of dynamic design rule checking in signals. + +#define DEBUG_SYSTEMC +#include "systemc.h" + +SC_MODULE( mod_a ) +{ + sc_in_clk clk; + + sc_out<int> out_int; + sc_out<bool> out_bool; + sc_out<sc_logic> out_logic; + sc_out<int> out_int2; + sc_out_resolved out_resolved; + sc_out_rv<1> out_rv1; + + void main_action1() + { + out_int = 42; + out_bool = true; + out_logic = SC_LOGIC_1; + out_int2 = 1; + out_resolved = SC_LOGIC_1; + out_rv1 = sc_lv<1>( SC_LOGIC_1 ); + } + + void main_action2() + { + // out_int = 0; + // out_bool = false; + // out_logic = SC_LOGIC_0; + // out_int2 = 0; + out_resolved = SC_LOGIC_0; + out_rv1 = sc_lv<1>( SC_LOGIC_0 ); + } + + SC_CTOR( mod_a ) + { + SC_METHOD( main_action1 ); + sensitive << clk.pos(); + dont_initialize(); + SC_METHOD( main_action2 ); + sensitive << clk.neg(); + dont_initialize(); + } +}; + +int +sc_main( int, char*[] ) +{ + sc_clock clk; + + sc_signal<int> sig_int; + sc_signal<bool> sig_bool; + sc_signal<sc_logic> sig_logic; + sc_buffer<int> buf_int; + sc_signal_resolved sig_resolved; + sc_signal_rv<1> sig_rv1; + + mod_a a("a"); + a(clk, sig_int, sig_bool, sig_logic, buf_int, sig_resolved, sig_rv1); + + sc_start( 20, SC_NS ); + + return 0; +} diff --git a/src/systemc/tests/systemc/communication/sc_signal/check_writer/test07/golden/test07.log b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test07/golden/test07.log new file mode 100644 index 000000000..fa5aabca2 --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test07/golden/test07.log @@ -0,0 +1,8 @@ +SystemC Simulation + +Error: (E115) sc_signal<T> cannot have more than one driver: + signal `signal_1' (sc_signal) + first driver `a.main_action1' (sc_method_process) + second driver `a.main_action2' (sc_method_process) +In file: <removed by verify.pl> +In process: a.main_action2 @ 500 ps diff --git a/src/systemc/tests/systemc/communication/sc_signal/check_writer/test07/test07.cpp b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test07/test07.cpp new file mode 100644 index 000000000..89a9d6566 --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test07/test07.cpp @@ -0,0 +1,103 @@ +/***************************************************************************** + + 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. + + *****************************************************************************/ + +/***************************************************************************** + + test07.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: Andy Goodrich, Forte Design Systems, 15 Oct 2003 + Description of Modification: + + *****************************************************************************/ + +// test of dynamic design rule checking in specialized signals. + +#define DEBUG_SYSTEMC +#include "systemc.h" + +SC_MODULE( mod_a ) +{ + sc_in_clk clk; + + sc_out<int> out_int; + sc_out<sc_uint<1> > out_uint; + sc_out<sc_logic> out_logic; + sc_out<int> out_int2; + sc_out_resolved out_resolved; + sc_out_rv<1> out_rv1; + + void main_action1() + { + out_int = 42; + out_uint = 1; + out_logic = SC_LOGIC_1; + out_int2 = 1; + out_resolved = SC_LOGIC_1; + out_rv1 = sc_lv<1>( SC_LOGIC_1 ); + } + + void main_action2() + { + // out_int = 0; + out_uint = 0; + out_logic = SC_LOGIC_0; + out_int2 = 0; + out_resolved = SC_LOGIC_0; + out_rv1 = sc_lv<1>( SC_LOGIC_0 ); + } + + SC_CTOR( mod_a ) + { + SC_METHOD( main_action1 ); + sensitive << clk.pos(); + dont_initialize(); + SC_METHOD( main_action2 ); + sensitive << clk.neg(); + dont_initialize(); + } +}; + +int +sc_main( int, char*[] ) +{ + sc_clock clk; + + sc_signal<int> sig_int; + sc_signal<sc_uint<1> > sig_bool; + sc_signal<sc_logic> sig_logic; + sc_buffer<int> buf_int; + sc_signal_resolved sig_resolved; + sc_signal_rv<1> sig_rv1; + + mod_a a("a"); + a(clk, sig_int, sig_bool, sig_logic, buf_int, sig_resolved, sig_rv1); + + sc_start( 20, SC_NS ); + + return 0; +} diff --git a/src/systemc/tests/systemc/communication/sc_signal/check_writer/test08/golden/test08.log b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test08/golden/test08.log new file mode 100644 index 000000000..2d63f201f --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test08/golden/test08.log @@ -0,0 +1,7 @@ +SystemC Simulation + +Error: (E115) sc_signal<T> cannot have more than one driver: + signal `signal_0' (sc_signal) + first driver `a.port_2' (sc_out) + second driver `a.port_1' (sc_out) +In file: <removed by verify.pl> diff --git a/src/systemc/tests/systemc/communication/sc_signal/check_writer/test08/test08.cpp b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test08/test08.cpp new file mode 100644 index 000000000..52f3f54ad --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test08/test08.cpp @@ -0,0 +1,69 @@ +/***************************************************************************** + + 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. + + *****************************************************************************/ + +/***************************************************************************** + + test08.cpp -- Test detection of two write ports connected to one signal + + Original Author: Andy Goodrich, Forte Design Systems, 15 Oct 2003 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +// test register port for more than one writer + +#define DEBUG_SYSTEMC +#include "systemc.h" +typedef int target; + +SC_MODULE( mod_a ) +{ + sc_in_clk clk; + + sc_out<target> out_target; + sc_out<target> out_target2; + + SC_CTOR( mod_a ) + { + } +}; + +int +sc_main( int, char*[] ) +{ + sc_clock clk; + + sc_signal<target> sig_target; + + mod_a a("a"); + a(clk, sig_target, sig_target); + + sc_start(1, SC_NS); + + return 0; +} diff --git a/src/systemc/tests/systemc/communication/sc_signal/check_writer/test09/golden/test09.log b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test09/golden/test09.log new file mode 100644 index 000000000..2d63f201f --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test09/golden/test09.log @@ -0,0 +1,7 @@ +SystemC Simulation + +Error: (E115) sc_signal<T> cannot have more than one driver: + signal `signal_0' (sc_signal) + first driver `a.port_2' (sc_out) + second driver `a.port_1' (sc_out) +In file: <removed by verify.pl> diff --git a/src/systemc/tests/systemc/communication/sc_signal/check_writer/test09/test09.cpp b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test09/test09.cpp new file mode 100644 index 000000000..daf15072d --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test09/test09.cpp @@ -0,0 +1,69 @@ +/***************************************************************************** + + 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. + + *****************************************************************************/ + +/***************************************************************************** + + test08.cpp -- + + Original Author: Andy Goodrich, Forte Design Systems, 15 Oct 2003 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +// test register port for more than one writer + +#define DEBUG_SYSTEMC +#include "systemc.h" +typedef sc_bigint<5> target; + +SC_MODULE( mod_a ) +{ + sc_in_clk clk; + + sc_out<target> out_target; + sc_out<target> out_target2; + + SC_CTOR( mod_a ) + { + } +}; + +int +sc_main( int, char*[] ) +{ + sc_clock clk; + + sc_signal<target> sig_target; + + mod_a a("a"); + a(clk, sig_target, sig_target); + + sc_start(1, SC_NS); + + return 0; +} diff --git a/src/systemc/tests/systemc/communication/sc_signal/check_writer/test10/golden/test10.log b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test10/golden/test10.log new file mode 100644 index 000000000..2d63f201f --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test10/golden/test10.log @@ -0,0 +1,7 @@ +SystemC Simulation + +Error: (E115) sc_signal<T> cannot have more than one driver: + signal `signal_0' (sc_signal) + first driver `a.port_2' (sc_out) + second driver `a.port_1' (sc_out) +In file: <removed by verify.pl> diff --git a/src/systemc/tests/systemc/communication/sc_signal/check_writer/test10/test10.cpp b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test10/test10.cpp new file mode 100644 index 000000000..7844e1307 --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test10/test10.cpp @@ -0,0 +1,69 @@ +/***************************************************************************** + + 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. + + *****************************************************************************/ + +/***************************************************************************** + + test08.cpp -- + + Original Author: Andy Goodrich, Forte Design Systems, 15 Oct 2003 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +// test register port for more than one writer + +#define DEBUG_SYSTEMC +#include "systemc.h" +typedef sc_biguint<5> target; + +SC_MODULE( mod_a ) +{ + sc_in_clk clk; + + sc_out<target> out_target; + sc_out<target> out_target2; + + SC_CTOR( mod_a ) + { + } +}; + +int +sc_main( int, char*[] ) +{ + sc_clock clk; + + sc_signal<target> sig_target; + + mod_a a("a"); + a(clk, sig_target, sig_target); + + sc_start(1, SC_NS); + + return 0; +} diff --git a/src/systemc/tests/systemc/communication/sc_signal/check_writer/test11/golden/test11.log b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test11/golden/test11.log new file mode 100644 index 000000000..2d63f201f --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test11/golden/test11.log @@ -0,0 +1,7 @@ +SystemC Simulation + +Error: (E115) sc_signal<T> cannot have more than one driver: + signal `signal_0' (sc_signal) + first driver `a.port_2' (sc_out) + second driver `a.port_1' (sc_out) +In file: <removed by verify.pl> diff --git a/src/systemc/tests/systemc/communication/sc_signal/check_writer/test11/test11.cpp b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test11/test11.cpp new file mode 100644 index 000000000..aa3bafa85 --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test11/test11.cpp @@ -0,0 +1,69 @@ +/***************************************************************************** + + 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. + + *****************************************************************************/ + +/***************************************************************************** + + test10.cpp -- Test detection of two write ports connected to 1 signal. + + Original Author: Andy Goodrich, Forte Design Systems, 15 Oct 2003 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +// test register port for more than one writer + +#define DEBUG_SYSTEMC +#include "systemc.h" +typedef sc_int<5> target; + +SC_MODULE( mod_a ) +{ + sc_in_clk clk; + + sc_out<target> out_target; + sc_out<target> out_target2; + + SC_CTOR( mod_a ) + { + } +}; + +int +sc_main( int, char*[] ) +{ + sc_clock clk; + + sc_signal<target> sig_target; + + mod_a a("a"); + a(clk, sig_target, sig_target); + + sc_start(1, SC_NS); + + return 0; +} diff --git a/src/systemc/tests/systemc/communication/sc_signal/check_writer/test12/golden/test12.log b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test12/golden/test12.log new file mode 100644 index 000000000..2d63f201f --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test12/golden/test12.log @@ -0,0 +1,7 @@ +SystemC Simulation + +Error: (E115) sc_signal<T> cannot have more than one driver: + signal `signal_0' (sc_signal) + first driver `a.port_2' (sc_out) + second driver `a.port_1' (sc_out) +In file: <removed by verify.pl> diff --git a/src/systemc/tests/systemc/communication/sc_signal/check_writer/test12/test12.cpp b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test12/test12.cpp new file mode 100644 index 000000000..dd638238e --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test12/test12.cpp @@ -0,0 +1,69 @@ +/***************************************************************************** + + 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. + + *****************************************************************************/ + +/***************************************************************************** + + test10.cpp -- Test detection of two write ports connected to 1 signal. + + Original Author: Andy Goodrich, Forte Design Systems, 15 Oct 2003 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +// test register port for more than one writer + +#define DEBUG_SYSTEMC +#include "systemc.h" +typedef sc_uint<5> target; + +SC_MODULE( mod_a ) +{ + sc_in_clk clk; + + sc_out<target> out_target; + sc_out<target> out_target2; + + SC_CTOR( mod_a ) + { + } +}; + +int +sc_main( int, char*[] ) +{ + sc_clock clk; + + sc_signal<target> sig_target; + + mod_a a("a"); + a(clk, sig_target, sig_target); + + sc_start(1, SC_NS); + + return 0; +} diff --git a/src/systemc/tests/systemc/communication/sc_signal/check_writer/test13/golden/test13.log b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test13/golden/test13.log new file mode 100644 index 000000000..0d934d401 --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test13/golden/test13.log @@ -0,0 +1,2 @@ +SystemC Simulation +Program completed diff --git a/src/systemc/tests/systemc/communication/sc_signal/check_writer/test13/test13.cpp b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test13/test13.cpp new file mode 100644 index 000000000..93c3b2124 --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test13/test13.cpp @@ -0,0 +1,73 @@ +/***************************************************************************** + + 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. + + *****************************************************************************/ + +/***************************************************************************** + + test13.cpp -- Test detection of write from process and sc_main. + + Original Author: Andy Goodrich, Forte Design Systems, 02 Apr 2007 + + *****************************************************************************/ + +/***************************************************************************** + + 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(DUT) +{ + SC_CTOR(DUT) + { + SC_CTHREAD(thread,m_clk.pos()); + } + void thread() + { + m_data = false; + for (;;) + { + wait(); + } + } + sc_in<bool> m_clk; + sc_out<bool> m_data; +}; + +int sc_main(int argc, char* argv[]) +{ + sc_clock clock; + sc_signal<bool> data; + DUT dut("dut"); + + dut.m_clk(clock); + dut.m_data(data); + + sc_start(1, SC_NS); + data = true; + sc_start(1, SC_NS); + + cout << "Program completed" << endl; + return 0; +} diff --git a/src/systemc/tests/systemc/communication/sc_signal/check_writer/test14/golden/test14.log b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test14/golden/test14.log new file mode 100644 index 000000000..f9660d5a8 --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test14/golden/test14.log @@ -0,0 +1,8 @@ +SystemC Simulation + +Error: (E115) sc_signal<T> cannot have more than one driver: + signal `dut.sig' (sc_signal) + first driver `dut.p2' (sc_thread_process) + second driver `dut.p1' (sc_thread_process) +In file: <removed by verify.pl> +In process: dut.p1 @ 10 ns diff --git a/src/systemc/tests/systemc/communication/sc_signal/check_writer/test14/test14.cpp b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test14/test14.cpp new file mode 100644 index 000000000..aa1ffbc6f --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test14/test14.cpp @@ -0,0 +1,62 @@ +/***************************************************************************** + + 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. + + *****************************************************************************/ + +/***************************************************************************** + + test14.cpp -- sc_writer_policy: writer check with terminated writer + + Original Author: Philipp A. Hartmann, OFFIS, 2014-11-15 + + *****************************************************************************/ + +// see https://github.com/OSCI-WG/systemc/issues/104 + +#include <systemc> + +using sc_core::SC_NS; + +SC_MODULE(dut) +{ + sc_core::sc_signal<int> sig; + + SC_CTOR(dut) + : sig("sig") + { + SC_THREAD(p1); + SC_THREAD(p2); + } + + void p1() { + wait( 10, SC_NS ); + sig.write(1); + } + + void p2() { + wait( 1, SC_NS ); + sig.write(0); + } +}; + +int sc_main( int, char*[] ) +{ + dut top("dut"); + sc_core::sc_start(); + std::cout << "Program completed" << std::endl; + return 0; +} diff --git a/src/systemc/tests/systemc/communication/sc_signal/check_writer/test15/golden/test15.log b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test15/golden/test15.log new file mode 100644 index 000000000..0a9ea351f --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test15/golden/test15.log @@ -0,0 +1,167 @@ +SystemC Simulation + +*** trigger each driver in individual delta cycles + dut.p1: 1 ns @ 1: writing dut.sig = 1 + dut.run: 1 ns @ 2: reading dut.sig = 1 + dut.p2: 1 ns @ 2: writing dut.sig = 2 + dut.run: 1 ns @ 3: reading dut.sig = 2 + dut.p3: 1 ns @ 3: writing dut.sig = 3 + dut.run: 1 ns @ 4: reading dut.sig = 3 + dut.p4: 1 ns @ 4: writing dut.sig = 1 + dut.run: 1 ns @ 5: reading dut.sig = 1 + +*** trigger 1-2-3 in the same delta cycle + dut.p1: 2 ns @ 6: writing dut.sig = 1 + dut.p2: 2 ns @ 6: writing dut.sig = 2 + +Error: (E115) sc_signal<T> cannot have more than one driver: + signal `dut.sig' (sc_signal) + first driver `dut.p1' (sc_method_process) + second driver `dut.p2' (sc_method_process) + conflicting write in delta cycle 6 +In file: <removed by verify.pl> +In process: dut.p2 @ 2 ns + + dut.p3: 2 ns @ 6: writing dut.sig = 3 + +Error: (E115) sc_signal<T> cannot have more than one driver: + signal `dut.sig' (sc_signal) + first driver `dut.p1' (sc_method_process) + second driver `dut.p3' (sc_method_process) + conflicting write in delta cycle 6 +In file: <removed by verify.pl> +In process: dut.p3 @ 2 ns + + dut.run: 2 ns @ 7: reading dut.sig = 1 + +*** trigger 2-3-1 in the same delta cycle + dut.p2: 3 ns @ 8: writing dut.sig = 2 + dut.p3: 3 ns @ 8: writing dut.sig = 3 + +Error: (E115) sc_signal<T> cannot have more than one driver: + signal `dut.sig' (sc_signal) + first driver `dut.p2' (sc_method_process) + second driver `dut.p3' (sc_method_process) + conflicting write in delta cycle 8 +In file: <removed by verify.pl> +In process: dut.p3 @ 3 ns + + dut.p1: 3 ns @ 8: writing dut.sig = 1 + +Error: (E115) sc_signal<T> cannot have more than one driver: + signal `dut.sig' (sc_signal) + first driver `dut.p2' (sc_method_process) + second driver `dut.p1' (sc_method_process) + conflicting write in delta cycle 8 +In file: <removed by verify.pl> +In process: dut.p1 @ 3 ns + + dut.run: 3 ns @ 9: reading dut.sig = 2 + +*** trigger 3-1-2 in the same delta cycle + dut.p3: 4 ns @ 10: writing dut.sig = 3 + dut.p1: 4 ns @ 10: writing dut.sig = 1 + +Error: (E115) sc_signal<T> cannot have more than one driver: + signal `dut.sig' (sc_signal) + first driver `dut.p3' (sc_method_process) + second driver `dut.p1' (sc_method_process) + conflicting write in delta cycle 10 +In file: <removed by verify.pl> +In process: dut.p1 @ 4 ns + + dut.p2: 4 ns @ 10: writing dut.sig = 2 + +Error: (E115) sc_signal<T> cannot have more than one driver: + signal `dut.sig' (sc_signal) + first driver `dut.p3' (sc_method_process) + second driver `dut.p2' (sc_method_process) + conflicting write in delta cycle 10 +In file: <removed by verify.pl> +In process: dut.p2 @ 4 ns + + dut.run: 4 ns @ 11: reading dut.sig = 3 + +*** trigger 1-2-1-2 in the same delta cycle + dut.p1: 5 ns @ 12: writing dut.sig = 1 + dut.p2: 5 ns @ 12: writing dut.sig = 2 + +Error: (E115) sc_signal<T> cannot have more than one driver: + signal `dut.sig' (sc_signal) + first driver `dut.p1' (sc_method_process) + second driver `dut.p2' (sc_method_process) + conflicting write in delta cycle 12 +In file: <removed by verify.pl> +In process: dut.p2 @ 5 ns + + dut.p1: 5 ns @ 12: writing dut.sig = 1 + dut.p2: 5 ns @ 12: writing dut.sig = 2 + +Error: (E115) sc_signal<T> cannot have more than one driver: + signal `dut.sig' (sc_signal) + first driver `dut.p1' (sc_method_process) + second driver `dut.p2' (sc_method_process) + conflicting write in delta cycle 12 +In file: <removed by verify.pl> +In process: dut.p2 @ 5 ns + + dut.run: 5 ns @ 13: reading dut.sig = 1 + +*** trigger 2-1 in the same delta cycle + dut.p2: 6 ns @ 14: writing dut.sig = 2 + dut.p1: 6 ns @ 14: writing dut.sig = 1 + +Error: (E115) sc_signal<T> cannot have more than one driver: + signal `dut.sig' (sc_signal) + first driver `dut.p2' (sc_method_process) + second driver `dut.p1' (sc_method_process) + conflicting write in delta cycle 14 +In file: <removed by verify.pl> +In process: dut.p1 @ 6 ns + + dut.run: 6 ns @ 15: reading dut.sig = 2 + +*** trigger 1-3 in the same delta cycle + dut.p1: 7 ns @ 16: writing dut.sig = 1 + dut.p3: 7 ns @ 16: writing dut.sig = 3 + +Error: (E115) sc_signal<T> cannot have more than one driver: + signal `dut.sig' (sc_signal) + first driver `dut.p1' (sc_method_process) + second driver `dut.p3' (sc_method_process) + conflicting write in delta cycle 16 +In file: <removed by verify.pl> +In process: dut.p3 @ 7 ns + + dut.run: 7 ns @ 17: reading dut.sig = 1 + +*** trigger 1-4-1 in the same delta cycle + dut.p1: 8 ns @ 18: writing dut.sig = 1 + dut.p4: 8 ns @ 18: writing dut.sig = 1 + +Error: (E115) sc_signal<T> cannot have more than one driver: + signal `dut.sig' (sc_signal) + first driver `dut.p1' (sc_method_process) + second driver `dut.p4' (sc_method_process) + conflicting write in delta cycle 18 +In file: <removed by verify.pl> +In process: dut.p4 @ 8 ns + + dut.p1: 8 ns @ 18: writing dut.sig = 1 + dut.run: 8 ns @ 19: reading dut.sig = 1 + +*** trigger 4-1 in the same delta cycle + dut.p4: 9 ns @ 20: writing dut.sig = 1 + dut.p1: 9 ns @ 20: writing dut.sig = 1 + +Error: (E115) sc_signal<T> cannot have more than one driver: + signal `dut.sig' (sc_signal) + first driver `dut.p4' (sc_method_process) + second driver `dut.p1' (sc_method_process) + conflicting write in delta cycle 20 +In file: <removed by verify.pl> +In process: dut.p1 @ 9 ns + + dut.run: 9 ns @ 21: reading dut.sig = 1 + +Program completed diff --git a/src/systemc/tests/systemc/communication/sc_signal/check_writer/test15/test15.cpp b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test15/test15.cpp new file mode 100644 index 000000000..1719abe87 --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test15/test15.cpp @@ -0,0 +1,175 @@ +/***************************************************************************** + + 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. + + *****************************************************************************/ + +/***************************************************************************** + + test15.cpp -- sc_writer_policy: check conflicts within an evaluation phase + + Original Author: Philipp A. Hartmann, Intel, 2017-05-12 + + *****************************************************************************/ + +// see https://github.com/OSCI-WG/systemc/issues/222 + +#define SC_INCLUDE_DYNAMIC_PROCESSES +#include <systemc> +#include <iomanip> +#include <sstream> + +using sc_core::SC_NS; +using sc_core::SC_ZERO_TIME; + +SC_MODULE(dut) +{ + static const int num_drivers = 4; + + SC_CTOR(dut) + : sig("sig") + { + SC_THREAD(run); + for(int id=1; id <= num_drivers; ++id) { + // first and last driver write the same values + spawn_driver( id, (id-1) % (num_drivers-1) + 1 ); + } + } + +private: + void spawn_driver(int id, int value) { + sc_assert( id > 0 && id <= num_drivers ); + sc_core::sc_spawn_options sp; + sp.set_sensitivity(&ev[id-1]); + sp.spawn_method(); + sp.dont_initialize(); + + std::stringstream nm; + nm << "p" << id; + sc_spawn( sc_bind(&dut::driver, this, value), nm.str().c_str(), &sp ); + } + + void run() { + wait(1, SC_NS); + + std::cout << "\n*** trigger each driver in individual delta cycles" << std::endl; + for(int id=1; id <= num_drivers; ++id) { + trigger(id); + wait(SC_ZERO_TIME); + log(); + } + + wait(1, SC_NS); + std::cout << "\n*** trigger 1-2-3 in the same delta cycle" << std::endl; + trigger(1); + trigger(2); // error expected + trigger(3); // error expected + wait(SC_ZERO_TIME); + log(); + + wait(1, SC_NS); + std::cout << "\n*** trigger 2-3-1 in the same delta cycle" << std::endl; + trigger(2); + trigger(3); // error expected + trigger(1); // error expected + wait(SC_ZERO_TIME); + log(); + + wait(1, SC_NS); + std::cout << "\n*** trigger 3-1-2 in the same delta cycle" << std::endl; + trigger(3); + trigger(1); // error expected + trigger(2); // error expected + wait(SC_ZERO_TIME); + log(); + + wait(1, SC_NS); + std::cout << "\n*** trigger 1-2-1-2 in the same delta cycle" << std::endl; + trigger(1); + trigger(2); // error expected + trigger(1); // NO error expected (original process) + trigger(2); // error expected + wait(SC_ZERO_TIME); + log(); + + wait(1, SC_NS); + std::cout << "\n*** trigger 2-1 in the same delta cycle" << std::endl; + trigger(2); + trigger(1); // error expected + wait(SC_ZERO_TIME); + log(); + + wait(1, SC_NS); + std::cout << "\n*** trigger 1-3 in the same delta cycle" << std::endl; + trigger(1); + trigger(3); // error expected + wait(SC_ZERO_TIME); + log(); + + wait(1, SC_NS); + std::cout << "\n*** trigger 1-4-1 in the same delta cycle" << std::endl; + trigger(1); + trigger(4); // error expected? (same value) + trigger(1); // NO error expected (original process) + wait(SC_ZERO_TIME); + log(); + + wait(1, SC_NS); + std::cout << "\n*** trigger 4-1 in the same delta cycle" << std::endl; + trigger(4); + trigger(1); // error expected? (same value) + wait(SC_ZERO_TIME); + log(); + } + + void trigger(int id) { + sc_assert( id > 0 && id <= num_drivers ); + ev[id-1].notify(); + wait(ev_schedule); + } + + void driver(int value) { + log(value); + try { + sig.write(value); + } catch (const sc_core::sc_report& msg ) { + std::cout << "\n" << msg.what() << "\n" << std::endl; + } + ev_schedule.notify(); + } + + void log(int value = -1) { + std::cout + << std::setw(8) << sc_core::sc_get_current_process_handle().name() << ": " + << std::setw(5) << sc_core::sc_time_stamp() + << " @ " << std::setw(2) << sc_core::sc_delta_count() << ": " + << ( (value!=-1) ? "writing " : "reading " ) + << sig.name() << " = " + << ( (value!=-1) ? value : sig.read() ) + << std::endl; + } + + sc_core::sc_signal<int, sc_core::SC_MANY_WRITERS> sig; + sc_core::sc_event ev_schedule, ev[num_drivers]; +}; + +int sc_main( int, char*[] ) +{ + dut top("dut"); + sc_core::sc_start(); + std::cout << "\nProgram completed" << std::endl; + return 0; +} diff --git a/src/systemc/tests/systemc/communication/sc_signal/check_writer/test16/golden/test16.log b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test16/golden/test16.log new file mode 100644 index 000000000..248e4b616 --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test16/golden/test16.log @@ -0,0 +1,115 @@ +SystemC Simulation + +*** trigger each driver in individual delta cycles + + dut.p1: 1 ns @ 1: writing dut.sig = 1 + + dut.run: 1 ns @ 2: reading dut.sig = 1 + + dut.p2: 1 ns @ 2: writing dut.sig = 2 + + dut.run: 1 ns @ 3: reading dut.sig = 2 + + dut.p3: 1 ns @ 3: writing dut.sig = 1 + + dut.run: 1 ns @ 4: reading dut.sig = 1 + +*** trigger 1-2-3 in the same delta cycle + + dut.p1: 2 ns @ 5: writing dut.sig = 1 + + dut.p2: 2 ns @ 5: writing dut.sig = 2 + +Error: (E115) sc_signal<T> cannot have more than one driver: + signal `dut.sig' (sc_signal) + first driver `dut.p1' (sc_method_process) + second driver `dut.p2' (sc_method_process) + conflicting write in delta cycle 5 +In file: <removed by verify.pl> +In process: dut.p2 @ 2 ns + + dut.p3: 2 ns @ 5: writing dut.sig = 1 + +Error: (E115) sc_signal<T> cannot have more than one driver: + signal `dut.sig' (sc_signal) + first driver `dut.p2' (sc_method_process) + second driver `dut.p3' (sc_method_process) + conflicting write in delta cycle 5 +In file: <removed by verify.pl> +In process: dut.p3 @ 2 ns + + dut.run: 2 ns @ 6: reading dut.sig = 1 + +*** trigger 2-3-1 in the same delta cycle + + dut.p2: 3 ns @ 7: writing dut.sig = 2 + + dut.p3: 3 ns @ 7: writing dut.sig = 1 + +Error: (E115) sc_signal<T> cannot have more than one driver: + signal `dut.sig' (sc_signal) + first driver `dut.p2' (sc_method_process) + second driver `dut.p3' (sc_method_process) + conflicting write in delta cycle 7 +In file: <removed by verify.pl> +In process: dut.p3 @ 3 ns + + dut.p1: 3 ns @ 7: writing dut.sig = 1 + +Error: (E115) sc_signal<T> cannot have more than one driver: + signal `dut.sig' (sc_signal) + first driver `dut.p3' (sc_method_process) + second driver `dut.p1' (sc_method_process) + conflicting write in delta cycle 7 +In file: <removed by verify.pl> +In process: dut.p1 @ 3 ns + + dut.run: 3 ns @ 8: reading dut.sig = 1 + +*** trigger 3-1-2 in the same delta cycle + + dut.p3: 4 ns @ 9: writing dut.sig = 1 + + dut.p1: 4 ns @ 9: writing dut.sig = 1 + +Error: (E115) sc_signal<T> cannot have more than one driver: + signal `dut.sig' (sc_signal) + first driver `dut.p3' (sc_method_process) + second driver `dut.p1' (sc_method_process) + conflicting write in delta cycle 9 +In file: <removed by verify.pl> +In process: dut.p1 @ 4 ns + + dut.p2: 4 ns @ 9: writing dut.sig = 2 + +Error: (E115) sc_signal<T> cannot have more than one driver: + signal `dut.sig' (sc_signal) + first driver `dut.p1' (sc_method_process) + second driver `dut.p2' (sc_method_process) + conflicting write in delta cycle 9 +In file: <removed by verify.pl> +In process: dut.p2 @ 4 ns + + dut.run: 4 ns @ 10: reading dut.sig = 2 + +*** trigger 1-1-2-2 in the same delta cycle + + dut.p1: 5 ns @ 11: writing dut.sig = 1 + + dut.p1: 5 ns @ 11: writing dut.sig = 1 + + dut.p2: 5 ns @ 11: writing dut.sig = 2 + +Error: (E115) sc_signal<T> cannot have more than one driver: + signal `dut.sig' (sc_signal) + first driver `dut.p1' (sc_method_process) + second driver `dut.p2' (sc_method_process) + conflicting write in delta cycle 11 +In file: <removed by verify.pl> +In process: dut.p2 @ 5 ns + + dut.p2: 5 ns @ 11: writing dut.sig = 2 + + dut.run: 5 ns @ 12: reading dut.sig = 2 + +Program completed diff --git a/src/systemc/tests/systemc/communication/sc_signal/check_writer/test16/test16.cpp b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test16/test16.cpp new file mode 100644 index 000000000..a295b6540 --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test16/test16.cpp @@ -0,0 +1,158 @@ +/***************************************************************************** + + 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. + + *****************************************************************************/ + +/***************************************************************************** + + test16.cpp -- sc_writer_policy: test SC_SIGNAL_WRITE_CHECK=CONFLICT + + Original Author: Philipp A. Hartmann, Intel, 2017-05-12 + + *****************************************************************************/ + +// see https://github.com/OSCI-WG/systemc/issues/222 + +#define SC_INCLUDE_DYNAMIC_PROCESSES +#include <systemc> +#include <iomanip> +#include <sstream> + +using sc_core::SC_NS; +using sc_core::SC_ZERO_TIME; + +SC_MODULE(dut) +{ + static const int num_drivers = 3; + + SC_CTOR(dut) + : sig("sig") + { + SC_THREAD(run); + for(int id=1; id <= num_drivers; ++id) { + // first and last driver write the same values + spawn_driver( id, (id-1) % (num_drivers-1) + 1 ); + } + } + +private: + void spawn_driver(int id, int value) { + sc_assert( id > 0 && id <= num_drivers ); + sc_core::sc_spawn_options sp; + sp.set_sensitivity(&ev[id-1]); + sp.spawn_method(); + sp.dont_initialize(); + + std::stringstream nm; + nm << "p" << id; + sc_spawn( sc_bind(&dut::driver, this, value), nm.str().c_str(), &sp ); + } + + void run() { + wait(1, SC_NS); + + std::cout << "\n*** trigger each driver in individual delta cycles" << std::endl; + for(int id=1; id <= num_drivers; ++id) { + trigger(id); // NO error expected (environment override) + wait(SC_ZERO_TIME); + log(); + } + + wait(1, SC_NS); + std::cout << "\n*** trigger 1-2-3 in the same delta cycle" << std::endl; + trigger(1); + trigger(2); // error expected + trigger(3); // error expected + wait(SC_ZERO_TIME); + log(); + + wait(1, SC_NS); + std::cout << "\n*** trigger 2-3-1 in the same delta cycle" << std::endl; + trigger(2); + trigger(3); // error expected + trigger(1); // error expected + wait(SC_ZERO_TIME); + log(); + + wait(1, SC_NS); + std::cout << "\n*** trigger 3-1-2 in the same delta cycle" << std::endl; + trigger(3); + trigger(1); // error expected + trigger(2); // error expected + wait(SC_ZERO_TIME); + log(); + + wait(1, SC_NS); + std::cout << "\n*** trigger 1-1-2-2 in the same delta cycle" << std::endl; + trigger(1); + trigger(1); // NO error expected (current process) + trigger(2); // error expected + trigger(2); // NO error expected (current process) + wait(SC_ZERO_TIME); + log(); + } + + void trigger(int id) { + sc_assert( id > 0 && id <= num_drivers ); + ev[id-1].notify(); + wait(ev_schedule); + } + + void driver(int value) { + log(value); + sig.write(value); // errors suppressed via report handler below + ev_schedule.notify(); + } + + void log(int value = -1) { + std::cout + << "\n" + << std::setw(8) << sc_core::sc_get_current_process_handle().name() << ": " + << std::setw(5) << sc_core::sc_time_stamp() + << " @ " << std::setw(2) << sc_core::sc_delta_count() << ": " + << ( (value!=-1) ? "writing " : "reading " ) + << sig.name() << " = " + << ( (value!=-1) ? value : sig.read() ) + << std::endl; + } + + sc_core::sc_signal<int, sc_core::SC_ONE_WRITER> sig; // use single-writer signal + sc_core::sc_event ev_schedule, ev[num_drivers]; +}; + +#ifdef _WIN32 +#define putenv _putenv // Windows deprecates putenv +#endif + +int sc_main( int, char*[] ) +{ + // prepare environment variable (takes a char*) + putenv(const_cast<char*>("SC_SIGNAL_WRITE_CHECK=CONFLICT")); + // and reset simulation context to pick it up (non-standard) + sc_core::sc_get_curr_simcontext()->reset(); + + // report multiple writer errors as warnings + sc_core::sc_report_handler::set_actions( + sc_core::SC_ID_MORE_THAN_ONE_SIGNAL_DRIVER_ + , sc_core::SC_DEFAULT_WARNING_ACTIONS + ); + + dut top("dut"); + sc_core::sc_start(); + std::cout << "\nProgram completed" << std::endl; + return 0; +} |