vvp code generation for class methods in class scope.

This commit is contained in:
Stephen Williams 2013-03-22 20:07:08 -07:00
parent b1613e99e6
commit 3b3a4d3ddc
4 changed files with 19 additions and 7 deletions

View File

@ -55,6 +55,7 @@ EXTERN_C_START
#define vpiArrayVar vpiRegArray #define vpiArrayVar vpiRegArray
/********* TYPESPECS *************/ /********* TYPESPECS *************/
#define vpiClassTypespec 630
#define vpiEnumTypespec 633 #define vpiEnumTypespec 633
#define vpiEnumConst 634 #define vpiEnumConst 634

View File

@ -59,6 +59,12 @@ static void function_argument_bool(ivl_signal_t port, ivl_expr_t expr)
function_argument_logic(port, expr); function_argument_logic(port, expr);
} }
static void function_argument_class(ivl_signal_t port, ivl_expr_t expr)
{
draw_eval_object(expr);
fprintf(vvp_out, " %%store/obj v%p_0;\n", port);
}
static void draw_function_argument(ivl_signal_t port, ivl_expr_t expr) static void draw_function_argument(ivl_signal_t port, ivl_expr_t expr)
{ {
ivl_variable_type_t dtype = ivl_signal_data_type(port); ivl_variable_type_t dtype = ivl_signal_data_type(port);
@ -72,6 +78,9 @@ static void draw_function_argument(ivl_signal_t port, ivl_expr_t expr)
case IVL_VT_BOOL: case IVL_VT_BOOL:
function_argument_bool(port, expr); function_argument_bool(port, expr);
break; break;
case IVL_VT_CLASS:
function_argument_class(port, expr);
break;
default: default:
fprintf(stderr, "XXXX function argument %s type=%d?!\n", fprintf(stderr, "XXXX function argument %s type=%d?!\n",
ivl_signal_basename(port), dtype); ivl_signal_basename(port), dtype);

View File

@ -2138,12 +2138,6 @@ int draw_scope(ivl_scope_t net, ivl_scope_t parent)
const char*prefix = ivl_scope_is_auto(net) ? "auto" : ""; const char*prefix = ivl_scope_is_auto(net) ? "auto" : "";
/* XXXX Classes may have scopes, but we are not ready yet. for
now, ignore them as they are not needed. */
if (ivl_scope_type(net) == IVL_SCT_CLASS) {
return 0;
}
switch (ivl_scope_type(net)) { switch (ivl_scope_type(net)) {
case IVL_SCT_MODULE: type = "module"; break; case IVL_SCT_MODULE: type = "module"; break;
case IVL_SCT_FUNCTION: type = "function"; break; case IVL_SCT_FUNCTION: type = "function"; break;
@ -2152,6 +2146,7 @@ int draw_scope(ivl_scope_t net, ivl_scope_t parent)
case IVL_SCT_FORK: type = "fork"; break; case IVL_SCT_FORK: type = "fork"; break;
case IVL_SCT_GENERATE: type = "generate"; break; case IVL_SCT_GENERATE: type = "generate"; break;
case IVL_SCT_PACKAGE: type = "package"; break; case IVL_SCT_PACKAGE: type = "package"; break;
case IVL_SCT_CLASS: type = "class"; break;
default: type = "?"; assert(0); default: type = "?"; assert(0);
} }

View File

@ -371,6 +371,11 @@ struct vpiScopeFork : public __vpiScope {
int get_type_code(void) const { return vpiNamedFork; } int get_type_code(void) const { return vpiNamedFork; }
}; };
struct vpiScopeClass : public __vpiScope {
inline vpiScopeClass() { }
int get_type_code(void) const { return vpiClassTypespec; }
};
/* /*
* The current_scope is a compile time concept. As the vvp source is * The current_scope is a compile time concept. As the vvp source is
* compiled, items that have scope are placed in the current * compiled, items that have scope are placed in the current
@ -431,6 +436,8 @@ compile_scope_decl(char*label, char*type, char*name, char*tname,
scope = new vpiScopeBegin; scope = new vpiScopeBegin;
} else if (strcmp(base_type,"package") == 0) { } else if (strcmp(base_type,"package") == 0) {
scope = new vpiScopePackage; scope = new vpiScopePackage;
} else if (strcmp(base_type,"class") == 0) {
scope = new vpiScopeClass;
} else { } else {
scope = new vpiScopeModule; scope = new vpiScopeModule;
assert(0); assert(0);