digi001
Full Member level 5
here is 2 different textbooks show a counter. is one any better than the other, or do both end up being synthesized the same way?
vs.
Code:
// Reset if needed, or increment if counting is enabled
always @ (posedge clk or posedge reset)
begin
if (reset)
count <= 0;
else if (enable == 1'b1)
count <= count + 1;
end
vs.
Code:
// Reset if needed, or increment if counting is enabled
always @ (posedge clk or posedge reset)
begin
if (reset)
r_reg <= 0;
else if (enable == 1'b1)
r_reg <= r_next;
end
assign r_next = r_reg + 1;