diff options
author | Jeff Wang <jjj11x@gmail.com> | 2020-02-03 01:12:24 -0500 |
---|---|---|
committer | Jeff Wang <jeff.wang@utexas.edu> | 2020-02-17 04:42:42 -0500 |
commit | d12ba42a741464d410773471813d0a78a7ae1db2 (patch) | |
tree | 218359053ff4c633932531a279cc8635244b88ec /frontends/verilog | |
parent | 6320f2692bc97d9d447622c1ba55a90cfe9dd411 (diff) | |
download | yosys-d12ba42a741464d410773471813d0a78a7ae1db2.tar.gz yosys-d12ba42a741464d410773471813d0a78a7ae1db2.tar.bz2 yosys-d12ba42a741464d410773471813d0a78a7ae1db2.zip |
add attributes for enumerated values in ilang
- information also useful for strongly-typed enums (not implemented)
- resolves enum values in ilang part of #1594
- still need to output enums to VCD (or better yet FST) files
Diffstat (limited to 'frontends/verilog')
-rw-r--r-- | frontends/verilog/verilog_parser.y | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/frontends/verilog/verilog_parser.y b/frontends/verilog/verilog_parser.y index ea0a09599..f25a8de28 100644 --- a/frontends/verilog/verilog_parser.y +++ b/frontends/verilog/verilog_parser.y @@ -1243,9 +1243,12 @@ single_defparam_decl: }; enum_type: TOK_ENUM { + static int enum_count; // create parent node for the enum astbuf2 = new AstNode(AST_ENUM); ast_stack.back()->children.push_back(astbuf2); + astbuf2->str = std::string("$enum"); + astbuf2->str += std::to_string(enum_count++); // create the template for the names astbuf1 = new AstNode(AST_ENUM_ITEM); astbuf1->children.push_back(AstNode::mkconst_int(0, true)); @@ -1254,6 +1257,7 @@ enum_type: TOK_ENUM { delete astbuf1; astbuf1 = tnode; tnode->type = AST_WIRE; + tnode->attributes["\\enum_type"] = AstNode::mkconst_str(astbuf2->str); // drop constant but keep any range delete tnode->children[0]; tnode->children.erase(tnode->children.begin()); } @@ -1311,7 +1315,10 @@ enum_var: TOK_ID { } ; -enum_decl: enum_type enum_var_list ';' { delete astbuf1; } +enum_decl: enum_type enum_var_list ';' { + //enum_type creates astbuf1 for use by typedef only + delete astbuf1; + } ; wire_decl: |