vvp: Code cleaning (vpi_tasks).
This commit is contained in:
parent
df6b24fd3a
commit
517c9785e8
160
vvp/vpi_tasks.cc
160
vvp/vpi_tasks.cc
|
|
@ -143,54 +143,25 @@ static vpiHandle systask_iter(int, vpiHandle ref)
|
|||
}
|
||||
|
||||
struct systask_def : public __vpiSysTaskCall {
|
||||
inline systask_def() { }
|
||||
int get_type_code(void) const { return vpiSysTaskCall; }
|
||||
int vpi_get(int code) { return systask_get(code, this); }
|
||||
char*vpi_get_str(int code) { return systask_get_str(code, this); }
|
||||
vpiHandle vpi_handle(int code) { return systask_handle(code, this); }
|
||||
vpiHandle vpi_iterate(int code){ return systask_iter(code, this); }
|
||||
virtual ~systask_def() {};
|
||||
virtual int get_type_code(void) const { return vpiSysTaskCall; }
|
||||
virtual int vpi_get(int code) { return systask_get(code, this); }
|
||||
virtual char*vpi_get_str(int code) { return systask_get_str(code, this); }
|
||||
virtual vpiHandle vpi_handle(int code) { return systask_handle(code, this); }
|
||||
virtual vpiHandle vpi_iterate(int code){ return systask_iter(code, this); }
|
||||
};
|
||||
|
||||
static vpiHandle sysfunc_put_rnet_value(vpiHandle ref, p_vpi_value vp, int)
|
||||
{
|
||||
struct __vpiSysTaskCall*rfp = dynamic_cast<__vpiSysTaskCall*>(ref);
|
||||
struct sysfunc_def : public systask_def {
|
||||
virtual ~sysfunc_def() {};
|
||||
virtual int get_type_code(void) const { return vpiSysFuncCall; }
|
||||
virtual int vpi_get(int code) { return sysfunc_get(code, this); }
|
||||
};
|
||||
|
||||
rfp->put_value = true;
|
||||
|
||||
double val;
|
||||
switch (vp->format) {
|
||||
|
||||
case vpiRealVal:
|
||||
val = vp->value.real;
|
||||
break;
|
||||
|
||||
default:
|
||||
val = 0.0;
|
||||
fprintf(stderr, "Unsupported format %d.\n", (int)vp->format);
|
||||
assert(0);
|
||||
}
|
||||
|
||||
rfp->fnet->send_real(val, vthread_get_wt_context());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static vpiHandle sysfunc_put_no_value(vpiHandle, p_vpi_value, int)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct sysfunc_real : public __vpiSysTaskCall {
|
||||
inline sysfunc_real() { }
|
||||
int get_type_code(void) const { return vpiSysFuncCall; }
|
||||
int vpi_get(int code) { return sysfunc_get(code, this); }
|
||||
char* vpi_get_str(int code) { return systask_get_str(code, this); }
|
||||
struct sysfunc_real : public sysfunc_def {
|
||||
vpiHandle vpi_put_value(p_vpi_value val, int flags);
|
||||
vpiHandle vpi_handle(int code)
|
||||
{ return systask_handle(code, this); }
|
||||
vpiHandle vpi_iterate(int code)
|
||||
{ return systask_iter(code, this); }
|
||||
inline double return_value() const { return return_value_; }
|
||||
|
||||
private:
|
||||
double return_value_;
|
||||
};
|
||||
|
||||
|
|
@ -211,19 +182,16 @@ vpiHandle sysfunc_real::vpi_put_value(p_vpi_value vp, int)
|
|||
return 0;
|
||||
}
|
||||
|
||||
struct sysfunc_string : public __vpiSysTaskCall {
|
||||
inline sysfunc_string() { }
|
||||
int get_type_code(void) const { return vpiSysFuncCall; }
|
||||
struct sysfunc_str : public sysfunc_def {
|
||||
int vpi_get(int code);
|
||||
char* vpi_get_str(int code) { return systask_get_str(code, this); }
|
||||
vpiHandle vpi_put_value(p_vpi_value val, int flags);
|
||||
vpiHandle vpi_handle(int code) { return systask_handle(code, this); }
|
||||
vpiHandle vpi_iterate(int code) { return systask_iter(code, this); }
|
||||
inline const std::string& return_value() const { return return_value_; };
|
||||
|
||||
private:
|
||||
std::string return_value_;
|
||||
};
|
||||
|
||||
int sysfunc_string::vpi_get(int code)
|
||||
int sysfunc_str::vpi_get(int code)
|
||||
{
|
||||
switch (code) {
|
||||
case vpiSize:
|
||||
|
|
@ -240,7 +208,7 @@ int sysfunc_string::vpi_get(int code)
|
|||
}
|
||||
}
|
||||
|
||||
vpiHandle sysfunc_string::vpi_put_value(p_vpi_value vp, int)
|
||||
vpiHandle sysfunc_str::vpi_put_value(p_vpi_value vp, int)
|
||||
{
|
||||
put_value = true;
|
||||
|
||||
|
|
@ -256,18 +224,11 @@ vpiHandle sysfunc_string::vpi_put_value(p_vpi_value vp, int)
|
|||
return 0;
|
||||
}
|
||||
|
||||
class sysfunc_vec4 : public __vpiSysTaskCall {
|
||||
class sysfunc_vec4 : public sysfunc_def {
|
||||
public:
|
||||
explicit inline sysfunc_vec4(unsigned wid): return_value_(wid, BIT4_X) { }
|
||||
int get_type_code(void) const { return vpiSysFuncCall; }
|
||||
int vpi_get(int code);
|
||||
char* vpi_get_str(int code) { return systask_get_str(code, this); }
|
||||
vpiHandle vpi_put_value(p_vpi_value val, int flags);
|
||||
vpiHandle vpi_handle(int code)
|
||||
{ return systask_handle(code, this); }
|
||||
vpiHandle vpi_iterate(int code)
|
||||
{ return systask_iter(code, this); }
|
||||
|
||||
inline const vvp_vector4_t& return_value() const { return return_value_; }
|
||||
|
||||
private:
|
||||
|
|
@ -277,7 +238,6 @@ class sysfunc_vec4 : public __vpiSysTaskCall {
|
|||
vpiHandle put_value_vector_(p_vpi_value vp);
|
||||
vpiHandle put_value_time_(p_vpi_value vp);
|
||||
|
||||
private:
|
||||
vvp_vector4_t return_value_;
|
||||
};
|
||||
|
||||
|
|
@ -433,48 +393,15 @@ vpiHandle sysfunc_vec4::vpi_put_value(p_vpi_value vp, int)
|
|||
return 0;
|
||||
}
|
||||
|
||||
struct sysfunc_4net : public __vpiSysTaskCall {
|
||||
struct sysfunc_4net : public sysfunc_def {
|
||||
explicit inline sysfunc_4net(unsigned wid) : vwid_(wid) { }
|
||||
int get_type_code(void) const { return vpiSysFuncCall; }
|
||||
int vpi_get(int code);
|
||||
char* vpi_get_str(int code) { return systask_get_str(code, this); }
|
||||
vpiHandle vpi_put_value(p_vpi_value val, int flags);
|
||||
vpiHandle vpi_handle(int code)
|
||||
{ return systask_handle(code, this); }
|
||||
vpiHandle vpi_iterate(int code)
|
||||
{ return systask_iter(code, this); }
|
||||
|
||||
private:
|
||||
unsigned vwid_;
|
||||
};
|
||||
|
||||
struct sysfunc_rnet : public __vpiSysTaskCall {
|
||||
inline sysfunc_rnet() { }
|
||||
int get_type_code(void) const { return vpiSysFuncCall; }
|
||||
int vpi_get(int code) { return sysfunc_get(code, this); }
|
||||
char* vpi_get_str(int code) { return systask_get_str(code, this); }
|
||||
vpiHandle vpi_put_value(p_vpi_value val, int flags)
|
||||
{ return sysfunc_put_rnet_value(this, val, flags); }
|
||||
vpiHandle vpi_handle(int code)
|
||||
{ return systask_handle(code, this); }
|
||||
vpiHandle vpi_iterate(int code)
|
||||
{ return systask_iter(code, this); }
|
||||
};
|
||||
|
||||
struct sysfunc_no : public __vpiSysTaskCall {
|
||||
inline sysfunc_no() { }
|
||||
int get_type_code(void) const { return vpiSysFuncCall; }
|
||||
int vpi_get(int code) { return sysfunc_get(code, this); }
|
||||
char* vpi_get_str(int code) { return systask_get_str(code, this); }
|
||||
vpiHandle vpi_put_value(p_vpi_value val, int flags)
|
||||
{ return sysfunc_put_no_value(this, val, flags); }
|
||||
vpiHandle vpi_handle(int code)
|
||||
{ return systask_handle(code, this); }
|
||||
vpiHandle vpi_iterate(int code)
|
||||
{ return systask_iter(code, this); }
|
||||
};
|
||||
|
||||
|
||||
// support getting vpiSize for a system function call
|
||||
int sysfunc_4net::vpi_get(int code)
|
||||
{
|
||||
|
|
@ -592,6 +519,41 @@ vpiHandle sysfunc_4net::vpi_put_value(p_vpi_value vp, int)
|
|||
return 0;
|
||||
}
|
||||
|
||||
struct sysfunc_rnet : public sysfunc_def {
|
||||
vpiHandle vpi_put_value(p_vpi_value val, int flags);
|
||||
};
|
||||
|
||||
vpiHandle sysfunc_rnet::vpi_put_value(p_vpi_value vp, int)
|
||||
{
|
||||
put_value = true;
|
||||
|
||||
double value;
|
||||
switch (vp->format) {
|
||||
|
||||
case vpiRealVal:
|
||||
value = vp->value.real;
|
||||
break;
|
||||
|
||||
default:
|
||||
value = 0.0;
|
||||
fprintf(stderr, "Unsupported format %d.\n", (int)vp->format);
|
||||
assert(0);
|
||||
}
|
||||
|
||||
fnet->send_real(value, vthread_get_wt_context());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct sysfunc_no : public sysfunc_def {
|
||||
vpiHandle vpi_put_value(p_vpi_value val, int flags);
|
||||
};
|
||||
|
||||
vpiHandle sysfunc_no::vpi_put_value(p_vpi_value, int)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* **** Manipulate the internal data structures. **** */
|
||||
|
||||
|
|
@ -891,7 +853,7 @@ vpiHandle vpip_build_vpi_call(const char*name, int val_code, unsigned return_wid
|
|||
obj = new sysfunc_vec4(return_width);
|
||||
|
||||
} else if (val_code == -vpiStringVal) {
|
||||
obj = new sysfunc_string;
|
||||
obj = new sysfunc_str;
|
||||
|
||||
} else if (val_code == 0 && fnet == 0) {
|
||||
obj = new sysfunc_no;
|
||||
|
|
@ -1008,12 +970,12 @@ void vpip_execute_vpi_call(vthread_t thr, vpiHandle ref)
|
|||
/* If the function returns a value, then push the value
|
||||
to the appropriate thread stack. */
|
||||
if (sysfunc_real*func_real = dynamic_cast<sysfunc_real*>(ref)) {
|
||||
vthread_push_real(thr, func_real->return_value_);
|
||||
vthread_push_real(thr, func_real->return_value());
|
||||
}
|
||||
if (sysfunc_string*func_string = dynamic_cast<sysfunc_string*>(ref)) {
|
||||
vthread_push_str(thr, func_string->return_value_);
|
||||
else if (sysfunc_str*func_string = dynamic_cast<sysfunc_str*>(ref)) {
|
||||
vthread_push_str(thr, func_string->return_value());
|
||||
}
|
||||
if (sysfunc_vec4*func_vec4 = dynamic_cast<sysfunc_vec4*>(ref)) {
|
||||
else if (sysfunc_vec4*func_vec4 = dynamic_cast<sysfunc_vec4*>(ref)) {
|
||||
vthread_push_vec4(thr, func_vec4->return_value());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue