//可逆计数器
module cy4(input PE,Up_down,En,CP,
input[3:0] D,
output reg[3:0] Q
);
integer direction;//设置计数方向
always @(posedge CP)
begin
if(Up_down)
direction <= 1;//实现递增计数
else
direction <= -1;//实现递减计数
if(PE)
Q <= D;
else if(En)
Q <= Q + direction;//实现加1或减1计数功能
else
Q <= Q;//输出保持不变
end
endmodule
带使能端和同步指数的端的通用可逆计数器
猜你喜欢
转载自blog.csdn.net/qq_41982581/article/details/82848865
今日推荐
周排行