D
Daku
Guest
Could some Verilog guru please help ? I have the following working D
flip-flop.
I would like to convert it to a 1 bit counter, where the Q_bar output
is fed back
into the D input - I am not sure what modifications to apply.
`timescale 1ns/1ns
module dff( d, clk, reset, q, q_bar);
input d;
input clk;
input reset;
output q;
output q_bar;
reg q;
reg q_bar;
reg reset;
always @ (posedge clk or negedge reset)
if(~reset)
begin
q <= 1'b0;
end
else
begin
q <= d;
q_bar <= !d;
end
endmodule
Thanks in advance for your help.
flip-flop.
I would like to convert it to a 1 bit counter, where the Q_bar output
is fed back
into the D input - I am not sure what modifications to apply.
`timescale 1ns/1ns
module dff( d, clk, reset, q, q_bar);
input d;
input clk;
input reset;
output q;
output q_bar;
reg q;
reg q_bar;
reg reset;
always @ (posedge clk or negedge reset)
if(~reset)
begin
q <= 1'b0;
end
else
begin
q <= d;
q_bar <= !d;
end
endmodule
Thanks in advance for your help.