diff --git a/ivl_target_priv.h b/ivl_target_priv.h index f6949cf07..a5a10d01d 100644 --- a/ivl_target_priv.h +++ b/ivl_target_priv.h @@ -59,7 +59,7 @@ struct ivl_design_s { std::vector root_scope_list; // Keep an array of constants objects. - std::valarray consts; + std::vector consts; // Keep a handy array of all of the disciplines in the design. std::valarray disciplines; diff --git a/t-dll.cc b/t-dll.cc index f7151084d..8b96a4636 100644 --- a/t-dll.cc +++ b/t-dll.cc @@ -2301,8 +2301,7 @@ bool dll_target::net_const(const NetConst*net) obj->pin_ = nex->t_cookie(); nexus_con_add(obj->pin_, obj, 0, drv0, drv1); - des_.consts.resize( des_.consts.size() + 1 ); - des_.consts[des_.consts.size()-1] = obj; + des_.consts.push_back(obj); make_const_delays_(obj, net); @@ -2333,8 +2332,7 @@ bool dll_target::net_literal(const NetLiteral*net) obj->pin_ = nex->t_cookie(); nexus_con_add(obj->pin_, obj, 0, drv0, drv1); - des_.consts.resize( des_.consts.size() + 1 ); - des_.consts[des_.consts.size()-1] = obj; + des_.consts.push_back(obj); make_const_delays_(obj, net); diff --git a/tgt-stub/Makefile.in b/tgt-stub/Makefile.in index bbbb91f1c..b294d3000 100644 --- a/tgt-stub/Makefile.in +++ b/tgt-stub/Makefile.in @@ -44,7 +44,7 @@ CPPFLAGS = $(INCLUDE_PATH) @CPPFLAGS@ @DEFS@ @PICFLAG@ CFLAGS = @WARNING_FLAGS@ @CFLAGS@ LDFLAGS = @LDFLAGS@ -O = stub.o classes.o enumerate.o expression.o statement.o switches.o types.o +O = stub.o classes.o constant.o enumerate.o expression.o statement.o switches.o types.o all: dep stub.tgt diff --git a/tgt-stub/constant.c b/tgt-stub/constant.c new file mode 100644 index 000000000..4074e071a --- /dev/null +++ b/tgt-stub/constant.c @@ -0,0 +1,37 @@ +/* + * 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 "config.h" +# include "priv.h" +# include +# include +# include + +void show_constant(ivl_net_const_t net) +{ + unsigned idx; + const char*bits = ivl_const_bits(net); + assert(net); + + fprintf(out, "constant "); + for (idx = 0 ; idx < ivl_const_width(net) ; idx += 1) + fprintf(out, "%c", bits[idx]); + + fprintf(out, " at %s:%u\n", ivl_const_file(net), ivl_const_lineno(net)); +} diff --git a/tgt-stub/priv.h b/tgt-stub/priv.h index 60902779d..9a2a48663 100644 --- a/tgt-stub/priv.h +++ b/tgt-stub/priv.h @@ -51,6 +51,7 @@ extern void test_expr_is_delay(ivl_expr_t expr); extern void show_class(ivl_type_t net); extern void show_enumerate(ivl_enumtype_t net); +extern void show_constant(ivl_net_const_t net); /* * Show the details of the expression. diff --git a/tgt-stub/stub.c b/tgt-stub/stub.c index c68c885ff..d16b73b2b 100644 --- a/tgt-stub/stub.c +++ b/tgt-stub/stub.c @@ -1738,6 +1738,12 @@ int target_design(ivl_design_t des) free(cur); } + fprintf(out, "# There are %u constants detected\n", ivl_design_consts(des)); + for (idx = 0 ; idx < ivl_design_consts(des) ; idx += 1) { + ivl_net_const_t con = ivl_design_const(des, idx); + show_constant(con); + } + ivl_design_process(des, show_process, 0); fclose(out);