cxxrtl: Fix handling of unclocked memory read ports
authorDavid Shah <dave@ds0.me>
Tue, 14 Apr 2020 19:39:13 +0000 (20:39 +0100)
committerDavid Shah <dave@ds0.me>
Tue, 14 Apr 2020 19:39:13 +0000 (20:39 +0100)
Signed-off-by: David Shah <dave@ds0.me>
backends/cxxrtl/cxxrtl.cc

index 3263f03fdc4b000abbdd42f497462be1323aa1e7..d1a855bf0f3f3c6254c2c61773e30420b2a74710 100644 (file)
@@ -871,7 +871,8 @@ struct CxxrtlWorker {
                        dump_sigspec_rhs(cell->getPort(ID(ADDR)));
                        f << ", " << memory->start_offset << ", " << memory->size << ");\n";
                        if (cell->type == ID($memrd)) {
-                               if (!cell->getPort(ID(EN)).is_fully_ones()) {
+                               bool has_enable = cell->getParam(ID(CLK_ENABLE)).as_bool() && !cell->getPort(ID(EN)).is_fully_ones();
+                               if (has_enable) {
                                        f << indent << "if (";
                                        dump_sigspec_rhs(cell->getPort(ID(EN)));
                                        f << ") {\n";
@@ -930,7 +931,7 @@ struct CxxrtlWorker {
                                        f << " = value<" << memory->width << "> {};\n";
                                dec_indent();
                                f << indent << "}\n";
-                               if (!cell->getPort(ID(EN)).is_fully_ones()) {
+                               if (has_enable) {
                                        dec_indent();
                                        f << indent << "}\n";
                                }