From c1c23812612fcd52be672375307567fd83169dc3 Mon Sep 17 00:00:00 2001 From: steve Date: Mon, 12 Feb 2007 01:52:21 +0000 Subject: [PATCH] Parse all specify paths to pform. --- PSpec.cc | 6 ++++-- PSpec.h | 33 ++++++++++++++++++++++++++++++- elaborate.cc | 28 +++++++++++++++++++++++++- parse.y | 54 +++++++++++++++++++++++++++++++++++++-------------- pform.cc | 25 +++++++++++++++++++++++- pform.h | 11 ++++++++++- pform_dump.cc | 24 +++++++++++++++++++++-- 7 files changed, 158 insertions(+), 23 deletions(-) diff --git a/PSpec.cc b/PSpec.cc index 4677c3060..3d4464504 100644 --- a/PSpec.cc +++ b/PSpec.cc @@ -17,13 +17,15 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: PSpec.cc,v 1.1 2006/09/26 19:48:40 steve Exp $" +#ident "$Id: PSpec.cc,v 1.2 2007/02/12 01:52:21 steve Exp $" #endif # include "PSpec.h" PSpecPath::PSpecPath(unsigned src_cnt, unsigned dst_cnt) -: src(src_cnt), dst(dst_cnt) +: conditional(false), condition(0), edge(0), + src(src_cnt), dst(dst_cnt), + data_source_expression(0) { } diff --git a/PSpec.h b/PSpec.h index 7f1f9d089..aaba5f322 100644 --- a/PSpec.h +++ b/PSpec.h @@ -19,13 +19,37 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: PSpec.h,v 1.1 2006/09/23 04:57:19 steve Exp $" +#ident "$Id: PSpec.h,v 1.2 2007/02/12 01:52:21 steve Exp $" #endif # include "LineInfo.h" # include "StringHeap.h" # include +class PExpr; + +/* +* The PSpecPath is the parse of a specify path, which is in its most +* general form = . The are collected into the +* "delays" vector in all cases, and the variety is in the other +* members. +* +* All paths also have a list of source names in the src vector, and a +* list of destination names in the dst vector. These pairs are the +* actual paths. +* +* If the path is a simple path, then: +* condition == nil +* edge == 0 +* data_source_expression == nil +* +* If the path is conditional, then conditional == true and condition +* is the condition expression. If the condition expression is nil, +* then this is an ifnone conditional path. +* +* If edge != 0, then the path is edge sensitive and the optional +* data_source_expression may be present. +*/ class PSpecPath : public LineInfo { public: @@ -37,10 +61,17 @@ class PSpecPath : public LineInfo { void dump(std::ostream&out, unsigned ind) const; public: + // Condition expression, if present. + bool conditional; + class PExpr* condition; + // Edge specification (-1==negedge, 0 = no edge, 1==posedge) + int edge; // Ordered set of source nodes of a path std::vector src; // Ordered set of destination nodes of a path std::vector dst; + // Data source expression + class PExpr* data_source_expression; std::vectordelays; }; diff --git a/elaborate.cc b/elaborate.cc index aec731aa8..f050ce33e 100644 --- a/elaborate.cc +++ b/elaborate.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: elaborate.cc,v 1.358 2007/02/01 05:52:24 steve Exp $" +#ident "$Id: elaborate.cc,v 1.359 2007/02/12 01:52:21 steve Exp $" #endif # include "config.h" @@ -41,6 +41,7 @@ # include "util.h" # include "parse_api.h" # include "compiler.h" +# include "ivl_assert.h" static Link::strength_t drive_type(PGate::strength_t drv) @@ -2914,6 +2915,28 @@ void PSpecPath::elaborate(Design*des, NetScope*scope) const if (!gn_specify_blocks_flag) return; + /* Check for various path types that are not supported. */ + + if (conditional) { + cerr << get_line() << ": sorry: Conditional specify paths" + << " are not supported." << endl; + cerr << get_line() << ": : Use -g no-specify to ignore" + << " specify blocks." << endl; + des->errors += 1; + } + + ivl_assert(*this, conditional || (condition==0)); + + if (edge != 0) { + cerr << get_line() << ": sorry: Edge sensitive specify paths" + << " are not supported." << endl; + cerr << get_line() << ": : Use -g no-specify to ignore" + << " specify blocks." << endl; + des->errors += 1; + } + + ivl_assert(*this, data_source_expression==0 || edge != 0); + ndelays = delays.size(); if (ndelays > 12) ndelays = 12; @@ -3343,6 +3366,9 @@ Design* elaborate(listroots) /* * $Log: elaborate.cc,v $ + * Revision 1.359 2007/02/12 01:52:21 steve + * Parse all specify paths to pform. + * * Revision 1.358 2007/02/01 05:52:24 steve * More generous handling of errors in blocks. * diff --git a/parse.y b/parse.y index fc5c8bc8a..0eb305957 100644 --- a/parse.y +++ b/parse.y @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: parse.y,v 1.225 2007/01/29 02:07:34 steve Exp $" +#ident "$Id: parse.y,v 1.226 2007/02/12 01:52:21 steve Exp $" #endif # include "config.h" @@ -28,6 +28,7 @@ # include "compiler.h" # include "pform.h" # include "Statement.h" +# include "PSpec.h" # include class PSpecPath; @@ -179,7 +180,7 @@ static list* list_from_identifier(list*tmp, char*id) %token KK_attribute %type number -%type signed_opt udp_reg_opt +%type signed_opt udp_reg_opt edge_operator %type drive_strength drive_strength_opt dr_strength0 dr_strength1 %type udp_input_sym udp_output_sym %type udp_input_list udp_sequ_entry udp_comb_entry @@ -242,6 +243,7 @@ static list* list_from_identifier(list*tmp, char*id) %type specify_path_identifiers %type specify_simple_path specify_simple_path_decl +%type specify_edge_path specify_edge_path_decl %token K_TAND %right '?' ':' @@ -2518,16 +2520,28 @@ specify_item { pform_module_specify_path($1); } | specify_edge_path_decl ';' - { + { pform_module_specify_path($1); } | K_if '(' expression ')' specify_simple_path_decl ';' - { + { PSpecPath*tmp = $5; + if (tmp) tmp->condition = $3; + pform_module_specify_path(tmp); } | K_if '(' expression ')' specify_edge_path_decl ';' - { + { PSpecPath*tmp = $5; + if (tmp) { + tmp->conditional = true; + tmp->condition = $3; + } + pform_module_specify_path(tmp); } | K_ifnone specify_simple_path_decl ';' - { + { PSpecPath*tmp = $2; + if (tmp) { + tmp->conditional = true; + tmp->condition = 0; + } + pform_module_specify_path(tmp); } | K_Shold '(' spec_reference_event ',' spec_reference_event ',' delay_value spec_notifier_opt ')' ';' @@ -2572,19 +2586,29 @@ specify_item_list specify_edge_path_decl : specify_edge_path '=' '(' delay_value_list ')' - { delete $4; } + { $$ = pform_assign_path_delay($1, $4); } | specify_edge_path '=' delay_value_simple + { svector*tmp = new svector(1); + (*tmp)[0] = $3; + $$ = pform_assign_path_delay($1, tmp); + } ; +edge_operator : K_posedge { $$ = true; } | K_negedge { $$ = false; } ; + specify_edge_path - : '(' K_posedge specify_path_identifiers spec_polarity K_EG IDENTIFIER ')' - | '(' K_posedge specify_path_identifiers spec_polarity K_EG '(' expr_primary polarity_operator expression ')' ')' - | '(' K_posedge specify_path_identifiers spec_polarity K_SG IDENTIFIER ')' - | '(' K_posedge specify_path_identifiers spec_polarity K_SG '(' expr_primary polarity_operator expression ')' ')' - | '(' K_negedge specify_path_identifiers spec_polarity K_EG IDENTIFIER ')' - | '(' K_negedge specify_path_identifiers spec_polarity K_EG '(' expr_primary polarity_operator expression ')' ')' - | '(' K_negedge specify_path_identifiers spec_polarity K_SG IDENTIFIER ')' - | '(' K_negedge specify_path_identifiers spec_polarity K_SG '(' expr_primary polarity_operator expression ')' ')' + : '(' edge_operator specify_path_identifiers spec_polarity + K_EG specify_path_identifiers ')' + { $$ = pform_make_specify_edge_path(@1, $2, $3, $4, false, $6, 0); } + | '(' edge_operator specify_path_identifiers spec_polarity + K_EG '(' specify_path_identifiers polarity_operator expression ')' ')' + { $$ = pform_make_specify_edge_path(@1, $2, $3, $4, false, $7, $9);} + | '(' edge_operator specify_path_identifiers spec_polarity + K_SG specify_path_identifiers ')' + { $$ = pform_make_specify_edge_path(@1, $2, $3, $4, true, $6, 0); } + | '(' edge_operator specify_path_identifiers spec_polarity + K_SG '(' specify_path_identifiers polarity_operator expression ')' ')' + { $$ = pform_make_specify_edge_path(@1, $2, $3, $4, true, $7, $9); } ; polarity_operator diff --git a/pform.cc b/pform.cc index 9658c084f..59669fbd9 100644 --- a/pform.cc +++ b/pform.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: pform.cc,v 1.139 2007/01/27 05:36:11 steve Exp $" +#ident "$Id: pform.cc,v 1.140 2007/02/12 01:52:21 steve Exp $" #endif # include "config.h" @@ -1562,8 +1562,26 @@ extern PSpecPath* pform_make_specify_path(const struct vlltype&li, return path; } +extern PSpecPath*pform_make_specify_edge_path(const struct vlltype&li, + bool edge_flag, /*posedge==true */ + list*src, char pol, + bool full_flag, list*dst, + PExpr*data_source_expression) +{ + PSpecPath*tmp = pform_make_specify_path(li, src, pol, full_flag, dst); + if (edge_flag) + tmp->edge = 1; + else + tmp->edge = -1; + tmp->data_source_expression = data_source_expression; + return tmp; +} + extern PSpecPath* pform_assign_path_delay(PSpecPath*path, svector*del) { + if (path == 0) + return 0; + assert(path->delays.size() == 0); path->delays.resize(del->count()); @@ -1578,6 +1596,8 @@ extern PSpecPath* pform_assign_path_delay(PSpecPath*path, svector*del) extern void pform_module_specify_path(PSpecPath*obj) { + if (obj == 0) + return; pform_cur_module->specify_paths.push_back(obj); } @@ -1744,6 +1764,9 @@ int pform_parse(const char*path, FILE*file) /* * $Log: pform.cc,v $ + * Revision 1.140 2007/02/12 01:52:21 steve + * Parse all specify paths to pform. + * * Revision 1.139 2007/01/27 05:36:11 steve * Fix padding of x when literal is sized and unsigned. * diff --git a/pform.h b/pform.h index 2125e4317..55126329c 100644 --- a/pform.h +++ b/pform.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: pform.h,v 1.87 2006/09/23 04:57:19 steve Exp $" +#ident "$Id: pform.h,v 1.88 2007/02/12 01:52:21 steve Exp $" #endif # include "netlist.h" @@ -265,7 +265,13 @@ extern void pform_set_specparam(perm_string name, PExpr*expr); extern PSpecPath*pform_make_specify_path(const struct vlltype&li, list*src, char pol, bool full_flag, list*dst); +extern PSpecPath*pform_make_specify_edge_path(const struct vlltype&li, + bool edge_flag, /*posedge==true */ + list*src, char pol, + bool full_flag, list*dst, + PExpr*data_source_expression); extern PSpecPath*pform_assign_path_delay(PSpecPath*obj, svector*delays); + extern void pform_module_specify_path(PSpecPath*obj); /* @@ -328,6 +334,9 @@ extern void pform_dump(ostream&out, Module*mod); /* * $Log: pform.h,v $ + * Revision 1.88 2007/02/12 01:52:21 steve + * Parse all specify paths to pform. + * * Revision 1.87 2006/09/23 04:57:19 steve * Basic support for specify timing. * diff --git a/pform_dump.cc b/pform_dump.cc index b26d3b835..0fc9ffbb5 100644 --- a/pform_dump.cc +++ b/pform_dump.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: pform_dump.cc,v 1.94 2006/09/23 04:57:19 steve Exp $" +#ident "$Id: pform_dump.cc,v 1.95 2007/02/12 01:52:21 steve Exp $" #endif # include "config.h" @@ -742,7 +742,18 @@ void PProcess::dump(ostream&out, unsigned ind) const void PSpecPath::dump(std::ostream&out, unsigned ind) const { - out << setw(ind) << "" << "specify path ("; + out << setw(ind) << "" << "specify path "; + + if (condition) + out << "if (" << *condition << ") "; + + out << "("; + if (edge) { + if (edge > 0) + out << "posedge "; + else + out << "negedge "; + } for (unsigned idx = 0 ; idx < src.size() ; idx += 1) { if (idx > 0) out << ", "; @@ -752,12 +763,18 @@ void PSpecPath::dump(std::ostream&out, unsigned ind) const out << " => "; + if (data_source_expression) + out << "("; + for (unsigned idx = 0 ; idx < dst.size() ; idx += 1) { if (idx > 0) out << ", "; assert(dst[idx]); out << dst[idx]; } + if (data_source_expression) + out << " : " << *data_source_expression << ")"; + out << ") = ("; for (unsigned idx = 0 ; idx < delays.size() ; idx += 1) { if (idx > 0) out << ", "; @@ -1007,6 +1024,9 @@ void PUdp::dump(ostream&out) const /* * $Log: pform_dump.cc,v $ + * Revision 1.95 2007/02/12 01:52:21 steve + * Parse all specify paths to pform. + * * Revision 1.94 2006/09/23 04:57:19 steve * Basic support for specify timing. *