<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

          EEPW首頁(yè) > EDA/PCB > 設(shè)計(jì)應(yīng)用 > 基于PLD的矩陣鍵盤(pán)狀態(tài)機(jī)控制

          基于PLD的矩陣鍵盤(pán)狀態(tài)機(jī)控制

          作者: 時(shí)間:2012-03-12 來(lái)源:網(wǎng)絡(luò) 收藏

          reg [3:0] col_data_r;

          reg [3:0] row_data_r;

          reg key_flag_r0;

          always@(posedge clk or negedge rst_n)

          begin

          if(!rst_n)

          begin

          row_data = 4'b0000;

          Key_flag_r0 = 0;

          end

          else if(cnt == 20'hfffff)

          begin

          case(next_state)

          SCAN_IDLE : begin

          row_data = 4'b0000;

          key_flag_r0 = 0;

          end

          //SCAN_JITTER:

          SCAN_COL0 : row_data = 4'b1110;

          SCAN_COL1 : row_data = 4'b1101;

          SCAN_COL2 : row_data = 4'b1011;

          SCAN_COL3 : row_data = 4'b0111;

          SCAN_READ : begin

          row_data_r = row_data;

          col_data_r = col_data;

          key_flag_r0 = 1;

          end

          //SCAN_JTTTER2:

          default:; //default vaule

          endcase

          end

          end

          always @(posedge clk or negedge rst_n)

          begin

          if(!rst_n)

          key_value = 0;

          else if(cnt == 20'hfffff)

          begin

          if(key_flag_r0 == 1'b1) //the mark of key is pressed

          begin

          case ({row_data_r,col_data_r}) //row_data Row, col_data Col

          8'b0111_0111: key_value = 4'h0;

          8'b0111_1011: key_value = 4'h1;

          8'b0111_1101: key_value = 4'h2;

          8'b0111_1110: key_value = 4'h3;

          8'b1011_0111: key_value = 4'h4;

          8'b1011_1011: key_value = 4'h5;

          8'b1011_1101: key_value = 4'h6;

          8'b1011_1110: key_value = 4'h7;

          8'b1101_0111: key_value = 4'h8;

          8'b1101_1011: key_value = 4'h9;

          8'b1101_1101: key_value = 4'hA;

          8'b1101_1110: key_value = 4'hB;

          8'b1110_0111: key_value = 4'hC;

          8'b1110_1011: key_value = 4'hD;

          8'b1110_1101: key_value = 4'hE;

          8'b1110_1110: key_value = 4'hF;

          default : key_value = key_value;

          endcase

          end



          關(guān)鍵詞: PLD 矩陣鍵盤(pán)

          評(píng)論


          相關(guān)推薦

          技術(shù)專(zhuān)區(qū)

          關(guān)閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();