diff options
Diffstat (limited to 'frontends')
-rw-r--r-- | frontends/ast/simplify.cc | 2 | ||||
-rw-r--r-- | frontends/ilang/lexer.l | 24 |
2 files changed, 24 insertions, 2 deletions
diff --git a/frontends/ast/simplify.cc b/frontends/ast/simplify.cc index 9b8ed7603..bc5dec7b9 100644 --- a/frontends/ast/simplify.cc +++ b/frontends/ast/simplify.cc @@ -1065,7 +1065,7 @@ skip_dynamic_range_lvalue_expansion:; { AstNode *buf = children[0]->clone(); while (buf->simplify(true, false, false, stage, width_hint, sign_hint)) { } - if (!buf->type == AST_CONSTANT) + if (buf->type != AST_CONSTANT) log_error("Failed to evaluate system function `%s' with non-constant value at %s:%d.\n", str.c_str(), filename.c_str(), linenum); RTLIL::Const arg_value = buf->bitsAsConst(); diff --git a/frontends/ilang/lexer.l b/frontends/ilang/lexer.l index d582d0413..fd842b3dc 100644 --- a/frontends/ilang/lexer.l +++ b/frontends/ilang/lexer.l @@ -25,6 +25,7 @@ %{ #include "kernel/rtlil.h" #include "parser.tab.h" +void update_autoidx(const char *p); %} %option yylineno @@ -68,7 +69,7 @@ [a-z]+ { return TOK_INVALID; } "\\"[^ \t\r\n]+ { rtlil_frontend_ilang_yylval.string = strdup(yytext); return TOK_ID; } -"$"[^ \t\r\n]+ { rtlil_frontend_ilang_yylval.string = strdup(yytext); return TOK_ID; } +"$"[^ \t\r\n]+ { rtlil_frontend_ilang_yylval.string = strdup(yytext); update_autoidx(yytext); return TOK_ID; } "."[0-9]+ { rtlil_frontend_ilang_yylval.string = strdup(yytext); return TOK_ID; } [0-9]+'[01xzm-]* { rtlil_frontend_ilang_yylval.string = strdup(yytext); return TOK_VALUE; } @@ -116,6 +117,27 @@ %% +void update_autoidx(const char *p) +{ + if (*p != '$') + return; + + while (*p) { + if (*(p++) != '$') + continue; + if ('0' <= *p && *p <= '9') { + const char *q = p; + while ('0' <= *q && *q <= '9') + q++; + if ((q - p) < 10) { + int idx = atoi(p); + if (idx > RTLIL::autoidx) + RTLIL::autoidx = idx; + } + } + } +} + // this is a hack to avoid the 'yyinput defined but not used' error msgs void *rtlil_frontend_ilang_avoid_input_warnings() { return (void*)&yyinput; |