summaryrefslogtreecommitdiff
path: root/src/systemc/tests/systemc/misc/unit/structure/clocks
diff options
context:
space:
mode:
Diffstat (limited to 'src/systemc/tests/systemc/misc/unit/structure/clocks')
-rw-r--r--src/systemc/tests/systemc/misc/unit/structure/clocks/clocks.cpp52
-rw-r--r--src/systemc/tests/systemc/misc/unit/structure/clocks/clocks.h195
-rw-r--r--src/systemc/tests/systemc/misc/unit/structure/clocks/golden/clocks.log33
-rw-r--r--src/systemc/tests/systemc/misc/unit/structure/clocks/tb.h69
4 files changed, 349 insertions, 0 deletions
diff --git a/src/systemc/tests/systemc/misc/unit/structure/clocks/clocks.cpp b/src/systemc/tests/systemc/misc/unit/structure/clocks/clocks.cpp
new file mode 100644
index 000000000..f6fa053df
--- /dev/null
+++ b/src/systemc/tests/systemc/misc/unit/structure/clocks/clocks.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.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ clocks.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 "clocks.h"
+#include "tb.h" /** Definition of testbench Structure **/
+
+int
+sc_main( int, char*[] )
+{
+ sc_clock clk( "CLK", 20, SC_NS, 0.5, 0, SC_NS);
+ sc_clock clk2( "_____________CLK2", 20, SC_NS, 0.2, 5, SC_NS);
+
+ testbench tb1("TB1", clk, clk2);
+
+ sc_start( 80, SC_NS ); // Simulation control
+ return 0;
+}
diff --git a/src/systemc/tests/systemc/misc/unit/structure/clocks/clocks.h b/src/systemc/tests/systemc/misc/unit/structure/clocks/clocks.h
new file mode 100644
index 000000000..96cb4f666
--- /dev/null
+++ b/src/systemc/tests/systemc/misc/unit/structure/clocks/clocks.h
@@ -0,0 +1,195 @@
+/*****************************************************************************
+
+ 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.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ clocks.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"
+
+/******************************************************************************/
+/*************************** CLK_POS Function **********************/
+/******************************************************************************/
+
+SC_MODULE( CLK_POS )
+{
+ SC_HAS_PROCESS( CLK_POS );
+
+ sc_in_clk clk;
+
+ sc_signal<bool>& out_clk_pos;
+
+ CLK_POS ( sc_module_name NAME,
+ sc_clock& TICK_P,
+ sc_signal<bool>& OUT_CLK_POS )
+
+ :
+ out_clk_pos (OUT_CLK_POS)
+ {
+ clk (TICK_P);
+ SC_CTHREAD( entry, clk.pos() );
+ }
+
+ void entry();
+};
+
+void
+CLK_POS::entry()
+{
+ cout << sc_time_stamp() << " : CLK UP\n" << endl;
+ out_clk_pos.write(1);
+ wait();
+ cout << sc_time_stamp() << " : CLK UP\n" << endl;
+ out_clk_pos.write(0);
+ wait();
+ cout << sc_time_stamp() << " : CLK UP\n" << endl;
+ wait();
+ cout << sc_time_stamp() << " : CLK UP\n" << endl;
+}
+
+/******************************************************************************/
+/*************************** CLK_NEG Function **********************/
+/******************************************************************************/
+
+SC_MODULE( CLK_NEG )
+{
+ SC_HAS_PROCESS( CLK_NEG );
+
+ sc_in_clk clk;
+
+ sc_signal<bool>& out_clk_neg;
+
+ CLK_NEG ( sc_module_name NAME,
+ sc_clock& TICK_N,
+ sc_signal<bool>& OUT_CLK_NEG )
+ :
+ out_clk_neg (OUT_CLK_NEG)
+ {
+ clk (TICK_N);
+ SC_CTHREAD( entry, clk.neg() );
+ }
+
+ void entry();
+};
+
+void
+CLK_NEG::entry()
+{
+ cout << sc_time_stamp() << " : CLK DN\n" << endl;
+ out_clk_neg.write(1);
+ wait();
+ cout << sc_time_stamp() << " : CLK DN\n" << endl;
+ out_clk_neg.write(0);
+ wait();
+ cout << sc_time_stamp() << " : CLK DN\n" << endl;
+ wait();
+ cout << sc_time_stamp() << " : CLK DN\n" << endl;
+}
+
+/******************************************************************************/
+/*************************** CLK2_POS Function **********************/
+/******************************************************************************/
+
+SC_MODULE( CLK2_POS )
+{
+ SC_HAS_PROCESS( CLK2_POS );
+
+ sc_in_clk clk;
+
+ sc_signal<bool>& out_clk2_pos;
+
+ CLK2_POS ( sc_module_name NAME,
+ sc_clock& TICK2_P,
+ sc_signal<bool>& OUT_CLK2_POS )
+ :
+ out_clk2_pos (OUT_CLK2_POS)
+ {
+ clk (TICK2_P);
+ SC_CTHREAD( entry, clk.pos() );
+ }
+
+ void entry();
+};
+
+void
+CLK2_POS::entry()
+{
+ cout << sc_time_stamp() << " : _____________CLK2 UP\n" << endl;
+ out_clk2_pos.write(1);
+ wait();
+ cout << sc_time_stamp() << " : _____________CLK2 UP\n" << endl;
+ out_clk2_pos.write(0);
+ wait();
+ cout << sc_time_stamp() << " : _____________CLK2 UP\n" << endl;
+ wait();
+ cout << sc_time_stamp() << " : _____________CLK2 UP\n" << endl;
+}
+
+/******************************************************************************/
+/*************************** CLK2_NEG Function **********************/
+/******************************************************************************/
+
+SC_MODULE( CLK2_NEG )
+{
+ SC_HAS_PROCESS( CLK2_NEG );
+
+ sc_in_clk clk;
+
+ sc_signal<bool>& out_clk2_neg;
+
+ CLK2_NEG ( sc_module_name NAME,
+ sc_clock& TICK2_N,
+ sc_signal<bool>& OUT_CLK2_NEG )
+ :
+ out_clk2_neg (OUT_CLK2_NEG)
+ {
+ clk (TICK2_N);
+ SC_CTHREAD( entry, clk.neg() );
+ }
+
+ void entry();
+};
+
+void
+CLK2_NEG::entry()
+{
+ cout << sc_time_stamp() << " : _____________CLK2 DN\n" << endl;
+ out_clk2_neg.write(1);
+ wait();
+ cout << sc_time_stamp() << " : _____________CLK2 DN\n" << endl;
+ out_clk2_neg.write(0);
+ wait();
+ cout << sc_time_stamp() << " : _____________CLK2 DN\n" << endl;
+ wait();
+ cout << sc_time_stamp() << " : _____________CLK2 DN\n" << endl;
+}
diff --git a/src/systemc/tests/systemc/misc/unit/structure/clocks/golden/clocks.log b/src/systemc/tests/systemc/misc/unit/structure/clocks/golden/clocks.log
new file mode 100644
index 000000000..4d160c918
--- /dev/null
+++ b/src/systemc/tests/systemc/misc/unit/structure/clocks/golden/clocks.log
@@ -0,0 +1,33 @@
+SystemC Simulation
+0 s : CLK UP
+
+5 ns : _____________CLK2 UP
+
+9 ns : _____________CLK2 DN
+
+10 ns : CLK DN
+
+20 ns : CLK UP
+
+25 ns : _____________CLK2 UP
+
+29 ns : _____________CLK2 DN
+
+30 ns : CLK DN
+
+40 ns : CLK UP
+
+45 ns : _____________CLK2 UP
+
+49 ns : _____________CLK2 DN
+
+50 ns : CLK DN
+
+60 ns : CLK UP
+
+65 ns : _____________CLK2 UP
+
+69 ns : _____________CLK2 DN
+
+70 ns : CLK DN
+
diff --git a/src/systemc/tests/systemc/misc/unit/structure/clocks/tb.h b/src/systemc/tests/systemc/misc/unit/structure/clocks/tb.h
new file mode 100644
index 000000000..e10f6c71c
--- /dev/null
+++ b/src/systemc/tests/systemc/misc/unit/structure/clocks/tb.h
@@ -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.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ 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 **********************/
+/******************************************************************************/
+
+struct testbench : public sc_module
+{
+ sc_signal<bool> out_clk_pos;
+ sc_signal<bool> out_clk_neg;
+ sc_signal<bool> out_clk2_pos;
+ sc_signal<bool> out_clk2_neg;
+ CLK_POS clkp;
+ CLK_NEG clkn;
+ CLK2_POS clkp2;
+ CLK2_NEG clkn2;
+
+ /*** Constructor ***/
+ testbench ( const sc_module_name& NAME,
+ sc_clock& TICK,
+ sc_clock& TICK2 )
+ : sc_module(),
+ out_clk_pos ("out_clk_pos"),
+ out_clk_neg ("out_clk_neg"),
+ out_clk2_pos ("out_clk2_pos"),
+ out_clk2_neg ("out_clk2_neg"),
+ clkp ("CLKP", TICK, out_clk_pos),
+ clkn ("CLKN", TICK, out_clk_neg),
+ clkp2 ("CLKP2", TICK2, out_clk2_pos),
+ clkn2 ("CLKN2", TICK2, out_clk2_neg)
+ {
+ end_module();
+ }
+};