From 7e3ea2ffe86208eec500b12c1b7e5cb753535544 Mon Sep 17 00:00:00 2001 From: steve Date: Thu, 28 Sep 2006 00:29:49 +0000 Subject: [PATCH] Allow specparams as constants in expressions. --- elab_expr.cc | 21 +++++++++++++++++++-- netmisc.h | 8 +++++++- t-dll.cc | 35 ++++++++++++++++++++++++----------- 3 files changed, 50 insertions(+), 14 deletions(-) diff --git a/elab_expr.cc b/elab_expr.cc index 6759f7a4e..340b9d295 100644 --- a/elab_expr.cc +++ b/elab_expr.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999-2005 Stephen Williams (steve@icarus.com) + * Copyright (c) 1999-2006 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 @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: elab_expr.cc,v 1.109 2006/09/19 23:00:15 steve Exp $" +#ident "$Id: elab_expr.cc,v 1.110 2006/09/28 00:29:49 steve Exp $" #endif # include "config.h" @@ -668,6 +668,20 @@ NetExpr* PEIdent::elaborate_expr(Design*des, NetScope*scope, return tmp; } + // A specparam? Look up the name to see if it is a + // specparam. If we find it, then turn it into a NetEConst + // value and return that. + + map::const_iterator specp; + const char*key = path_.peek_name(0); + if (path_.component_count() == 1 + && ((specp = scope->specparams.find(perm_string::literal(key))) != scope->specparams.end())) { + verinum val ((*specp).second); + NetEConst*tmp = new NetEConst(val); + tmp->set_line(*this); + return tmp; + } + // Finally, if this is a scope name, then return that. Look // first to see if this is a name of a local scope. Failing // that, search globally for a hierarchical name. @@ -1399,6 +1413,9 @@ NetExpr* PEUnary::elaborate_expr(Design*des, NetScope*scope, /* * $Log: elab_expr.cc,v $ + * Revision 1.110 2006/09/28 00:29:49 steve + * Allow specparams as constants in expressions. + * * Revision 1.109 2006/09/19 23:00:15 steve * Use elab_and_eval for bit select expressions. * diff --git a/netmisc.h b/netmisc.h index 5f2075a57..0f9372982 100644 --- a/netmisc.h +++ b/netmisc.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: netmisc.h,v 1.25 2006/06/02 04:48:50 steve Exp $" +#ident "$Id: netmisc.h,v 1.26 2006/09/28 00:29:49 steve Exp $" #endif # include "netlist.h" @@ -112,6 +112,9 @@ extern unsigned count_lval_width(const class NetAssign_*first); * right away. If the expression can be evaluated, this returns a * constant expression. If it cannot be evaluated, it returns whatever * it can. If the expression cannot be elaborated, return 0. + * + * The expr_width is the width of the context where the expression is + * being elaborated, or -1 if the expression is self-determinted width. */ class PExpr; extern NetExpr* elab_and_eval(Design*des, NetScope*scope, @@ -119,6 +122,9 @@ extern NetExpr* elab_and_eval(Design*des, NetScope*scope, /* * $Log: netmisc.h,v $ + * Revision 1.26 2006/09/28 00:29:49 steve + * Allow specparams as constants in expressions. + * * Revision 1.25 2006/06/02 04:48:50 steve * Make elaborate_expr methods aware of the width that the context * requires of it. In the process, fix sizing of the width of unary diff --git a/t-dll.cc b/t-dll.cc index 874e25e30..e781ab64c 100644 --- a/t-dll.cc +++ b/t-dll.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: t-dll.cc,v 1.158 2006/09/23 04:57:19 steve Exp $" +#ident "$Id: t-dll.cc,v 1.159 2006/09/28 00:29:49 steve Exp $" #endif # include "config.h" @@ -2175,20 +2175,30 @@ void dll_target::signal(const NetNet*net) } /* Collect the delay paths for this signal. */ - obj->npath = net->delay_paths(); - if (obj->npath > 0) { + obj->npath = 0; + if (net->delay_paths() > 0) { + /* Figure out how many paths there really are. */ + for (unsigned idx = 0 ; idx < net->delay_paths() ; idx += 1) { + const NetDelaySrc*src = net->delay_path(idx); + obj->npath += src->pin_count(); + } + obj->path = new struct ivl_delaypath_s[obj->npath]; - for (unsigned idx = 0 ; idx < obj->npath ; idx += 1) { + unsigned ptr = 0; + for (unsigned idx = 0 ; idx < net->delay_paths() ; idx += 1) { const NetDelaySrc*src = net->delay_path(idx); - // For now, only handle single-source paths. - assert(src->pin_count() == 1); - const Nexus*nex = src->pin(0).nexus(); - assert(nex->t_cookie()); - obj->path[idx].src = (ivl_nexus_t) nex->t_cookie(); - for (unsigned pe = 0 ; pe < 12 ; pe += 1) { - obj->path[idx].delay[pe] = src->get_delay(pe); + for (unsigned pin = 0; pin < src->pin_count(); pin += 1) { + const Nexus*nex = src->pin(pin).nexus(); + assert(nex->t_cookie()); + obj->path[ptr].src = (ivl_nexus_t) nex->t_cookie(); + + for (unsigned pe = 0 ; pe < 12 ; pe += 1) { + obj->path[ptr].delay[pe] = src->get_delay(pe); + } + + ptr += 1; } } @@ -2229,6 +2239,9 @@ extern const struct target tgt_dll = { "dll", &dll_target_obj }; /* * $Log: t-dll.cc,v $ + * Revision 1.159 2006/09/28 00:29:49 steve + * Allow specparams as constants in expressions. + * * Revision 1.158 2006/09/23 04:57:19 steve * Basic support for specify timing. *