1/*
2 * Copyright 2018 Google, Inc.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met: redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer;
8 * redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution;
11 * neither the name of the copyright holders nor the names of its
12 * contributors may be used to endorse or promote products derived from
13 * this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 *
27 * Authors: Gabe Black
28 */
29
30#include "systemc/ext/core/messages.hh"
31#include "systemc/utils/report.hh"
32
33namespace sc_core
34{
35
36const char SC_ID_NO_BOOL_RETURNED_[] = "operator does not return boolean";
37const char SC_ID_NO_INT_RETURNED_[] = "operator does not return int";
38const char SC_ID_NO_SC_LOGIC_RETURNED_[] = "operator does not return sc_logic";
39const char SC_ID_OPERAND_NOT_SC_LOGIC_[] = "operand is not sc_logic";
40const char SC_ID_OPERAND_NOT_BOOL_[] = "operand is not bool";
41const char SC_ID_INSTANCE_EXISTS_[] = "object already exists";
42const char SC_ID_ILLEGAL_CHARACTERS_[] = "illegal characters";
43const char SC_ID_VC6_PROCESS_HELPER_[] =
44    "internal error: sc_vc6_process_helper";
45const char SC_ID_VC6_MAX_PROCESSES_EXCEEDED_[] =
46    "maximum number of processes per module exceeded (VC6)";
47const char SC_ID_END_MODULE_NOT_CALLED_[] =
48    "module construction not properly completed: did "
49    "you forget to add a sc_module_name parameter to "
50    "your module constructor?";
51const char SC_ID_HIER_NAME_INCORRECT_[] =
52    "hierarchical name as shown may be incorrect due to previous errors";
53const char SC_ID_SET_STACK_SIZE_[] =
54    "set_stack_size() is only allowed for SC_THREADs and SC_CTHREADs";
55const char SC_ID_SC_MODULE_NAME_USE_[] = "incorrect use of sc_module_name";
56const char SC_ID_SC_MODULE_NAME_REQUIRED_[] =
57    "an sc_module_name parameter for your constructor is required";
58const char SC_ID_SET_TIME_RESOLUTION_[] = "set time resolution failed";
59const char SC_ID_SET_DEFAULT_TIME_UNIT_[] = "set default time unit failed";
60const char SC_ID_DEFAULT_TIME_UNIT_CHANGED_[] =
61    "default time unit changed to time resolution";
62const char SC_ID_INCONSISTENT_API_CONFIG_[] =
63    "inconsistent library configuration detected";
64const char SC_ID_WAIT_NOT_ALLOWED_[] =
65    "wait() is only allowed in SC_THREADs and SC_CTHREADs";
66const char SC_ID_NEXT_TRIGGER_NOT_ALLOWED_[] =
67    "next_trigger() is only allowed in SC_METHODs";
68const char SC_ID_IMMEDIATE_NOTIFICATION_[] =
69    "immediate notification is not allowed during update phase or elaboration";
70const char SC_ID_HALT_NOT_ALLOWED_[] = "halt() is only allowed in SC_CTHREADs";
71const char SC_ID_WATCHING_NOT_ALLOWED_[] =
72    "watching() has been deprecated, use reset_signal_is()";
73const char SC_ID_DONT_INITIALIZE_[] =
74    "dont_initialize() has no effect for SC_CTHREADs";
75const char SC_ID_WAIT_N_INVALID_[] = "wait(n) is only valid for n > 0";
76const char SC_ID_MAKE_SENSITIVE_[] = "make sensitive failed";
77const char SC_ID_MAKE_SENSITIVE_POS_[] = "make sensitive pos failed";
78const char SC_ID_MAKE_SENSITIVE_NEG_[] = "make sensitive neg failed";
79const char SC_ID_INSERT_MODULE_[] = "insert module failed";
80const char SC_ID_REMOVE_MODULE_[] = "remove module failed";
81const char SC_ID_NOTIFY_DELAYED_[] =
82    "notify_delayed() cannot be called on events "
83    "that have pending notifications";
84const char SC_ID_GEN_UNIQUE_NAME_[] =
85    "cannot generate unique name from null string";
86const char SC_ID_MODULE_NAME_STACK_EMPTY_[] =
87    "module name stack is empty: did you forget to "
88    "add a sc_module_name parameter to your module "
89    "constructor?";
90const char SC_ID_NAME_EXISTS_[] = "name already exists";
91const char SC_ID_IMMEDIATE_SELF_NOTIFICATION_[] =
92    "immediate self-notification ignored as of IEEE 1666-2011";
93const char SC_ID_WAIT_DURING_UNWINDING_[] =
94    "wait() not allowed during unwinding";
95const char SC_ID_CYCLE_MISSES_EVENTS_[] =
96    "the simulation contains timed-events but they are "
97    "ignored by sc_cycle() ==> the simulation will be "
98    "incorrect";
99const char SC_ID_RETHROW_UNWINDING_[] =
100    "sc_unwind_exception not re-thrown during kill/reset";
101const char SC_ID_PROCESS_ALREADY_UNWINDING_[] =
102    "kill/reset ignored during unwinding";
103const char SC_ID_MODULE_METHOD_AFTER_START_[] =
104    "call to SC_METHOD in sc_module while simulation running";
105const char SC_ID_MODULE_THREAD_AFTER_START_[] =
106    "call to SC_THREAD in sc_module while simulation running";
107const char SC_ID_MODULE_CTHREAD_AFTER_START_[] =
108    "call to SC_CTHREAD in sc_module while simulation running";
109const char SC_ID_SIMULATION_TIME_OVERFLOW_[] =
110    "simulation time value overflow, simulation aborted";
111const char SC_ID_SIMULATION_STOP_CALLED_TWICE_[] =
112    "sc_stop has already been called";
113const char SC_ID_SIMULATION_START_AFTER_STOP_[] =
114    "sc_start called after sc_stop has been called";
115const char SC_ID_STOP_MODE_AFTER_START_[] =
116    "attempt to set sc_stop mode  after start will be ignored";
117const char SC_ID_SIMULATION_START_AFTER_ERROR_[] =
118    "attempt to restart simulation after error";
119const char SC_ID_SIMULATION_UNCAUGHT_EXCEPTION_[] = "uncaught exception";
120const char SC_ID_PHASE_CALLBACKS_UNSUPPORTED_[] =
121    "simulation phase callbacks not enabled";
122const char SC_ID_PHASE_CALLBACK_NOT_IMPLEMENTED_[] =
123    "empty simulation phase callback called";
124const char SC_ID_PHASE_CALLBACK_REGISTER_[] =
125    "register simulation phase callback";
126const char SC_ID_PHASE_CALLBACK_FORBIDDEN_[] =
127    "forbidden action in simulation phase callback";
128const char SC_ID_SIMULATION_START_UNEXPECTED_[] =
129    "sc_start called unexpectedly";
130const char SC_ID_THROW_IT_IGNORED_[] =
131    "throw_it on method/non-running process is being ignored ";
132const char SC_ID_NOT_EXPECTING_DYNAMIC_EVENT_NOTIFY_[] =
133    "dynamic event notification encountered when sensitivity is static";
134const char SC_ID_DISABLE_WILL_ORPHAN_PROCESS_[] =
135    "disable() or dont_initialize() called on process with no static "
136    "sensitivity, it will be orphaned";
137const char SC_ID_PROCESS_CONTROL_CORNER_CASE_[] =
138    "Undefined process control interaction";
139const char SC_ID_METHOD_TERMINATION_EVENT_[] =
140    "Attempt to get terminated event for a method process";
141const char SC_ID_JOIN_ON_METHOD_HANDLE_[] =
142    "Attempt to register method process with sc_join object";
143const char SC_ID_NO_PROCESS_SEMANTICS_[] =
144    "Attempt to invoke process with no semantics() method";
145const char SC_ID_EVENT_ON_NULL_PROCESS_[] =
146    "Attempt to get an event for non-existent process";
147const char SC_ID_EVENT_LIST_FAILED_[] =
148    "invalid use of sc_(and|or)_event list";
149const char SC_ID_UNKNOWN_PROCESS_TYPE_[] = "Unknown process type";
150const char SC_ID_TIME_CONVERSION_FAILED_[] = "sc_time conversion failed";
151const char SC_ID_NEGATIVE_SIMULATION_TIME_[] =
152    "negative simulation interval specified in sc_start call";
153const char SC_ID_BAD_SC_MODULE_CONSTRUCTOR_[] =
154    "sc_module(const char*), sc_module(const std::string&) "
155    "have been deprecated, use sc_module(const sc_module_name&)";
156const char SC_ID_EMPTY_PROCESS_HANDLE_[] =
157    "attempt to use an empty process handle ignored";
158const char SC_ID_NO_SC_START_ACTIVITY_[] =
159    "no activity or clock movement for sc_start() invocation";
160const char SC_ID_KILL_PROCESS_WHILE_UNITIALIZED_[] =
161    "a process may not be killed before it is initialized";
162const char SC_ID_RESET_PROCESS_WHILE_NOT_RUNNING_[] =
163    "a process may not be asynchronously reset while the "
164    "simulation is not running";
165const char SC_ID_THROW_IT_WHILE_NOT_RUNNING_[] =
166    "throw_it not allowed unless simulation is running ";
167
168namespace {
169
170sc_gem5::DefaultReportMessages predfinedMessages{
171    {500, SC_ID_NO_BOOL_RETURNED_},
172    {501, SC_ID_NO_INT_RETURNED_},
173    {502, SC_ID_NO_SC_LOGIC_RETURNED_},
174    {503, SC_ID_OPERAND_NOT_SC_LOGIC_},
175    {504, SC_ID_OPERAND_NOT_BOOL_},
176    {505, SC_ID_INSTANCE_EXISTS_},
177    {506, SC_ID_ILLEGAL_CHARACTERS_},
178    {507, SC_ID_VC6_PROCESS_HELPER_},
179    {508, SC_ID_VC6_MAX_PROCESSES_EXCEEDED_},
180    {509, SC_ID_END_MODULE_NOT_CALLED_},
181    {510, SC_ID_HIER_NAME_INCORRECT_},
182    {511, SC_ID_SET_STACK_SIZE_},
183    {512, SC_ID_SC_MODULE_NAME_USE_},
184    {513, SC_ID_SC_MODULE_NAME_REQUIRED_},
185    {514, SC_ID_SET_TIME_RESOLUTION_},
186    {515, SC_ID_SET_DEFAULT_TIME_UNIT_},
187    {516, SC_ID_DEFAULT_TIME_UNIT_CHANGED_},
188    {517, SC_ID_INCONSISTENT_API_CONFIG_},
189    {519, SC_ID_WAIT_NOT_ALLOWED_},
190    {520, SC_ID_NEXT_TRIGGER_NOT_ALLOWED_},
191    {521, SC_ID_IMMEDIATE_NOTIFICATION_},
192    {522, SC_ID_HALT_NOT_ALLOWED_},
193    {523, SC_ID_WATCHING_NOT_ALLOWED_},
194    {524, SC_ID_DONT_INITIALIZE_},
195    {525, SC_ID_WAIT_N_INVALID_},
196    {526, SC_ID_MAKE_SENSITIVE_},
197    {527, SC_ID_MAKE_SENSITIVE_POS_},
198    {528, SC_ID_MAKE_SENSITIVE_NEG_},
199    {529, SC_ID_INSERT_MODULE_},
200    {530, SC_ID_REMOVE_MODULE_},
201    {531, SC_ID_NOTIFY_DELAYED_},
202    {532, SC_ID_GEN_UNIQUE_NAME_},
203    {533, SC_ID_MODULE_NAME_STACK_EMPTY_},
204    {534, SC_ID_NAME_EXISTS_},
205    {536, SC_ID_IMMEDIATE_SELF_NOTIFICATION_},
206    {537, SC_ID_WAIT_DURING_UNWINDING_},
207    {538, SC_ID_CYCLE_MISSES_EVENTS_},
208    {539, SC_ID_RETHROW_UNWINDING_},
209    {540, SC_ID_PROCESS_ALREADY_UNWINDING_},
210    {541, SC_ID_MODULE_METHOD_AFTER_START_},
211    {542, SC_ID_MODULE_THREAD_AFTER_START_},
212    {543, SC_ID_MODULE_CTHREAD_AFTER_START_},
213    {544, SC_ID_SIMULATION_TIME_OVERFLOW_},
214    {545, SC_ID_SIMULATION_STOP_CALLED_TWICE_},
215    {546, SC_ID_SIMULATION_START_AFTER_STOP_},
216    {547, SC_ID_STOP_MODE_AFTER_START_},
217    {548, SC_ID_SIMULATION_START_AFTER_ERROR_},
218    {549, SC_ID_SIMULATION_UNCAUGHT_EXCEPTION_},
219    {550, SC_ID_PHASE_CALLBACKS_UNSUPPORTED_},
220    {551, SC_ID_PHASE_CALLBACK_NOT_IMPLEMENTED_},
221    {552, SC_ID_PHASE_CALLBACK_REGISTER_},
222    {553, SC_ID_PHASE_CALLBACK_FORBIDDEN_},
223    {554, SC_ID_SIMULATION_START_UNEXPECTED_},
224    {556, SC_ID_THROW_IT_IGNORED_},
225    {557, SC_ID_NOT_EXPECTING_DYNAMIC_EVENT_NOTIFY_},
226    {558, SC_ID_DISABLE_WILL_ORPHAN_PROCESS_},
227    {559, SC_ID_PROCESS_CONTROL_CORNER_CASE_},
228    {560, SC_ID_METHOD_TERMINATION_EVENT_},
229    {561, SC_ID_JOIN_ON_METHOD_HANDLE_},
230    {563, SC_ID_NO_PROCESS_SEMANTICS_},
231    {564, SC_ID_EVENT_ON_NULL_PROCESS_},
232    {565, SC_ID_EVENT_LIST_FAILED_},
233    {566, SC_ID_UNKNOWN_PROCESS_TYPE_},
234    {567, SC_ID_TIME_CONVERSION_FAILED_},
235    {568, SC_ID_NEGATIVE_SIMULATION_TIME_},
236    {569, SC_ID_BAD_SC_MODULE_CONSTRUCTOR_},
237    {570, SC_ID_EMPTY_PROCESS_HANDLE_},
238    {571, SC_ID_NO_SC_START_ACTIVITY_},
239    {572, SC_ID_KILL_PROCESS_WHILE_UNITIALIZED_},
240    {573, SC_ID_RESET_PROCESS_WHILE_NOT_RUNNING_},
241    {574, SC_ID_THROW_IT_WHILE_NOT_RUNNING_}
242};
243
244} // anonymous namespace
245
246} // namespace sc_core
247