diff --git a/vpi/sys_deposit.c b/vpi/sys_deposit.c index 7233a266c..a17f54737 100644 --- a/vpi/sys_deposit.c +++ b/vpi/sys_deposit.c @@ -48,6 +48,8 @@ static PLI_INT32 sys_deposit_compiletf(PLI_BYTE8 *name) return 0; } + assert(target); + /* Check the targets type. It must be a net or a register. */ switch (vpi_get(vpiType, target)) { case vpiNet: @@ -66,6 +68,8 @@ static PLI_INT32 sys_deposit_compiletf(PLI_BYTE8 *name) vpi_control(vpiFinish, 1); return 0; } + + return 0; } static PLI_INT32 sys_deposit_calltf(PLI_BYTE8 *name) @@ -76,7 +80,9 @@ static PLI_INT32 sys_deposit_calltf(PLI_BYTE8 *name) callh = vpi_handle(vpiSysTfCall, 0); argv = vpi_iterate(vpiArgument, callh); target = vpi_scan(argv); + assert(target); value = vpi_scan(argv); + assert(value); val.format = vpiIntVal; vpi_get_value(value, &val); diff --git a/vvp/compile.cc b/vvp/compile.cc index 508e2d14a..8a0b8f900 100644 --- a/vvp/compile.cc +++ b/vvp/compile.cc @@ -36,6 +36,7 @@ # include #endif # include +# include # include # include # include @@ -608,6 +609,16 @@ static void compile_array_lookup(struct vvp_code_s*code, char*label) resolv_submit(res); } +static list scheduled_compiletf; + +void compile_compiletf(struct __vpiSysTaskCall*obj) +{ + if (obj->defn->info.compiletf == 0) + return; + + scheduled_compiletf.push_back(obj); +} + /* * When parsing is otherwise complete, this function is called to do * the final stuff. Clean up deferred linking here. @@ -667,6 +678,24 @@ void compile_cleanup(void) delete_symbol_table(sym_functors); sym_functors = 0; + + if (verbose_flag) { + fprintf(stderr, " ... Compiletf functions\n"); + fflush(stderr); + } + + assert(vpi_mode_flag == VPI_MODE_NONE); + vpi_mode_flag = VPI_MODE_COMPILETF; + + while (! scheduled_compiletf.empty()) { + struct __vpiSysTaskCall*obj = scheduled_compiletf.front(); + scheduled_compiletf.pop_front(); + vpip_cur_task = obj; + obj->defn->info.compiletf (obj->defn->info.user_data); + vpip_cur_task = 0; + } + + vpi_mode_flag = VPI_MODE_NONE; } void compile_vpi_symbol(const char*label, vpiHandle obj) diff --git a/vvp/compile.h b/vvp/compile.h index c5aaab4de..88dbbe992 100644 --- a/vvp/compile.h +++ b/vvp/compile.h @@ -114,6 +114,12 @@ extern void compile_concat(char*label, unsigned w0, unsigned w1, unsigned w2, unsigned w3, unsigned argc, struct symb_s*argv); +/* + * Arrange for the system task/function call to have its compiletf + * function called. + */ +extern void compile_compiletf(struct __vpiSysTaskCall*); + /* * Compile delay nodes of various form. */ @@ -378,120 +384,4 @@ extern void compile_alias_real(char*label, char*name, int msb, int lsb, unsigned argc, struct symb_s*argv); -/* - * $Log: compile.h,v $ - * Revision 1.88 2007/04/10 01:26:16 steve - * variable arrays generated without writing a record for each word. - * - * Revision 1.87 2007/03/02 06:13:22 steve - * Add support for edge sensitive spec paths. - * - * Revision 1.86 2007/03/01 06:19:39 steve - * Add support for conditional specify delay paths. - * - * Revision 1.85 2007/01/16 05:44:16 steve - * Major rework of array handling. Memories are replaced with the - * more general concept of arrays. The NetMemory and NetEMemory - * classes are removed from the ivl core program, and the IVL_LPM_RAM - * lpm type is removed from the ivl_target API. - * - * Revision 1.84 2006/11/22 06:10:05 steve - * Fix spurious event from net8 that is forced. - * - * Revision 1.83 2006/09/23 04:57:19 steve - * Basic support for specify timing. - * - * Revision 1.82 2006/07/30 02:51:36 steve - * Fix/implement signed right shift. - * - * Revision 1.81 2006/06/18 04:15:50 steve - * Add support for system functions in continuous assignments. - * - * Revision 1.80 2006/03/18 22:51:10 steve - * Syntax for carrying sign with parameter. - * - * Revision 1.79 2006/03/08 05:29:42 steve - * Add support for logic parameters. - * - * Revision 1.78 2006/01/02 05:32:07 steve - * Require explicit delay node from source. - * - * Revision 1.77 2005/11/25 17:55:26 steve - * Put vec8 and vec4 nets into seperate net classes. - * - * Revision 1.76 2005/10/12 17:23:15 steve - * Add alias nodes. - * - * Revision 1.75 2005/07/14 23:34:19 steve - * gcc4 compile errors. - * - * Revision 1.74 2005/07/06 04:29:25 steve - * Implement real valued signals and arith nodes. - * - * Revision 1.73 2005/06/17 03:46:52 steve - * Make functors know their own width. - * - * Revision 1.72 2005/05/24 01:43:27 steve - * Add a sign-extension node. - * - * Revision 1.71 2005/05/08 23:40:14 steve - * Add support for variable part select. - * - * Revision 1.70 2005/04/28 04:59:53 steve - * Remove dead functor code. - * - * Revision 1.69 2005/04/24 20:07:26 steve - * Add DFF nodes. - * - * Revision 1.68 2005/04/03 05:45:51 steve - * Rework the vvp_delay_t class. - * - * Revision 1.67 2005/04/01 06:02:45 steve - * Reimplement combinational UDPs. - * - * Revision 1.66 2005/03/18 02:56:04 steve - * Add support for LPM_UFUNC user defined functions. - * - * Revision 1.65 2005/03/09 05:52:04 steve - * Handle case inequality in netlists. - * - * Revision 1.64 2005/03/09 04:52:40 steve - * reimplement memory ports. - * - * Revision 1.63 2005/03/03 04:33:10 steve - * Rearrange how memories are supported as vvp_vector4 arrays. - * - * Revision 1.62 2005/02/07 22:42:42 steve - * Add .repeat functor and BIFIF functors. - * - * Revision 1.61 2005/02/03 04:55:13 steve - * Add support for reduction logic gates. - * - * Revision 1.60 2005/01/22 01:06:20 steve - * Implement the .cmp/eeq LPM node. - * - * Revision 1.59 2005/01/09 20:11:15 steve - * Add the .part/pv node and related functionality. - * - * Revision 1.58 2004/12/29 23:45:13 steve - * Add the part concatenation node (.concat). - * - * Add a vvp_event_anyedge class to handle the special - * case of .event statements of edge type. This also - * frees the posedge/negedge types to handle all 4 inputs. - * - * Implement table functor recv_vec4 method to receive - * and process vectors. - * - * Revision 1.57 2004/12/11 02:31:29 steve - * Rework of internals to carry vectors through nexus instead - * of single bits. Make the ivl, tgt-vvp and vvp initial changes - * down this path. - * - * Revision 1.56 2004/10/04 01:10:59 steve - * Clean up spurious trailing white space. - * - * Revision 1.55 2004/06/30 02:15:57 steve - * Add signed LPM divide. - */ #endif diff --git a/vvp/vpi_tasks.cc b/vvp/vpi_tasks.cc index a0bf573b7..fbe53d1ca 100644 --- a/vvp/vpi_tasks.cc +++ b/vvp/vpi_tasks.cc @@ -27,6 +27,7 @@ */ # include "vpi_priv.h" # include "vthread.h" +# include "compile.h" # include #ifdef HAVE_MALLOC_H # include @@ -544,16 +545,7 @@ vpiHandle vpip_build_vpi_call(const char*name, unsigned vbit, int vwid, obj->fnet = fnet; obj->userdata = 0; - /* If there is a compiletf function, call it here. */ - if (obj->defn->info.compiletf) { - - assert(vpi_mode_flag == VPI_MODE_NONE); - vpi_mode_flag = VPI_MODE_COMPILETF; - vpip_cur_task = obj; - obj->defn->info.compiletf (obj->defn->info.user_data); - vpip_cur_task = 0; - vpi_mode_flag = VPI_MODE_NONE; - } + compile_compiletf(obj); return &obj->base; } @@ -630,125 +622,3 @@ void* vpi_get_userdata(vpiHandle ref) return rfp->userdata; } - -/* - * $Log: vpi_tasks.cc,v $ - * Revision 1.35 2007/04/12 04:45:53 steve - * Support for vpi_get_value of scaler values. (ravi@bluespec) - * - * Revision 1.34 2007/04/12 04:33:39 steve - * Add support for vpiSize on system task handle. (ravi@bluespec.com) - * - * Revision 1.33 2006/09/22 22:33:00 steve - * Correct return code for vpi_put_userdata. - * - * Revision 1.32 2006/06/18 04:15:50 steve - * Add support for system functions in continuous assignments. - * - * Revision 1.31 2005/09/20 18:34:02 steve - * Clean up compiler warnings. - * - * Revision 1.30 2005/08/29 02:38:50 steve - * Eliminate int to vvp_bit4_t casts. - * - * Revision 1.29 2004/10/04 01:10:59 steve - * Clean up spurious trailing white space. - * - * Revision 1.28 2004/06/30 03:00:36 steve - * Some explination of vpi_func arguments. - * - * Revision 1.27 2004/05/19 03:30:46 steve - * Support delayed/non-blocking assignment to reals and others. - * - * Revision 1.26 2004/02/18 02:51:59 steve - * Fix type mismatches of various VPI functions. - * - * Revision 1.25 2003/12/07 20:05:56 steve - * Ducument lxt2 access. - * - * Revision 1.24 2003/06/18 00:54:28 steve - * Account for all 64 bits in results of $time. - * - * Revision 1.23 2003/03/14 05:00:44 steve - * Support vpi_get of vpiTimeUnit. - * - * Revision 1.22 2003/03/13 05:07:10 steve - * signed/unsigned warnings. - * - * Revision 1.21 2003/03/07 02:44:14 steve - * Support vector put of function return values. - * - * Revision 1.20 2003/03/03 03:27:35 steve - * Support vpiName for system task/function calls. - * - * Revision 1.19 2003/01/27 00:14:37 steve - * Support in various contexts the $realtime - * system task. - * - * Revision 1.18 2003/01/09 04:09:44 steve - * Add vpi_put_userdata - * - * Revision 1.17 2002/12/21 00:55:58 steve - * The $time system task returns the integer time - * scaled to the local units. Change the internal - * implementation of vpiSystemTime the $time functions - * to properly account for this. Also add $simtime - * to get the simulation time. - * - * Revision 1.16 2002/08/12 01:35:09 steve - * conditional ident string using autoconfig. - * - * Revision 1.15 2002/06/02 19:05:50 steve - * Check for null pointers from users. - * - * Revision 1.14 2002/05/18 02:34:11 steve - * Add vpi support for named events. - * - * Add vpi_mode_flag to track the mode of the - * vpi engine. This is for error checking. - * - * Revision 1.13 2002/05/09 03:34:31 steve - * Handle null time and calltf pointers. - * - * Revision 1.12 2002/05/03 15:44:11 steve - * Add vpiModule iterator to vpiScope objects. - * - * Revision 1.11 2002/04/07 02:34:10 steve - * Set vpip_cur_task while calling compileft - * - * Revision 1.10 2001/09/15 18:27:05 steve - * Make configure detect malloc.h - * - * Revision 1.9 2001/08/03 06:50:44 steve - * Detect system function used as a task. - * - * Revision 1.8 2001/06/25 03:12:06 steve - * Give task/function definitions a vpi type object. - * - * Revision 1.7 2001/05/20 00:46:12 steve - * Add support for system function calls. - * - * Revision 1.6 2001/05/10 00:26:53 steve - * VVP support for memories in expressions, - * including general support for thread bit - * vectors as system task parameters. - * (Stephan Boettcher) - * - * Revision 1.5 2001/04/18 04:21:23 steve - * Put threads into scopes. - * - * Revision 1.4 2001/03/22 22:38:14 steve - * Detect undefined system tasks at compile time. - * - * Revision 1.3 2001/03/18 04:35:18 steve - * Add support for string constants to VPI. - * - * Revision 1.2 2001/03/18 00:37:55 steve - * Add support for vpi scopes. - * - * Revision 1.1 2001/03/16 01:44:34 steve - * Add structures for VPI support, and all the %vpi_call - * instruction. Get linking of VPI modules to work. - * - */ -