Skip to content

Instantly share code, notes, and snippets.

@ka9e
Created July 18, 2015 03:47
Show Gist options
  • Save ka9e/66ac8293972132d16010 to your computer and use it in GitHub Desktop.
Save ka9e/66ac8293972132d16010 to your computer and use it in GitHub Desktop.
clocked RS-filpflop by 3 input gates
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity three_input_gate is
port (
CK, S, P : in std_logic;
Q : out std_logic
);
end entity;
architecture IMP of three_input_gate is
begin
Q <= (not P) or (CK and S);
end IMP;
-- Q(n+1) = CK * S + not(P(n))
-- P(n+1) = CK * R + not(Q(n))
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity top_level is
port (
S, R, CK : in std_logic;
Q, nQ : buffer std_logic
);
end entity;
architecture IMP of top_level is
component three_input_gate
port (
CK, S, P : in std_logic;
Q : out std_logic
);
end component;
begin
U1 : three_input_gate
port map(
CK => CK,
S => S,
P => nQ,
Q => Q
);
U2 : three_input_gate
port map(
CK => CK,
S => R,
P => Q,
Q => nQ
);
end IMP;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment