Engineers Garage

  • Electronics Projects and Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe

VHDL Tutorial 18: Design a T flip-flop (with enable and an active high reset input) using VHDL

By Ashutosh Bhatt October 16, 2023

Note: it’s recommended to follow this VHDL tutorial series in order, starting with the first tutorial.

In the previous tutorial, VHDL tutorial – 17, we designed a JK flip-flop circuit by using VHDL.

For this project, we will:

  • Write a VHDL program to build the T flip-flop circuit
  • Verify the output waveform of the program (the digital circuit) with the flip-flop’s truth table

The T flip-flop with an enable and active high reset input circuit:

Truth table

  • Note 1: when T=1, the Q output toggles every time (from 0 to 1 and 1 to 0)
  • Note 2: when T=0, the Q output retains its previous state

Now, let’s write, compile, and simulate a VHDL program. Then, we’ll get the output in waveform and verify it with the given truth table.

Before starting, be sure to review the step-by-step procedure provided in VHDL Tutorial – 3 to design the project. It will ensure that you properly edit and compile the program and the waveform file, including the final output.

Here. we’ve used a behavioral modeling style to write the VHDL program and build this flip-flop circuit because it’s the model preferred for sequential digital circuits.

VHDL program

library ieee;
use ieee.std_logic_1164.all;
entity T_flip_flop is
  port (clk,t,en,rst : in std_logic;
        Q: out std_logic;
        Qnot : out std_logic);
 end T_flip_flop;
architecture TFF_arch of T_flip_flop is  
 signal op: std_logic;                           
  begin                                              
   process(clk, rst) is
    begin
      if(en=’0′) then op<=’Z’;
      elsif (en=’1′ and rst=’1′) then
          op <= ‘0’;
      elsif (clk’event and clk=’1′ and en=’1′) then
          if(t=’1′) then op <= not op;
          else op <= op;
          end if;
     end if;
   end process;
   Q <= op;
   Qnot <= not op;                               
 end TFF_arch;

To refresh your memory about how this works, go through the first two VHDL tutorials (1 and 2) of this series.

Next, compile the above program, creating and then saving a waveform file with all of the necessary inputs and outputs that are listed (and be sure to apply all of the different input combinations). Then, simulate the project. You should get the following result…

As shown in this figure, three cases are highlighted in red, blue, and green.

  • Case 1: when en=0  ->  both outputs are at a high impedance
  • Case 2: when en=1 and rst=1  ->  Q=0 and Qnot = 1 (the flip-flop is reset)
  • Case 3: when en=1, rst=0 and clk=1 and T=1 – > Q = 1 and Qnot = 0 (the output toggles between 0-1)

Be sure to verify the different input-output combinations as per the circuit’s truth table.

In the next tutorial, we’ll learn how to build a 4-bit binary counter using VHDL.

You may also like:

  • VHDL
    VHDL Tutorial 14: Design 1×8  demultiplexer and 8×1 multiplexer using…

  • VHDL Tutorial 15: Design a clocked SR latch (flip-flop) using…

  • VHDL Tutorial 16: Design a D flip-flop using VHDL

  • VHDL Tutorial 17: Design a JK flip-flop (with preset and…
  • VHDL
    VHDL Tutorial 1: Introduction to VHDL
  • VHDL
    VHDL Tutorial 2: VHDL programs

Filed Under: Tutorials, VHDL, VHDL

 

Next Article

← Previous Article
Next Article →

Questions related to this article?
👉Ask and discuss on EDAboard.com and Electro-Tech-Online.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

EE TECH TOOLBOX

“ee
Tech Toolbox: Internet of Things
Explore practical strategies for minimizing attack surfaces, managing memory efficiently, and securing firmware. Download now to ensure your IoT implementations remain secure, efficient, and future-ready.

EE Learning Center

EE Learning Center
“engineers
EXPAND YOUR KNOWLEDGE AND STAY CONNECTED
Get the latest info on technologies, tools and strategies for EE professionals.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


RSS EDABOARD.com Discussions

  • Disappearing clock
  • How to best test Electrolytic capacitors for premature failure reduced life?
  • 12VAC to 12VDC 5A on 250ft 12AWG
  • TMP117 > Can not read temperature on LCD
  • LDO simulation by pcb

RSS Electro-Tech-Online.com Discussions

  • Electronic board faulty?!?
  • Is there a Power Bank that can also be charged with electricity?
  • applying solder paste from a jar
  • Did a Buyer Kill My Amp?
  • An Update On Tarrifs

Featured – Designing of Audio Amplifiers part 9 series

  • Basics of Audio Amplifier – 1/9
  • Designing 250 Milli Watt Audio Power Amplifier – 2/9
  • Designing 1 Watt Audio Power Amplifier – 3/9
  • Designing a Bass Boost Amplifier – 4/9
  • Designing a 6 Watt Car Audio Amplifier – 5/9
  • Design a low power amplifier for headphones- 6/9

Recent Articles

  • Sienna Semiconductor data converters feature sample rates from 20 to 250 Msps
  • Delta’s 5,500 W power supplies achieve 97.5% energy efficiency for AI servers
  • Novosense Microelectronics releases digital isolators with capacitive-based design
  • MIPI C-PHY adds encoding option to support next-gen image sensor applications
  • Littelfuse gate driver delivers 1.9 A source and 2.3 A sink output current

EE ENGINEERING TRAINING DAYS

engineering

Submit a Guest Post

submit a guest post
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • Battery Power Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • EV Engineering
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • Subscribe to our newsletter
  • About Us
  • Contact Us
  • Advertise

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy

Search Engineers Garage

  • Electronics Projects and Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe