0470185317 (2008) fpga prototyping by vhdl examples xilinx spartan 3 version

Page 406

SQUARE PROGRAM WITH A SWITCH AND SEVEN-SEGMENT LED DISPLAY INTERFACE

375

Figure 16.7 Input interface of a square circuit. fetch data, led1 output d a t a , ssegl-port fetch d a t a , led2 output d a t a , sseg2-port fetch data, led3 output d a t a , sseg3-port return

16.4.2 Input interface The input interface consists of an 8-bit switch and two 1-bit pushbuttons. The former is a continuous-access port since the value is always present. The latter is a single-access port since pressing a button leads to only a single event (e.g., loading a to the register once rather than continuously). Because of the mechanical glitches, a debouncing circuit is needed to generate a clean one-clock-cycle tick. Since PicoBlaze’s port can take up 8-bit data, inputs from the two pushbuttons can be grouped together as a single input port. The block diagram of the input interface is shown in Figure 16.7. The interface consists of two debouncing circuits, a two-to-one multiplexer, a decoding circuit, and two flag FFs. The function of the two flag FFs is discussed in Section 7.2.4. They provide a mechanism to set and clear the “button-pressing event.” When a button is pressed, the debouncing circuit’s output sets the flag. It remains asserted until it is retrieved by the PicoBlaze’s input instruction, which sets the selection signal of the multiplexer to route the desired value to PicoBlaze’s input port, and activates the clear signal. For clarity, we name the pushbutton 1 as the s button (for setting the value) and pushbutton 0 as the c button (for clearing the data RAM). The pseudo code to process the input is ;input the button flags ; i f c = l then


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.