finite-state machine for a system

38 Views Asked by At

Every cycle we get a bit $x_t$. We output $1$ iff $$(x_1\ldots x_t) \bmod 5 = 2 \lor (x_1\ldots x_t) \bmod 5 = 4$$

I need to design an FSM (preferably Mealy machine but that doesn't really matter. The idea is what important)

Of course we need $5$ states represent the remainder. Now, if the next bit is $0$ then it's essentaily doubling the number, and if the next bit is $1$ then it's doubling the number and adding $1$. How can I use this information to build the FSM? I haven't figured it out..

1

There are 1 best solutions below

0
On BEST ANSWER

Hint. As you said, your FSM has five states, $0$, $1$, $2$, $3$, $4$, corresponding to the possible values of $(x_1 \dotsm x_t)$ modulo $5$. As you observed, if the next bit is $0$, then the value of the number doubles, and if the next bit is $1$, then the value of the number is obtained by doubling and adding $1$.

Therefore, for each state $q$, you have two transitions $$ q \xrightarrow{0} 2q \quad \text{and} \quad q \xrightarrow{0} 2q+1 $$ where $2q$ and $2q + 1$ are of course computed modulo $5$.