We will first look at the simplest solution and then examine the assumptions that must be made for this to be valid. We will then add circuitry so as to make the system work for a more general case. The circuit of Figure 8.24 is our first attempt at a solution. No clear was provided. Once the system produces its last 1 output, the counter will be left with 0 in it; so there is no need to clear it. When x is 1, the D/U is set to 0, and the counter is enabled; thus, it counts up. When x returns to 0, it will count down, as long as it is enabled, that is, as long as there