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/*****************************************************************************
21
22  test01.cpp --
23
24  Original Author: Martin Janssen, Synopsys, Inc., 2002-03-13
25
26 *****************************************************************************/
27
28/*****************************************************************************
29
30  MODIFICATION LOG - modifiers, enter your name, affiliation, date and
31  changes you are making here.
32
33      Name, Affiliation, Date:
34  Description of Modification:
35
36 *****************************************************************************/
37
38// $Log: test01.cpp,v $
39// Revision 1.1.1.1  2006/12/15 20:26:10  acg
40// systemc_tests-2.3
41//
42// Revision 1.2  2006/01/24 21:05:13  acg
43//  Andy Goodrich: replacement of deprecated features with their non-deprecated
44//  counterparts.
45//
46
47// test of former asserts (should not be reachable from public APIs) now errors
48
49#include "systemc.h"
50
51SC_MODULE( mod_a )
52{
53    sc_in_clk clk;
54
55    SC_CTOR( mod_a )
56    {
57        clk.pos().find_event();
58    }
59};
60
61SC_MODULE( mod_b )
62{
63    sc_in_clk clk;
64
65    SC_CTOR( mod_b )
66    {
67        clk->read();
68    }
69};
70
71SC_MODULE( mod_c )
72{
73    const sc_in_clk clk;
74
75    SC_CTOR( mod_c )
76    {
77        clk->read();
78    }
79};
80
81int
82sc_main( int, char*[] )
83{
84    // sc_clock error(s)
85
86    try {
87        sc_clock clk1( "clk1", 0, SC_PS );
88    } catch( sc_report x ) {
89        cout << "\nException caught" << endl;
90        cout << x.what() << endl;
91    }
92
93    try {
94        sc_clock clk2( "clk2", 1, SC_PS, 0.1 );
95    } catch( sc_report x ) {
96        cout << "\nException caught" << endl;
97        cout << x.what() << endl;
98    }
99
100    try {
101        sc_clock clk3( "clk3", 1, SC_PS, 0.9 );
102    } catch( sc_report x ) {
103        cout << "\nException caught" << endl;
104        cout << x.what() << endl;
105    }
106
107
108    // sc_event_finder error(s)
109
110    try {
111        mod_a a( "a" );
112    } catch( sc_report x ) {
113        cout << "\nException caught" << endl;
114        cout << x.what() << endl;
115    }
116
117
118    // sc_port error(s)
119
120    try {
121        mod_b b( "b" );
122    } catch( sc_report x ) {
123        cout << "\nException caught" << endl;
124        cout << x.what() << endl;
125    }
126
127    try {
128        mod_c c( "c" );
129    } catch( sc_report x ) {
130        cout << "\nException caught" << endl;
131        cout << x.what() << endl;
132    }
133
134
135    // sc_semaphore error(s)
136
137    try {
138        sc_semaphore sem1( -1 );
139    } catch( sc_report x ) {
140        cout << "\nException caught" << endl;
141        cout << x.what() << endl;
142    }
143
144    try {
145        sc_semaphore sem2( "sem2", -1 );
146    } catch( sc_report x ) {
147        cout << "\nException caught" << endl;
148        cout << x.what() << endl;
149    }
150
151
152    // sc_event error(s)
153
154    try {
155        sc_event e1;
156        e1.notify( 10, SC_MS );
157        e1.notify_delayed();
158    } catch( sc_report x ) {
159        cout << "\nException caught" << endl;
160        cout << x.what() << endl;
161    }
162
163    try {
164        sc_event e2;
165        e2.notify( 10, SC_MS );
166        e2.notify_delayed( SC_ZERO_TIME );
167    } catch( sc_report x ) {
168        cout << "\nException caught" << endl;
169        cout << x.what() << endl;
170    }
171
172
173    // sc_name_gen error(s)
174
175    try {
176        sc_gen_unique_name( 0 );
177    } catch( sc_report x ) {
178        cout << "\nException caught" << endl;
179        cout << x.what() << endl;
180    }
181
182    return 0;
183}
184