112855Sgabeblack@google.com#include "systemc.h"
212855Sgabeblack@google.com#include "sc_barrier.h"
312855Sgabeblack@google.comusing sc_dp::sc_barrier;
412855Sgabeblack@google.com
512855Sgabeblack@google.comSC_MODULE(X)
612855Sgabeblack@google.com{
712855Sgabeblack@google.com	SC_CTOR(X)
812855Sgabeblack@google.com	{
912855Sgabeblack@google.com		sc_thread_handle last_thread;
1012855Sgabeblack@google.com
1112855Sgabeblack@google.com		SC_THREAD(a);
1212855Sgabeblack@google.com		SC_THREAD(b);
1312855Sgabeblack@google.com		SC_THREAD(c);
1412855Sgabeblack@google.com
1512855Sgabeblack@google.com		m_barrier.initialize(3);
1612855Sgabeblack@google.com	}
1712855Sgabeblack@google.com	void a()
1812855Sgabeblack@google.com	{
1912855Sgabeblack@google.com		wait(5.0, SC_NS);
2012855Sgabeblack@google.com		m_barrier.wait();
2112855Sgabeblack@google.com		cout << sc_time_stamp() << " - a" << endl;
2212855Sgabeblack@google.com	}
2312855Sgabeblack@google.com	void b()
2412855Sgabeblack@google.com	{
2512855Sgabeblack@google.com		wait(11.0, SC_NS);
2612855Sgabeblack@google.com		m_barrier.wait();
2712855Sgabeblack@google.com		cout << sc_time_stamp() << " - b" << endl;
2812855Sgabeblack@google.com	}
2912855Sgabeblack@google.com	void c()
3012855Sgabeblack@google.com	{
3112855Sgabeblack@google.com		m_barrier.wait();
3212855Sgabeblack@google.com		cout << sc_time_stamp() << " - c" << endl;
3312855Sgabeblack@google.com	}
3412855Sgabeblack@google.com	sc_barrier   m_barrier;
3512855Sgabeblack@google.com};
3612855Sgabeblack@google.com
3712855Sgabeblack@google.comint sc_main( int argc, char* argv[] )
3812855Sgabeblack@google.com{
3912855Sgabeblack@google.com	sc_clock clock;
4012855Sgabeblack@google.com	X x("x");
4112855Sgabeblack@google.com
4212855Sgabeblack@google.com	sc_start(1000, SC_NS);
4312855Sgabeblack@google.com
4413158Sgabeblack@google.com	cout << "Program completed" << endl;
4512855Sgabeblack@google.com	return 0;
4612855Sgabeblack@google.com}
4712855Sgabeblack@google.com
48