test01.cpp revision 12855:588919e0e4aa
1/*****************************************************************************
2
3  Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
4  more contributor license agreements.  See the NOTICE file distributed
5  with this work for additional information regarding copyright ownership.
6  Accellera licenses this file to you under the Apache License, Version 2.0
7  (the "License"); you may not use this file except in compliance with the
8  License.  You may obtain a copy of the License at
9
10    http://www.apache.org/licenses/LICENSE-2.0
11
12  Unless required by applicable law or agreed to in writing, software
13  distributed under the License is distributed on an "AS IS" BASIS,
14  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
15  implied.  See the License for the specific language governing
16  permissions and limitations under the License.
17
18 *****************************************************************************/
19
20// test01.cpp -- sc_start With Event Starvation Policy
21//
22//  Original Author: John Aynsley, Doulos
23//
24// MODIFICATION LOG - modifiers, enter your name, affiliation, date and
25//
26// $Log: test01.cpp,v $
27// Revision 1.1  2011/02/05 21:14:24  acg
28//  Andy Goodrich: moving tests John Aynsley will replace.
29//
30// Revision 1.2  2011/01/25 20:54:03  acg
31//  Andy Goodrich: regolden for new delta counter rules.
32//
33// Revision 1.1  2011/01/24 12:06:06  acg
34//  Andy Goodrich: changes for IEEE 1666 2011
35//
36
37#include <systemc>
38using namespace sc_core;
39using std::cout;
40using std::endl;
41
42SC_MODULE(Top)
43{
44  SC_CTOR(Top)
45  {
46    SC_THREAD(T);
47  }
48
49  sc_event ev;
50
51  void T()
52  {
53    ev.notify(150, SC_NS);
54  }
55};
56
57int sc_main(int argc, char* argv[])
58{
59  Top top("top");
60
61  sc_assert( sc_get_status() == SC_ELABORATION );
62  sc_assert( sc_time_stamp() == SC_ZERO_TIME );
63  sc_start(100, SC_NS);
64  sc_assert( sc_time_stamp() == sc_time(100, SC_NS) );
65
66  sc_start(10, SC_NS, SC_RUN_TO_TIME);
67  sc_assert( sc_time_stamp() == sc_time(110, SC_NS) );
68
69  sc_start(10, SC_NS, SC_EXIT_ON_STARVATION);
70  // sc_assert( sc_time_stamp() == sc_time(120, SC_NS) );
71  sc_assert( sc_time_stamp() == sc_time(110, SC_NS) );
72
73  sc_start(80, SC_NS, SC_EXIT_ON_STARVATION);
74  sc_assert( sc_time_stamp() == sc_time(150, SC_NS) );
75
76  sc_start();
77  sc_assert( sc_time_stamp() == sc_time(150, SC_NS) );
78  sc_assert( sc_get_status() == SC_PAUSED );
79
80  cout << endl << "Success" << endl;
81  return 0;
82}
83