Countersprints
Countersprints
Countersprints
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_unsigned.ALL;
--use IEEE.NUMERIC_STD.ALL;
--library UNISIM;
--use UNISIM.VComponents.all;
entity sync_up is
Port ( i : in STD_LOGIC;
clk : in STD_LOGIC;
rst : in STD_LOGIC;
end sync_up;
process(i,clk,rst)
begin
else count<=count + 1;
q<=count;
qbar<=not q;
end if;
end if;
end process;
end Behavioral;
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
--USE ieee.numeric_std.ALL;
ENTITY sync_uptest IS
END sync_uptest;
COMPONENT sync_up
PORT(
i : IN std_logic;
clk : IN std_logic;
rst : IN std_logic;
);
END COMPONENT;
--Inputs
--BiDirs
BEGIN
i => i,
q => q,
);
clk_process :process
begin
-- Stimulus process
stim_proc: process
begin
rst<='1';
rst<='0';i<='0';
i<='1';
wait;
end process;
END;
----------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_unsigned.ALL;
-- Uncomment the following library declaration if using
--use IEEE.NUMERIC_STD.ALL;
--library UNISIM;
--use UNISIM.VComponents.all;
entity sync_down is
Port ( i : in STD_LOGIC;
clk : in STD_LOGIC;
rst : in STD_LOGIC;
end sync_down;
begin
process(i,clk,rst)
begin
else count<=count - 1;
end if;
q<=count;
qbar<=not q;
end if;
end process;
end Behavioral;
--------------------------------------------------------------------------------
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
-- Uncomment the following library declaration if using
--USE ieee.numeric_std.ALL;
ENTITY sync_downtest IS
END sync_downtest;
COMPONENT sync_down
PORT(
i : IN std_logic;
clk : IN std_logic;
rst : IN std_logic;
);
END COMPONENT;
--Inputs
--BiDirs
--Outputs
BEGIN
i => i,
q => q,
);
clk_process :process
begin
end process;
-- Stimulus process
stim_proc: process
begin
rst<='1';
rst<='0';i<='0';
i<='1';
wait;
end process;
END;
USE ieee.std_logic_1164.ALL;
--USE ieee.numeric_std.ALL;
ENTITY tfft IS
END tfft;
COMPONENT tff
PORT(
t : IN std_logic;
clk : IN std_logic;
en : IN std_logic;
q : INOUT std_logic;
END COMPONENT;
--Inputs
--Outputs
signal q : std_logic;
BEGIN
t => t,
en => en,
q => q,
clk_process :process
begin
end process;
-- Stimulus process
stim_proc: process
begin
en<='0';
en<='1'; t<='0';
t<='1';
-- insert stimulus here
wait;
end process;
END;
Code (t flipflop)
----------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
--use IEEE.NUMERIC_STD.ALL;
--library UNISIM;
--use UNISIM.VComponents.all;
entity tff is
Port ( t : in STD_LOGIC;
clk : in STD_LOGIC;
en : in STD_LOGIC;
q : inout STD_LOGIC;
end tff;
begin
process(t,clk,en)
begin
end if;
end if;
end process;
Functional program
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
-- Uncomment the following library declaration if using
--use IEEE.NUMERIC_STD.ALL;
--library UNISIM;
--use UNISIM.VComponents.all;
entity tff is
Port ( t : in STD_LOGIC;
rst : in STD_LOGIC;
clk : in STD_LOGIC;
q : inout STD_LOGIC;
end tff;
begin
process(t,rst,clk)
begin
end if;
end if;
end process;
end Behavioral;
----------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
--use IEEE.NUMERIC_STD.ALL;
--library UNISIM;
--use UNISIM.VComponents.all;
entity async_up is
Port ( i : in STD_LOGIC;
clk : in STD_LOGIC;
rst : in STD_LOGIC;
component tff
Port ( t : in STD_LOGIC;
rst : in STD_LOGIC;
clk : in STD_LOGIC;
q : inout STD_LOGIC;
end component;
begin
end Behavioral;