From 1b8034818c51c7d84a2d4a6925584636e1197088 Mon Sep 17 00:00:00 2001 From: steve Date: Mon, 27 Oct 2003 02:18:27 +0000 Subject: [PATCH] Emit constants for LPM device. --- tgt-fpga/d-lpm.c | 60 +++++++++++++++++++++++++++++++++++++++++++++-- tgt-fpga/device.h | 7 +++++- tgt-fpga/fpga.c | 20 +++++++++++++++- 3 files changed, 83 insertions(+), 4 deletions(-) diff --git a/tgt-fpga/d-lpm.c b/tgt-fpga/d-lpm.c index f904345cd..f4d0f7db5 100644 --- a/tgt-fpga/d-lpm.c +++ b/tgt-fpga/d-lpm.c @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: d-lpm.c,v 1.8 2003/09/03 23:34:09 steve Exp $" +#ident "$Id: d-lpm.c,v 1.9 2003/10/27 02:18:27 steve Exp $" #endif /* @@ -785,6 +785,58 @@ static void lpm_show_mult(ivl_lpm_t net) } +static void lpm_show_constant(ivl_net_const_t net) +{ + edif_cell_t cell0 = edif_xlibrary_findcell(xlib, "cell0"); + edif_cell_t cell1 = edif_xlibrary_findcell(xlib, "cell1"); + edif_cellref_t ref0 = 0, ref1 = 0; + + const char*bits; + unsigned idx; + + if (cell0 == 0) { + cell0 = edif_xcell_create(xlib, "cell0", 1); + edif_cell_portconfig(cell0, 0, "Result0", IVL_SIP_OUTPUT); + + edif_cell_pstring(cell0, "LPM_Type", "LPM_CONSTANT"); + edif_cell_pinteger(cell0, "LPM_Width", 1); + edif_cell_pinteger(cell0, "LPM_CValue", 0); + } + + if (cell1 == 0) { + cell1 = edif_xcell_create(xlib, "cell1", 1); + edif_cell_portconfig(cell1, 0, "Result0", IVL_SIP_OUTPUT); + + edif_cell_pstring(cell1, "LPM_Type", "LPM_CONSTANT"); + edif_cell_pinteger(cell1, "LPM_Width", 1); + edif_cell_pinteger(cell1, "LPM_CValue", 1); + } + + bits = ivl_const_bits(net); + for (idx = 0 ; idx < ivl_const_pins(net) ; idx += 1) { + if (bits[idx] == '1') { + if (ref1 == 0) + ref1 = edif_cellref_create(edf, cell1); + + } else { + if (ref0 == 0) + ref0 = edif_cellref_create(edf, cell0); + } + } + + for (idx = 0 ; idx < ivl_const_pins(net) ; idx += 1) { + edif_joint_t jnt; + + jnt = edif_joint_of_nexus(edf, ivl_const_pin(net,idx)); + if (bits[idx] == '1') + edif_add_to_joint(jnt, ref1, 0); + else + edif_add_to_joint(jnt, ref0, 0); + } + +} + + const struct device_s d_lpm_edif = { lpm_show_header, lpm_show_footer, @@ -800,11 +852,15 @@ const struct device_s d_lpm_edif = { lpm_show_add, /* show_sub */ 0, /* show_shiftl */ 0, /* show_shiftr */ - lpm_show_mult /* show_mult */ + lpm_show_mult, /* show_mult */ + lpm_show_constant /* show_constant */ }; /* * $Log: d-lpm.c,v $ + * Revision 1.9 2003/10/27 02:18:27 steve + * Emit constants for LPM device. + * * Revision 1.8 2003/09/03 23:34:09 steve * Support synchronous set of LPM_FF devices. * diff --git a/tgt-fpga/device.h b/tgt-fpga/device.h index a84662320..6ae6fca50 100644 --- a/tgt-fpga/device.h +++ b/tgt-fpga/device.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: device.h,v 1.12 2003/08/09 03:23:03 steve Exp $" +#ident "$Id: device.h,v 1.13 2003/10/27 02:18:27 steve Exp $" #endif # include @@ -63,6 +63,8 @@ struct device_s { void (*show_shiftr)(ivl_lpm_t net); /* Multipliers */ void (*show_mult)(ivl_lpm_t net); + /* Constants */ + void (*show_constant)(ivl_net_const_t net); }; /* @@ -77,6 +79,9 @@ extern device_t device_from_arch(const char*arch); /* * $Log: device.h,v $ + * Revision 1.13 2003/10/27 02:18:27 steve + * Emit constants for LPM device. + * * Revision 1.12 2003/08/09 03:23:03 steve * Add support for IVL_LPM_MULT device. * diff --git a/tgt-fpga/fpga.c b/tgt-fpga/fpga.c index 3f170f126..54775b520 100644 --- a/tgt-fpga/fpga.c +++ b/tgt-fpga/fpga.c @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: fpga.c,v 1.9 2003/08/07 04:04:01 steve Exp $" +#ident "$Id: fpga.c,v 1.10 2003/10/27 02:18:28 steve Exp $" #endif # include "config.h" @@ -88,6 +88,19 @@ static void show_pads(ivl_scope_t scope) } } +static void show_constants(ivl_design_t des) +{ + unsigned idx; + + if (device->show_constant == 0) + return; + + for (idx = 0 ; idx < ivl_design_consts(des) ; idx += 1) { + ivl_net_const_t con = ivl_design_const(des, idx); + device->show_constant(con); + } +} + /* * This is the main entry point that ivl uses to invoke me, the code * generator. @@ -135,6 +148,8 @@ int target_design(ivl_design_t des) netlist. */ show_scope_gates(root, 0); + show_constants(des); + /* Call the device driver to close out the file. */ device->show_footer(des); @@ -145,6 +160,9 @@ int target_design(ivl_design_t des) /* * $Log: fpga.c,v $ + * Revision 1.10 2003/10/27 02:18:28 steve + * Emit constants for LPM device. + * * Revision 1.9 2003/08/07 04:04:01 steve * Add an LPM device type. *