Your counter has a width of only 1 bit, you did not enable reset, if necessary, you also do not reset the counter. == 2 will be just a phase shift == 7500000. Try:
module tick_counter(
input clk,
input reset,
input fast,
output reg tick
);
reg [22:0] count;
always @(posedge clk or negedge reset) begin
if (~reset) begin
count <= 'd0;
tick <= 0;
end
else begin
if((fast == 1)&&(count == 2)) begin
tick <= 1;
count <= 'd0;
end
else if(fast == 0)&&(count == 7500000)) begin
tick <= 1;
count <= 'd0;
end
else begin
tick <= 0;
count <= count + 1;
end
end
end
endmodule
- :
reg [22:0] count;
wire [22:0] comp = (fast) ? 23'd2: 23'd7500000 ;
wire done = count >= comp ;
always @(posedge clk or negedge reset) begin
if (~reset) begin
count <= 'd0;
tick <= 0;
end
else begin
if(done) begin
tick <= 1;
count <= 'd0;
end
else begin
tick <= 0;
count <= count + 1;
end
end
end