Muthuraja.M
Advanced Member level 4
- Joined
- Jul 20, 2013
- Messages
- 101
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 16
- Activity points
- 634
Hi friends,
I wrote a verilog code for clock divider using D flip flop.
i want to divide by 10 . so i write a D flip flop module and i instance 5 times in my top module.
But one time only it will be instanced. remaining shows as 'x' value.
Pls correct my code if i done any mistake...
pls see this
module clk_div(clock,reset,out);
input clock,reset;
output out;
wire w1,w2,w3,w4;
dff d1(clock,reset,w1);
dff d2(w1,reset,w2);
dff d3(w2,reset,w3);
dff d4(w3,reset,w4);
dff d5(w4,reset,out);
endmodule
module dff(clock,reset,q);
input clock,reset;
output q;
reg q;
always @(posedge clock)
begin
if (!reset)
begin
q<=0;
end
else
begin
q<=~q;
end
end
endmodule
I wrote a verilog code for clock divider using D flip flop.
i want to divide by 10 . so i write a D flip flop module and i instance 5 times in my top module.
But one time only it will be instanced. remaining shows as 'x' value.
Pls correct my code if i done any mistake...
pls see this
module clk_div(clock,reset,out);
input clock,reset;
output out;
wire w1,w2,w3,w4;
dff d1(clock,reset,w1);
dff d2(w1,reset,w2);
dff d3(w2,reset,w3);
dff d4(w3,reset,w4);
dff d5(w4,reset,out);
endmodule
module dff(clock,reset,q);
input clock,reset;
output q;
reg q;
always @(posedge clock)
begin
if (!reset)
begin
q<=0;
end
else
begin
q<=~q;
end
end
endmodule