diff options
author | Gabe Black <gabeblack@google.com> | 2018-05-24 01:37:55 -0700 |
---|---|---|
committer | Gabe Black <gabeblack@google.com> | 2018-08-08 10:09:54 +0000 |
commit | 16fa8d7cc8c92f5ab879e4cf9c6c0bbb3567860f (patch) | |
tree | 7b6faaacb4574a555e561534aa4a8508c0624c32 /src/systemc/tests/systemc/misc/unit/control/posedge | |
parent | 7235d3b5211d0ba8f528d930a4c1e7ad62eec51a (diff) | |
download | gem5-16fa8d7cc8c92f5ab879e4cf9c6c0bbb3567860f.tar.xz |
systemc: Import tests from the Accellera systemc distribution.
Change-Id: Iad76b398949a55d768a34d027a2d8e3739953da6
Reviewed-on: https://gem5-review.googlesource.com/10845
Reviewed-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Maintainer: Gabe Black <gabeblack@google.com>
Diffstat (limited to 'src/systemc/tests/systemc/misc/unit/control/posedge')
5 files changed, 308 insertions, 0 deletions
diff --git a/src/systemc/tests/systemc/misc/unit/control/posedge/golden/posedge.log b/src/systemc/tests/systemc/misc/unit/control/posedge/golden/posedge.log new file mode 100644 index 000000000..38978c665 --- /dev/null +++ b/src/systemc/tests/systemc/misc/unit/control/posedge/golden/posedge.log @@ -0,0 +1,9 @@ +SystemC Simulation +10 ns : ready = 0 (RDY) +30 ns : ready = 0 (RDY) +40 ns : POSEDGE READY DETECTED +50 ns : ready = 1 (RDY) +70 ns : ready = 0 (RDY) +80 ns : POSEDGE READY DETECTED +90 ns : ready = 1 (RDY) +Terminating process TB1.RD1.entry diff --git a/src/systemc/tests/systemc/misc/unit/control/posedge/posedge.cpp b/src/systemc/tests/systemc/misc/unit/control/posedge/posedge.cpp new file mode 100644 index 000000000..89968ae01 --- /dev/null +++ b/src/systemc/tests/systemc/misc/unit/control/posedge/posedge.cpp @@ -0,0 +1,52 @@ +/***************************************************************************** + + 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. + + *****************************************************************************/ + +/***************************************************************************** + + posedge.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: + + *****************************************************************************/ + +#include "systemc.h" +#include "rdy.h" +#include "stim.h" +#include "tb.h" /** Definition of testbench Structure **/ + +/******************************************************************************/ +/*************************** Main Function *********************************/ +/******************************************************************************/ +int sc_main(int ac, char *av[]) +{ + sc_clock clk( "CLK", 20, SC_NS, 0.5, 0, SC_NS); // Clock function + testbench tb1("TB1", clk); // Testbench Instantiation + sc_start( 120, SC_NS ); // Simulation control + return 0; +} diff --git a/src/systemc/tests/systemc/misc/unit/control/posedge/rdy.h b/src/systemc/tests/systemc/misc/unit/control/posedge/rdy.h new file mode 100644 index 000000000..d9c988538 --- /dev/null +++ b/src/systemc/tests/systemc/misc/unit/control/posedge/rdy.h @@ -0,0 +1,109 @@ +/***************************************************************************** + + 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. + + *****************************************************************************/ + +/***************************************************************************** + + rdy.h -- + + 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: + + *****************************************************************************/ + +#include "systemc.h" + +/******************************************************************************/ +/*************************** rdy Function **********************/ +/******************************************************************************/ + +SC_MODULE( RDY ) +{ + SC_HAS_PROCESS( RDY ); + + sc_in_clk clk; + + /*** Input and Output Ports ***/ + sc_signal<bool>& data; + + /*** Constructor ***/ + RDY ( sc_module_name NAME, + sc_clock& TICK_N, + sc_signal<bool>& DATA ) + + : + data (DATA) + + { + clk (TICK_N); + SC_CTHREAD( entry, clk.neg() ); + } + + /*** Call to Process Functionality ***/ + void entry(); + +}; + +void +RDY::entry() +{ + // IMPLICIT wait(); AT FIRST NEGEDGE + cout << sc_time_stamp() << " : " // Time 10 + << "ready = " << data + << "\t\t (RDY) " + << endl; + data.write(0); + + wait(); // Time 30 + cout << sc_time_stamp() << " : " + << "ready = " << data + << "\t\t (RDY) " + << endl; + data.write(1); + + wait(); // Time 50 + cout << sc_time_stamp() << " : " + << "ready = " << data + << "\t\t (RDY) " + << endl; + data.write(0); + + wait(); // Time 70 + cout << sc_time_stamp() << " : " + << "ready = " << data + << "\t\t (RDY) " + << endl; + data.write(1); + + wait(); // Time 90 + cout << sc_time_stamp() << " : " + << "ready = " << data + << "\t\t (RDY) " + << endl; + + halt(); +} diff --git a/src/systemc/tests/systemc/misc/unit/control/posedge/stim.h b/src/systemc/tests/systemc/misc/unit/control/posedge/stim.h new file mode 100644 index 000000000..18e2dd617 --- /dev/null +++ b/src/systemc/tests/systemc/misc/unit/control/posedge/stim.h @@ -0,0 +1,80 @@ +/***************************************************************************** + + 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. + + *****************************************************************************/ + +/***************************************************************************** + + stim.h -- + + 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: + + *****************************************************************************/ + +#include "systemc.h" + +/******************************************************************************/ +/*************************** stim Function **********************/ +/******************************************************************************/ + +SC_MODULE( STIM ) +{ + SC_HAS_PROCESS( STIM ); + + sc_in_clk clk; + + /*** Input and Output Ports ***/ + const sc_signal<bool>& data; + + /*** Constructor ***/ + STIM ( sc_module_name NAME, + sc_clock& TICK_P, + const sc_signal<bool>& DATA ) + + : + data (DATA) + + { + clk (TICK_P); + SC_CTHREAD( entry, clk.pos() ); + } + + /*** Call to Process Functionality ***/ + void entry(); + +}; + +void +STIM::entry() +{ + while(true) { + at_posedge(data); + cout << sc_time_stamp() << " : " + << "POSEDGE READY DETECTED" + << endl; + } +} diff --git a/src/systemc/tests/systemc/misc/unit/control/posedge/tb.h b/src/systemc/tests/systemc/misc/unit/control/posedge/tb.h new file mode 100644 index 000000000..095450002 --- /dev/null +++ b/src/systemc/tests/systemc/misc/unit/control/posedge/tb.h @@ -0,0 +1,58 @@ +/***************************************************************************** + + 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. + + *****************************************************************************/ + +/***************************************************************************** + + tb.h -- + + 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: + + *****************************************************************************/ + +/******************************************************************************/ +/*************************** Testbench Function **********************/ +/******************************************************************************/ + +SC_MODULE( testbench ) +{ + sc_signal<bool> ready; + STIM st1; + RDY rd1; + + /*** Constructor ***/ + testbench ( sc_module_name NAME, + sc_clock& TICK ) + + : sc_module(), + st1 ("ST1", TICK, ready), + rd1 ("RD1", TICK, ready) + { + end_module(); + } +}; |