NOTICE:The comparison if (q < 1010)
is not valid because 1010
is an integer, not a binary number. To compare q
with 4'b1010
, you should explicitly write it as 4'b1010
.
module top_module (
input clk,
input reset,
output [3:0] q);
always @(posedge clk) begin
if (reset) begin
q <= 4'b0001;
end
else begin
if (q < 4'b1010) begin
q <= q+1;
end
else
q <= 4'b0001;
end
end
endmodule