#include <vpi_user.h>
#include <string.h>

static int outcnt = 0;

static int simu_compiletf(char*user_data)
{
return 0;
}

static int simu_calltf(char*user_data)
{

vpiHandle tos = vpi_handle_by_name ( "cpu_tb.UUT.tos", NULL);
vpiHandle ir = vpi_handle_by_name ( "cpu_tb.UUT.ir", NULL);

s_vpi_value value_s = {vpiHexStrVal};
p_vpi_value value_p = &value_s;

char tosval[40];
char irval[40];

vpi_get_value ( tos, value_p );
strcpy ( tosval, value_p->value.str );

vpi_get_value ( ir, value_p );
strcpy ( irval, value_p->value.str );

if (strncmp (irval, "ff3c", 4) == 0) {
	vpi_printf("++ print %d: tos = %s\n", outcnt++, tosval);
}

return 0;
}

void simu_register()
{
s_vpi_systf_data tf_data;

tf_data.type      = vpiSysTask;
tf_data.tfname    = "$simu";
tf_data.calltf    = simu_calltf;
tf_data.compiletf = simu_compiletf;
tf_data.sizetf    = 0;
tf_data.user_data = 0;
vpi_register_systf(&tf_data);
}

void (*vlog_startup_routines[])() = {
    simu_register,
    0
};
