Engineers Garage

  • Projects and Tutorials
    • Circuit Design
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Components
    • Contributions
  • Articles
    • EG Blogs
    • Insight
    • Invention Stories
    • How to
    • What Is
    • News
      • EE Design News
      • DIY Reviews
      • Guest Post
      • Sponsored Content
  • Forums
    • EG Forum Archive
    • EDABoard.com
    • Electro-Tech-Online
  • 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 15: Design a clocked SR latch (flip-flop) using VHDL

December 9, 2020 By Ashutosh Bhatt

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

In the previous tutorial, VHDL tutorial – 14, we designed two circuits using VHDL: a 1×8 de-multiplexer and a 8×1 multiplexer.

In this project, we will,

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

A clocked SR latch circuit:

Truth table

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 properly design the project, as well as edit and compile the program and the waveform file, including the final output.

For this tutorial, we’ve used a behavioral modeling style to write the VHDL program that will build the flip-flop circuit. This is the preferred modeling style for sequential digital circuits.

VHDL program

library ieee;
use ieee.std_logic_1164.all;
entity RS_FF is
  port (clk,r,s : in std_logic;
        Q: out std_logic;
        Qnot : out std_logic);
 end RS_FF;
architecture RSFF_arch of RS_FF is  
  signal t1,t2 : std_logic; 
   begin    
    t1 <= r nor t2;
    t2 <= s nor t1;
      process (clk,r,s)  
      begin
       if(clk’event and clk=’1′ ) then
             if(r=’0′ and s=’0′) then
              Q <=t1;
              Qnot <= t2;
             elsif(r=’0′ and s=’1′) then
              Q <=’1′;
              Qnot <=’0′;
             elsif(r=’1′ and s=’0′) then
              Q <=’0′;
              Qnot <=’1′;
             elsif(r=’1′ and s=’1′) then
              Q <=’X’;
              Qnot <=’X’;
             end if;
            end if;          
      end process;
end RSFF_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 a waveform file with all of the necessary inputs and outputs that are listed, and simulate the project. You should get the following result…

Simulation waveform

As shown in this figure, when the clock input is ‘1,’ then “s” is ‘1.’ And when “r” is ‘0,’ the flip-flop is set – which means that the Q output is ‘1’ and the Qnot is ‘0.’

Be sure to verify the different combinations with the given truth table.

In the next tutorial, we’ll design a D flip-flop by using VHDL.

Related Articles Read More >

VHDL Tutorial – 19: Designing a 4-bit binary counter using VHDL
VHDL Tutorial 18: Design a T flip-flop (with enable and an active high reset input) using VHDL
VHDL Tutorial 17: Design a JK flip-flop (with preset and clear) using VHDL
VHDL Tutorial 16: Design a D flip-flop using VHDL

Featured Tutorials

  • Capacitive Touch Controlled Robot using X-Bee Module
  • Keypad Controlled RF based Wireless Robot
  • A Bluetooth-controlled datalogger robot
  • Keypad Controlled And Industrial Gas Monitoring Wireless Robot
  • Joystick Controlled Wireless Robot
  • CAN Protocol – Understanding the Controller Area Network Protocol

Stay Up To Date

Newsletter Signup

EE Training Center Classrooms

“ee

“ee

“ee

“ee

Recent Articles

  • How to build an IR remote-operated RGB LED strip using Arduino
  • Maxim launches automotive-grade secure authenticator for enhanced vehicle safety
  • Samsung offers compact, WiFi-enabled VRF air-conditioning systems
  • Nexperia launches industry’s first 80-V RET family for high-voltage circuits
  • The Amazing World of Robotics and its Promising Future
...

RSS EDABOARD.com Discussions

  • Rippe current rating of aluminium electrolytic capacitor is very low.
  • Start-up resistor for offline flyback suffers overvoltage..but is it OK?
  • Why disabled autoCsEnable in SPI doesn't allow CS gpio control in EFR32FG14
  • Spice correlation issue
  • Mic preamp and Tx on MAX260x

RSS Electro-Tech-Online.com Discussions

  • new to Ardunio but trying to compile
  • Any Ideas As to why circuit keeps breaking
  • 12v zvs induction heater
  • First time using MOSFETs project
  • Engine Temperature using an AD590 on the Oil Pressure Wire to the engine
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
    • Contributions
  • Articles
    • EG Blogs
    • Insight
    • Invention Stories
    • How to
    • What Is
    • News
      • EE Design News
      • DIY Reviews
      • Guest Post
      • Sponsored Content
  • Forums
    • EG Forum Archive
    • EDABoard.com
    • Electro-Tech-Online
  • 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