Skip to content

Commit

Permalink
parse functions and tasks and delay value lists.
Browse files Browse the repository at this point in the history
  • Loading branch information
steve committed May 30, 1999
1 parent 982cce6 commit 0ca5a28
Showing 1 changed file with 95 additions and 26 deletions.
121 changes: 95 additions & 26 deletions parse.y
Expand Up @@ -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 !defined(WINNT) #if !defined(WINNT)
#ident "$Id: parse.y,v 1.29 1999/05/29 02:36:17 steve Exp $" #ident "$Id: parse.y,v 1.30 1999/05/30 03:12:56 steve Exp $"
#endif #endif


# include "parse_misc.h" # include "parse_misc.h"
Expand Down Expand Up @@ -108,7 +108,8 @@ extern void lex_end_table();
%type <gate> gate_instance %type <gate> gate_instance
%type <gates> gate_instance_list %type <gates> gate_instance_list


%type <expr> delay delay_opt expression expr_primary %type <expr> delay delay_opt delay_value delay_value_list
%type <expr> expression expr_primary
%type <expr> lavalue lpvalue %type <expr> lavalue lpvalue
%type <exprs> expression_list %type <exprs> expression_list


Expand Down Expand Up @@ -177,37 +178,46 @@ case_items
; ;


delay delay
: '#' NUMBER : '#' delay_value
{ verinum*tmp = $2; { $$ = $2;
}
| '#' '(' delay_value_list ')'
{ $$ = $3;
}
;

delay_opt
: delay { $$ = $1; }
| { $$ = 0; }
;

delay_value
: NUMBER
{ verinum*tmp = $1;
if (tmp == 0) { if (tmp == 0) {
yyerror(@2, "XXXX internal error: delay."); yyerror(@1, "XXXX internal error: delay.");
$$ = 0; $$ = 0;
} else { } else {
$$ = new PENumber(tmp); $$ = new PENumber(tmp);
} }
} }
| '#' IDENTIFIER | IDENTIFIER
{ PEIdent*tmp = new PEIdent(*$2); { PEIdent*tmp = new PEIdent(*$1);
tmp->set_file(@2.text);
tmp->set_lineno(@2.first_line);
$$ = tmp;
delete $2;
}
| '#' '(' IDENTIFIER ')'
{ PEIdent*tmp = new PEIdent(*$3);
tmp->set_file(@1.text); tmp->set_file(@1.text);
tmp->set_lineno(@1.first_line); tmp->set_lineno(@1.first_line);
$$ = tmp; $$ = tmp;
delete $3; delete $1;
}
| '#' '(' expression ')'
{ $$ = $3;
} }
; ;


delay_opt delay_value_list
: delay { $$ = $1; } : delay_value
| { $$ = 0; } { $$ = $1; }
| delay_value_list ',' delay_value
{ yyerror(@1, "Sorry, delay value lists not supported.");
$$ = $1;
delete $3;
}
; ;


description description
Expand Down Expand Up @@ -448,9 +458,20 @@ expression
{ yyerror(@2, "Sorry, ?: operator not supported."); { yyerror(@2, "Sorry, ?: operator not supported.");
$$ = 0; $$ = 0;
} }
| '(' expression ':' expression ':' expression ')'
{ yyerror(@2, "Sorry, (min:typ:max) not supported.");
$$ = $4;
delete $2;
delete $6;
}
| IDENTIFIER '(' expression_list ')'
{ yyerror(@2, "Sorry, function calls not supported.");
$$ = 0;
}
; ;





expression_list expression_list
: expression_list ',' expression : expression_list ',' expression
{ svector<PExpr*>*tmp = new svector<PExpr*>(*$1, $3); { svector<PExpr*>*tmp = new svector<PExpr*>(*$1, $3);
Expand Down Expand Up @@ -522,6 +543,21 @@ expr_primary
} }
; ;



func_body
: function_item_list statement
;

function_item
: K_input range_opt list_of_variables ';'
| K_reg range_opt list_of_variables ';'
;

function_item_list
: function_item
| function_item_list function_item
;

