大家看看这个用D触发器的3分频器 哪个地方错了 谢谢
module div3(div1,div2,div,clk,reset);
input clk;
input reset;
output div1,div2,div;
reg div1,div2;
reg div;
reg i,j;
always@(posedge clk)
begin
if (!reset)
begin
i<=0;
div1<=0;
end
else
begin
div1<=~div1;
if (i==0)
div1<=~div1;
else if (i==2)
div1<=~div1;
else
i<=i+1;
end
end
always@(negedge clk)
begin
if (!reset)
begin
j<=0;
div2<=0;
end
else
begin
div2<=~div2;
if (i==1)
div2<=~div2;
else if (i==2)
div2<=~div2;
else
i<=i+1;
end
end
assign div=div1|div2;
endmodule
占空比1:1
谢谢指教 |