From d209d8ee391cfdaa38f01063a25197e488fc0351 Mon Sep 17 00:00:00 2001 From: Stephen Williams Date: Mon, 19 Aug 2013 16:42:49 -0700 Subject: [PATCH] blif support for IVL_LPM_FF devices. --- tgt-blif/Makefile.in | 2 +- tgt-blif/lpm.cc | 3 +++ tgt-blif/lpm_ff.cc | 62 ++++++++++++++++++++++++++++++++++++++++++++ tgt-blif/priv.h | 1 + 4 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 tgt-blif/lpm_ff.cc diff --git a/tgt-blif/Makefile.in b/tgt-blif/Makefile.in index 2fd4163bc..c45d8885e 100644 --- a/tgt-blif/Makefile.in +++ b/tgt-blif/Makefile.in @@ -45,7 +45,7 @@ CXXFLAGS = @WARNING_FLAGS@ @WARNING_FLAGS_CXX@ @CXXFLAGS@ LDFLAGS = @LDFLAGS@ O = blif.o constants.o logic_gate.o lpm.o lpm_add.o lpm_cmp_eq.o lpm_cmp_gt.o \ - lpm_mux.o lpm_part_vp.o lpm_re_logic.o nex_data.o + lpm_ff.o lpm_mux.o lpm_part_vp.o lpm_re_logic.o nex_data.o all: dep blif.tgt diff --git a/tgt-blif/lpm.cc b/tgt-blif/lpm.cc index 2c7de5736..3b0a4fba6 100644 --- a/tgt-blif/lpm.cc +++ b/tgt-blif/lpm.cc @@ -88,6 +88,9 @@ int print_lpm(FILE*fd, ivl_lpm_t net) case IVL_LPM_CMP_NEE: rc += print_lpm_cmp_ne(fd, net); break; + case IVL_LPM_FF: + rc += print_lpm_ff(fd, net); + break; case IVL_LPM_MUX: rc += print_lpm_mux(fd, net); break; diff --git a/tgt-blif/lpm_ff.cc b/tgt-blif/lpm_ff.cc new file mode 100644 index 000000000..755b11559 --- /dev/null +++ b/tgt-blif/lpm_ff.cc @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2013 Stephen Williams (steve@icarus.com) + * + * This source code is free software; you can redistribute it + * and/or modify it in source code form under the terms of the GNU + * General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +# include "priv.h" +# include "nex_data.h" +# include + +using namespace std; + +int print_lpm_ff(FILE*fd, ivl_lpm_t net) +{ + int errors = 0; + + ivl_nexus_t nex_q = ivl_lpm_q(net); + blif_nex_data_t*ned_q = blif_nex_data_t::get_nex_data(nex_q); + + ivl_nexus_t nex_d = ivl_lpm_data(net,0); + blif_nex_data_t*ned_d = blif_nex_data_t::get_nex_data(nex_d); + + ivl_nexus_t nex_c = ivl_lpm_clk(net); + blif_nex_data_t*ned_c = blif_nex_data_t::get_nex_data(nex_c); + + if (ivl_lpm_async_clr(net)) { + errors += 1; + fprintf(stderr, "%s:%u: sorry: blif: Asynchronous clear not implemented yet\n", + ivl_lpm_file(net), ivl_lpm_lineno(net)); + } + + if (ivl_lpm_async_set(net)) { + errors += 1; + fprintf(stderr, "%s:%u: sorry: blif: Asynchronous set not implemented yet\n", + ivl_lpm_file(net), ivl_lpm_lineno(net)); + } + + fprintf(fd, "# IVL_LPM_FF: width=%u, Q=%s, D=%s, C=%s\n", + ivl_lpm_width(net), ned_q->get_name(), ned_d->get_name(), ned_c->get_name()); + + for (unsigned wid = 0 ; wid < ivl_lpm_width(net) ; wid += 1) { + fprintf(fd, ".latch %s%s %s%s re %s%s 3\n", + ned_d->get_name(), ned_d->get_name_index(wid), + ned_q->get_name(), ned_q->get_name_index(wid), + ned_c->get_name(), ned_c->get_name_index(0)); + } + + return errors; +} diff --git a/tgt-blif/priv.h b/tgt-blif/priv.h index ce14b2c3e..db83c0e99 100644 --- a/tgt-blif/priv.h +++ b/tgt-blif/priv.h @@ -32,6 +32,7 @@ extern int print_logic_gate(FILE*fd, ivl_net_logic_t net); extern int print_lpm(FILE*fd, ivl_lpm_t net); extern int print_lpm_add(FILE*fd, ivl_lpm_t net); +extern int print_lpm_ff(FILE*fd, ivl_lpm_t net); extern int print_lpm_sub(FILE*fd, ivl_lpm_t net); extern int print_lpm_cmp_eq(FILE*fd, ivl_lpm_t net); extern int print_lpm_cmp_gt(FILE*fd, ivl_lpm_t net);