Add API to support user defined function.

This commit is contained in:
steve 2002-03-17 19:30:20 +00:00
parent f5049c2f14
commit 828ca0ef9d
4 changed files with 65 additions and 7 deletions

View File

@ -57,6 +57,8 @@ ivl_lpm_clk
ivl_lpm_data
ivl_lpm_datab
ivl_lpm_data2
ivl_lpm_data2_width
ivl_lpm_define
ivl_lpm_enable
ivl_lpm_memory
ivl_lpm_name

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: ivl_target.h,v 1.93 2002/03/09 02:10:22 steve Exp $"
#ident "$Id: ivl_target.h,v 1.94 2002/03/17 19:30:20 steve Exp $"
#endif
#ifdef __cplusplus
@ -563,14 +563,18 @@ extern unsigned ivl_lpm_width(ivl_lpm_t net);
/* IVL_LPM_FF IVL_LPM_RAM */
extern ivl_nexus_t ivl_lpm_clk(ivl_lpm_t net);
/* IVL_LPM_UFUNC */
extern ivl_scope_t ivl_lpm_define(ivl_lpm_t net);
/* IVL_LPM_FF IVL_LPM_RAM */
extern ivl_nexus_t ivl_lpm_enable(ivl_lpm_t net);
/* IVL_LPM_ADD IVL_LPM_FF IVL_LPM_MULT IVL_LPM_RAM IVL_LPM_SUB */
extern ivl_nexus_t ivl_lpm_data(ivl_lpm_t net, unsigned idx);
/* IVL_LPM_ADD IVL_LPM_MULT IVL_LPM_SUB */
/* IVL_LPM_MUX IVL_LPM_UFUNC */
extern ivl_nexus_t ivl_lpm_datab(ivl_lpm_t net, unsigned idx);
/* IVL_LPM_MUX */
extern ivl_nexus_t ivl_lpm_data2(ivl_lpm_t net, unsigned sdx, unsigned idx);
/* IVL_LPM_UFUNC */
extern unsigned ivl_lpm_data2_width(ivl_lpm_t net, unsigned sdx);
/* IVL_LPM_ADD IVL_LPM_FF IVL_LPM_MULT IVL_LPM_RAM IVL_LPM_SUB
IVL_LPM_UFUNC */
extern ivl_nexus_t ivl_lpm_q(ivl_lpm_t net, unsigned idx);
@ -1002,6 +1006,9 @@ _END_DECL
/*
* $Log: ivl_target.h,v $
* Revision 1.94 2002/03/17 19:30:20 steve
* Add API to support user defined function.
*
* Revision 1.93 2002/03/09 02:10:22 steve
* Add the NetUserFunc netlist node.
*

View File

@ -2,7 +2,7 @@
Icarus Verilog LOADABLE TARGET API (ivl_target)
Copyright 2002 Stephen Williams <steve@icarus.com>
$Id: ivl_target.txt,v 1.1 2002/03/09 02:10:22 steve Exp $
$Id: ivl_target.txt,v 1.2 2002/03/17 19:31:17 steve Exp $
The ivl_target API is the interface available to modules that the
@ -19,21 +19,30 @@ the API are used to access and interpret the netlist of the design.
LPM DEVICES
All LPM devices support a small set of common LPM functions, as
described in the ivl_target header file.
described in the ivl_target header file. The ivl_lpm_t object has a
type enumerated by ivl_lpm_type_t, and that type is accessible via the
ivl_lpm_type function.
The following are type specific aspects of LPM devices.
* IVL_LPM_UFUNC
This LPM represents a user defined function. It is a way to connect
behavioral code into a structural network. The UFUNC device has a
vector output and a set of inputs.
vector output and a set of inputs. The ivl_lpm_define function returns
the definition as an ivl_scope_t object.
The output vector is accessible through the ivl_lpm_q, and the output
has the width defined by ivl_lpm_width. This similar to most every
other LPM device with outputs.
There are ivl_lpm_size() input ports, each with the width
ivl_lpm_data2_width(). The actual nexus is indexed by ivl_lpm_data2().
$Log: ivl_target.txt,v $
Revision 1.2 2002/03/17 19:31:17 steve
Add API to support user defined function.
Revision 1.1 2002/03/09 02:10:22 steve
Add the NetUserFunc netlist node.

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: t-dll-api.cc,v 1.76 2002/03/09 02:10:22 steve Exp $"
#ident "$Id: t-dll-api.cc,v 1.77 2002/03/17 19:30:47 steve Exp $"
#endif
# include "config.h"
@ -543,6 +543,18 @@ extern "C" ivl_nexus_t ivl_lpm_clk(ivl_lpm_t net)
}
}
extern "C" ivl_scope_t ivl_lpm_define(ivl_lpm_t net)
{
assert(net);
switch (net->type) {
case IVL_LPM_UFUNC:
return net->u_.ufunc.def;
default:
assert(0);
return 0;
}
}
extern "C" ivl_nexus_t ivl_lpm_enable(ivl_lpm_t net)
{
assert(net);
@ -623,12 +635,35 @@ extern "C" ivl_nexus_t ivl_lpm_data2(ivl_lpm_t net, unsigned sdx, unsigned idx)
assert(idx < net->u_.mux.width);
return net->u_.mux.d[sdx*net->u_.mux.width + idx];
case IVL_LPM_UFUNC: {
sdx += 1; /* skip the output port. */
assert(sdx < net->u_.ufunc.ports);
assert(idx < net->u_.ufunc.port_wid[sdx]);
unsigned base = 0;
for (unsigned i = 0 ; i < sdx ; i += 1)
base += net->u_.ufunc.port_wid[i];
return net->u_.ufunc.pins[base+idx];
}
default:
assert(0);
return 0;
}
}
extern "C" unsigned ivl_lpm_data2_width(ivl_lpm_t net, unsigned sdx)
{
assert(net);
switch (net->type) {
case IVL_LPM_UFUNC:
sdx += 1; /* skip the output port. */
assert(sdx < net->u_.ufunc.ports);
return net->u_.ufunc.port_wid[sdx];
default:
assert(0);
return 0;
}
}
extern "C" const char* ivl_lpm_name(ivl_lpm_t net)
{
return net->name;
@ -739,6 +774,8 @@ extern "C" unsigned ivl_lpm_size(ivl_lpm_t net)
switch (net->type) {
case IVL_LPM_MUX:
return net->u_.mux.size;
case IVL_LPM_UFUNC:
return net->u_.ufunc.ports - 1;
default:
assert(0);
return 0;
@ -1458,6 +1495,9 @@ extern "C" ivl_statement_t ivl_stmt_sub_stmt(ivl_statement_t net)
/*
* $Log: t-dll-api.cc,v $
* Revision 1.77 2002/03/17 19:30:47 steve
* Add API to support user defined function.
*
* Revision 1.76 2002/03/09 02:10:22 steve
* Add the NetUserFunc netlist node.
*