完善资料让更多小伙伴认识你,还能领取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 |
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
求FPGA 驱动控制ltc2271 或者 ltc2180 或者 ltc2190或者 ltc2202 的代码
1337 浏览 0 评论
418 浏览 0 评论
求助:遇见诡异问题,FPGA模块A输出端口连接模块B输入后,模块A不能正常工作的
1488 浏览 1 评论
475 浏览 0 评论
1445 浏览 1 评论
4303 浏览 95 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-8-17 17:43 , Processed in 0.487465 second(s), Total 75, Slave 57 queries .
Powered by 电子发烧友网
© 2015 www.ws-dc.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号