Don't change existing binary FSM encoding if it is already optimal
authorClifford Wolf <clifford@clifford.at>
Sat, 30 Aug 2014 12:43:06 +0000 (14:43 +0200)
committerClifford Wolf <clifford@clifford.at>
Sat, 30 Aug 2014 12:43:06 +0000 (14:43 +0200)
passes/fsm/fsm_recode.cc

index 9c0da0a37c87de86fb8d5d9a0731c7985b30ea0a..ea10cdf801942fd0180a8a1c2dc4034136b6873f 100644 (file)
@@ -82,7 +82,12 @@ static void fsm_recode(RTLIL::Cell *cell, RTLIL::Module *module, FILE *fm_set_fs
                fsm_data.state_bits = fsm_data.state_table.size();
        } else
        if (encoding == "binary") {
-               fsm_data.state_bits = ceil(log2(fsm_data.state_table.size()));
+               int new_num_state_bits = ceil(log2(fsm_data.state_table.size()));
+               if (fsm_data.state_bits == new_num_state_bits) {
+                       log("  existing encoding is already a packed binary encoding.\n");
+                       return;
+               }
+               fsm_data.state_bits = new_num_state_bits;
        } else
                log_error("FSM encoding `%s' is not supported!\n", encoding.c_str());