N
Nirav
Hello Everybody,
I'm the student of Electronics and Communication Engineering and
finding a problem in implementing SR Flip flop on VHDL Platform, using
Quartus 7.1 tool. Please help me out.
I've made a few programs for that but in all those I'm finding same or
other Problem or not perfect output, Can you please let me know where
I'm making this mistake ??
1st Program :
library IEEE;
use IEEE.STD_LOGIC_1164.all;
entity RSFF_NRK is
port(s,r,clk : in BIT ; q,qbar : buffer BIT);
end RSFF_NRK;
architecture RSFF_NRK_ARC of RSFF_NRK is
begin
process(clk)
begin
if (clk'event and clk = '1') then
if( r = '1' and s = '0' ) then
q <= r nor qsbar;
qs <= r nor qsbar;
qbar <= s nor qs;
qsbar <= s nor qs;
elsif(s= '1' and r = '0') then
qbar <= s nor qs;
qsbar <= s nor qs;
q <= r nor qsbar;
qs <= r nor qsbar;
elsif(s = '1' and r = '1') then
q <= '1';
qbar <= '1';
end if;
end if;
end process;
end RSFF_NRK_ARC;
Here the program runs well but its RTL schematic shows a very large
circuit instead of having only 2 gates.
2nd Program :
library IEEE;
use IEEE.STD_LOGIC_1164.all;
entity RSFF_NRK is
port(ip : in std_logic_vector (1 downto 0); clk : in BIT ; q,qbar :
out BIT);
signal qs,qsbar : BIT;
signal sel : INTEGER;
end RSFF_NRK;
architecture RSFF_NRK_ARC of RSFF_NRK is
begin
process(clk,ip)
begin
if (clk'event and clk = '1') then
case ip is
when "00" => sel <= 0;
when "01" => sel <= 1;
when "10" => sel <= 2;
when "11" => sel <= 3;
end case;
if(sel = 1) then
q <= ip[0] nor qsbar;
qs <=ip[0] nor qsbar;
qbar <=ip[1] nor qs;
qsbar <=ip[1] nor qs;
elsif(sel=2) then
qbar <=ip[1] nor qs;
qsbar <=ip[1] nor qs;
q <=ip[0] nor qsbar;
qs <=ip[0] nor qsbar;
elsif(sel=3) then
q <= ip[1] ;
qbar <= ip[0] ;
end if;
end if;
end process;
end RSFF_NRK_ARC;
Here, I've made the program but ip[_] is not being supported, always
at this point I'm given an error report.
3rd Program :
library IEEE;
use IEEE.STD_LOGIC_1164.all;
entity RSFF_NRK is
port(s,r,clk : in BIT ; q,qbar : out BIT);
end RSFF_NRK;
architecture RSFF_NRK_ARC of RSFF_NRK is
begin
process(clk)
begin
if (clk'event and clk = '1') then
if( r = '1' and s = '0' ) then
q <= s;
qbar <= r;
elsif(s= '1' and r = '0') then
qbar <= r;
q <= s;
elsif(s = '1' and r = '1') then
q <= s;
qbar <= r;
end if;
end if;
end process;
end RSFF_NRK_ARC;
Here program works well but circuit becomes much a complex.
Please point out my error or let me have an alternate solution.
Nirav
I'm the student of Electronics and Communication Engineering and
finding a problem in implementing SR Flip flop on VHDL Platform, using
Quartus 7.1 tool. Please help me out.
I've made a few programs for that but in all those I'm finding same or
other Problem or not perfect output, Can you please let me know where
I'm making this mistake ??
1st Program :
library IEEE;
use IEEE.STD_LOGIC_1164.all;
entity RSFF_NRK is
port(s,r,clk : in BIT ; q,qbar : buffer BIT);
end RSFF_NRK;
architecture RSFF_NRK_ARC of RSFF_NRK is
begin
process(clk)
begin
if (clk'event and clk = '1') then
if( r = '1' and s = '0' ) then
q <= r nor qsbar;
qs <= r nor qsbar;
qbar <= s nor qs;
qsbar <= s nor qs;
elsif(s= '1' and r = '0') then
qbar <= s nor qs;
qsbar <= s nor qs;
q <= r nor qsbar;
qs <= r nor qsbar;
elsif(s = '1' and r = '1') then
q <= '1';
qbar <= '1';
end if;
end if;
end process;
end RSFF_NRK_ARC;
Here the program runs well but its RTL schematic shows a very large
circuit instead of having only 2 gates.
2nd Program :
library IEEE;
use IEEE.STD_LOGIC_1164.all;
entity RSFF_NRK is
port(ip : in std_logic_vector (1 downto 0); clk : in BIT ; q,qbar :
out BIT);
signal qs,qsbar : BIT;
signal sel : INTEGER;
end RSFF_NRK;
architecture RSFF_NRK_ARC of RSFF_NRK is
begin
process(clk,ip)
begin
if (clk'event and clk = '1') then
case ip is
when "00" => sel <= 0;
when "01" => sel <= 1;
when "10" => sel <= 2;
when "11" => sel <= 3;
end case;
if(sel = 1) then
q <= ip[0] nor qsbar;
qs <=ip[0] nor qsbar;
qbar <=ip[1] nor qs;
qsbar <=ip[1] nor qs;
elsif(sel=2) then
qbar <=ip[1] nor qs;
qsbar <=ip[1] nor qs;
q <=ip[0] nor qsbar;
qs <=ip[0] nor qsbar;
elsif(sel=3) then
q <= ip[1] ;
qbar <= ip[0] ;
end if;
end if;
end process;
end RSFF_NRK_ARC;
Here, I've made the program but ip[_] is not being supported, always
at this point I'm given an error report.
3rd Program :
library IEEE;
use IEEE.STD_LOGIC_1164.all;
entity RSFF_NRK is
port(s,r,clk : in BIT ; q,qbar : out BIT);
end RSFF_NRK;
architecture RSFF_NRK_ARC of RSFF_NRK is
begin
process(clk)
begin
if (clk'event and clk = '1') then
if( r = '1' and s = '0' ) then
q <= s;
qbar <= r;
elsif(s= '1' and r = '0') then
qbar <= r;
q <= s;
elsif(s = '1' and r = '1') then
q <= s;
qbar <= r;
end if;
end if;
end process;
end RSFF_NRK_ARC;
Here program works well but circuit becomes much a complex.
Please point out my error or let me have an alternate solution.
Nirav