新聞中心

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

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

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

        parameter SCAN_IDLE = 3'b000;

        parameter SCAN_JITTER= 3'b001;

        parameter SCAN_COL0 = 3'b011;

        parameter SCAN_COL1 = 3'b010;

        parameter SCAN_COL2 = 3'b110;

        parameter SCAN_COL3 = 3'b100;

        parameter SCAN_READ = 3'b101;

        parameter SCAN_JTTTER2= 3'b111;

        reg [2:0] current_state;

        reg [2:0] next_state;

        always@(posedge clk or negedge rst_n)

        begin

        if(!rst_n)

        current_state = SCAN_IDLE;

        else if(cnt == 20'hfffff)

        current_state = next_state;

        end

        always@*

        begin

        case(current_state)

        SCAN_IDLE : //init

        if(col_data != 4'b1111) next_state = SCAN_JITTER;

        else next_state = SCAN_IDLE;

        SCAN_JITTER: //escape the jitter

        if(col_data != 4'b1111) next_state = SCAN_COL0;

        else next_state = SCAN_IDLE;

        SCAN_COL0 : //1th row

        if(col_data != 4'b1111) next_state = SCAN_READ;

        else next_state = SCAN_COL1;

        SCAN_COL1 : //2th row

        if(col_data != 4'b1111) next_state = SCAN_READ;

        else next_state = SCAN_COL2;

        SCAN_COL2 : //3th row

        if(col_data != 4'b1111) next_state = SCAN_READ;

        else next_state = SCAN_COL3;

        SCAN_COL3 : //4th row

        if(col_data != 4'b1111) next_state = SCAN_READ;

        else next_state = SCAN_IDLE;

        SCAN_READ : //lock the vaule

        if(col_data != 4'b1111) next_state = SCAN_JTTTER2;

        else next_state = SCAN_IDLE;

        SCAN_JTTTER2: //when your hand is gone

        if(col_data != 4'b1111) next_state = SCAN_JTTTER2;

        else next_state = SCAN_IDLE;

        endcase

        end



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

        評論


        相關(guān)推薦

        技術(shù)專區(qū)

        關(guān)閉
        主站蜘蛛池模板: 延庆县| 化州市| 邢台市| 荆门市| 湖南省| 湟中县| 保靖县| 如东县| 逊克县| 龙里县| 扎囊县| 玛纳斯县| 锡林郭勒盟| 霍林郭勒市| 休宁县| 介休市| 松溪县| 交城县| 鄂温| 盐山县| 紫阳县| 福海县| 甘泉县| 新余市| 襄垣县| 都匀市| 华容县| 扶余县| 延庆县| 西充县| 天祝| 虞城县| 湘西| 土默特右旗| 巫山县| 绿春县| 花莲县| 柯坪县| 井陉县| 辉南县| 肥乡县|