本帖最后由 martinawd 于 2020-6-8 21:22 编辑
写了个三分频的模块
module fenpin(clk,rst,out);
input clk,rst;
output out;
reg out;
reg [1:0] i,j;
always @(posedge clk)
begin
if(!rst)
begin
i<=2'b00;
j<=2'b00;
end
else if (i==2'b10)
i<=2'b00;
else
i=i+1;
end
always @(negedge clk)
if(j==2'b10)
j<=2'b00;
else
j<=j+1;
always @(posedge clk)
begin
if(!rst)
out<=0;
else if (i==2'b10)
out<=~out;
else
out<=out;
end
always @(negedge clk)
begin
if(!rst)
out<=0;
else if (j==2'b01)
out<=~out;
else
out<=out;
end
endmodule
仿真结果在画圈的地方信号不应该有跳变,却产生了跳变,请教大神是什么问题,谢谢啦!
|