Fix handling of certain constants in ivl_target.h API.

The construction of the ivl_design_t consts member was broken,
not properly handling the addition of new objects.
This commit is contained in:
Stephen Williams 2013-07-27 18:19:26 -07:00
parent e709849243
commit b4dbb81af7
6 changed files with 48 additions and 6 deletions

View File

@ -59,7 +59,7 @@ struct ivl_design_s {
std::vector<ivl_scope_t> root_scope_list; std::vector<ivl_scope_t> root_scope_list;
// Keep an array of constants objects. // Keep an array of constants objects.
std::valarray<ivl_net_const_t> consts; std::vector<ivl_net_const_t> consts;
// Keep a handy array of all of the disciplines in the design. // Keep a handy array of all of the disciplines in the design.
std::valarray<ivl_discipline_t> disciplines; std::valarray<ivl_discipline_t> disciplines;

View File

@ -2301,8 +2301,7 @@ bool dll_target::net_const(const NetConst*net)
obj->pin_ = nex->t_cookie(); obj->pin_ = nex->t_cookie();
nexus_con_add(obj->pin_, obj, 0, drv0, drv1); nexus_con_add(obj->pin_, obj, 0, drv0, drv1);
des_.consts.resize( des_.consts.size() + 1 ); des_.consts.push_back(obj);
des_.consts[des_.consts.size()-1] = obj;
make_const_delays_(obj, net); make_const_delays_(obj, net);
@ -2333,8 +2332,7 @@ bool dll_target::net_literal(const NetLiteral*net)
obj->pin_ = nex->t_cookie(); obj->pin_ = nex->t_cookie();
nexus_con_add(obj->pin_, obj, 0, drv0, drv1); nexus_con_add(obj->pin_, obj, 0, drv0, drv1);
des_.consts.resize( des_.consts.size() + 1 ); des_.consts.push_back(obj);
des_.consts[des_.consts.size()-1] = obj;
make_const_delays_(obj, net); make_const_delays_(obj, net);

View File

@ -44,7 +44,7 @@ CPPFLAGS = $(INCLUDE_PATH) @CPPFLAGS@ @DEFS@ @PICFLAG@
CFLAGS = @WARNING_FLAGS@ @CFLAGS@ CFLAGS = @WARNING_FLAGS@ @CFLAGS@
LDFLAGS = @LDFLAGS@ 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 all: dep stub.tgt

37
tgt-stub/constant.c Normal file
View File

@ -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 <stdlib.h>
# include <inttypes.h>
# include <assert.h>
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));
}

View File

@ -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_class(ivl_type_t net);
extern void show_enumerate(ivl_enumtype_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. * Show the details of the expression.

View File

@ -1738,6 +1738,12 @@ int target_design(ivl_design_t des)
free(cur); 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); ivl_design_process(des, show_process, 0);
fclose(out); fclose(out);