Experiment No. 2: Aim: A) D Flip-Flop: Synchronous VHDL Code
Experiment No. 2: Aim: A) D Flip-Flop: Synchronous VHDL Code
2
AIM : Model a flip-flop, register and a latch in VHDL. Implement with asynchronous and synchronous
reset.
a) D flip-flop : Synchronous
VHDL CODE :
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity dff is
port (d,clk,rst : IN std_logic;
q : OUT std_logic);
end dff;
SIMULATION :
RTL SCHEMATIC :
b) D flip-flop : ASYNCHRONOUS
VHDL CODE :
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity DFFASR is
port
(ASR,D,CLK: IN STD_LOGIC;
Q :OUT STD_LOGIC);
end DFFASR;
architecture Behavioral of DFFASR is
begin
process(CLK,ASR)
begin
if(ASR='1') then
Q <= '0';
elsif(CLK'EVENT and CLK ='1') then
Q <= D;
end if;
end process;
end Behavioral;
SIMULATION :
RTL SCHEMATIC :
VHDL CODE :
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity LRSR is
port
( Din: in std_logic_vector(7 downto 0);
Qout: out std_logic_vector(7 downto 0);
Load,clk,reset: in std_logic );
end LRSR;
SIMULATION :
RTL SCHEMATIC :
VHDL CODE :
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity LRASR is
port
( Din: in std_logic_vector(7 downto 0);
Qout: out std_logic_vector(7 downto 0);
Load,clk,reset: in std_logic );
end LRASR;
architecture Behavioral of LRASR is
signal NS, PS : std_logic_vector(7 downto 0) := "01010101";
begin
abc:process(clk,Reset)
begin
if(Reset='1') then
PS<= "00000000";
elsif(clk'event and clk='1')then
PS<=NS;
end if;
end process abc;
SIMULATION :
RTL SCHEMATIC :
e) LATCH
VHDL CODE :
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity latch is
port (d,rst : IN std_logic;
q : OUT std_logic);
end latch;
SIMULATION :
RTL SCHEMATIC :