Fixed hex string generation bug in edif backend
authorClifford Wolf <clifford@clifford.at>
Sun, 27 Oct 2013 07:21:05 +0000 (08:21 +0100)
committerClifford Wolf <clifford@clifford.at>
Sun, 27 Oct 2013 07:21:05 +0000 (08:21 +0100)
backends/edif/edif.cc

index f898dc6d757324c4bbfac5a97e63727bc002b18e..fe6e7bade28b4224bf0cc7cd7f8556afbe69849a 100644 (file)
@@ -250,10 +250,10 @@ struct EdifBackend : public Backend {
                                                std::string hex_string = "";
                                                for (size_t i = 0; i < p.second.bits.size(); i += 4) {
                                                        int digit_value = 0;
-                                                       if (i+0 < p.second.bits.size() && p.second.bits.at(i+0) == RTLIL::State::S1) digit_value += 1;
-                                                       if (i+1 < p.second.bits.size() && p.second.bits.at(i+1) == RTLIL::State::S1) digit_value += 2;
-                                                       if (i+2 < p.second.bits.size() && p.second.bits.at(i+2) == RTLIL::State::S1) digit_value += 3;
-                                                       if (i+3 < p.second.bits.size() && p.second.bits.at(i+3) == RTLIL::State::S1) digit_value += 4;
+                                                       if (i+0 < p.second.bits.size() && p.second.bits.at(i+0) == RTLIL::State::S1) digit_value |= 1;
+                                                       if (i+1 < p.second.bits.size() && p.second.bits.at(i+1) == RTLIL::State::S1) digit_value |= 2;
+                                                       if (i+2 < p.second.bits.size() && p.second.bits.at(i+2) == RTLIL::State::S1) digit_value |= 4;
+                                                       if (i+3 < p.second.bits.size() && p.second.bits.at(i+3) == RTLIL::State::S1) digit_value |= 8;
                                                        char digit_str[2] = { "0123456789abcdef"[digit_value], 0 };
                                                        hex_string = std::string(digit_str) + hex_string;
                                                }