# Pastebin VqvkowFI def state_string(fsm): fsm.finalize() longest_state = 0 for s in fsm.actions: longest_state = max(longest_state, len(s)) fsm.state_string = Signal(8 * longest_state, name="state_string") for s, i in fsm.encoding.items(): s_padded = s+'\0'*(longest_state-len(s)) print(repr(s_padded)) fsm.comb += [ If(fsm.state == i, *(fsm.state_string[j*8:(j+1)*8].eq(ord(b)) for j, b in enumerate(list(reversed(s_padded)))) ), ]