Added support for notif0/notif1 primitives
authorJohann Glaser <Johann.Glaser@gmx.at>
Tue, 20 Aug 2013 09:23:59 +0000 (11:23 +0200)
committerJohann Glaser <Johann.Glaser@gmx.at>
Tue, 20 Aug 2013 09:23:59 +0000 (11:23 +0200)
frontends/ast/simplify.cc
frontends/verilog/lexer.l

index 1d381740b7973494c7f2ceca5dced915151c566a..5f0e6867700cf63e164184e1dc2ad08e7770f1f0 100644 (file)
@@ -498,7 +498,7 @@ bool AstNode::simplify(bool const_fold, bool at_zero, bool in_lvalue, int stage)
                }
                children.clear();
 
-               if (str == "bufif0" || str == "bufif1")
+               if (str == "bufif0" || str == "bufif1" || str == "notif0" || str == "notif1")
                {
                        if (children_list.size() != 3)
                                log_error("Invalid number of arguments for primitive `%s' at %s:%d!\n",
@@ -506,12 +506,16 @@ bool AstNode::simplify(bool const_fold, bool at_zero, bool in_lvalue, int stage)
 
                        std::vector<RTLIL::State> z_const(1, RTLIL::State::Sz);
 
+                       AstNode *mux_input = children_list.at(1);
+                       if (str == "notif0" || str == "notif1") {
+                               mux_input = new AstNode(AST_BIT_NOT, mux_input);
+                       }
                        AstNode *node = new AstNode(AST_TERNARY, children_list.at(2));
                        if (str == "bufif0") {
                                node->children.push_back(AstNode::mkconst_bits(z_const, false));
-                               node->children.push_back(children_list.at(1));
+                               node->children.push_back(mux_input);
                        } else {
-                               node->children.push_back(children_list.at(1));
+                               node->children.push_back(mux_input);
                                node->children.push_back(AstNode::mkconst_bits(z_const, false));
                        }
 
index e873f9d91a140a118ce2245b4515a8397949c964..bdd01cae52774f379e3c45569328fda24957a258 100644 (file)
@@ -169,7 +169,7 @@ namespace VERILOG_FRONTEND {
 }
 <STRING>.      { yymore(); }
 
-and|nand|or|nor|xor|xnor|not|buf|bufif0|bufif1 {
+and|nand|or|nor|xor|xnor|not|buf|bufif0|bufif1|notif0|notif1 {
        frontend_verilog_yylval.string = new std::string(yytext);
        return TOK_PRIMITIVE;
 }