久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

標題: FPGA:利用ch451驅動數碼管,實現按鍵控制顯示數字 [打印本頁]

作者: 撒兩個卡進度款    時間: 2019-3-7 20:52
標題: FPGA:利用ch451驅動數碼管,實現按鍵控制顯示數字
/****************************************/
//Code to transfer serial command to CH451, for EDA students in 7-Segments experiments
//3-line serial command:LDA,LCLK,LOAD,from CH451
//By you,2017.0922
//steps of transfer serial command:
// 1.recevie the parrel command from SEDLED_COMMAND
// 2.transfer the command via serial command
/****************************************************/
module CH451SPI_MODULE(rst,clk,command,command_idle,command_start,LDA,LCLK,LOAD);
parameter command_length=12;
input rst,clk; //system
input[command_length-1:0] command;
input command_start; //inidcate if the command start
//output
output LDA,LCLK,LOAD;
output command_idle;

//command
// state machine
reg[3:0] state;
parameter state_idle=4'h0;
parameter state_start=4'h1;// command start
parameter state_tran=4'h2;// transfer command
parameter state_judge=4'h3;// see if all command complete
parameter state_end=4'h4;
parameter state_rdy=4'h5;//load command
reg[7:0] count;// count number of commands
reg[command_length-1:0] current_command;
reg reg_LDA;
reg reg_LOAD;
/**************************************/
always@(negedge clk) // use negedge to avoid competion risk,
if(~rst)
   begin
        state<=state_idle;
        count<=0;
        reg_LDA<=1;
   end
else
   case(state)
   state_idle: if(command_start) // if SPI module not busy,idle
                 state<=state_rdy;
               else
                 state<=state_idle;
   state_rdy: begin
                   current_command<=command;
                   state<=state_tran;
              end// transfer the current command, one command only
   state_tran:begin
                   if(count<command_length)
                      begin
                            reg_LDA<=current_command[0];
                            current_command<=(current_command>>1);
                            count<=count+1'b1;
                      end
                   else
                      begin
                          state<=state_end;
                          count<=0;
                          reg_LDA<=1;
                      end
              end              
   state_end:  state<=state_idle; // stop to here              
   default: state<=state_idle;
   endcase
/*******************/
assign LDA=reg_LDA;
assign LCLK=clk;
always@(posedge clk)
if(~rst)
   reg_LOAD<=1'b1;
else
   begin
        if(count==(command_length))
           reg_LOAD<=1'b0;
        else
            reg_LOAD<=1'b1;
   end
//assign LOAD=(count==(command_length-1))?1'b0:1'b1;
assign LOAD=reg_LOAD;// assign
assign command_idle=(state==state_idle)?1'b1:1'b0;
endmodule






歡迎光臨 (http://m.zg4o1577.cn/bbs/) Powered by Discuz! X3.1
主站蜘蛛池模板: 欧美色综合一区二区三区 | 国产精品福利视频 | 免费在线a视频 | 黄色三级在线播放 | 国产传媒毛片精品视频第一次 | 日本三级网址 | 日韩精品视频在线 | 欧美在线视频不卡 | 麻豆91av | 成人免费观看男女羞羞视频 | 成人av免费 | 99福利视频导航 | 不卡的av在线| 欧美在线视频一区二区 | 玖玖国产 | 久久久久国产精品免费免费搜索 | 久久国产精品久久国产精品 | 成人福利网站 | 久操福利 | 欧美日韩国产在线观看 | www.久久| 三级视频在线观看电影 | 97精品超碰一区二区三区 | 亚洲国产精品日本 | 亚洲天堂精品一区 | 欧美一区二区三区视频 | 欧美激情五月 | 日本精品一区二区三区在线观看视频 | 91伊人网| 久久三级av | 日本午夜在线视频 | 56pao在线 | 99精品在线 | www国产成人免费观看视频 | 久久99久久98精品免观看软件 | 国产精品地址 | 欧美视频一区二区三区 | 久久亚洲精品视频 | 一区二区视频免费观看 | 欧美专区在线 | 国产精品精品视频 |