diff --git a/tgt-blif/Makefile.in b/tgt-blif/Makefile.in index 79f8811e5..cde16b3cd 100644 --- a/tgt-blif/Makefile.in +++ b/tgt-blif/Makefile.in @@ -45,7 +45,7 @@ CXXFLAGS = @WARNING_FLAGS@ @CXXFLAGS@ LDFLAGS = @LDFLAGS@ O = blif.o constants.o logic_gate.o lpm.o lpm_add.o lpm_cmp_eq.o lpm_cmp_gt.o \ - nex_data.o + lpm_part_vp.o nex_data.o all: dep blif.tgt diff --git a/tgt-blif/lpm.cc b/tgt-blif/lpm.cc index 470fd4e85..0c894a82a 100644 --- a/tgt-blif/lpm.cc +++ b/tgt-blif/lpm.cc @@ -64,37 +64,6 @@ static int print_concat(FILE*fd, ivl_lpm_t net) return 0; } -/* - * This implements the IVL_LPM_PART_VP, which is the vector-to-part - * part select. Implement this as a .names buffer. - */ -static int print_part_vp(FILE*fd, ivl_lpm_t net) -{ - int rc = 0; - - ivl_nexus_t nex_out = ivl_lpm_q(net); - blif_nex_data_t*ned_out = blif_nex_data_t::get_nex_data(nex_out); - - // Only handle bit selects. - assert(ned_out->get_width() == 1); - // Only handle constant part select base. - assert(ivl_lpm_data(net,1) == 0); - - unsigned bit_sel = ivl_lpm_base(net); - - ivl_nexus_t nex_in = ivl_lpm_data(net,0); - blif_nex_data_t*ned_in = blif_nex_data_t::get_nex_data(nex_in); - - assert(bit_sel < ned_in->get_width()); - - fprintf(fd, ".names %s%s %s%s # %s:%u\n1 1\n", - ned_in->get_name(), ned_in->get_name_index(bit_sel), - ned_out->get_name(), ned_out->get_name_index(0), - ivl_lpm_file(net), ivl_lpm_lineno(net)); - - return rc; -} - int print_lpm(FILE*fd, ivl_lpm_t net) { int rc = 0; @@ -120,7 +89,7 @@ int print_lpm(FILE*fd, ivl_lpm_t net) rc += print_lpm_cmp_ne(fd, net); break; case IVL_LPM_PART_VP: - rc += print_part_vp(fd, net); + rc += print_lpm_part_vp(fd, net); break; case IVL_LPM_SUB: rc += print_lpm_sub(fd, net); diff --git a/tgt-blif/lpm_part_vp.cc b/tgt-blif/lpm_part_vp.cc new file mode 100644 index 000000000..add2ffe9a --- /dev/null +++ b/tgt-blif/lpm_part_vp.cc @@ -0,0 +1,113 @@ +/* + * 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 + +static int print_part_vp_mux(FILE*fd, ivl_lpm_t net); + +/* + * This implements the IVL_LPM_PART_VP, which is the vector-to-part + * part select. Implement this as a .names buffer. + */ +int print_lpm_part_vp(FILE*fd, ivl_lpm_t net) +{ + int rc = 0; + + // If this is a non-constant bit select, then handle it + // elsewhere. + if (ivl_lpm_data(net,1) != 0) + return print_part_vp_mux(fd, net); + + ivl_nexus_t nex_out = ivl_lpm_q(net); + blif_nex_data_t*ned_out = blif_nex_data_t::get_nex_data(nex_out); + + // Only handle bit selects. + assert(ned_out->get_width() == 1); + // Only handle constant part select base. + assert(ivl_lpm_data(net,1) == 0); + + unsigned bit_sel = ivl_lpm_base(net); + + ivl_nexus_t nex_in = ivl_lpm_data(net,0); + blif_nex_data_t*ned_in = blif_nex_data_t::get_nex_data(nex_in); + + assert(bit_sel < ned_in->get_width()); + + fprintf(fd, ".names %s%s %s%s # %s:%u\n1 1\n", + ned_in->get_name(), ned_in->get_name_index(bit_sel), + ned_out->get_name(), ned_out->get_name_index(0), + ivl_lpm_file(net), ivl_lpm_lineno(net)); + + return rc; +} + +static int print_part_vp_mux(FILE*fd, ivl_lpm_t net) +{ + // Only handle constant part select base. + assert(ivl_lpm_data(net,1) != 0); + + + ivl_nexus_t nex_out = ivl_lpm_q(net); + blif_nex_data_t*ned_out = blif_nex_data_t::get_nex_data(nex_out); + + // Only handle bit selects. + assert(ned_out->get_width() == 1); + + ivl_nexus_t nex_in = ivl_lpm_data(net,0); + blif_nex_data_t*ned_in = blif_nex_data_t::get_nex_data(nex_in); + + ivl_nexus_t nex_sel = ivl_lpm_data(net,1); + blif_nex_data_t*ned_sel = blif_nex_data_t::get_nex_data(nex_sel); + + unsigned sel_wid = ned_sel->get_width(); + unsigned in_wid = ned_in->get_width(); + + assert((1U<get_name(), ned_sel->get_name_index(idx)); + } + for (unsigned idx = 0 ; idx < in_wid ; idx += 1) { + fprintf(fd, " %s%s", + ned_in->get_name(), ned_in->get_name_index(idx)); + } + fprintf(fd, " %s%s\n", + ned_out->get_name(), ned_out->get_name_index(0)); + + for (unsigned idx = 0 ; idx < (1U<