test2.cpp revision 12855
16657Snate@binkert.org/*****************************************************************************
26657Snate@binkert.org
36657Snate@binkert.org  Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
46657Snate@binkert.org  more contributor license agreements.  See the NOTICE file distributed
56657Snate@binkert.org  with this work for additional information regarding copyright ownership.
66657Snate@binkert.org  Accellera licenses this file to you under the Apache License, Version 2.0
76657Snate@binkert.org  (the "License"); you may not use this file except in compliance with the
86657Snate@binkert.org  License.  You may obtain a copy of the License at
96657Snate@binkert.org
106657Snate@binkert.org    http://www.apache.org/licenses/LICENSE-2.0
116657Snate@binkert.org
126657Snate@binkert.org  Unless required by applicable law or agreed to in writing, software
136657Snate@binkert.org  distributed under the License is distributed on an "AS IS" BASIS,
146657Snate@binkert.org  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
156657Snate@binkert.org  implied.  See the License for the specific language governing
166657Snate@binkert.org  permissions and limitations under the License.
176657Snate@binkert.org
186657Snate@binkert.org *****************************************************************************/
196657Snate@binkert.org
206657Snate@binkert.org/*****************************************************************************
216657Snate@binkert.org
226657Snate@binkert.org  test2.cpp -- Test use of sc_pending_activity_at_current_time()
236657Snate@binkert.org
246657Snate@binkert.org  Original Author: Andy Goodrich, Forte Design Systems, 18 August 2006
256657Snate@binkert.org
266657Snate@binkert.org *****************************************************************************/
276657Snate@binkert.org
286657Snate@binkert.org/*****************************************************************************
296657Snate@binkert.org
306657Snate@binkert.org  MODIFICATION LOG - modifiers, enter your name, affiliation, date and
316657Snate@binkert.org  changes you are making here.
326657Snate@binkert.org
336657Snate@binkert.org      Name, Affiliation, Date:
346657Snate@binkert.org  Description of Modification: -
356657Snate@binkert.org
366657Snate@binkert.org *****************************************************************************/
376657Snate@binkert.org
386657Snate@binkert.org#include "systemc.h"
396657Snate@binkert.org
406657Snate@binkert.orgSC_MODULE(DUT)
416657Snate@binkert.org{
426657Snate@binkert.org    SC_CTOR(DUT)
436657Snate@binkert.org    {
446657Snate@binkert.org        SC_THREAD(thread)
456657Snate@binkert.org        sensitive << m_clk.pos();
466657Snate@binkert.org        dont_initialize();
476657Snate@binkert.org        SC_METHOD(cascade0_monitor);
486657Snate@binkert.org        sensitive << m_cascade0;
496657Snate@binkert.org        dont_initialize();
506657Snate@binkert.org        SC_METHOD(cascade1_monitor);
516657Snate@binkert.org        sensitive << m_cascade1;
526657Snate@binkert.org        dont_initialize();
536657Snate@binkert.org        SC_METHOD(cascade2_monitor);
546657Snate@binkert.org        sensitive << m_cascade2;
556657Snate@binkert.org        dont_initialize();
566657Snate@binkert.org    }
576657Snate@binkert.org
586657Snate@binkert.org    void cascade0_monitor()
596657Snate@binkert.org    {
606657Snate@binkert.org        cout << sc_time_stamp() << " " << sc_delta_count() << " cascade0"
616657Snate@binkert.org             << endl;
626657Snate@binkert.org        m_cascade1 = m_cascade0;
636657Snate@binkert.org    }
646657Snate@binkert.org
656657Snate@binkert.org    void cascade1_monitor()
666657Snate@binkert.org    {
676657Snate@binkert.org        cout << sc_time_stamp() << " " << sc_delta_count() << " cascade1"
686657Snate@binkert.org             << endl;
696657Snate@binkert.org        m_cascade2 = m_cascade1;
706657Snate@binkert.org    }
716657Snate@binkert.org
726657Snate@binkert.org    void cascade2_monitor()
736657Snate@binkert.org    {
746657Snate@binkert.org        cout << sc_time_stamp() << " " << sc_delta_count() << " cascade2"
756657Snate@binkert.org             << endl;
766657Snate@binkert.org    }
776657Snate@binkert.org
786657Snate@binkert.org    void thread()
79    {
80        for (;;)
81        {
82            cout << sc_time_stamp() << " " << sc_delta_count() << " thread"
83                 << endl;
84            m_cascade0 = !m_cascade0.read();
85            wait();
86        }
87    }
88    sc_signal<bool> m_cascade0;
89    sc_signal<bool> m_cascade1;
90    sc_signal<bool> m_cascade2;
91    sc_in<bool>     m_clk;
92};
93
94int sc_main(int argc, char* argv[])
95{
96    sc_clock        clock;
97    DUT             dut("dut");
98
99    dut.m_clk(clock);
100
101
102    do { sc_start(0, SC_NS); } while (sc_pending_activity_at_current_time());
103    cout << endl;
104    sc_start(1, SC_NS);
105    do { sc_start(0, SC_NS); } while (sc_pending_activity_at_current_time());
106    cout << endl;
107    sc_start(1, SC_NS);
108    do { sc_start(0, SC_NS); } while (sc_pending_activity_at_current_time());
109
110    cout << "Program completed" << endl;
111    return 0;
112}
113