Design Example: Demo Display Unit Say we are given an arrangement of 8 LEDs in a diamond pattern, with the LED labelled 7 at the top of the diamond, then numbered down to 0 in the clockwise direction. (See diagram). We are told that the following behaviour is desired. When the START button is pressed, the system displays 10000000 on the LEDs (that is, LED 7 is lit, and all the rest are off). On every clock pulse, the LED to the left of the current lit LED lights up, and the LED that was lit is turned off. Thus, the LEDs are lit one at a time, in a counterclockwise direction. This continues until 11 clock cycles have passed, or until the user presses the REVERSE button. Then the LEDs are lit one at a time, moving now in the clockwise direction, until 11 clock cycles have passed, or until the user presses the REVERSE button. Then, the LED starts moving counterclockwise again. This process of moving counterclockwise, then clockwise, then counterclockwise, and so on continues until the user presses STOP, at which time the LEDs state however they were when STOP was pressed. This sort of display might be used in a gadget or toy as some kind of fancy display. Or, alternately, if the clock is fast enough, it might serve as a sort of randomizer. (In reality, this is a pretty contrived example, but a useful one). So we consider our overall system. As always, we break things up into control and datapath. The inputs to the controller consist of the top-level system inputs START, STOP, and REVERSE. The LEDs are driven by the datapath. At this point, we don t know enough about the datapath to determine what kind of signals we need between the controller and datapath. Copyright 2003 by Andrew W. H. House Page 1 of 7
So we must now design the datapath. Datapath Well, the behaviour of the system is such that it involves lighting up adjacent LEDs in either the left or right directions. Visually, it appears as if the lit LEDs is moving around the circle. We know of a basic component that allows bits to move to adjacent locations the shift register. So we can conclude that we probably need an 8-bit universal shift register. The shift register will load to the desired 10000000 patter when START is pressed, then shift either left or right to emulate the lit LED moving counterclockwise or clockwise. Not that to do this successfully, we need to hook up the least significant output of the shift register to the SIR (shift-in-right) input, and the most significant output to the SIL (shift-in-left) input to allow the bit to wrap around. We can build our 8-bit shift register out of two 74194 devices, or just assume it exists (see multiplier example). The shift register operation is set by the controller. The LEDs are driven directly by the outputs of the shift register. We also have to count until 11. This suggests a counter. A 4-bit counter will be sufficient. Because the counter starts counting at zero, we actually check to see when the counter has reached 10 before reloading. The loading of the counter to zeroes is controlled by the state machine. The outputs of the counter are used to send a signal to the controller as to how many clock cycles have passed. The datapath is fully drawn in the diagram on the next page. Copyright 2003 by Andrew W. H. House Page 2 of 7
Copyright 2003 by Andrew W. H. House Page 3 of 7
With the datapath designed, we can complete our top level diagram to show the communication between the controller and datapath. Controller Now we can design the controller for our system, since we know its inputs (START, STOP, REVERSE, CLK_11) and its outputs (S0, S1, and LOAD_CNT). We will start in an IDLE state. We can specify that this state holds the output to whatever it currently is, since nothing in our original specification said what the LEDs displayed before START is pressed. When START is pressed, we must load the counter, load the initial pattern into the shift register, and start shifting left until CLK_11 is high or REVERSE is high. Then, we start shifting right until CLK_11 is high or REVERSE is high, and so on. If STOP is pressed at any time after leaving the idle state, we return to idle on the next clock edge. The ASM chart for this algorithm is on the next page. Because there are only three states, and for the sake of a bit of variety from the other examples we ve covered in class, we will use one-hot design. Hence, we need three flip-flops to store the state variables: C k, B k, and A k. We will map the IDLE state to 001, LEFT to 010, and RIGHT to 100. Copyright 2003 by Andrew W. H. House Page 4 of 7
Copyright 2003 by Andrew W. H. House Page 5 of 7
From the ASM chart we can write the state sequences: Current State C k B k A k Next State C k+1 B k+1 A k+1 Conditions IDLE 001 IDLE 001 START LEFT 010 START LEFT 010 LEFT 010 STOP @CLK_11 @REVERSE RIGHT 100 STOP @(REVERSE + CLK_11) IDLE 001 STOP RIGHT 100 RIGHT 100 STOP @CLK_11 @REVERSE LEFT 010 STOP @(REVERSE + CLK_11) IDLE 001 STOP C k+1 = LEFT@STOP @(REVERSE + CLK_11) + RIGHT@STOP @CLK_11 @REVERSE = B k @STOP @(REVERSE + CLK_11) + A k @STOP @CLK_11 @REVERSE B k+1 = IDLE@START + LEFT@STOP @CLK_11 @REVERSE + RIGHT@STOP @(REVERSE + CLK_11) = A k @START + B k @STOP @CLK_11 @REVERSE + C k @STOP @(REVERSE + CLK_11) A k+1 = IDLE@START + LEFT@STOP + RIGHT@STOP = A k @START + STOP@(B k + C k ) The outputs can also be determined. S0 = IDLE@START + LEFT = A k @START + B k S1 = IDLE@START + RIGHT = A k @START + C k LOAD_CNT = IDLE@START + LEFT@STOP @(REVERSE + CLK_11) + RIGHT@STOP @(REVERSE + CLK_11) = A k @START + B k @STOP @(REVERSE + CLK_11) + C k @STOP @(REVERSE + CLK_11) We have reached the point where we can implement using 3 D-type flip-flops and basic logic gates. Copyright 2003 by Andrew W. H. House Page 6 of 7
Class notes by Andrew W. H. House, 02 December 2003. Copyright 2003 by Andrew W. H. House Page 7 of 7