/* A gate_instance is a module instantiation or a built in part /* A gate_instance is a module instantiation or a built in part
type. In any case, the gate has a set of connections to ports. */ type. In any case, the gate has a set of connections to ports. */
gate_instance gate_instance
Expand All @@ -534,6 +570,15 @@ gate_instance
delete $1; delete $1;
$$ = tmp; $$ = tmp;
} }
| IDENTIFIER '(' ')'
{ lgate*tmp = new lgate;
tmp->name = *$1;
tmp->parms = 0;
tmp->file = @1.text;
tmp->lineno = @1.first_line;
delete $1;
$$ = tmp;
}
| IDENTIFIER range '(' expression_list ')' | IDENTIFIER range '(' expression_list ')'
{ lgate*tmp = new lgate; { lgate*tmp = new lgate;
svector<PExpr*>*rng = $2; svector<PExpr*>*rng = $2;
Expand Down Expand Up @@ -775,9 +820,13 @@ module_item
| gatetype delay_opt gate_instance_list ';' | gatetype delay_opt gate_instance_list ';'
{ pform_makegates($1, $2, $3); { pform_makegates($1, $2, $3);
} }
| IDENTIFIER gate_instance_list ';' | IDENTIFIER delay_opt gate_instance_list ';'
{ pform_make_modgates(*$1, $2); { pform_make_modgates(*$1, $3);
delete $1; delete $1;
if ($2) {
yyerror(@2, "Sorry, parameter override not supported.");
delete $2;
}
} }
| K_assign lavalue '=' expression ';' | K_assign lavalue '=' expression ';'
{ PGAssign*tmp = pform_make_pgassign($2, $4); { PGAssign*tmp = pform_make_pgassign($2, $4);
Expand All @@ -795,10 +844,10 @@ module_item
tmp->set_file(@1.text); tmp->set_file(@1.text);
tmp->set_lineno(@1.first_line); tmp->set_lineno(@1.first_line);
} }
| K_task IDENTIFIER ';' statement K_endtask | K_task IDENTIFIER ';' task_body K_endtask
{ yyerror(@1, "Sorry, task declarations not supported."); { yyerror(@1, "Sorry, task declarations not supported.");
} }
| K_function range_or_type_opt IDENTIFIER ';' statement K_endfunction | K_function range_or_type_opt IDENTIFIER ';' func_body K_endfunction
{ yyerror(@1, "Sorry, function declarations not supported."); { yyerror(@1, "Sorry, function declarations not supported.");
} }
| KK_attribute '(' IDENTIFIER ',' STRING ',' STRING ')' ';' | KK_attribute '(' IDENTIFIER ',' STRING ',' STRING ')' ';'
Expand Down Expand Up @@ -1000,7 +1049,11 @@ register_variable_list
; ;


statement statement
: K_begin statement_list K_end : K_assign lavalue '=' expression ';'
{ yyerror(@1, "Sorry, proceedural continuous assign not supported.");
$$ = 0;
}
| K_begin statement_list K_end
{ $$ = pform_make_block(PBlock::BL_SEQ, $2); } { $$ = pform_make_block(PBlock::BL_SEQ, $2); }
| K_fork statement_list K_join | K_fork statement_list K_join
{ $$ = pform_make_block(PBlock::BL_PAR, $2); } { $$ = pform_make_block(PBlock::BL_PAR, $2); }
Expand Down Expand Up @@ -1137,6 +1190,22 @@ statement_opt
| ';' { $$ = 0; } | ';' { $$ = 0; }
; ;


task_body
: task_item_list statement
;

task_item
: K_input range_opt list_of_variables ';'
| K_output range_opt list_of_variables ';'
| K_inout range_opt list_of_variables ';'
| K_reg range_opt list_of_variables ';'
;

task_item_list
: task_item_list task_item
| task_item
;

udp_body udp_body
: K_table { lex_start_table(); } : K_table { lex_start_table(); }
udp_entry_list udp_entry_list
Expand Down

0 comments on commit 0ca5a28

Please sign in to comment.