Date: Wed, 08 Jan 1997 21:43:00 GMT Server: NCSA/1.4.2 Content-type: text/html
Distributed: Oct 18
Schematics/Simulation Due: TA opt
(Constructed circuit Due: TA opt)
(Functional circuit Due: TA opt)
Note: Although the tutorial is rather complete, you may need to look in the Synario manuals in the lab to answer questions you may have or to use more advanced features.
Note: You will not be following the tutorial exactly, but we will let you know where things diverge.
The figure below shows the components of your system:
(Figure 1)
The keypad has nine wires: one for each column (5 through 8), one for each row (1 through 4), and a common wire (9) to be connected to ground (this is the common connection for all the switches). When a key is pressed the corresponding column and row wires are connected to the common signal (see the figure below). Therefore, the keypad is called a 2-of-8, 2 of the 8 wires will be active low when a key is pressed, the others are pulled high through resistor connections to 5v.
The first part of the task is to convert the 2-of-8-bit value from the keypad wires into a 4-bit value plus a "ready" bit. The 4-bit value encodes the key pressed into a binary number (0000 to 1101 for 0 through 9 followed by A, B, C, and D; 1110 for *; and 1111 for #). The ready bit is synchronized to the clock and is asserted high for one cycle indicating that a key has been pressed. The rest of your circuit will collect two 4-bit values and send them serially according to our protocal across the link to the LCD display circuit. Also, you will need to latch (i.e., store in a register) the first key pressed while you wait for the second so it might be a good idea to just latch both (this can be done with one or two `373s).
The display you will be using has a very straightforward interface. It takes instructions or data depending on the value of the RS wire. The table below shows the instructions you will be using. Four instructions are required to initialize the display for the configuration we require (a 1 line by 16 character display). These are shown in the first four lines of the table. So your control logic must be sure to issue these instructions whenever it is reset.
After reset, all you need to do is write characters to the display (the fifth line in the table). These will be displayed immediately by the display unit. Finally, you will hit the reset switch again and start entering a new number. You can find the character codes in the display documentation.
Operation RS R/W DB7...DB0 Clear Display 0 0 0000 0001 Function Set 0 0 0011 00** Display ON 0 0 0000 1100 Entry Mode Set 0 0 0000 0110 Write Character 1 0 DDDD DDDD Backspace 0 0 0001 00** Return Home 0 0 0000 000* Read Character 1 1 DDDD DDDDThe timing constraints that must be satisfied when writing information into the display are quite straightforward. Basically, the display samples the RS line on the rising edge of the enable signal (E) and DB lines on the falling edge of E. To keep things simple, the set up and hold time for RS should be one cycle before and after the rising edge of E, respectively. Similarly for the DB lines and the falling edge of E. The only other timing information of importance is to allow up to 1.6ms for the display to actually clear (the internal controllers takes some time to actually go and enter 0s in the internal memory of the display unit).
Since your project does not need to perform read operations, the R/W control line can be tied directly to GND. For normal character write operations, the RS signal should be 1. To execute a command, the RS signal should be 0. The easiest way to perform a write is by asserting the enable signal (E) for one clock cycle during which RS and data are both stable. You must ensure that the number code is stable while this is happening. This shouldn't be a problem as a key press takes a lot longer than your circuit will need. However, you should ensure that RS is stable for a cycle before and after the write operation is performed. You will need to do this in your controller's finite state machine. Since the Enable signal is used to clock data into the display, it should be hazard-free (no spurious glitches). The easiest way to ensure this is to make it a direct output of a flip-flop in the PLD.
NOTES:
You should simulate your designs separately as best you can, and then combine the two projects using a new top-level schematic. (Start a new project then import the pieces of the two projects.) To simulate the complete design, you will need to provide the keypad stimulus, which is easy to do on eight inputs, and you will need to check that the commands to the LCD display are correct. For now, you will just have to check this by hand.
Here is an example of a Verilog test fixture which uses one process to set the "test vectors" and a separate process to generate a free-running clock:
// Consistently set the timescale (1 ns) and the precision (1 ns) // Should be set in the top level file (here) because it may be // defaulted differently in separate submodules `timescale 1 ns/1 ns // Declare the toplevel module name module t; // Include the interface to the schematic and ABEL source `include "keypad.tfi" // Initialize the inputs. Then form input stimuli. // Because of the way the clock is structured, // it is safe to change inputs at times: 0, 100, 200, 300, etc. initial begin CLK = 0; RESET = 1; {R0,R1,R2,R3} = 0; {C0,C1,C2,C3} = 0; #200 RESET = 0; #1000 {R0,R1,R2,R3} = {1,0,0,0}; {C0,C1,C2,C3} = {0,1,0,0}; #300 {R0,R1,R2,R3} = {0,0,0,0}; {C0,C1,C2,C3} = {0,0,0,0}; #300 {R0,R1,R2,R3} = {0,0,1,0}; {C0,C1,C2,C3} = {0,0,0,1}; #300 {R0,R1,R2,R3} = {0,0,0,0}; {C0,C1,C2,C3} = {0,0,0,0}; end // This clock has a period of 100 ns. The rising edges occur at // times 50, 150, 250, etc. always begin #50 CLK = 1; #50 CLK = 0; end endmodule