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

 找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開始

搜索
查看: 3300|回復(fù): 0
打印 上一主題 下一主題
收起左側(cè)

FPGA:利用ch451驅(qū)動(dòng)數(shù)碼管,實(shí)現(xiàn)按鍵控制顯示數(shù)字

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
ID:449230 發(fā)表于 2019-3-7 20:52 | 只看該作者 回帖獎(jiǎng)勵(lì) |倒序?yàn)g覽 |閱讀模式
/****************************************/
//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

評(píng)分

參與人數(shù) 1黑幣 +50 收起 理由
admin + 50 共享資料的黑幣獎(jiǎng)勵(lì)!

查看全部評(píng)分

分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩
回復(fù)

使用道具 舉報(bào)

本版積分規(guī)則

手機(jī)版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表
主站蜘蛛池模板: 伊人成人免费视频 | 国产一级网站 | 久久aⅴ乱码一区二区三区 91综合网 | 日日干日日操 | 999热精品 | 国产精品网页 | 91久久精品日日躁夜夜躁欧美 | 欧美xxxx日本 | 日韩三级在线观看 | 精品伊人| 中文字幕av亚洲精品一部二部 | 久久精品国产久精国产 | 午夜日韩 | 国产精品国产成人国产三级 | 手机av在线 | 欧美日韩综合精品 | av在线成人 | 日韩在线观看网站 | 国产91色在线 | 亚洲 | 欧美一区二区三区在线播放 | www.av7788.com| 亚洲激情一区二区三区 | 久久亚洲一区二区 | 国产一区二区不卡 | 国产精品福利一区二区三区 | 玖玖综合网| 欧美性影院| 波多野结衣精品在线 | 欧美久久免费观看 | 久久久免费电影 | 天天干国产 | 亚洲一区精品视频 | 亚洲乱码国产乱码精品精98午夜 | 亚洲精品久久久蜜桃 | 午夜在线视频 | 久久国产精品一区二区三区 | 欧美一区二区三区在线播放 | 色毛片| 国产精品99久久免费观看 | 99热这里有精品 | 日本不卡一区 |