1 / 12

Keypad BFM

Keypad BFM. +5V. Key pressed. ROW[0]. X. ROW[1]. ROW[2]. R2. R1. R1. R1. R2. R2. R2. R1. ROW[3]. +5V. COL[3]. COL[0]. COL[1]. COL[2]. 5V  0V. R. ?. Keypad BFM. module keypad (ROW, COL); input [3:0] ROW; output [3:0] COL; …. Keypad BFM (cont.). parameter R1 = 8200;

syshe
Télécharger la présentation

Keypad BFM

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Keypad BFM

  2. +5V Key pressed ROW[0] X ROW[1] ROW[2] R2 R1 R1 R1 R2 R2 R2 R1 ROW[3] +5V COL[3] COL[0] COL[1] COL[2] 5V0V R ? Keypad BFM module keypad (ROW, COL); input [3:0] ROW; output [3:0] COL; …

  3. Keypad BFM (cont.) parameter R1 = 8200; parameter R2 = 220; parameter C = 0.025; initial begin for (i = 0; i < 16; i = i+1) begin keystate[i] = 0; end on_delay = R2*C*(0.51); off_delay = R1*C*(0.51); end buffers buffs (COL, new_col);

  4. Keypad BFM (cont.) // bitwise ands assign new_col[3:0] = ~( ({4{(ROW[0] === 1'b0)}} & keystate[3:0]) |({4{(ROW[1] === 1'b0)}} & keystate[7:4]) |({4{(ROW[2] === 1'b0)}} & keystate[11:8]) |({4{(ROW[3] === 1'b0)}} & keystate[15:12]) ); wire row_test = (ROW[3] === 1'b0); // not used

  5. Keypad BFM (cont.) // keys task to define key states // for 16 keys of keypad task keys; input [3:0] key_no; input pressed; begin keystate[key_no] = pressed; end endtask endmodule

  6. Pressing a Key w/the BFM Assume module keypad has instance name kp1. Then, somewhere in the test module… `define tb test_bench `tb.kp1.keys(4,1); //press 4th key `tb.kp1.keys(4,0); //release 4th `tb.kp1.keys(9,1); //press 9th key `tb.kp1.keys(9,0); //release 9th `tb.kp1.keys(7,1); `tb.kp1.keys(14,1);

  7. Scanner Logic • Column signal rising delay is long due to pullup and switch+input buffer capacitance • Ghosting is possible if you sample keys too early… • LFSR counter provides ghosting and debounce delay

  8. Scanner Logic (2) • Scanning stops after key is debounced • KEY_RDY signal is asserted • KEY_RDY signal handshakes with KEY_RD_

  9. Scanner Logic (3) • KEY_DATA is updated at the point of key debounce complete • KEY_DATA is driven to target system with encoded key data corresponding to pressed key while KEY_RD_ is asserted • Auto_read module generates KEY_RD_ read strobe when KEY_RDY is asserted • By connecting AUTO_RD_ to KEY_RD_, key data is automatically read after a key has been detected • Scanning resumes after key is read by host system

  10. Using the Keypad BFM • Rows are sequentially driven either 0 or “z” • Columns are either “1” from pullup when no key is pressed or… • “0” when key is pressed at intersection of row and column • keystate register defines pressed keys…

  11. Using the Keypad BFM (2) • BFM allows modeling multiple asserted keys • keystate is declared as 16 bit register - bits are assigned value of “one” when key is pressed • Bit 0 of 16-bit register corresponds to row/col 00/00 • Key positions 0-3 are on first row (row 0), key positions 4-7 are on second row (row 1), etc.

  12. The End!

More Related