找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 3257|回复: 0
打印 上一主题 下一主题
收起左侧

VHDL键盘码

[复制链接]
跳转到指定楼层
楼主
ID:71407 发表于 2015-1-1 17:42 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
  1. `resetall
  2. `timescale 1ns/100ps

  3. `define TOTAL_BITS   11
  4. `define EXTEND_CODE  16'hE0
  5. `define RELEASE_CODE 16'hF0
  6. `define LEFT_SHIFT   16'h12
  7. `define RIGHT_SHIFT  16'h59


  8. module ps2_keyboard_interface (
  9.   clk,
  10.   reset,
  11.   ps2_clk,
  12.   ps2_data,
  13.   rx_extended,
  14.   rx_released,
  15.   rx_shift_key_on,
  16.   rx_scan_code,
  17.   rx_ascii,
  18.   rx_data_ready,       // rx_read_o
  19.   rx_read,             // rx_read_ack_i
  20.   tx_data,
  21.   tx_write,
  22.   tx_write_ack_o,
  23.   tx_error_no_keyboard_ack
  24.   );

  25. // Parameters

  26. // The timer value can be up to (2^bits) inclusive.
  27. parameter TIMER_60USEC_VALUE_PP = 2950; // Number of sys_clks for 60usec.
  28. parameter TIMER_60USEC_BITS_PP  = 12;   // Number of bits needed for timer
  29. parameter TIMER_5USEC_VALUE_PP = 186;   // Number of sys_clks for debounce
  30. parameter TIMER_5USEC_BITS_PP  = 8;     // Number of bits needed for timer
  31. parameter TRAP_SHIFT_KEYS_PP = 0;       // Default: No shift key trap.

  32. // State encodings, provided as parameters
  33. // for flexibility to the one instantiating the module.
  34. // In general, the default values need not be changed.

  35. // State "m1_rx_clk_l" has been chosen on purpose.  Since the input
  36. // synchronizing flip-flops initially contain zero, it takes one clk
  37. // for them to update to reflect the actual (idle = high) status of
  38. // the I/O lines from the keyboard.  Therefore, choosing 0 for m1_rx_clk_l
  39. // allows the state machine to transition to m1_rx_clk_h when the true
  40. // values of the input signals become present at the outputs of the
  41. // synchronizing flip-flops.  This initial transition is harmless, and it
  42. // eliminates the need for a "reset" pulse before the interface can operate.

  43. parameter m1_rx_clk_h = 1;
  44. parameter m1_rx_clk_l = 0;
  45. parameter m1_rx_falling_edge_marker = 13;
  46. parameter m1_rx_rising_edge_marker = 14;
  47. parameter m1_tx_force_clk_l = 3;
  48. parameter m1_tx_first_wait_clk_h = 10;
  49. parameter m1_tx_first_wait_clk_l = 11;
  50. parameter m1_tx_reset_timer = 12;
  51. parameter m1_tx_wait_clk_h = 2;
  52. parameter m1_tx_clk_h = 4;
  53. parameter m1_tx_clk_l = 5;
  54. parameter m1_tx_wait_keyboard_ack = 6;
  55. parameter m1_tx_done_recovery = 7;
  56. parameter m1_tx_error_no_keyboard_ack = 8;
  57. parameter m1_tx_rising_edge_marker = 9;
  58. parameter m2_rx_data_ready = 1;
  59. parameter m2_rx_data_ready_ack = 0;

  60.   
  61. // I/O declarations
  62. input clk;
  63. input reset;
  64. inout ps2_clk;
  65. inout ps2_data;
  66. output rx_extended;
  67. output rx_released;
  68. output rx_shift_key_on;
  69. output [7:0] rx_scan_code;
  70. output [7:0] rx_ascii;
  71. output rx_data_ready;
  72. input rx_read;
  73. input [7:0] tx_data;
  74. input tx_write;
  75. output tx_write_ack_o;
  76. output tx_error_no_keyboard_ack;

  77. reg rx_extended;
  78. reg rx_released;
  79. reg [7:0] rx_scan_code;
  80. reg [7:0] rx_ascii;
  81. reg rx_data_ready;
  82. reg tx_error_no_keyboard_ack;

  83. // Internal signal declarations
  84. wire timer_60usec_done;
  85. wire timer_5usec_done;
  86. wire extended;
  87. wire released;
  88. wire shift_key_on;

  89.                          // NOTE: These two signals used to be one.  They
  90.                          //       were split into two signals because of
  91.                          //       shift key trapping.  With shift key
  92.                          //       trapping, no event is generated externally,
  93.                          //       but the "hold" data must still be cleared
  94.                          //       anyway regardless, in preparation for the
  95.                          //       next scan codes.
  96. wire rx_output_event;    // Used only to clear: hold_released, hold_extended
  97. wire rx_output_strobe;   // Used to produce the actual output.

  98. wire tx_parity_bit;
  99. wire rx_shifting_done;
  100. wire tx_shifting_done;
  101. wire [11:0] shift_key_plus_code;

  102. reg [`TOTAL_BITS-1:0] q;
  103. reg [3:0] m1_state;
  104. reg [3:0] m1_next_state;
  105. reg m2_state;
  106. reg m2_next_state;
  107. reg [3:0] bit_count;
  108. reg enable_timer_60usec;
  109. reg enable_timer_5usec;
  110. reg [TIMER_60USEC_BITS_PP-1:0] timer_60usec_count;
  111. reg [TIMER_5USEC_BITS_PP-1:0] timer_5usec_count;
  112. reg [7:0] ascii;      // "REG" type only because a case statement is used.
  113. reg left_shift_key;
  114. reg right_shift_key;
  115. reg hold_extended;    // Holds prior value, cleared at rx_output_strobe
  116. reg hold_released;    // Holds prior value, cleared at rx_output_strobe
  117. reg ps2_clk_s;        // Synchronous version of this input
  118. reg ps2_data_s;       // Synchronous version of this input
  119. reg ps2_clk_hi_z;     // Without keyboard, high Z equals 1 due to pullups.
  120. reg ps2_data_hi_z;    // Without keyboard, high Z equals 1 due to pullups.

  121. //--------------------------------------------------------------------------
  122. // Module code

  123. assign ps2_clk = ps2_clk_hi_z?1'bZ:1'b0;
  124. assign ps2_data = ps2_data_hi_z?1'bZ:1'b0;

  125. // Input "synchronizing" logic -- synchronizes the inputs to the state
  126. // machine clock, thus avoiding errors related to
  127. // spurious state machine transitions.
  128. always @(posedge clk)
  129. begin
  130.   ps2_clk_s <= ps2_clk;
  131.   ps2_data_s <= ps2_data;
  132. end

  133. // State register
  134. always @(posedge clk)
  135. begin : m1_state_register
  136.   if (reset) m1_state <= m1_rx_clk_h;
  137.   else m1_state <= m1_next_state;
  138. end

  139. // State transition logic
  140. always @(m1_state
  141.          or q
  142.          or tx_shifting_done
  143.          or tx_write
  144.          or ps2_clk_s
  145.          or ps2_data_s
  146.          or timer_60usec_done
  147.          or timer_5usec_done
  148.          )
  149. begin : m1_state_logic

  150.   // Output signals default to this value, unless changed in a state condition.
  151.   ps2_clk_hi_z <= 1;
  152.   ps2_data_hi_z <= 1;
  153.   tx_error_no_keyboard_ack <= 0;
  154.   enable_timer_60usec <= 0;
  155.   enable_timer_5usec <= 0;

  156.   case (m1_state)

  157.     m1_rx_clk_h :
  158.       begin
  159.         enable_timer_60usec <= 1;
  160.         if (tx_write) m1_next_state <= m1_tx_reset_timer;
  161.         else if (~ps2_clk_s) m1_next_state <= m1_rx_falling_edge_marker;
  162.         else m1_next_state <= m1_rx_clk_h;
  163.       end
  164.       
  165.     m1_rx_falling_edge_marker :
  166.       begin
  167.         enable_timer_60usec <= 0;
  168.         m1_next_state <= m1_rx_clk_l;
  169.       end

  170.     m1_rx_rising_edge_marker :
  171.       begin
  172.         enable_timer_60usec <= 0;
  173.         m1_next_state <= m1_rx_clk_h;
  174.       end


  175.     m1_rx_clk_l :
  176.       begin
  177.         enable_timer_60usec <= 1;
  178.         if (tx_write) m1_next_state <= m1_tx_reset_timer;
  179.         else if (ps2_clk_s) m1_next_state <= m1_rx_rising_edge_marker;
  180.         else m1_next_state <= m1_rx_clk_l;
  181.       end

  182.     m1_tx_reset_timer:
  183.       begin
  184.         enable_timer_60usec <= 0;
  185.         m1_next_state <= m1_tx_force_clk_l;
  186.       end

  187.     m1_tx_force_clk_l :
  188.       begin
  189.         enable_timer_60usec <= 1;
  190.         ps2_clk_hi_z <= 0;  // Force the ps2_clk line low.
  191.         if (timer_60usec_done) m1_next_state <= m1_tx_first_wait_clk_h;
  192.         else m1_next_state <= m1_tx_force_clk_l;
  193.       end

  194.     m1_tx_first_wait_clk_h :
  195.       begin
  196.         enable_timer_5usec <= 1;
  197.         ps2_data_hi_z <= 0;        // Start bit.
  198.         if (~ps2_clk_s && timer_5usec_done)
  199.           m1_next_state <= m1_tx_clk_l;
  200.         else
  201.           m1_next_state <= m1_tx_first_wait_clk_h;
  202.       end
  203.       
  204.     // This state must be included because the device might possibly
  205.     // delay for up to 10 milliseconds before beginning its clock pulses.
  206.     // During that waiting time, we cannot drive the data (q[0]) because it
  207.     // is possibly 1, which would cause the keyboard to abort its receive
  208.     // and the expected clocks would then never be generated.
  209.     m1_tx_first_wait_clk_l :
  210.       begin
  211.         ps2_data_hi_z <= 0;
  212.         if (~ps2_clk_s) m1_next_state <= m1_tx_clk_l;
  213.         else m1_next_state <= m1_tx_first_wait_clk_l;
  214.       end

  215.     m1_tx_wait_clk_h :
  216.       begin
  217.         enable_timer_5usec <= 1;
  218.         ps2_data_hi_z <= q[0];
  219.         if (ps2_clk_s && timer_5usec_done)
  220.           m1_next_state <= m1_tx_rising_edge_marker;
  221.         else
  222.           m1_next_state <= m1_tx_wait_clk_h;
  223.       end

  224.     m1_tx_rising_edge_marker :
  225.       begin
  226.         ps2_data_hi_z <= q[0];
  227.         m1_next_state <= m1_tx_clk_h;
  228.       end

  229.     m1_tx_clk_h :
  230.       begin
  231.         ps2_data_hi_z <= q[0];
  232.         if (tx_shifting_done) m1_next_state <= m1_tx_wait_keyboard_ack;
  233.         else if (~ps2_clk_s) m1_next_state <= m1_tx_clk_l;
  234.         else m1_next_state <= m1_tx_clk_h;
  235.       end

  236.     m1_tx_clk_l :
  237.       begin
  238.         ps2_data_hi_z <= q[0];
  239.         if (ps2_clk_s) m1_next_state <= m1_tx_wait_clk_h;
  240.         else m1_next_state <= m1_tx_clk_l;
  241.       end

  242.     m1_tx_wait_keyboard_ack :
  243.       begin
  244.         if (~ps2_clk_s && ps2_data_s)
  245.           m1_next_state <= m1_tx_error_no_keyboard_ack;
  246.         else if (~ps2_clk_s && ~ps2_data_s)
  247.           m1_next_state <= m1_tx_done_recovery;
  248.         else m1_next_state <= m1_tx_wait_keyboard_ack;
  249.       end

  250.     m1_tx_done_recovery :
  251.       begin
  252.         if (ps2_clk_s && ps2_data_s) m1_next_state <= m1_rx_clk_h;
  253.         else m1_next_state <= m1_tx_done_recovery;
  254.       end

  255.     m1_tx_error_no_keyboard_ack :
  256.       begin
  257.         tx_error_no_keyboard_ack <= 1;
  258.         if (ps2_clk_s && ps2_data_s) m1_next_state <= m1_rx_clk_h;
  259.         else m1_next_state <= m1_tx_error_no_keyboard_ack;
  260.       end

  261.     default : m1_next_state <= m1_rx_clk_h;
  262.   endcase
  263. end

  264. // State register
  265. always @(posedge clk)
  266. begin : m2_state_register
  267.   if (reset) m2_state <= m2_rx_data_ready_ack;
  268.   else m2_state <= m2_next_state;
  269. end

  270. // State transition logic
  271. always @(m2_state or rx_output_strobe or rx_read)
  272. begin : m2_state_logic
  273.   case (m2_state)
  274.     m2_rx_data_ready_ack:
  275.           begin
  276.             rx_data_ready <= 1'b0;
  277.             if (rx_output_strobe) m2_next_state <= m2_rx_data_ready;
  278.             else m2_next_state <= m2_rx_data_ready_ack;
  279.           end
  280.     m2_rx_data_ready:
  281.           begin
  282.             rx_data_ready <= 1'b1;
  283.             if (rx_read) m2_next_state <= m2_rx_data_ready_ack;
  284.             else m2_next_state <= m2_rx_data_ready;
  285.           end
  286.     default : m2_next_state <= m2_rx_data_ready_ack;
  287.   endcase
  288. end

  289. // This is the bit counter
  290. always @(posedge clk)
  291. begin
  292.   if (   reset
  293.       || rx_shifting_done
  294.       || (m1_state == m1_tx_wait_keyboard_ack)        // After tx is done.
  295.       ) bit_count <= 0;  // normal reset
  296.   else if (timer_60usec_done
  297.            && (m1_state == m1_rx_clk_h)
  298.            && (ps2_clk_s)
  299.       ) bit_count <= 0;  // rx watchdog timer reset
  300.   else if ( (m1_state == m1_rx_falling_edge_marker)   // increment for rx
  301.            ||(m1_state == m1_tx_rising_edge_marker)   // increment for tx
  302.            )
  303.     bit_count <= bit_count + 1;
  304. end
  305. // This signal is high for one clock at the end of the timer count.
  306. assign rx_shifting_done = (bit_count == `TOTAL_BITS);
  307. assign tx_shifting_done = (bit_count == `TOTAL_BITS-1);

  308. // This is the signal which enables loading of the shift register.
  309. // It also indicates "ack" to the device writing to the transmitter.
  310. assign tx_write_ack_o = (  (tx_write && (m1_state == m1_rx_clk_h))
  311.                          ||(tx_write && (m1_state == m1_rx_clk_l))
  312.                          );

  313. // This is the ODD parity bit for the transmitted word.
  314. assign tx_parity_bit = ~^tx_data;

  315. // This is the shift register
  316. always @(posedge clk)
  317. begin
  318.   if (reset) q <= 0;
  319.   else if (tx_write_ack_o) q <= {1'b1,tx_parity_bit,tx_data,1'b0};
  320.   else if ( (m1_state == m1_rx_falling_edge_marker)
  321.            ||(m1_state == m1_tx_rising_edge_marker) )
  322.     q <= {ps2_data_s,q[`TOTAL_BITS-1:1]};
  323. end

  324. // This is the 60usec timer counter
  325. always @(posedge clk)
  326. begin
  327.   if (~enable_timer_60usec) timer_60usec_count <= 0;
  328.   else if (~timer_60usec_done) timer_60usec_count <= timer_60usec_count + 1;
  329. end
  330. assign timer_60usec_done = (timer_60usec_count == (TIMER_60USEC_VALUE_PP - 1));

  331. // This is the 5usec timer counter
  332. always @(posedge clk)
  333. begin
  334.   if (~enable_timer_5usec) timer_5usec_count <= 0;
  335.   else if (~timer_5usec_done) timer_5usec_count <= timer_5usec_count + 1;
  336. end
  337. assign timer_5usec_done = (timer_5usec_count == TIMER_5USEC_VALUE_PP - 1);


  338. // Create the signals which indicate special scan codes received.
  339. // These are the "unlatched versions."
  340. assign extended = (q[8:1] == `EXTEND_CODE) && rx_shifting_done;
  341. assign released = (q[8:1] == `RELEASE_CODE) && rx_shifting_done;

  342. // Store the special scan code status bits
  343. // Not the final output, but an intermediate storage place,
  344. // until the entire set of output data can be assembled.
  345. always @(posedge clk)
  346. begin
  347.   if (reset || rx_output_event)
  348.   begin
  349.     hold_extended <= 0;
  350.     hold_released <= 0;
  351.   end
  352.   else
  353.   begin
  354.     if (rx_shifting_done && extended) hold_extended <= 1;
  355.     if (rx_shifting_done && released) hold_released <= 1;
  356.   end
  357. end


  358. // These bits contain the status of the two shift keys
  359. always @(posedge clk)
  360. begin
  361.   if (reset) left_shift_key <= 0;
  362.   else if ((q[8:1] == `LEFT_SHIFT) && rx_shifting_done && ~hold_released)
  363.     left_shift_key <= 1;
  364.   else if ((q[8:1] == `LEFT_SHIFT) && rx_shifting_done && hold_released)
  365.     left_shift_key <= 0;
  366. end

  367. always @(posedge clk)
  368. begin
  369.   if (reset) right_shift_key <= 0;
  370.   else if ((q[8:1] == `RIGHT_SHIFT) && rx_shifting_done && ~hold_released)
  371.     right_shift_key <= 1;
  372.   else if ((q[8:1] == `RIGHT_SHIFT) && rx_shifting_done && hold_released)
  373.     right_shift_key <= 0;
  374. end

  375. assign rx_shift_key_on = left_shift_key || right_shift_key;

  376. // Output the special scan code flags, the scan code and the ascii
  377. always @(posedge clk)
  378. begin
  379.   if (reset)
  380.   begin
  381.     rx_extended <= 0;
  382.     rx_released <= 0;
  383.     rx_scan_code <= 0;
  384.     rx_ascii <= 0;
  385.   end
  386.   else if (rx_output_strobe)
  387.   begin
  388.     rx_extended <= hold_extended;
  389.     rx_released <= hold_released;
  390.     rx_scan_code <= q[8:1];
  391.     rx_ascii <= ascii;
  392.   end
  393. end

  394. // Store the final rx output data only when all extend and release codes
  395. // are received and the next (actual key) scan code is also ready.
  396. // (the presence of rx_extended or rx_released refers to the
  397. // the current latest scan code received, not the previously latched flags.)
  398. assign rx_output_event  = (rx_shifting_done
  399.                           && ~extended  
  400.                           && ~released
  401.                           );

  402. assign rx_output_strobe = (rx_shifting_done
  403.                           && ~extended  
  404.                           && ~released
  405.                           && ( (TRAP_SHIFT_KEYS_PP == 0)  
  406.                                || ( (q[8:1] != `RIGHT_SHIFT)
  407.                                     &&(q[8:1] != `LEFT_SHIFT)
  408.                                   )
  409.                              )
  410.                           );

  411. // This part translates the scan code into an ASCII value...
  412. // Only the ASCII codes which I considered important have been included.
  413. // if you want more, just add the appropriate case statement lines...
  414. // (You will need to know the keyboard scan codes you wish to assign.)
  415. // The entries are listed in ascending order of ASCII value.
  416. assign shift_key_plus_code = {3'b0,rx_shift_key_on,q[8:1]};
  417. always @(shift_key_plus_code)
  418. begin
  419.   casez (shift_key_plus_code)
  420.     12'h?66 : ascii <= 8'h08;  // Backspace ("backspace" key)
  421.     12'h?0d : ascii <= 8'h09;  // Horizontal Tab
  422.     12'h?5a : ascii <= 8'h0d;  // Carriage return ("enter" key)
  423.     12'h?76 : ascii <= 8'h1b;  // Escape ("esc" key)
  424.     12'h?29 : ascii <= 8'h20;  // Space
  425.     12'h116 : ascii <= 8'h21;  // !
  426.     12'h152 : ascii <= 8'h22;  // "
  427.     12'h126 : ascii <= 8'h23;  // #
  428.     12'h125 : ascii <= 8'h24;  // $
  429.     12'h12e : ascii <= 8'h25;  // %
  430.     12'h13d : ascii <= 8'h26;  // &
  431.     12'h052 : ascii <= 8'h27;  // '
  432.     12'h146 : ascii <= 8'h28;  // (
  433.     12'h145 : ascii <= 8'h29;  // )
  434.     12'h13e : ascii <= 8'h2a;  // *
  435.     12'h155 : ascii <= 8'h2b;  // +
  436.     12'h041 : ascii <= 8'h2c;  // ,
  437.     12'h04e : ascii <= 8'h2d;  // -
  438.     12'h049 : ascii <= 8'h2e;  // .
  439.     12'h04a : ascii <= 8'h2f;  // /
  440.     12'h045 : ascii <= 8'h30;  // 0
  441.     12'h016 : ascii <= 8'h31;  // 1
  442.     12'h01e : ascii <= 8'h32;  // 2
  443.     12'h026 : ascii <= 8'h33;  // 3
  444.     12'h025 : ascii <= 8'h34;  // 4
  445.     12'h02e : ascii <= 8'h35;  // 5
  446.     12'h036 : ascii <= 8'h36;  // 6
  447.     12'h03d : ascii <= 8'h37;  // 7
  448.     12'h03e : ascii <= 8'h38;  // 8
  449.     12'h046 : ascii <= 8'h39;  // 9
  450.     12'h14c : ascii <= 8'h3a;  // :
  451.     12'h04c : ascii <= 8'h3b;  // ;
  452.     12'h141 : ascii <= 8'h3c;  // <
  453.     12'h055 : ascii <= 8'h3d;  // =
  454.     12'h149 : ascii <= 8'h3e;  // >
  455.     12'h14a : ascii <= 8'h3f;  // ?
  456.     12'h11e : ascii <= 8'h40;  // @
  457.     12'h11c : ascii <= 8'h41;  // A
  458.     12'h132 : ascii <= 8'h42;  // B
  459.     12'h121 : ascii <= 8'h43;  // C
  460.     12'h123 : ascii <= 8'h44;  // D
  461.     12'h124 : ascii <= 8'h45;  // E
  462.     12'h12b : ascii <= 8'h46;  // F
  463.     12'h134 : ascii <= 8'h47;  // G
  464.     12'h133 : ascii <= 8'h48;  // H
  465.     12'h143 : ascii <= 8'h49;  // I
  466.     12'h13b : ascii <= 8'h4a;  // J
  467.     12'h142 : ascii <= 8'h4b;  // K
  468.     12'h14b : ascii <= 8'h4c;  // L
  469.     12'h13a : ascii <= 8'h4d;  // M
  470.     12'h131 : ascii <= 8'h4e;  // N
  471.     12'h144 : ascii <= 8'h4f;  // O
  472.     12'h14d : ascii <= 8'h50;  // P
  473.     12'h115 : ascii <= 8'h51;  // Q
  474.     12'h12d : ascii <= 8'h52;  // R
  475.     12'h11b : ascii <= 8'h53;  // S
  476.     12'h12c : ascii <= 8'h54;  // T
  477.     12'h13c : ascii <= 8'h55;  // U
  478.     12'h12a : ascii <= 8'h56;  // V
  479.     12'h11d : ascii <= 8'h57;  // W
  480.     12'h122 : ascii <= 8'h58;  // X
  481.     12'h135 : ascii <= 8'h59;  // Y
  482.     12'h11a : ascii <= 8'h5a;  // Z
  483.     12'h054 : ascii <= 8'h5b;  // [
  484.     12'h05d : ascii <= 8'h5c;  // \
  485.     12'h05b : ascii <= 8'h5d;  // ]
  486.     12'h136 : ascii <= 8'h5e;  // ^
  487.     12'h14e : ascii <= 8'h5f;  // _   
  488.     12'h00e : ascii <= 8'h60;  // `
  489.     12'h01c : ascii <= 8'h61;  // a
  490.     12'h032 : ascii <= 8'h62;  // b
  491.     12'h021 : ascii <= 8'h63;  // c
  492.     12'h023 : ascii <= 8'h64;  // d
  493.     12'h024 : ascii <= 8'h65;  // e
  494.     12'h02b : ascii <= 8'h66;  // f
  495.     12'h034 : ascii <= 8'h67;  // g
  496.     12'h033 : ascii <= 8'h68;  // h
  497.     12'h043 : ascii <= 8'h69;  // i
  498.     12'h03b : ascii <= 8'h6a;  // j
  499.     12'h042 : ascii <= 8'h6b;  // k
  500.     12'h04b : ascii <= 8'h6c;  // l
  501.     12'h03a : ascii <= 8'h6d;  // m
  502.     12'h031 : ascii <= 8'h6e;  // n
  503.     12'h044 : ascii <= 8'h6f;  // o
  504.     12'h04d : ascii <= 8'h70;  // p
  505.     12'h015 : ascii <= 8'h71;  // q
  506.     12'h02d : ascii <= 8'h72;  // r
  507.     12'h01b : ascii <= 8'h73;  // s
  508.     12'h02c : ascii <= 8'h74;  // t
  509.     12'h03c : ascii <= 8'h75;  // u
  510.     12'h02a : ascii <= 8'h76;  // v
  511.     12'h01d : ascii <= 8'h77;  // w
  512.     12'h022 : ascii <= 8'h78;  // x
  513.     12'h035 : ascii <= 8'h79;  // y
  514.     12'h01a : ascii <= 8'h7a;  // z
  515.     12'h154 : ascii <= 8'h7b;  // {
  516.     12'h15d : ascii <= 8'h7c;  // |
  517.     12'h15b : ascii <= 8'h7d;  // }
  518.     12'h10e : ascii <= 8'h7e;  // ~
  519.     12'h?71 : ascii <= 8'h7f;  // (Delete OR DEL on numeric keypad)
  520.     default : ascii <= 8'h2e;  // '.' used for unlisted characters.
  521.   endcase
  522. end


  523. endmodule

  524. //`undefine TOTAL_BITS
  525. //`undefine EXTEND_CODE
  526. //`undefine RELEASE_CODE
  527. //`undefine LEFT_SHIFT
  528. //`undefine RIGHT_SHIFT
复制代码


分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 顶 踩
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表