From 16fa8d7cc8c92f5ab879e4cf9c6c0bbb3567860f Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Thu, 24 May 2018 01:37:55 -0700 Subject: systemc: Import tests from the Accellera systemc distribution. Change-Id: Iad76b398949a55d768a34d027a2d8e3739953da6 Reviewed-on: https://gem5-review.googlesource.com/10845 Reviewed-by: Giacomo Travaglini Maintainer: Gabe Black --- .../sc_buffer/test01/golden/test01.log | 102 +++++++++++++++++++++ .../communication/sc_buffer/test01/test01.cpp | 102 +++++++++++++++++++++ .../test02/golden/sc_buffer_edge_reset.log | 31 +++++++ .../sc_buffer/test02/sc_buffer_edge_reset.cpp | 101 ++++++++++++++++++++ 4 files changed, 336 insertions(+) create mode 100644 src/systemc/tests/systemc/communication/sc_buffer/test01/golden/test01.log create mode 100644 src/systemc/tests/systemc/communication/sc_buffer/test01/test01.cpp create mode 100644 src/systemc/tests/systemc/communication/sc_buffer/test02/golden/sc_buffer_edge_reset.log create mode 100644 src/systemc/tests/systemc/communication/sc_buffer/test02/sc_buffer_edge_reset.cpp (limited to 'src/systemc/tests/systemc/communication/sc_buffer') diff --git a/src/systemc/tests/systemc/communication/sc_buffer/test01/golden/test01.log b/src/systemc/tests/systemc/communication/sc_buffer/test01/golden/test01.log new file mode 100644 index 000000000..708a33b5c --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_buffer/test01/golden/test01.log @@ -0,0 +1,102 @@ +SystemC Simulation +0 s 0 +0 s 3 +1 ns 3 +2 ns 3 +3 ns 3 +4 ns 3 +5 ns 3 +6 ns 3 +7 ns 3 +8 ns 3 +9 ns 3 +10 ns 3 +11 ns 3 +12 ns 3 +13 ns 3 +14 ns 3 +15 ns 3 +16 ns 3 +17 ns 3 +18 ns 3 +19 ns 3 +20 ns 3 +21 ns 3 +22 ns 3 +23 ns 3 +24 ns 3 +25 ns 3 +26 ns 3 +27 ns 3 +28 ns 3 +29 ns 3 +30 ns 3 +31 ns 3 +32 ns 3 +33 ns 3 +34 ns 3 +35 ns 3 +36 ns 3 +37 ns 3 +38 ns 3 +39 ns 3 +40 ns 3 +41 ns 3 +42 ns 3 +43 ns 3 +44 ns 3 +45 ns 3 +46 ns 3 +47 ns 3 +48 ns 3 +49 ns 3 +50 ns 3 +51 ns 3 +52 ns 3 +53 ns 3 +54 ns 3 +55 ns 3 +56 ns 3 +57 ns 3 +58 ns 3 +59 ns 3 +60 ns 3 +61 ns 3 +62 ns 3 +63 ns 3 +64 ns 3 +65 ns 3 +66 ns 3 +67 ns 3 +68 ns 3 +69 ns 3 +70 ns 3 +71 ns 3 +72 ns 3 +73 ns 3 +74 ns 3 +75 ns 3 +76 ns 3 +77 ns 3 +78 ns 3 +79 ns 3 +80 ns 3 +81 ns 3 +82 ns 3 +83 ns 3 +84 ns 3 +85 ns 3 +86 ns 3 +87 ns 3 +88 ns 3 +89 ns 3 +90 ns 3 +91 ns 3 +92 ns 3 +93 ns 3 +94 ns 3 +95 ns 3 +96 ns 3 +97 ns 3 +98 ns 3 +99 ns 3 diff --git a/src/systemc/tests/systemc/communication/sc_buffer/test01/test01.cpp b/src/systemc/tests/systemc/communication/sc_buffer/test01/test01.cpp new file mode 100644 index 000000000..2f7b49f4f --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_buffer/test01/test01.cpp @@ -0,0 +1,102 @@ +/***************************************************************************** + + 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: + + *****************************************************************************/ + +// $Log: test01.cpp,v $ +// Revision 1.1.1.1 2006/12/15 20:25:56 acg +// systemc_tests-2.3 +// +// Revision 1.2 2006/01/24 19:11:29 acg +// Andy Goodrich: Changed sc_simulation_time() usage to sc_time_stamp(). +// + +// test of sc_buffer -- general test + +#include "systemc.h" + +SC_MODULE( mod_a ) +{ + sc_in clk; + sc_out out; + + void main_action() + { + while( true ) { + wait(); + out = 3; + } + } + + SC_CTOR( mod_a ) + { + SC_THREAD( main_action ); + sensitive << clk.pos(); + } +}; + +SC_MODULE( mod_b ) +{ + sc_in in; + + void main_action() + { + cout << sc_time_stamp() << " " << in.read() << endl; + } + + SC_CTOR( mod_b ) + { + SC_METHOD( main_action ); + sensitive << in; + } +}; + +int +sc_main( int, char*[] ) +{ + mod_a a( "a" ); + mod_b b( "b" ); + + sc_clock clk; + sc_buffer buf; + + a.clk( clk ); + a.out( buf ); + b.in( buf ); + + sc_start( 100, SC_NS); + + return 0; +} diff --git a/src/systemc/tests/systemc/communication/sc_buffer/test02/golden/sc_buffer_edge_reset.log b/src/systemc/tests/systemc/communication/sc_buffer/test02/golden/sc_buffer_edge_reset.log new file mode 100644 index 000000000..15f6aaa60 --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_buffer/test02/golden/sc_buffer_edge_reset.log @@ -0,0 +1,31 @@ +SystemC Simulation +sig_mod.trigger_rst @ 0 s: in = 1 +buf_mod.trigger_rst @ 0 s: in = 1 +buf_mod.trigger_pos @ 0 s: in = 1 +buf_mod.trigger_val @ 0 s: in = 1 +sig_mod.trigger_pos @ 0 s: in = 1 +sig_mod.trigger_val @ 0 s: in = 1 +buf_mod.trigger_rst @ 1 ns: in = 1 +buf_mod.trigger_pos @ 1 ns: in = 1 +buf_mod.trigger_val @ 1 ns: in = 1 +buf_mod.trigger_neg @ 2 ns: in = 0 +buf_mod.trigger_val @ 2 ns: in = 0 +sig_mod.trigger_neg @ 2 ns: in = 0 +sig_mod.trigger_val @ 2 ns: in = 0 +buf_mod.trigger_neg @ 3 ns: in = 0 +buf_mod.trigger_val @ 3 ns: in = 0 +sig_mod.trigger_rst @ 4 ns: in = 1 +buf_mod.trigger_rst @ 4 ns: in = 1 +buf_mod.trigger_pos @ 4 ns: in = 1 +buf_mod.trigger_val @ 4 ns: in = 1 +sig_mod.trigger_pos @ 4 ns: in = 1 +sig_mod.trigger_val @ 4 ns: in = 1 +buf_mod.trigger_rst @ 5 ns: in = 1 +buf_mod.trigger_pos @ 5 ns: in = 1 +buf_mod.trigger_val @ 5 ns: in = 1 +buf_mod.trigger_neg @ 6 ns: in = 0 +buf_mod.trigger_val @ 6 ns: in = 0 +sig_mod.trigger_neg @ 6 ns: in = 0 +sig_mod.trigger_val @ 6 ns: in = 0 +buf_mod.trigger_neg @ 7 ns: in = 0 +buf_mod.trigger_val @ 7 ns: in = 0 diff --git a/src/systemc/tests/systemc/communication/sc_buffer/test02/sc_buffer_edge_reset.cpp b/src/systemc/tests/systemc/communication/sc_buffer/test02/sc_buffer_edge_reset.cpp new file mode 100644 index 000000000..98fe8a5bb --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_buffer/test02/sc_buffer_edge_reset.cpp @@ -0,0 +1,101 @@ +/***************************************************************************** + + 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_buffer_edge_reset.cpp -- Test sc_buffer edge events and reset + + Original Author: Philipp A. Hartmann, OFFIS, 2013-10-12 + + ----------------------------------------------------------------------------- + + This test checks the functionality of the pos(), neg() event finders and + the async_reset_signal_is functionality, if the target port is bound to + an sc_buffer instead of an sc_signal. + + *****************************************************************************/ + +#define SC_INCLUDE_DYNAMIC_PROCESSES +#include +#include + +SC_MODULE(print_edge) +{ + sc_in in; + + SC_CTOR(print_edge) + : in("in") + { + spawn_trigger( "trigger_val", &in.value_changed() ); + spawn_trigger( "trigger_pos", &in.pos() ); + spawn_trigger( "trigger_neg", &in.neg() ); + spawn_trigger( "trigger_rst", NULL ); + } + + void spawn_trigger( const char* name, sc_event_finder* ef ) + { + sc_spawn_options opts; + opts.spawn_method(); + opts.dont_initialize(); + if( ef ) { + opts.set_sensitivity( ef ); + } else { + opts.async_reset_signal_is( in, true ); + } + sc_spawn( sc_bind(&print_edge::trigger,this) + , name, &opts); + } + + void trigger() + { + std::cout << sc_get_current_process_handle().name() + << " @ " << std::setw(4) << sc_time_stamp() + << ": " << "in = " << in.read() + << std::endl; + } +}; + +int sc_main(int, char*[]) +{ + sc_report_handler::set_actions( SC_ID_DISABLE_WILL_ORPHAN_PROCESS_ + , SC_DO_NOTHING ); + + sc_signal sig_int; + + sc_buffer buf; + sc_signal sig; + + print_edge sig_mod("sig_mod"); + sig_mod.in(sig); + + print_edge buf_mod("buf_mod"); + buf_mod.in(buf); + + for(int i=0; i<4; ++i) { + buf.write( !buf.read() ); + sig.write( !sig.read() ); + sc_start( 1, SC_NS ); + + buf.write( buf.read() ); + sig.write( sig.read() ); + sc_start( 1, SC_NS ); + } + + return 0; +} -- cgit v1.2.3