I am trying to create a 4 bit counter using D flip flops in Verilog. I am following this diagram https://i.stack.imgur.com/XbRAv.png. I got the code for the individual D flip flop. The problem I am having is with D0 in the first clock cycle. I am guessing I have to assume Q0 to be 1 and Q1, Q2, Q3 to be 0 at first. I am not sure how to pass the initial value for D0 only once in the code.
module DFlipFlop(CLK, D, Q);
input CLK, D;
output Q;
reg Q;
always @(posedge CLK) begin
Q <= D;
end
endmodule
module RippleMod(CLK, q0, q1, q2, q3);
input CLK;
output q0, q1, q2, q3;
DFlipFlop d1 (CLK,q3,q0);//not sure about q3 there, think I will get X if i do this.
DFlipFlop d2 (CLK,q0,q1);
DFlipFlop d3 (CLK,q1,q2);
DFlipFlop d4 (CLK,q2,q4);
endmodule