diff options
author | Clifford Wolf <clifford@clifford.at> | 2014-01-19 04:18:22 +0100 |
---|---|---|
committer | Clifford Wolf <clifford@clifford.at> | 2014-01-19 04:18:22 +0100 |
commit | 9a1eb45c7517f224a2516ce235fd53d01d9ef908 (patch) | |
tree | bb049a5739784ba74c7574433cc0a7ab73d4b400 /frontends | |
parent | 3d7a1491aac0849a2a9fae2a06242e125de883d0 (diff) | |
download | yosys-9a1eb45c7517f224a2516ce235fd53d01d9ef908.tar.gz yosys-9a1eb45c7517f224a2516ce235fd53d01d9ef908.tar.bz2 yosys-9a1eb45c7517f224a2516ce235fd53d01d9ef908.zip |
Added Verilog parser support for asserts
Diffstat (limited to 'frontends')
-rw-r--r-- | frontends/ast/ast.cc | 1 | ||||
-rw-r--r-- | frontends/ast/ast.h | 1 | ||||
-rw-r--r-- | frontends/verilog/lexer.l | 2 | ||||
-rw-r--r-- | frontends/verilog/parser.y | 11 |
4 files changed, 12 insertions, 3 deletions
diff --git a/frontends/ast/ast.cc b/frontends/ast/ast.cc index 201584885..ecc58cf63 100644 --- a/frontends/ast/ast.cc +++ b/frontends/ast/ast.cc @@ -80,6 +80,7 @@ std::string AST::type2str(AstNodeType type) X(AST_CELLTYPE) X(AST_IDENTIFIER) X(AST_PREFIX) + X(AST_ASSERT) X(AST_FCALL) X(AST_TO_SIGNED) X(AST_TO_UNSIGNED) diff --git a/frontends/ast/ast.h b/frontends/ast/ast.h index 22853d0f9..6aaa90e86 100644 --- a/frontends/ast/ast.h +++ b/frontends/ast/ast.h @@ -58,6 +58,7 @@ namespace AST AST_CELLTYPE, AST_IDENTIFIER, AST_PREFIX, + AST_ASSERT, AST_FCALL, AST_TO_SIGNED, diff --git a/frontends/verilog/lexer.l b/frontends/verilog/lexer.l index 9e606d90f..81167cf4e 100644 --- a/frontends/verilog/lexer.l +++ b/frontends/verilog/lexer.l @@ -113,6 +113,8 @@ namespace VERILOG_FRONTEND { "generate" { return TOK_GENERATE; } "endgenerate" { return TOK_ENDGENERATE; } +"assert"([ \t\r\n]+"property")? { return TOK_ASSERT; } + "input" { return TOK_INPUT; } "output" { return TOK_OUTPUT; } "inout" { return TOK_INOUT; } diff --git a/frontends/verilog/parser.y b/frontends/verilog/parser.y index 874482d6e..b0c4db8ae 100644 --- a/frontends/verilog/parser.y +++ b/frontends/verilog/parser.y @@ -104,7 +104,7 @@ static void free_attr(std::map<std::string, AstNode*> *al) %token TOK_GENERATE TOK_ENDGENERATE TOK_GENVAR %token TOK_SYNOPSYS_FULL_CASE TOK_SYNOPSYS_PARALLEL_CASE %token TOK_SUPPLY0 TOK_SUPPLY1 TOK_TO_SIGNED TOK_TO_UNSIGNED -%token TOK_POS_INDEXED TOK_NEG_INDEXED +%token TOK_POS_INDEXED TOK_NEG_INDEXED TOK_ASSERT %type <ast> wire_type range non_opt_range expr basic_expr concat_list rvalue lvalue lvalue_concat_list %type <string> opt_label tok_prim_wrapper hierarchical_id @@ -366,7 +366,7 @@ module_body: module_body_stmt: task_func_decl | param_decl | localparam_decl | defparam_decl | wire_decl | assign_stmt | cell_stmt | - always_stmt | TOK_GENERATE module_gen_body TOK_ENDGENERATE | defattr; + always_stmt | TOK_GENERATE module_gen_body TOK_ENDGENERATE | defattr | assert; task_func_decl: TOK_TASK TOK_ID ';' { @@ -748,6 +748,11 @@ opt_label: $$ = NULL; }; +assert: + TOK_ASSERT '(' expr ')' ';' { + ast_stack.back()->children.push_back(new AstNode(AST_ASSERT, $3)); + }; + simple_behavioral_stmt: lvalue '=' expr { AstNode *node = new AstNode(AST_ASSIGN_EQ, $1, $3); @@ -760,7 +765,7 @@ simple_behavioral_stmt: // this production creates the obligatory if-else shift/reduce conflict behavioral_stmt: - defattr | wire_decl | + defattr | assert | wire_decl | simple_behavioral_stmt ';' | hierarchical_id attr { AstNode *node = new AstNode(AST_TCALL); |