specparams as far as pform.

This commit is contained in:
steve 2003-02-27 06:45:11 +00:00
parent a275133ff9
commit e58030498f
5 changed files with 97 additions and 14 deletions

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: Module.h,v 1.28 2003/01/26 21:15:58 steve Exp $" #ident "$Id: Module.h,v 1.29 2003/02/27 06:45:11 steve Exp $"
#endif #endif
# include <list> # include <list>
@ -77,6 +77,12 @@ class Module : public LineInfo {
map<string,param_expr_t>parameters; map<string,param_expr_t>parameters;
map<string,param_expr_t>localparams; map<string,param_expr_t>localparams;
/* specparams are simpler then other params, in that they have
no type information. They are merely constant
expressions. */
map<string,PExpr*>specparams;
/* The module also has defparam assignments which don't create /* The module also has defparam assignments which don't create
new parameters within the module, but may be used to set new parameters within the module, but may be used to set
values within this module (when instantiated) or in other values within this module (when instantiated) or in other
@ -155,6 +161,9 @@ class Module : public LineInfo {
/* /*
* $Log: Module.h,v $ * $Log: Module.h,v $
* Revision 1.29 2003/02/27 06:45:11 steve
* specparams as far as pform.
*
* Revision 1.28 2003/01/26 21:15:58 steve * Revision 1.28 2003/01/26 21:15:58 steve
* Rework expression parsing and elaboration to * Rework expression parsing and elaboration to
* accommodate real/realtime values and expressions. * accommodate real/realtime values and expressions.

55
parse.y
View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if HAVE_CVS_IDENT #if HAVE_CVS_IDENT
#ident "$Id: parse.y,v 1.172 2003/02/07 23:16:09 steve Exp $" #ident "$Id: parse.y,v 1.173 2003/02/27 06:45:11 steve Exp $"
#endif #endif
# include "config.h" # include "config.h"
@ -201,6 +201,9 @@ const static struct str_pair_t str_strength = { PGate::STRONG, PGate::STRONG };
%type <range_delay> range_delay %type <range_delay> range_delay
%type <letter> spec_polarity
%type <texts> specify_path_identifiers
%token K_TAND %token K_TAND
%right '?' ':' %right '?' ':'
%left K_LOR %left K_LOR
@ -2163,8 +2166,12 @@ specify_simple_path_decl
; ;
specify_simple_path specify_simple_path
: '(' specify_path_identifiers spec_polarity K_EG expression ')' : '(' specify_path_identifiers spec_polarity
| '(' specify_path_identifiers spec_polarity K_SG expression ')' K_EG specify_path_identifiers ')'
{ pform_make_specify_path($2, $3, false, $5); }
| '(' specify_path_identifiers spec_polarity
K_SG specify_path_identifiers ')'
{ pform_make_specify_path($2, $3, true, $5); }
| '(' error ')' | '(' error ')'
{ yyerror(@2, "Invalid simple path"); { yyerror(@2, "Invalid simple path");
yyerrok; yyerrok;
@ -2172,16 +2179,40 @@ specify_simple_path
; ;
specify_path_identifiers specify_path_identifiers
: IDENTIFIER { } : IDENTIFIER
| IDENTIFIER '[' expr_primary ']' { } { list<char*>*tmp = new list<char*>;
| specify_path_identifiers ',' IDENTIFIER { } tmp->push_back($1);
| specify_path_identifiers ',' IDENTIFIER '[' expr_primary ']' { } $$ = tmp;
}
| IDENTIFIER '[' expr_primary ']'
{ list<char*>*tmp = new list<char*>;
tmp->push_back($1);
$$ = tmp;
}
| specify_path_identifiers ',' IDENTIFIER
{ list<char*>*tmp = $1;
tmp->push_back($3);
$$ = tmp;
}
| specify_path_identifiers ',' IDENTIFIER '[' expr_primary ']'
{ list<char*>*tmp = $1;
tmp->push_back($3);
$$ = tmp;
}
; ;
specparam specparam
: IDENTIFIER '=' expression : IDENTIFIER '=' expression
{ delete $1; { PExpr*tmp = $3;
delete $3; if (!pform_expression_is_constant(tmp)) {
yyerror(@3, "error: specparam value "
"must be a constant expression.");
delete tmp;
tmp = 0;
} else {
pform_set_specparam($1, tmp);
}
delete $1;
} }
| IDENTIFIER '=' expression ':' expression ':' expression | IDENTIFIER '=' expression ':' expression ':' expression
{ delete $1; { delete $1;
@ -2205,7 +2236,11 @@ specparam_list
| specparam_list ',' specparam | specparam_list ',' specparam
; ;
spec_polarity: '+' | '-' | ; spec_polarity
: '+' { $$ = '+'; }
| '-' { $$ = '-'; }
| { $$ = 0; }
;
spec_reference_event spec_reference_event
: K_posedge expression : K_posedge expression

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: pform.cc,v 1.108 2003/02/02 19:02:39 steve Exp $" #ident "$Id: pform.cc,v 1.109 2003/02/27 06:45:11 steve Exp $"
#endif #endif
# include "config.h" # include "config.h"
@ -1231,12 +1231,28 @@ void pform_set_localparam(const string&name, PExpr*expr)
pform_cur_module->localparams[name].signed_flag = false; pform_cur_module->localparams[name].signed_flag = false;
} }
void pform_set_specparam(const string&name, PExpr*expr)
{
assert(expr);
pform_cur_module->specparams[name] = expr;
}
void pform_set_defparam(const hname_t&name, PExpr*expr) void pform_set_defparam(const hname_t&name, PExpr*expr)
{ {
assert(expr); assert(expr);
pform_cur_module->defparms[name] = expr; pform_cur_module->defparms[name] = expr;
} }
/*
* XXXX Not implemented yet.
*/
extern void pform_make_specify_path(list<char*>*src, char pol,
bool full_flag, list<char*>*dst)
{
delete src;
delete dst;
}
void pform_set_port_type(const struct vlltype&li, void pform_set_port_type(const struct vlltype&li,
list<char*>*names, list<char*>*names,
svector<PExpr*>*range, svector<PExpr*>*range,
@ -1396,6 +1412,9 @@ int pform_parse(const char*path, FILE*file)
/* /*
* $Log: pform.cc,v $ * $Log: pform.cc,v $
* Revision 1.109 2003/02/27 06:45:11 steve
* specparams as far as pform.
*
* Revision 1.108 2003/02/02 19:02:39 steve * Revision 1.108 2003/02/02 19:02:39 steve
* Add support for signed ports and nets. * Add support for signed ports and nets.
* *

12
pform.h
View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: pform.h,v 1.67 2003/02/02 19:02:40 steve Exp $" #ident "$Id: pform.h,v 1.68 2003/02/27 06:45:11 steve Exp $"
#endif #endif
# include "netlist.h" # include "netlist.h"
@ -207,6 +207,13 @@ extern void pform_set_parameter(const string&name,
extern void pform_set_localparam(const string&name, PExpr*expr); extern void pform_set_localparam(const string&name, PExpr*expr);
extern void pform_set_defparam(const hname_t&name, PExpr*expr); extern void pform_set_defparam(const hname_t&name, PExpr*expr);
/*
* Functions related to specify blocks.
*/
extern void pform_set_specparam(const string&name, PExpr*expr);
extern void pform_make_specify_path(list<char*>*src, char pol,
bool full_flag, list<char*>*dst);
/* /*
* pform_make_behavior creates processes that are declared with always * pform_make_behavior creates processes that are declared with always
* or initial items. * or initial items.
@ -268,6 +275,9 @@ extern void pform_dump(ostream&out, Module*mod);
/* /*
* $Log: pform.h,v $ * $Log: pform.h,v $
* Revision 1.68 2003/02/27 06:45:11 steve
* specparams as far as pform.
*
* Revision 1.67 2003/02/02 19:02:40 steve * Revision 1.67 2003/02/02 19:02:40 steve
* Add support for signed ports and nets. * Add support for signed ports and nets.
* *

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: pform_dump.cc,v 1.78 2003/01/26 21:15:59 steve Exp $" #ident "$Id: pform_dump.cc,v 1.79 2003/02/27 06:45:11 steve Exp $"
#endif #endif
# include "config.h" # include "config.h"
@ -738,6 +738,13 @@ void Module::dump(ostream&out) const
out << "/* ERROR */;" << endl; out << "/* ERROR */;" << endl;
} }
typedef map<string,PExpr*>::const_iterator specparm_iter_t;
for (specparm_iter_t cur = specparams.begin()
; cur != specparams.end() ; cur ++) {
out << " specparam " << (*cur).first << " = "
<< *(*cur).second << ";" << endl;
}
for (parm_hiter_t cur = defparms.begin() for (parm_hiter_t cur = defparms.begin()
; cur != defparms.end() ; cur ++) { ; cur != defparms.end() ; cur ++) {
out << " defparam " << (*cur).first << " = "; out << " defparam " << (*cur).first << " = ";
@ -856,6 +863,9 @@ void PUdp::dump(ostream&out) const
/* /*
* $Log: pform_dump.cc,v $ * $Log: pform_dump.cc,v $
* Revision 1.79 2003/02/27 06:45:11 steve
* specparams as far as pform.
*
* Revision 1.78 2003/01/26 21:15:59 steve * Revision 1.78 2003/01/26 21:15:59 steve
* Rework expression parsing and elaboration to * Rework expression parsing and elaboration to
* accommodate real/realtime values and expressions. * accommodate real/realtime values and expressions.