完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
input clk; input a_in; output reg [15:0] count; begin cp<=1'b0; else begin state[0]<=b_in; if((prestate==2'b00)&&(state==2'b10))begin end cp<=1'b1;dire<=1'b1; else if((prestate==2'b11)&&(state==2'b01))begin end cp<=1'b1;dire<=1'b1; else if((prestate==2'b00)&&(state==2'b01))begin end cp<=1'b1;dire<=1'b0; else if((prestate==2'b11)&&(state==2'b10))begin end cp<=1'b1;dire<=1'b0; else cp<=1'b0; end if(!rst_n)begin end count<=count+1'b1; endmodule 先不管方向,这种应该没错吧
|
|
相关推荐
1个回答
|
|
module encoder(clk,rst_n,a_in,b_in,count,dire);
input clk; input rst_n; input a_in; input b_in; output reg [15:0] count; output reg dire; always@(posedge clk or negedge rst_n) begin if(!rst_n)begin cp<=1'b0; end else begin state[1]<=a_in; state[0]<=b_in; prestate<=state; if((prestate==2'b00)&&(state==2'b10))begin cp<=1'b1;dire<=1'b1; end else if((prestate==2'b10)&&(state==2'b11))begin cp<=1'b1;dire<=1'b1; end else if((prestate==2'b11)&&(state==2'b01))begin cp<=1'b1;dire<=1'b1; end else if((prestate==2'b01)&&(state==2'b00))begin cp<=1'b1;dire<=1'b1; end else if((prestate==2'b00)&&(state==2'b01))begin cp<=1'b1;dire<=1'b0; end else if((prestate==2'b01)&&(state==2'b11))begin cp<=1'b1;dire<=1'b0; end else if((prestate==2'b11)&&(state==2'b10))begin cp<=1'b1;dire<=1'b0; end else if((prestate==2'b10)&&(state==2'b00))begin cp<=1'b1;dire<=1'b0; end else begin cp<=1'b0; end end end always@(cp or rst_n) if(!rst_n)begin count<=16'd0; end else if(cp==1'b1)begin count<=count+1'b1; end endmodule |
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
1516 浏览 0 评论
2869 浏览 0 评论
2305 浏览 0 评论
927 浏览 0 评论
1541 浏览 0 评论
3288 浏览 62 评论
6984 浏览 115 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-7-12 12:27 , Processed in 0.353105 second(s), Total 40, Slave 34 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191