Added $dffe support to write_verilog
authorClifford Wolf <clifford@clifford.at>
Fri, 19 Dec 2014 23:03:20 +0000 (00:03 +0100)
committerClifford Wolf <clifford@clifford.at>
Fri, 19 Dec 2014 23:03:20 +0000 (00:03 +0100)
backends/verilog/verilog_backend.cc

index 7d08cc4e0196ec4cd44688aca49cd9d351ca6c0f..9e8342ab9d7fd59efdd3d807403c2bdd62c366f6 100644 (file)
@@ -664,10 +664,10 @@ bool dump_cell_expr(std::ostream &f, std::string indent, RTLIL::Cell *cell)
                return true;
        }
 
-       if (cell->type == "$dff" || cell->type == "$adff")
+       if (cell->type == "$dff" || cell->type == "$adff" || cell->type == "$dffe")
        {
-               RTLIL::SigSpec sig_clk, sig_arst, val_arst;
-               bool pol_clk, pol_arst = false;
+               RTLIL::SigSpec sig_clk, sig_arst, sig_en, val_arst;
+               bool pol_clk, pol_arst = false, pol_en = false;
 
                sig_clk = cell->getPort("\\CLK");
                pol_clk = cell->parameters["\\CLK_POLARITY"].as_bool();
@@ -678,6 +678,11 @@ bool dump_cell_expr(std::ostream &f, std::string indent, RTLIL::Cell *cell)
                        val_arst = RTLIL::SigSpec(cell->parameters["\\ARST_VALUE"]);
                }
 
+               if (cell->type == "$dffe") {
+                       sig_en = cell->getPort("\\EN");
+                       pol_en = cell->parameters["\\EN_POLARITY"].as_bool();
+               }
+
                std::string reg_name = cellname(cell);
                bool out_is_reg_wire = is_reg_wire(cell->getPort("\\Q"), reg_name);
 
@@ -702,6 +707,12 @@ bool dump_cell_expr(std::ostream &f, std::string indent, RTLIL::Cell *cell)
                        f << stringf("%s" "  else\n", indent.c_str());
                }
 
+               if (cell->type == "$dffe") {
+                       f << stringf("%s" "  if (%s", indent.c_str(), pol_en ? "" : "!");
+                       dump_sigspec(f, sig_en);
+                       f << stringf(")\n");
+               }
+
                f << stringf("%s" "    %s <= ", indent.c_str(), reg_name.c_str());
                dump_cell_expr_port(f, cell, "D", false);
                f << stringf(";\n");