| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| #include "gpi_priv.h" |
|
|
| const char *GpiObjHdl::get_name_str() { return m_name.c_str(); } |
|
|
| const char *GpiObjHdl::get_fullname_str() { return m_fullname.c_str(); } |
|
|
| const std::string &GpiObjHdl::get_fullname() { return m_fullname; } |
|
|
| const char *GpiObjHdl::get_type_str() { |
| #define CASE_OPTION(_X) \ |
| case _X: \ |
| ret = #_X; \ |
| break |
|
|
| const char *ret; |
|
|
| switch (m_type) { |
| CASE_OPTION(GPI_UNKNOWN); |
| CASE_OPTION(GPI_MEMORY); |
| CASE_OPTION(GPI_MODULE); |
| CASE_OPTION(GPI_NET); |
| |
| CASE_OPTION(GPI_REGISTER); |
| CASE_OPTION(GPI_ARRAY); |
| CASE_OPTION(GPI_ENUM); |
| CASE_OPTION(GPI_STRUCTURE); |
| CASE_OPTION(GPI_REAL); |
| CASE_OPTION(GPI_INTEGER); |
| CASE_OPTION(GPI_STRING); |
| CASE_OPTION(GPI_GENARRAY); |
| CASE_OPTION(GPI_PACKAGE); |
| default: |
| ret = "unknown"; |
| } |
|
|
| return ret; |
| } |
|
|
| const std::string &GpiObjHdl::get_name() { return m_name; } |
|
|
| |
| bool GpiHdl::is_this_impl(GpiImplInterface *impl) { |
| return impl == this->m_impl; |
| } |
|
|
| int GpiObjHdl::initialise(const std::string &name, const std::string &fq_name) { |
| m_name = name; |
| m_fullname = fq_name; |
| return 0; |
| } |
|
|
| void GpiCbHdl::set_call_state(gpi_cb_state_e new_state) { m_state = new_state; } |
|
|
| gpi_cb_state_e GpiCbHdl::get_call_state() { return m_state; } |
|
|
| GpiCbHdl::~GpiCbHdl() {} |
|
|
| int GpiCommonCbHdl::run_callback() { |
| this->gpi_function(m_cb_data); |
| return 0; |
| } |
|
|
| int GpiCommonCbHdl::set_user_data(int (*gpi_function)(void *), void *data) { |
| if (!gpi_function) { |
| LOG_ERROR("gpi_function to set_user_data is NULL"); |
| } |
| this->gpi_function = gpi_function; |
| this->m_cb_data = data; |
| return 0; |
| } |
|
|
| GpiValueCbHdl::GpiValueCbHdl(GpiImplInterface *impl, GpiSignalObjHdl *signal, |
| int edge) |
| : GpiCbHdl(impl), GpiCommonCbHdl(impl), m_signal(signal) { |
| if (edge == (GPI_RISING | GPI_FALLING)) |
| required_value = "X"; |
| else if (edge & GPI_RISING) |
| required_value = "1"; |
| else if (edge & GPI_FALLING) |
| required_value = "0"; |
| } |
|
|
| int GpiValueCbHdl::run_callback() { |
| std::string current_value; |
| bool pass = false; |
|
|
| if (required_value == "X") |
| pass = true; |
| else { |
| current_value = m_signal->get_signal_value_binstr(); |
| if (current_value == required_value) pass = true; |
| } |
|
|
| if (pass) { |
| this->gpi_function(m_cb_data); |
| } else { |
| cleanup_callback(); |
| arm_callback(); |
| } |
|
|
| return 0; |
| } |
|
|