Suppose we wish to measure the traffic at a point on a railroad track, counting the axle crossings in each direction. We set up a light beam just above the rails and place two photocells A and B some inches apart, as shown (looking from above):
![1432_d2.png](https://secure.tutorsglobe.com/CMSImages/1432_d2.png)
When the beam shines on a photocell, it produces a 0, and when the beam is interrupted, it produces a 1. Thus, when an axle crosses straight through from left to right, we read the following signals from A and B:
![1916_d1.png](https://secure.tutorsglobe.com/CMSImages/1916_d1.png)
(and the reverse for the opposite direction). Unfortunately, not all axles cross straight through, and an axle may turn back after going part way through. An axle may move back and forth within the scope of the beam. We wish to construct a synchronous finite-state machine taking its two inputs from A and B and producing two outputs X and Y such that
• normally, both outputs are 0;
• when an axle has crossed completely from left to right, X becomes 1 for exactly one clock period;
• when an axle has crossed completely from right to left, Y becomes 1 for exactly one clock period. (The pulses generated by X and Y could drive two counters, for example.) Assume that the only things that interrupt the light beams are axles, and that the clock is fast enough that we do not miss any transitions.
A. Draw a state-transition diagram for this FSM. Clearly label the inputs and out-puts.
B. Construct the state-transition table for your FSM.
C. Show an implementation for this FSM using D flip-flops and a ROM.
D. Suppose we need to notify the maintenance department periodically about wear and tear on the track, and further that X and Y drive another FSM with one output that goes from 0 to 1 after every 100,000 axle crossings (total, both directions). How many states must that FSM have? How many D flip-flops would be needed to implement that FSM?