* Authors: Gabe Black
*/
+#include <string>
+
#include "base/logging.hh"
#include "systemc/ext/channel/sc_semaphore.hh"
#include "systemc/ext/core/sc_module.hh" // for sc_gen_unique_name
+#include "systemc/ext/utils/sc_report_handler.hh"
namespace sc_core
{
sc_semaphore::sc_semaphore(int value) :
- sc_interface(), sc_semaphore_if(),
- sc_object(sc_gen_unique_name("semaphore")), _value(value)
+ sc_semaphore(sc_gen_unique_name("semaphore"), value)
{}
-sc_semaphore::sc_semaphore(const char *name, int value) :
- sc_interface(), sc_semaphore_if(), sc_object(name), _value(value)
-{}
+sc_semaphore::sc_semaphore(const char *_name, int value) :
+ sc_interface(), sc_semaphore_if(), sc_object(_name), _value(value)
+{
+ if (value < 0) {
+ std::string msg = "semaphore '" + std::string(name()) + "'";
+ SC_REPORT_ERROR("(E119) sc_semaphore requires an initial value >= 0",
+ msg.c_str());
+ }
+}
int
sc_semaphore::wait()