staraimm
Full Member level 2
mixed single- and double-edge expressions
Hi,
I wrote the code as the following, and I compiled it using Quartus II.
module edgectrl(clk, clr, en, outnum);
input clk, clr, en;
output[7:0] outnum;
reg[7:0] outnum;
always @ (posedge clk or negedge clr)
begin
if(~clr)
begin
if(~en)
outnum <= 0;
else
outnum <= outnum + 8'h1;
end
else
outnum <= 0;
end
endmodule
But I can't get the corrct counter, the result is in the attachment. Can anybody tell me why?
Hi,
I wrote the code as the following, and I compiled it using Quartus II.
module edgectrl(clk, clr, en, outnum);
input clk, clr, en;
output[7:0] outnum;
reg[7:0] outnum;
always @ (posedge clk or negedge clr)
begin
if(~clr)
begin
if(~en)
outnum <= 0;
else
outnum <= outnum + 8'h1;
end
else
outnum <= 0;
end
endmodule
But I can't get the corrct counter, the result is in the attachment. Can anybody tell me why?