完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
最近按照特权同学很早的文章程序写了一个,可是用示波器感觉输出 CS,RD,WR都没有变化。将AD0804数据输出口直接接流水灯,流水灯也没有变化。
module AD(clk,rst_n,cs_n,rd_n,wr_n,LED_Out); input clk; input rst_n; // input intr_n; output cs_n,rd_n,wr_n; output [1:0]LED_Out; /***********************************************/ reg[1:0] idle,start,start_wait,convert,current_state,next_state; reg[15:0] delay; reg cs_n,rd_n,wr_n; // reg[7:0] data_reg; // reg read_flag; always @ (posedge clk or negedge rst_n) begin if(!rst_n) begin current_state <= 0; delay <= 0; // data_reg <= 0; end else begin case(current_state) idle: begin if(delay<10) begin delay <= delay+16'd1; end else begin current_state <= next_state; delay <= 0; end end start: begin current_state <= next_state; end start_wait: begin current_state <= next_state; end convert: begin if(delay<2) begin delay <= delay+16'd1; end else begin // data_reg <= data; current_state <= next_state; delay <= 0; end end default: ; endcase end end // always @ (current_state or intr_n or rst_n) begin always @ (current_state or rst_n) begin if(!rst_n) begin idle <= 0; start <= 1; start_wait <= 2; convert <= 3; // read_flag <= 0; end else begin case (current_state) idle: begin cs_n <= 1; wr_n <= 1; rd_n <= 1; // read_flag <= 0; next_state <= start; end start: begin cs_n <= 0; wr_n <= 0; rd_n <= 1; // read_flag <= 0; next_state <= start_wait; end start_wait: begin wr_n <= 1; cs_n <= 1; rd_n <= 1; // read_flag <= 0; // if(!intr_n) next_state <= convert; // else next_state <= start_wait; end convert: begin cs_n <= 0; rd_n <= 0; wr_n <= 1; // read_flag <= 1; next_state <= idle; end default: next_state <= idle; endcase end end /************************************** */ wire LED0_Out; led0_module U3 ( .clk( clk ), .rst_n( rst_n ), .LED_Out( LED0_Out ) ); /*********************************/ wire LED1_Out; led1_module U4 ( .clk( clk ), .rst_n( rst_n ), .LED_Out( LED1_Out ) ); /*********************************/ assign LED_Out = { LED0_Out, LED1_Out}; endmodule |
|
相关推荐 |
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
1421 浏览 1 评论
1215 浏览 0 评论
矩阵4x4个按键,如何把识别结果按编号01-16(十进制)显示在两个七段数码管上?
1426 浏览 0 评论
913 浏览 0 评论
2229 浏览 0 评论
1432 浏览 35 评论
5616 浏览 113 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-22 22:49 , Processed in 0.552076 second(s), Total 69, Slave 51 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号