DSD Lab Experiment-8 (A) : To Design and Implement A SR Flip-Flop Using Behavioural Modeling
DSD Lab Experiment-8 (A) : To Design and Implement A SR Flip-Flop Using Behavioural Modeling
DSD Lab Experiment-8 (A) : To Design and Implement A SR Flip-Flop Using Behavioural Modeling
EXPERIMENT-8(A)
AIM : T
O DESIGN AND IMPLEMENT A SR FLIP-FLOP USING
BEHAVIOURAL MODELING.
APPARATUS USED : E
DA PLAYGROUND , LOGISIM
THEORY :
BLOCK DIAGRAM :
CIRCUIT DIAGRAM :
TRUTH TABLE :
CLK S R Q Q’
0 x x Qprv Q’prv
1 0 0 Qprv Q’prv
1 0 1 0 1
1 1 0 1 0
1 1 1 – –
PROGRAM CODE :
VHDL CODE :
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity SR_FLIPFLOP_SOURCE is
Port ( S,R,RST,CLK : in STD_LOGIC;
Q,Qb : out STD_LOGIC);
end SR_FLIPFLOP_SOURCE;
architecture Behavioral of SR_FLIPFLOP_SOURCE is
begin
process (S,R,RST,CLK)
begin
if (RST = '1') then
Q <= '0';
Qb <='0';
elsif (CLK='1')then
if (S /= R) then
Q <= S;
Qb <= R;
elsif(S ='0' and R = '0')then
Q <= Q;
Qb <= Qb;
end if;
elsif (S = '1' AND R = '1') then
Q <= 'Z';
Qb <= 'Z';
end if;
end process;
end Behavioral;
TESTBENCH CODE :
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity testbench is
end entity;
architecture tb of testbench is
component SR_FLIPFLOP_SOURCE is
Port ( S,R,RST,CLK : in STD_LOGIC;
Q,Qb : out STD_LOGIC);
end component;
signal S_tb, R_tb, RST_tb, CLK_tb, Q_tb, Qb_tb : STD_LOGIC;
begin
uut: SR_FLIPFLOP_SOURCE port map(S_tb, R_tb, RST_tb, CLK_tb, Q_tb, Qb_tb);
Stim : process
begin
RST_tb <= '0';
wait for 10ns;
RST_tb <= '1';
wait for 10ns;
RST_tb <= '0';
wait for 10ns;
CLK_tb <='0';
wait for 10ns;
CLK_tb<='1';
wait for 10ns;
S_tb <= '1';
R_tb <= '0';
wait for 20 ns;
S_tb <= '0';
R_tb <= '0';
wait for 20 ns;
S_tb <= '0';
R_tb <= '1';
wait for 20 ns;
S_tb <= '1';
R_tb <= '1';
wait for 20 ns;
assert false report "Test done." severity note;
wait;
end process;
end tb;
PROGRAM SCREENSHOT :
SIMULATION :
LOGISIM SCREENSHOT :
RESULT : THE PROGRAM AND SIMULATION OF S
R FLIP-FLOP IS
WORKING PROPERLY.