← ProblemsCircuits / Sequential Logic / Finite State Machines

Serial two's complementer (Mealy)

15%fsmfsm-design

Implement the same serial two's complementer as the previous problem, but this time as a Mealy machine with only two states. The input x delivers a number one bit per cycle, LSB first; the output z is the two's complement of the stream, produced in the same cycle as the corresponding input bit (combinational output).

The bit-serial negation rule: copy every bit up to and including the first 1; invert every bit after it. That gives:

StateMeaningznext state
Ano 1 seen yetz = xx=1 → B, x=0 → A
Ba 1 has been seenz = ~xB (stay forever)

The machine has an asynchronous, active-low reset resetn that returns it to state A.