T Flip-Flop Using A D Flip-Flop HDL?

  • Thread starter Thread starter pags920
  • Start date Start date
AI Thread Summary
To create a T Flip-Flop using a D Flip-Flop in Verilog, an XOR gate is necessary to toggle the output based on the T input. The existing D Flip-Flop module can be modified by wiring the D input to the inverted output (bar(Q)) to achieve the toggle functionality. There is no need to create a separate module for the XOR gate; it can be integrated within the T Flip-Flop module. The provided code outlines the basic structure, but adjustments are required to implement the toggling behavior. Understanding these modifications is essential for successful implementation in HDL.
pags920
Messages
20
Reaction score
0
I am trying to figure out how to make a T Flip Flop using a D Flip-Flop. I know that I need to use a XOR gate in order to make the T Flip-Flop, but I am having trouble putting it into a Verilog code. Below is the module for the flip-flop. Do I have to create a new module just for the XOR gate or can I incorporate it somehow in the flip flop module?


module T_flip_flop (Q, D, CLK, Clr);
output Q;
input D, CLK, Clr;
reg Q;

always @ (posedge CLK or negedge Clr)
if(~Clr)Q<=1'b0; else Q<=D;
endmodule
 
Physics news on Phys.org
I don't know verilog but a D flip flop outputs whatever is at the D input when you clock it.

If you want it to toggle, wire D to bar(Q).
 

Similar threads

Back
Top