T Flip Flop from D Flip Flop Template
Modern FPGA architectures standardise on D-type flip flops for their logic cells, omitting dedicated T-type (toggle) flip flops to save silicon area. Hardware engineers must synthesise toggle functionality using standard D flip flops paired with combinational feedback logic.
The circuit maintains its current state until the toggle enable signal is asserted. When enabled, the output state inverts on every active clock edge. This fundamental building block is heavily used in binary counters, clock dividers, and state machine design.
- Clock edge:
posedge - Reset type: asynchronous
- Reset polarity: active-low (
rst_n) - Output values on reset:
qgoes to 0 - Priority rules:
rst_nassertion overrides thetinput - The output
qmust be registered
Cycle 1: rst_n=0, t=X → q=0 (reset) Cycle 2: rst_n=1, t=0 → q=0 (hold) Cycle 3: rst_n=1, t=1 → q=1 (toggle) Cycle 4: rst_n=1, t=1 → q=0 (toggle) Cycle 5: rst_n=1, t=0 → q=0 (hold) Cycle 6: rst_n=1, t=1 → q=1 (toggle) Cycle 7: rst_n=0, t=1 → q=0 (reset overrides toggle) Cycle 8: rst_n=1, t=0 → q=0 (hold)
{ "signal": [
{ "name": "clk", "wave": "p......." },
{ "name": "rst_n", "wave": "01....01" },
{ "name": "t", "wave": "x01.01.0" },
{},
{ "name": "q", "wave": "0.10.10." }
], "head": { "text": "Toggle behaviour with asynchronous reset." } }| Signal | Direction | Width | Description | |--------|-----------|-------|-------------| | clk | input | 1 | Positive-edge triggered clock | | rst_n | input | 1 | Asynchronous active-low reset; q goes to 0 when asserted | | t | input | 1 | Toggle enable; q inverts on posedge clk while t is 1 | | q | output | 1 | Registered output state |
Constraints
- Output
qmust be registered, updating only on the positive edge ofclkor upon asynchronous reset. - The reset signal
rst_nis asynchronous and active-low. - Output must initialise to 0 on reset.
- Reset assertion strictly overrides the
tinput.
Topics
Solve this problem
Write the module in Verilog, SystemVerilog or VHDL. Your submission is compiled and simulated against a real testbench — you get the waveform back, not a stored answer.
This problem is part of Codiode Pro. The statement above is free to read.
The circuit builder and code editor need a desktop screen. On a phone, read the problem here and open it on a laptop to solve.