diff --git a/vvp/compile.cc b/vvp/compile.cc index ed3ec4a4d..71ba609e0 100644 --- a/vvp/compile.cc +++ b/vvp/compile.cc @@ -1131,17 +1131,20 @@ struct __vpiModPath* compile_modpath(char*label, struct symb_s drv, define_functor_symbol(label, net); - vpiHandle tmp = vpip_make_modpath(label, drv.text, net); - __vpiModPath*modpath = vpip_modpath_from_handle(tmp); + __vpiModPath*modpath = vpip_make_modpath(net); compile_vpi_lookup(&modpath->path_term_out.expr, dest.text); + free(label); + modpath->modpath = obj; return modpath; } -static vvp_net_t*make_modpath_src(struct __vpiModPath*path, char edge, - struct symb_s src, struct numbv_s vals) +static struct __vpiModPathSrc*make_modpath_src(struct __vpiModPath*path, + char edge, + struct symb_s src, + struct numbv_s vals) { vvp_fun_modpath*dst = path->modpath; @@ -1188,29 +1191,36 @@ static vvp_net_t*make_modpath_src(struct __vpiModPath*path, char edge, Compiling the delays values into actual modpath vpiHandle */ //vpip_add_mopdath_delay ( vpiobj, src.text, use_delay ) ; - vpiHandle srcobj = vpip_make_modpath_src ( src.text, use_delay, net ) ; - vpip_add_modpath_src (vpi_handle(path), srcobj); + struct __vpiModPathSrc* srcobj = vpip_make_modpath_src (path, use_delay, net) ; + vpip_attach_to_current_scope(vpi_handle(srcobj)); net->fun = obj; input_connect(net, 0, src.text); dst->add_modpath_src(obj); - return net; -} - -void compile_modpath_src(struct __vpiModPath*dst, char edge, - struct symb_s src, struct numbv_s vals) -{ - make_modpath_src(dst, edge, src, vals); + return srcobj; } void compile_modpath_src(struct __vpiModPath*dst, char edge, struct symb_s src, struct numbv_s vals, - struct symb_s condit_src) + struct symb_s condit_src, + struct symb_s path_term_in) { - vvp_net_t*net = make_modpath_src(dst, edge, src, vals); - input_connect(net, 1, condit_src.text); + struct __vpiModPathSrc*obj = make_modpath_src(dst, edge, src, vals); + input_connect(obj->net, 1, condit_src.text); + compile_vpi_lookup(&obj->path_term_in.expr, path_term_in.text); +} + +void compile_modpath_src(struct __vpiModPath*dst, char edge, + struct symb_s src, + struct numbv_s vals, + int condit_src, + struct symb_s path_term_in) +{ + assert(condit_src == 0); + struct __vpiModPathSrc*obj = make_modpath_src(dst, edge, src, vals); + compile_vpi_lookup(&obj->path_term_in.expr, path_term_in.text); } /* diff --git a/vvp/compile.h b/vvp/compile.h index 05b51aff8..1ead83ae1 100644 --- a/vvp/compile.h +++ b/vvp/compile.h @@ -181,12 +181,15 @@ extern __vpiModPath* compile_modpath(char*label, extern void compile_modpath_src(__vpiModPath*dst, char edge, struct symb_s input, - struct numbv_s d); + struct numbv_s d, + int condit_input, /* match with '0' */ + struct symb_s path_term_input); extern void compile_modpath_src(__vpiModPath*dst, char edge, struct symb_s input, struct numbv_s d, - struct symb_s condit_input); + struct symb_s condit_input, + struct symb_s path_term_input); extern void compile_reduce_and(char*label, struct symb_s arg); extern void compile_reduce_or(char*label, struct symb_s arg); diff --git a/vvp/delay.cc b/vvp/delay.cc index d89893338..43df5db21 100644 --- a/vvp/delay.cc +++ b/vvp/delay.cc @@ -497,42 +497,11 @@ bool vvp_fun_modpath_edge::test_vec4(const vvp_vector4_t&bit) */ static int modpath_src_get(int code, vpiHandle ref) { - assert((ref->vpi_type->type_code == vpiModPath)); + struct __vpiModPathSrc*obj = vpip_modpath_src_from_handle(ref); + assert(obj); return 0 ; } -/* - * This routine will return an modpathIn input port - * name for an modpath vpiHandle object - * - */ -static char* modpath_src_get_str(int code, vpiHandle ref) -{ - assert((ref->vpi_type->type_code == vpiModPathIn)); - struct __vpiModPathSrc *refp = (struct __vpiModPathSrc *)ref; - char *bn = strdup(vpi_get_str(vpiFullName, &refp->scope->base)); - - char *nm = (char *)refp->name ; - - char *rbuf = need_result_buf(strlen(bn) + strlen(nm) + 2, RBUF_STR); - - switch (code) - { - case vpiFullName: - sprintf(rbuf, "%s.%s", bn, nm); - free(bn); - return rbuf; - - case vpiName: - strcpy(rbuf, nm); - free(bn); - return rbuf; - } - - free(bn); - return 0; -} - static void modpath_src_get_value(vpiHandle ref, p_vpi_value vp) { assert((ref->vpi_type->type_code == vpiModPathIn)); @@ -551,24 +520,28 @@ static vpiHandle modpath_src_put_value(vpiHandle ref, s_vpi_value *vp ) static vpiHandle modpath_src_get_handle(int code, vpiHandle ref) { - assert( (ref->vpi_type->type_code==vpiModPathIn ) ); - struct __vpiModPathSrc *rfp = (struct __vpiModPathSrc *)ref ; - - switch (code) - { + struct __vpiModPathSrc*rfp = vpip_modpath_src_from_handle(ref); + assert(rfp); + + switch (code) { + case vpiScope: - return &rfp->scope->base ; - - case vpiModule: - { - struct __vpiScope*scope = rfp->scope; - while (scope && scope->base.vpi_type->type_code != vpiModule) - scope = scope->scope; - - assert(scope); - return &scope->base; - } - } + return vpi_handle(rfp->dest->scope); + + case vpiModule: + { struct __vpiScope*scope = rfp->dest->scope; + while (scope && scope->base.vpi_type->type_code != vpiModule) + scope = scope->scope; + assert(scope); + return vpi_handle(scope); + } + + case vpiModPathIn: + return vpi_handle(&rfp->path_term_in); + + case vpiModPathOut: + return vpi_handle(&rfp->dest->path_term_out); + } return 0; } @@ -586,7 +559,6 @@ static int modpath_src_free_object( vpiHandle ref ) return 1 ; } - /* * This Routine will put specific demension of delay[] values * into a vpiHandle. In this case, he will put an @@ -596,17 +568,15 @@ static int modpath_src_free_object( vpiHandle ref ) static void modpath_src_put_delays ( vpiHandle ref, p_vpi_delay delays ) { int i ; - assert((ref->vpi_type->type_code == vpiModPathIn)); - struct __vpiModPathSrc * src = vpip_modpath_src_from_handle( ref) ; - assert ( src ) ; - vvp_fun_modpath_src *fun = dynamic_cast(src->node->fun); + assert(src) ; + + vvp_fun_modpath_src *fun = dynamic_cast(src->net->fun); assert( fun ); - for ( i = 0 ; i < delays->no_of_delays ; i++) - { - fun->delay[i] = delays->da[ i ].real ; - } + for ( i = 0 ; i < delays->no_of_delays ; i++) { + fun->delay[i] = delays->da[ i ].real ; + } } /* @@ -620,183 +590,15 @@ static void modpath_src_put_delays ( vpiHandle ref, p_vpi_delay delays ) static void modpath_src_get_delays ( vpiHandle ref, p_vpi_delay delays ) { int i ; - assert(( ref->vpi_type->type_code == vpiModPathIn )); - struct __vpiModPathSrc * src = vpip_modpath_src_from_handle( ref) ; - assert ( src ) ; - vvp_fun_modpath_src *fun = dynamic_cast(src->node->fun); + assert(src); + + vvp_fun_modpath_src *fun = dynamic_cast(src->net->fun); assert( fun ); for ( i = 0 ; i < delays->no_of_delays ; i++) - delays->da[ i ].real = fun->delay[i]; + delays->da[ i ].real = fun->delay[i]; } -/* - This Struct will be used by the make_vpi_modpath_src ( ) - to initializa the vpiModPathIn vpiHandle type, and assign - method routines - - vpiModPathIn vpiHandle interanl operations : - - we have - - vpi_get == modpath_src_get (..) ; - vpi_get_str == modpath_src_get_str (..) ; - vpi_get_value == modpath_src_get_value (..) ; - vpi_put_value == modpath_src_put_value (..) ; - vpi_get_handle == modpath_src_get_handle (..) ; - vpi_iterate == modpath_src_iterate (..) ; - vpi_index == modpath_src_index ( .. ) ; - vpi_free_object == modpath_src_free_object ( .. ) ; - vpi_get_delay == modpath_src_get_delay (..) ; - vpi_put_delay == modpath_src_put_delay (..) ; - - -*/ - -static const struct __vpirt vpip_modpath_src = { - vpiModPathIn, - modpath_src_get, - modpath_src_get_str, - modpath_src_get_value, - modpath_src_put_value, - modpath_src_get_handle, - 0, /* modpath_src_iterate,*/ - modpath_src_index, - modpath_src_free_object, - modpath_src_get_delays, - modpath_src_put_delays -}; - -/* - * This function will Constructs a vpiModPathIn - * ( struct __vpiModPathSrc ) Object. will give - * a delays[12] values, and point to the specified functor - * - */ - -vpiHandle vpip_make_modpath_src ( char *name, vvp_time64_t use_delay[12] , vvp_net_t *net ) -{ - struct __vpiModPathSrc *obj = (struct __vpiModPathSrc *) calloc (1, sizeof ( struct __vpiModPathSrc ) ) ; - obj->base.vpi_type = &vpip_modpath_src; - obj->scope = vpip_peek_current_scope ( ); - obj->name = (char *)calloc(strlen(name) + 1 , sizeof ( char )) ; - strcpy ( obj->name, name ) ; - obj->node = net ; - vpip_attach_to_current_scope (&obj->base) ; - return &obj->base ; -} - - -/* - vpiModPath vpiHandle interanl operations : - - we have - - vpi_get == modpath_get (..) ; - vpi_get_str == modpath_get_str (..) ; - vpi_get_value == modpath_get_value (..) ; - vpi_put_value == modpath_put_value (..) ; - vpi_get_handle == modpath_get_handle (..) ; - vpi_iterate == modpath_iterate (..) ; - vpi_index == modpath_index ( .. ) ; - vpi_free_object == modpath_free_object ( .. ) ; - vpi_get_delay == modpath_get_delay (..) ; - vpi_put_delay == modpath_put_delay (..) ; - -*/ - -static int modpath_get(int code, vpiHandle ref) -{ - assert((ref->vpi_type->type_code == vpiModPath)); - - return 0 ; -} - -static char* modpath_get_str(int code, vpiHandle ref) -{ - assert((ref->vpi_type->type_code == vpiModPath)); - - struct __vpiModPath *refp = (struct __vpiModPath *)ref; - char *bn = strdup(vpi_get_str(vpiFullName, &refp->scope->base)); - char *nm = (char *)refp->name ; - char *rbuf = need_result_buf(strlen(bn) + strlen(nm) + 2, RBUF_STR); - - switch (code) - { - case vpiFullName: - sprintf(rbuf, "%s.%s", bn, nm); - free(bn); - return rbuf; - - case vpiName: - strcpy(rbuf, nm); - free(bn); - return rbuf; - } - - free(bn); - return 0; -} - -static void modpath_get_value(vpiHandle ref, p_vpi_value vp) -{ - assert((ref->vpi_type->type_code == vpiModPath)); - // struct __vpiModPath* modpath = vpip_modpath_from_handle( ref) ; - // assert ( modpath ) ; - return ; -} - -static vpiHandle modpath_put_value(vpiHandle ref, s_vpi_value *vp ) -{ - assert((ref->vpi_type->type_code == vpiModPath)); - // struct __vpiModPath* modpath = vpip_modpath_from_handle( ref) ; - // assert ( modpath ) ; - return 0 ; -} - -static vpiHandle modpath_get_handle(int code, vpiHandle ref) -{ - struct __vpiModPath *rfp = vpip_modpath_from_handle(ref); - assert(rfp); - - switch (code) { - case vpiScope: - return vpi_handle(rfp->scope); - - case vpiModule: - { struct __vpiScope*scope = rfp->scope; - while (scope && scope->base.vpi_type->type_code != vpiModule) - scope = scope->scope; - assert(scope); - return vpi_handle(scope); - } - - case vpiModPathOut: - return vpi_handle(&rfp->path_term_out); - } - return 0; -} - - -static vpiHandle modpath_iterate (int code , vpiHandle ref ) -{ - assert( (ref->vpi_type->type_code == vpiModPath) ); - return 0 ; -} - -static vpiHandle modpath_index ( vpiHandle ref, int code ) -{ - assert( (ref->vpi_type->type_code == vpiModPath) ); - return 0 ; -} - - -static int modpath_free_object( vpiHandle ref ) -{ - assert( (ref->vpi_type->type_code == vpiModPath) ); - free ( ref ) ; - return 1 ; -} static vpiHandle pathterm_get_handle(int code, vpiHandle ref) { @@ -811,24 +613,23 @@ static vpiHandle pathterm_get_handle(int code, vpiHandle ref) } } - /* - This Struct will be used by the make_vpi_modpath ( ) - to initializa the vpiModPath vpiHandle type, and assign - method routines +* The __vpiModPathSrc class is what the VPI client sees as a +* vpiModPath object. The __vpiModPath structure contains items that +* are common to a bunch of modpaths, including the destination term. */ -static const struct __vpirt vpip_modpath_rt = { - vpiModPath, - modpath_get, - modpath_get_str, - modpath_get_value, - modpath_put_value, - modpath_get_handle, - modpath_iterate, - modpath_index, - modpath_free_object, - 0, // modpath_get_delays, - 0 // modpath_put_delays +static const struct __vpirt vpip_modpath_src_rt = { + vpiModPath, + modpath_src_get, + 0, /* vpi_get_str */ + modpath_src_get_value, + modpath_src_put_value, + modpath_src_get_handle, + 0, /* modpath_src_iterate,*/ + modpath_src_index, + modpath_src_free_object, + modpath_src_get_delays, + modpath_src_put_delays }; static const struct __vpirt vpip_modpath_term_rt = { @@ -857,25 +658,35 @@ static void initialize_path_term(struct __vpiModPathTerm&obj) * respective functor */ -vpiHandle vpip_make_modpath ( char *name, char *input, vvp_net_t *net ) +struct __vpiModPath* vpip_make_modpath(vvp_net_t *net) { - - struct __vpiModPath *obj = (struct __vpiModPath *) calloc (1, sizeof ( struct __vpiModPath ) ) ; - obj->base.vpi_type = &vpip_modpath_rt ; - obj->scope = vpip_peek_current_scope ( ); + struct __vpiModPath*obj = (struct __vpiModPath *)calloc(1, sizeof ( struct __vpiModPath ) ); + obj->scope = vpip_peek_current_scope ( ); initialize_path_term(obj->path_term_out); + obj->input_net = net ; - obj->name = (char *)calloc(strlen(name) + 1 , sizeof ( char )) ; - strcpy ( obj->name, name ) ; + return obj; +} - obj->input = (char *)calloc(strlen(input) + 1 , sizeof ( char )) ; - strcpy ( obj->input,input ) ; - fprintf(stderr, "XXXX: Add vpiModpath...\n"); - obj->input_net = net ; - vpip_attach_to_current_scope (&obj->base) ; - return &obj->base ; +/* + * This function will Constructs a vpiModPathIn + * ( struct __vpiModPathSrc ) Object. will give + * a delays[12] values, and point to the specified functor + * + */ + +struct __vpiModPathSrc* vpip_make_modpath_src (struct __vpiModPath*path, vvp_time64_t use_delay[12] , vvp_net_t *net ) +{ + struct __vpiModPathSrc *obj = (struct __vpiModPathSrc *) calloc (1, sizeof ( struct __vpiModPathSrc ) ) ; + + obj->base.vpi_type = &vpip_modpath_src_rt; + obj->dest = path; + obj->net = net; + initialize_path_term(obj->path_term_in); + + return obj; } @@ -884,14 +695,6 @@ vpiHandle vpip_make_modpath ( char *name, char *input, vvp_net_t *net ) to a struct __vpiModPath { } */ -struct __vpiModPath* vpip_modpath_from_handle(vpiHandle ref) -{ - if (ref->vpi_type->type_code != vpiModPath) - return 0; - - return (struct __vpiModPath *) ref; -} - struct __vpiModPathTerm* vpip_modpath_term_from_handle(vpiHandle ref) { if (ref->vpi_type->type_code != vpiPathTerm) @@ -908,7 +711,7 @@ struct __vpiModPathTerm* vpip_modpath_term_from_handle(vpiHandle ref) struct __vpiModPathSrc* vpip_modpath_src_from_handle(vpiHandle ref) { - if (ref->vpi_type->type_code != vpiModPathIn) + if (ref->vpi_type->type_code != vpiModPath) return 0; return (struct __vpiModPathSrc *) ref; @@ -925,13 +728,3 @@ void vpip_add_mopdath_edge ( vpiHandle vpiobj, char *label, } - - - -void vpip_add_modpath_src ( vpiHandle modpath, vpiHandle src ) -{ - assert( (src->vpi_type->type_code == vpiModPathIn )); - assert( (modpath->vpi_type->type_code == vpiModPath )); - - return ; -} diff --git a/vvp/parse.y b/vvp/parse.y index 022ebc8ae..1579b4fc6 100644 --- a/vvp/parse.y +++ b/vvp/parse.y @@ -775,19 +775,19 @@ modpath_src_list ; modpath_src - : symbol '(' numbers ')' - { compile_modpath_src(modpath_dst, 0, $1, $3); } - | symbol '(' numbers '?' symbol ')' - { compile_modpath_src(modpath_dst, 0, $1, $3, $5); } - | symbol '+' '(' numbers ')' - { compile_modpath_src(modpath_dst, '+', $1, $4); } - | symbol '+' '(' numbers '?' symbol ')' - { compile_modpath_src(modpath_dst, '+', $1, $4, $6); } - | symbol '-' '(' numbers ')' - { compile_modpath_src(modpath_dst, '-', $1, $4); } - | symbol '-' '(' numbers '?' symbol ')' - { compile_modpath_src(modpath_dst, '-', $1, $4, $6); } - ; + : symbol '(' numbers ')' symbol + { compile_modpath_src(modpath_dst, 0, $1, $3, 0, $5); } + | symbol '(' numbers '?' symbol ')' symbol + { compile_modpath_src(modpath_dst, 0, $1, $3, $5, $7); } + | symbol '+' '(' numbers ')' symbol + { compile_modpath_src(modpath_dst, '+', $1, $4, 0, $6); } + | symbol '+' '(' numbers '?' symbol ')' symbol + { compile_modpath_src(modpath_dst, '+', $1, $4, $6, $8); } + | symbol '-' '(' numbers ')' symbol + { compile_modpath_src(modpath_dst, '-', $1, $4, 0, $6); } + | symbol '-' '(' numbers '?' symbol ')' symbol + { compile_modpath_src(modpath_dst, '-', $1, $4, $6, $8); } + ; udp_table : T_STRING diff --git a/vvp/vpi_priv.h b/vvp/vpi_priv.h index 1dcb7f8e1..81c964395 100644 --- a/vvp/vpi_priv.h +++ b/vvp/vpi_priv.h @@ -218,18 +218,19 @@ extern vpiHandle vpip_make_net(const char*name, int msb, int lsb, extern __vpiSignal* vpip_signal_from_handle(vpiHandle obj); +struct __vpiModPathTerm { + struct __vpiHandle base; + vpiHandle expr; +}; + struct __vpiModPathSrc { - struct __vpiHandle base ; - struct __vpiScope *scope ; - int type ; - char *label ; /* - Must Be removed in Future - because the ModPathSrc have - no label - */ - char *name ; - struct __vpiModPathSrc *next ; - + struct __vpiHandle base; + struct __vpiModPath *dest; + int type; + + /* This is the input expression for this modpath. */ + struct __vpiModPathTerm path_term_in; + /* Just Temporary */ vvp_time64_t use_delay [12] ; /* @@ -243,21 +244,13 @@ struct __vpiModPathSrc { */ p_vpi_delay delays ; - /* - The Posedge, Negedge are already defined - in the "delays->p_vpi_time(da)->high/low" - - bool posedge, negedge ; - */ - vvp_net_t *node; + /* This is the input net for the modpath. signals on this net + are used to determine the modpath. They are *not* propagated + anywhere. */ + vvp_net_t *net; } ; -struct __vpiModPathTerm { - struct __vpiHandle base; - vpiHandle expr; -}; - /* * * The vpiMoaPath vpiHandle will define @@ -267,35 +260,14 @@ struct __vpiModPathTerm { */ struct __vpiModPath { - struct __vpiHandle base ; struct __vpiScope *scope ; class vvp_fun_modpath*modpath; struct __vpiModPathTerm path_term_out; - - /* - * The name, input must be removed - * in future um ModPathSrc have no - * name. - */ - char *name ; - char *input ; vvp_net_t *input_net ; - struct __vpiModPathSrc *src_list ; - /* - * Keep an array of internal modpath_src - * vpiHandle - */ - struct __vpiHandle **src ; - /* - * Registering the number of modpath_src - * number - */ - unsigned int src_no ; }; -extern struct __vpiModPath* vpip_modpath_from_handle(vpiHandle ref); extern struct __vpiModPathTerm* vpip_modpath_term_from_handle(vpiHandle ref); extern struct __vpiModPathSrc* vpip_modpath_src_from_handle(vpiHandle ref); @@ -305,13 +277,11 @@ extern struct __vpiModPathSrc* vpip_modpath_src_from_handle(vpiHandle ref); * for vpiModPath && vpiModPathIn objects */ -extern vpiHandle vpip_make_modpath_src ( char *name, - vvp_time64_t use_delay[12] , - vvp_net_t *net ) ; +extern struct __vpiModPathSrc* vpip_make_modpath_src (struct __vpiModPath*path_dest, + vvp_time64_t use_delay[12] , + vvp_net_t *net ) ; -extern vpiHandle vpip_make_modpath ( char *name, - char *input, - vvp_net_t *net ) ; +extern struct __vpiModPath* vpip_make_modpath(vvp_net_t *net) ; extern void vpip_add_mopdath_delay ( vpiHandle vpiobj, char *label, @@ -323,15 +293,6 @@ extern void vpip_add_mopdath_edge ( vpiHandle vpiobj, bool posedge , bool negedge ) ; -extern void vpip_add_modpath_src ( vpiHandle modpath, - vpiHandle src ) ; - -extern __vpiModPath* vpip_modpath_from_handle ( vpiHandle obj); - -extern __vpiModPathSrc* vpip_modpath_src_from_handle( vpiHandle obj); - - - /* * These methods support the vpi creation of events. The name string