text: 
  #include <stdlib.h>
  #include "SmuTypes.h"
  #include "kcg_types.h"
  #include "counter3_type.h"
  #include "counter3_mapping.h"
  
  extern ScSimulator * pSimulator;
  
  /****************************************************************
   ** Boolean entity activation
   ****************************************************************/
  int _SCSIM_BoolEntity_is_active(void* pValue) {
  	return *((kcg_bool*)pValue) == kcg_true ? 1 : 0;
  }
  
  /****************************************************************
   ** kcg_real
   ****************************************************************/
  struct SimTypeVTable* pSimDoubleVTable;
  const char * kcg_real_to_string(const void* pValue) {
  	if (pSimDoubleVTable != 0 && pSimDoubleVTable->m_pfnGetConvInfo(SptString, SptNone) == 1)
  		return *(char**)pSimDoubleVTable->m_pfnToType(SptString, pValue);
  	return pSimulator->m_pfnRealToString((double)(*(const kcg_real*)pValue));
  }
  
  int string_to_kcg_real(const char* strValue, void* pValue) {
  	double nTemp = 0;
  	kcg_real rTemp;
  	int nResult;
  	if (pSimDoubleVTable != 0 && pSimDoubleVTable->m_pfnGetConvInfo(SptNone, SptString) == 1) {
  		nResult = pSimDoubleVTable->m_pfnFromType(SptString, (const void*)&strValue, &rTemp);
  		if (nResult == 1)
  			*(kcg_real*)pValue = rTemp;
  		return nResult;
  	}
  	nResult = pSimulator->m_pfnStringToReal(strValue, &nTemp);
  	if (nResult == 1)
  		*(kcg_real*)pValue = (kcg_real)nTemp;
  	return nResult;
  }
  
  int compare_kcg_real_type(int* pResult, const char* toCompare, const void* pValue) {
  	kcg_real rTemp;
  	const kcg_real* pCurrent = (const kcg_real*)pValue;
  	if (string_to_kcg_real(toCompare, &rTemp) == 0)
  		return 0;
  	if (*pCurrent > rTemp)
  		*pResult = 1;
  	else if (*pCurrent < rTemp)
  		*pResult = -1;
  	else
  		*pResult = 0;
  	return 1;
  }
  
  int is_kcg_real_allow_double_convertion() {
  	if (pSimDoubleVTable != 0) {
  		int nConvertionAllowed = 0;
  		nConvertionAllowed |= pSimDoubleVTable->m_pfnGetConvInfo(SptNone, SptLong) == 1;
  		nConvertionAllowed |= pSimDoubleVTable->m_pfnGetConvInfo(SptNone, SptShort) == 1;
  		nConvertionAllowed |= pSimDoubleVTable->m_pfnGetConvInfo(SptNone, SptDouble) == 1;
  		nConvertionAllowed |= pSimDoubleVTable->m_pfnGetConvInfo(SptNone, SptFloat) == 1;
  		return nConvertionAllowed;
  	}
  	return 1;
  }
  
  int kcg_real_to_double(double * nValue, const void* pValue) {
  	if (pSimDoubleVTable != 0) {
  		if (pSimDoubleVTable->m_pfnGetConvInfo(SptNone, SptLong) == 1)
  			*nValue = (double)(*(long*)pSimDoubleVTable->m_pfnToType(SptLong, pValue));
  		else if (pSimDoubleVTable->m_pfnGetConvInfo(SptNone, SptShort) == 1)
  			*nValue = (double)(*(int*)pSimDoubleVTable->m_pfnToType(SptShort, pValue));
  		else if (pSimDoubleVTable->m_pfnGetConvInfo(SptNone, SptDouble) == 1)
  			*nValue = (*(double*)pSimDoubleVTable->m_pfnToType(SptDouble, pValue));
  		else if (pSimDoubleVTable->m_pfnGetConvInfo(SptNone, SptFloat) == 1)
  			*nValue = (double)(*(float*)pSimDoubleVTable->m_pfnToType(SptFloat, pValue));
  		else
  			return 0;
  		return 1;
  	}
  	*nValue = (double)*((kcg_real*)pValue);
  	return 1;
  }
  
  const char * get_kcg_real_signature() {
  	return "R";
  }
  
  int check_kcg_real_string(const char* strValue) {
  	kcg_real rTemp;
  	return string_to_kcg_real(strValue, &rTemp);
  }
  
  
  /****************************************************************
   ** kcg_bool
   ****************************************************************/
  struct SimTypeVTable* pSimBoolVTable;
  const char * kcg_bool_to_string(const void* pValue) {
  	if (pSimBoolVTable != 0 && pSimBoolVTable->m_pfnGetConvInfo(SptString, SptNone) == 1)
  		return *(char**)pSimBoolVTable->m_pfnToType(SptString, pValue);
  	return pSimulator->m_pfnBoolToString((*(const kcg_bool*)pValue) == kcg_true ? 1 : 0);
  }
  
  int string_to_kcg_bool(const char* strValue, void* pValue) {
  	int nTemp = 0;
  	kcg_bool rTemp;
  	int nResult;
  	if (pSimBoolVTable != 0 && pSimBoolVTable->m_pfnGetConvInfo(SptNone, SptString) == 1) {
  		nResult = pSimBoolVTable->m_pfnFromType(SptString, (const void*)&strValue, &rTemp);
  		if (nResult == 1)
  			*(kcg_bool*)pValue = rTemp;
  		return nResult;
  	}
  	nResult = pSimulator->m_pfnStringToBool(strValue, &nTemp);
  	if (nResult == 1)
  		*(kcg_bool*)pValue = nTemp == 1 ? kcg_true : kcg_false;
  	return nResult;
  }
  
  int compare_kcg_bool_type(int* pResult, const char* toCompare, const void* pValue) {
  	kcg_bool rTemp;
  	const kcg_bool* pCurrent = (const kcg_bool*)pValue;
  	if (string_to_kcg_bool(toCompare, &rTemp) == 0)
  		return 0;
  	if (*pCurrent > rTemp)
  		*pResult = 1;
  	else if (*pCurrent < rTemp)
  		*pResult = -1;
  	else
  		*pResult = 0;
  	return 1;
  }
  
  int is_kcg_bool_allow_double_convertion() {
  	if (pSimBoolVTable != 0) {
  		int nConvertionAllowed = 0;
  		nConvertionAllowed |= pSimBoolVTable->m_pfnGetConvInfo(SptNone, SptLong) == 1;
  		nConvertionAllowed |= pSimBoolVTable->m_pfnGetConvInfo(SptNone, SptShort) == 1;
  		nConvertionAllowed |= pSimBoolVTable->m_pfnGetConvInfo(SptNone, SptDouble) == 1;
  		nConvertionAllowed |= pSimBoolVTable->m_pfnGetConvInfo(SptNone, SptFloat) == 1;
  		return nConvertionAllowed;
  	}
  	return 1;
  }
  
  int kcg_bool_to_double(double * nValue, const void* pValue) {
  	if (pSimBoolVTable != 0) {
  		if (pSimBoolVTable->m_pfnGetConvInfo(SptNone, SptLong) == 1)
  			*nValue = (double)(*(long*)pSimBoolVTable->m_pfnToType(SptLong, pValue));
  		else if (pSimBoolVTable->m_pfnGetConvInfo(SptNone, SptShort) == 1)
  			*nValue = (double)(*(int*)pSimBoolVTable->m_pfnToType(SptShort, pValue));
  		else if (pSimBoolVTable->m_pfnGetConvInfo(SptNone, SptDouble) == 1)
  			*nValue = (*(double*)pSimBoolVTable->m_pfnToType(SptDouble, pValue));
  		else if (pSimBoolVTable->m_pfnGetConvInfo(SptNone, SptFloat) == 1)
  			*nValue = (double)(*(float*)pSimBoolVTable->m_pfnToType(SptFloat, pValue));
  		else
  			return 0;
  		return 1;
  	}
  	*nValue = *((kcg_bool*)pValue) == kcg_true ? 1.0 : 0.0;
  	return 1;
  }
  
  const char * get_kcg_bool_signature() {
  	return "B";
  }
  
  int check_kcg_bool_string(const char* strValue) {
  	kcg_bool rTemp;
  	return string_to_kcg_bool(strValue, &rTemp);
  }
  
  
  /****************************************************************
   ** kcg_char
   ****************************************************************/
  struct SimTypeVTable* pSimCharVTable;
  const char * kcg_char_to_string(const void* pValue) {
  	if (pSimCharVTable != 0 && pSimCharVTable->m_pfnGetConvInfo(SptString, SptNone) == 1)
  		return *(char**)pSimCharVTable->m_pfnToType(SptString, pValue);
  	return pSimulator->m_pfnCharToString((char)(*(const kcg_char*)pValue));
  }
  
  int string_to_kcg_char(const char* strValue, void* pValue) {
  	char nTemp = 0;
  	kcg_char rTemp;
  	int nResult;
  	if (pSimCharVTable != 0 && pSimCharVTable->m_pfnGetConvInfo(SptNone, SptString) == 1) {
  		nResult = pSimCharVTable->m_pfnFromType(SptString, (const void*)&strValue, &rTemp);
  		if (nResult == 1)
  			*(kcg_char*)pValue = rTemp;
  		return nResult;
  	}
  	nResult = pSimulator->m_pfnStringToChar(strValue, &nTemp);
  		if (nResult == 1)
  	*(kcg_char*)pValue = (kcg_char)nTemp;
  	return nResult;
  }
  
  int compare_kcg_char_type(int* pResult, const char* toCompare, const void* pValue) {
  	kcg_char rTemp;
  	const kcg_char* pCurrent = (const kcg_char*)pValue;
  	if (string_to_kcg_char(toCompare, &rTemp) == 0)
  		return 0;
  	if (*pCurrent > rTemp)
  		*pResult = 1;
  	else if (*pCurrent < rTemp)
  		*pResult = -1;
  	else
  		*pResult = 0;
  	return 1;
  }
  
  int is_kcg_char_allow_double_convertion() {
  	if (pSimCharVTable != 0) {
  		int nConvertionAllowed = 0;
  		nConvertionAllowed |= pSimCharVTable->m_pfnGetConvInfo(SptNone, SptLong) == 1;
  		nConvertionAllowed |= pSimCharVTable->m_pfnGetConvInfo(SptNone, SptShort) == 1;
  		nConvertionAllowed |= pSimCharVTable->m_pfnGetConvInfo(SptNone, SptDouble) == 1;
  		nConvertionAllowed |= pSimCharVTable->m_pfnGetConvInfo(SptNone, SptFloat) == 1;
  		return nConvertionAllowed;
  	}
  	return 1;
  }
  
  int kcg_char_to_double(double * nValue, const void* pValue) {
  	if (pSimCharVTable != 0) {
  		if (pSimCharVTable->m_pfnGetConvInfo(SptNone, SptLong) == 1)
  			*nValue = (double)(*(long*)pSimCharVTable->m_pfnToType(SptLong, pValue));
  		else if (pSimCharVTable->m_pfnGetConvInfo(SptNone, SptShort) == 1)
  			*nValue = (double)(*(int*)pSimCharVTable->m_pfnToType(SptShort, pValue));
  		else if (pSimCharVTable->m_pfnGetConvInfo(SptNone, SptDouble) == 1)
  			*nValue = (*(double*)pSimCharVTable->m_pfnToType(SptDouble, pValue));
  		else if (pSimCharVTable->m_pfnGetConvInfo(SptNone, SptFloat) == 1)
  			*nValue = (double)(*(float*)pSimCharVTable->m_pfnToType(SptFloat, pValue));
  		else
  			return 0;
  		return 1;
  	}
  	*nValue = (double)*((kcg_char*)pValue);
  	return 1;
  }
  
  const char * get_kcg_char_signature() {
  	return "C";
  }
  
  int check_kcg_char_string(const char* strValue) {
  	kcg_char rTemp;
  	return string_to_kcg_char(strValue, &rTemp);
  }
  
  
  /****************************************************************
   ** kcg_int
   ****************************************************************/
  struct SimTypeVTable* pSimLongVTable;
  const char * kcg_int_to_string(const void* pValue) {
  	if (pSimLongVTable != 0 && pSimLongVTable->m_pfnGetConvInfo(SptString, SptNone) == 1)
  		return *(char**)pSimLongVTable->m_pfnToType(SptString, pValue);
  	return pSimulator->m_pfnIntToString(*(const int*)pValue);
  }
  
  int string_to_kcg_int(const char* strValue, void* pValue) {
  	int nTemp = 0;
  	kcg_int rTemp;
  	int nResult;
  	if (pSimLongVTable != 0 && pSimLongVTable->m_pfnGetConvInfo(SptNone, SptString) == 1) {
  		nResult = pSimLongVTable->m_pfnFromType(SptString, (const void*)&strValue, &rTemp);
  		if (nResult == 1)
  			*(kcg_int*)pValue = rTemp;
  		return nResult;
  	}
  	nResult = pSimulator->m_pfnStringToInt(strValue, &nTemp);
  	if (nResult == 1)
  		*(kcg_int*)pValue = (kcg_int)nTemp;
  	return nResult;
  }
  
  int compare_kcg_int_type(int* pResult, const char* toCompare, const void* pValue) {
  	kcg_int rTemp;
  	const kcg_int* pCurrent = (const kcg_int*)pValue;
  	if (string_to_kcg_int(toCompare, &rTemp) == 0)
  		return 0;
  	if (*pCurrent > rTemp)
  		*pResult = 1;
  	else if (*pCurrent < rTemp)
  		*pResult = -1;
  	else
  		*pResult = 0;
  	return 1;
  }
  
  int is_kcg_int_allow_double_convertion() {
  	if (pSimLongVTable != 0) {
  		int nConvertionAllowed = 0;
  		nConvertionAllowed |= pSimLongVTable->m_pfnGetConvInfo(SptNone, SptLong) == 1;
  		nConvertionAllowed |= pSimLongVTable->m_pfnGetConvInfo(SptNone, SptShort) == 1;
  		nConvertionAllowed |= pSimLongVTable->m_pfnGetConvInfo(SptNone, SptDouble) == 1;
  		nConvertionAllowed |= pSimLongVTable->m_pfnGetConvInfo(SptNone, SptFloat) == 1;
  		return nConvertionAllowed;
  	}
  	return 1;
  }
  
  int kcg_int_to_double(double * nValue, const void* pValue) {
  	if (pSimLongVTable != 0) {
  		if (pSimLongVTable->m_pfnGetConvInfo(SptNone, SptLong) == 1)
  			*nValue = (double)(*(long*)pSimLongVTable->m_pfnToType(SptLong, pValue));
  		else if (pSimLongVTable->m_pfnGetConvInfo(SptNone, SptShort) == 1)
  			*nValue = (double)(*(int*)pSimLongVTable->m_pfnToType(SptShort, pValue));
  		else if (pSimLongVTable->m_pfnGetConvInfo(SptNone, SptDouble) == 1)
  			*nValue = (*(double*)pSimLongVTable->m_pfnToType(SptDouble, pValue));
  		else if (pSimLongVTable->m_pfnGetConvInfo(SptNone, SptFloat) == 1)
  			*nValue = (double)(*(float*)pSimLongVTable->m_pfnToType(SptFloat, pValue));
  		else
  			return 0;
  		return 1;
  	}
  	*nValue = (double)*((kcg_int*)pValue);
  	return 1;
  }
  
  const char * get_kcg_int_signature() {
  	return "I";
  }
  
  int check_kcg_int_string(const char* strValue) {
  	kcg_int rTemp;
  	return string_to_kcg_int(strValue, &rTemp);
  }
  
  
  