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

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 3387|回復: 0
打印 上一主題 下一主題
收起左側

FPGA:利用ch451驅動數碼管,實現按鍵控制顯示數字

[復制鏈接]
跳轉到指定樓層
樓主
ID:449230 發表于 2019-3-7 20:52 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
/****************************************/
//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

評分

參與人數 1黑幣 +50 收起 理由
admin + 50 共享資料的黑幣獎勵!

查看全部評分

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

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術交流QQ群281945664

Powered by 單片機教程網

快速回復 返回頂部 返回列表
主站蜘蛛池模板: 欧美久久久久久 | 欧美日韩在线一区二区 | 日韩国产一区 | 免费a国产| 国产欧美精品一区二区 | 夜夜爽99久久国产综合精品女不卡 | 97精品超碰一区二区三区 | 久久久天天 | 成人羞羞国产免费视频 | 成人免费xxxxx在线视频 | 亚洲第一网站 | 成人中文字幕在线 | 国产精品视频一二三 | 日韩在线一区二区 | 在线播放中文字幕 | 久久久新视频 | 三极网站 | 久久久久久久久久久久一区二区 | 四虎永久影院 | 最近日韩中文字幕 | 777zyz色资源站在线观看 | 福利社午夜影院 | 天天爽夜夜操 | 中文字幕一区二区在线观看 | 91中文| 殴美成人在线视频 | 亚洲成a人片 | 在线观看视频你懂得 | 亚洲二区视频 | 欧美性久久久 | 国产精久久久久久 | 亚洲瑟瑟 | 一区二区精品 | 日韩欧美一区二区三区免费看 | 人人九九精 | 欧美激情综合五月色丁香小说 | 久久99视频免费观看 | 99精品网 | 日日干夜夜操天天操 | 美女一区| 日本福利片 |