Much expression parsing work,

mark continuous assigns with source line info,
 replace some assertion failures with Sorry messages.
This commit is contained in:
steve 1999-05-20 04:31:45 +00:00
parent fe8ca1f72f
commit 0352864470
4 changed files with 82 additions and 12 deletions

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: elaborate.cc,v 1.26 1999/05/16 05:08:42 steve Exp $"
#ident "$Id: elaborate.cc,v 1.27 1999/05/20 04:31:45 steve Exp $"
#endif
/*
@ -179,6 +179,21 @@ void PGAssign::elaborate(Design*des, const string&path) const
{
NetNet*lval = pin(0)->elaborate_net(des, path);
NetNet*rval = pin(1)->elaborate_net(des, path);
if (lval == 0) {
cerr << get_line() << ": Unable to elaborate l-value: " <<
*pin(0) << endl;
des->errors += 1;
return;
}
if (rval == 0) {
cerr << get_line() << ": Unable to elaborate r-value: " <<
*pin(1) << endl;
des->errors += 1;
return;
}
assert(lval && rval);
do_assign(des, path, lval, rval);
@ -752,7 +767,11 @@ NetExpr*PEIdent::elaborate_expr(Design*des, const string&path) const
if (NetNet*net = des->find_signal(name)) {
NetESignal*node = des->get_esignal(net);
assert(idx_ == 0);
assert(lsb_ == 0);
if (lsb_) {
cerr << get_line() << ": Sorry, I cannot yet elaborate "
"bit ranges in this context." << endl;
des->errors += 1;
}
if (msb_) {
NetExpr*ex = msb_->elaborate_expr(des, path);
NetESubSignal*ss = new NetESubSignal(node, ex);
@ -1150,6 +1169,11 @@ Design* elaborate(const map<string,Module*>&modules,
/*
* $Log: elaborate.cc,v $
* Revision 1.27 1999/05/20 04:31:45 steve
* Much expression parsing work,
* mark continuous assigns with source line info,
* replace some assertion failures with Sorry messages.
*
* Revision 1.26 1999/05/16 05:08:42 steve
* Redo constant expression detection to happen
* after parsing.

47
parse.y
View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: parse.y,v 1.26 1999/05/16 05:08:42 steve Exp $"
#ident "$Id: parse.y,v 1.27 1999/05/20 04:31:45 steve Exp $"
#endif
# include "parse_misc.h"
@ -71,7 +71,8 @@ extern void lex_end_table();
%token K_initial K_inout K_input K_integer K_join K_large K_macromodule
%token K_medium K_module K_nand K_negedge K_nmos K_nor K_not K_notif0
%token K_notif1 K_or K_output K_parameter K_pmos K_posedge K_primitive
%token K_pull0 K_pull1 K_pulldown K_pullup K_rcmos K_reg K_release K_repeat
%token K_pull0 K_pull1 K_pulldown K_pullup K_rcmos K_real K_realtime
%token K_reg K_release K_repeat
%token K_rnmos K_rpmos K_rtran K_rtranif0 K_rtranif1 K_scalered
%token K_small K_specify
%token K_specparam K_strong0 K_strong1 K_supply0 K_supply1 K_table K_task
@ -115,6 +116,7 @@ extern void lex_end_table();
%type <statement> statement statement_opt
%type <statement_list> statement_list
%left '?' ':'
%left K_LOR
%left K_LAND
%left '|'
@ -192,6 +194,9 @@ delay
$$ = tmp;
delete $3;
}
| '#' '(' expression ')'
{ $$ = $3;
}
;
delay_opt
@ -271,15 +276,27 @@ expression
delete $2;
$$ = tmp;
}
| '~' expression %prec UNARY_PREC
| '+' expr_primary %prec UNARY_PREC
{ $$ = new PEUnary('+', $2);
}
| '-' expr_primary %prec UNARY_PREC
{ $$ = new PEUnary('-', $2);
}
| '~' expr_primary %prec UNARY_PREC
{ $$ = new PEUnary('~', $2);
}
| '&' expression %prec UNARY_PREC
| '&' expr_primary %prec UNARY_PREC
{ $$ = new PEUnary('&', $2);
}
| '!' expression %prec UNARY_PREC
| '!' expr_primary %prec UNARY_PREC
{ $$ = new PEUnary('!', $2);
}
| '|' expr_primary %prec UNARY_PREC
{ $$ = new PEUnary('|', $2);
}
| '^' expr_primary %prec UNARY_PREC
{ $$ = new PEUnary('^', $2);
}
| expression '^' expression
{ $$ = new PEBinary('^', $1, $3);
}
@ -340,6 +357,10 @@ expression
| expression K_LAND expression
{ $$ = new PEBinary('a', $1, $3);
}
| expression '?' expression ':' expression
{ yyerror(@2, "Sorry, ?: operator not supported.");
$$ = 0;
}
;
@ -667,7 +688,10 @@ module_item
delete $1;
}
| K_assign lavalue '=' expression ';'
{ pform_make_pgassign($2, $4); }
{ PGAssign*tmp = pform_make_pgassign($2, $4);
tmp->set_file(@1.text);
tmp->set_lineno(@1.first_line);
}
| K_assign error '=' expression ';'
| K_always statement
{ PProcess*tmp = pform_make_behavior(PProcess::PR_ALWAYS, $2);
@ -682,6 +706,9 @@ module_item
| K_task IDENTIFIER ';' statement K_endtask
{ yyerror(@1, "Sorry, task declarations not supported.");
}
| K_function range_or_type_opt IDENTIFIER ';' statement K_endfunction
{ yyerror(@1, "Sorry, function declarations not supported.");
}
| KK_attribute '(' IDENTIFIER ',' STRING ',' STRING ')' ';'
{ pform_set_attrib(*$3, *$5, *$7);
delete $3;
@ -816,6 +843,14 @@ range_opt
| { $$ = 0; }
;
range_or_type_opt
: range { }
| K_integer
| K_real
| K_realtime
| K_time
|
;
/* The register_variable rule is matched only when I am parsing
variables in a "reg" definition. I therefore know that I am
creating registers and I do not need to let the containing rule

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: pform.cc,v 1.18 1999/05/16 05:08:42 steve Exp $"
#ident "$Id: pform.cc,v 1.19 1999/05/20 04:31:45 steve Exp $"
#endif
# include "pform.h"
@ -304,13 +304,14 @@ void pform_make_modgates(const string&type, svector<lgate>*gates)
delete gates;
}
void pform_make_pgassign(PExpr*lval, PExpr*rval)
PGAssign* pform_make_pgassign(PExpr*lval, PExpr*rval)
{
svector<PExpr*> wires (2);
wires[0] = lval;
wires[1] = rval;
PGAssign*cur = new PGAssign(wires);
cur_module->add_gate(cur);
return cur;
}
void pform_makewire(const string&name, NetNet::Type type)
@ -516,6 +517,11 @@ int pform_parse(const char*path, map<string,Module*>&modules,
/*
* $Log: pform.cc,v $
* Revision 1.19 1999/05/20 04:31:45 steve
* Much expression parsing work,
* mark continuous assigns with source line info,
* replace some assertion failures with Sorry messages.
*
* Revision 1.18 1999/05/16 05:08:42 steve
* Redo constant expression detection to happen
* after parsing.

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: pform.h,v 1.14 1999/05/16 05:08:42 steve Exp $"
#ident "$Id: pform.h,v 1.15 1999/05/20 04:31:45 steve Exp $"
#endif
# include "netlist.h"
@ -126,7 +126,7 @@ extern void pform_makegates(PGBuiltin::Type type,
extern void pform_make_modgates(const string&type, svector<lgate>*gates);
/* Make a continuous assignment node, with optional bit- or part- select. */
extern void pform_make_pgassign(PExpr*lval, PExpr*rval);
extern PGAssign* pform_make_pgassign(PExpr*lval, PExpr*rval);
/*
* These are functions that the outside-the-parser code uses the do
@ -140,6 +140,11 @@ extern void pform_dump(ostream&out, Module*mod);
/*
* $Log: pform.h,v $
* Revision 1.15 1999/05/20 04:31:45 steve
* Much expression parsing work,
* mark continuous assigns with source line info,
* replace some assertion failures with Sorry messages.
*
* Revision 1.14 1999/05/16 05:08:42 steve
* Redo constant expression detection to happen
* after parsing.