Engineers Garage

  • Projects and Tutorials
    • Circuit Design
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Components
  • Articles
    • EG Blogs
    • Insight
    • Invention Stories
    • How to
    • What Is
    • News
      • EE Design News
      • DIY Reviews
      • Guest Post
      • Sponsored Content
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key 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
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • Video
    • White Papers
    • Webinars
  • EE Learning Center
  • Women in Engineering

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

December 28, 2020 By Ashutosh Bhatt

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

In 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 next tutorial, we’ll learn how to build a 4-bit binary counter using VHDL.

Related Articles Read More >

How to configure the X bee modules using AT command mode to transmit analog data
How to configure the X bee modules using AT command mode to transmit digital data
VHDL Tutorial – 19: Designing a 4-bit binary counter using VHDL
Introduction to DE- Representing everything into numbers – DE Part 1

Featured Tutorials

  • Screenshot of Raspbian OS on Raspberry Pi RPi Python Programming 03: Raspberry Pi as Linux System
  • Raspberry Pi Models RPI Python Programming 02: Raspberry Pi Models
  • Raspberry Pi 4 RPi Python Programming 01: Introduction to Raspberry Pi 4
  • RPi Python Programming 05: Introduction to Python
  • RPi Python programming 04 RPi Python programming 04: Setting up Raspberry Pi Linux computer
  • Python Basics RPi Python Programming 06: Python basics

Stay Up To Date

Newsletter Signup

EE Training Center Classrooms

“ee

“ee

“ee

“ee

Recent Articles

  • Arduino’s L293D motor driver shield guide
  • NXP launches its first Wi-Fi 6E Tri-Band system-on-chip
  • Nexperia launches industry’s first 80 V RETs for high-voltage bus circuits
  • TDK releases low-profile medical sensors
  • Getting started with Raspberry Pi
...

RSS EDABOARD.com Discussions

  • What the best way to store data of size ( 90,000 * 32) bit (taken from a text file) using VHDL?
  • HSPICE Simulation refuses to match the Spectre Simulation
  • How to draw a helical coil around a rectangular core in Maxwell?
  • Where can I find the description of each layer in TSMC's pdk?
  • Same geometry but slightly different results

RSS Electro-Tech-Online.com Discussions

  • Where has the fun gone?
  • Where can I find a pole pig?
  • Voltage based relay
  • XC8 v2.31 Help: Integer Arithmetic With Numbers Larger Than 32 Bits?
  • new to Ardunio but trying to compile
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • About Us
  • Contact Us
  • Advertise

Copyright © 2021 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 | Advertising | About Us

Search Engineers Garage

  • Projects and Tutorials
    • Circuit Design
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Components
  • Articles
    • EG Blogs
    • Insight
    • Invention Stories
    • How to
    • What Is
    • News
      • EE Design News
      • DIY Reviews
      • Guest Post
      • Sponsored Content
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key 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
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • Video
    • White Papers
    • Webinars
  • EE Learning Center
  • Women in Engineering