L
laserbeak43
Hello, I've tried making a 16 bit timer out of TFFs using this code:
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
entity myTFF is
port( T, Clk, Reset : in std_logic;
Q : out std_logic
);
end myTFF;
architecture behavioral of myTFF is
signal buf : std_logic;
begin
process(T, Clk, Reset)
begin
if(reset = '1') then
buf <= '0';
end if;
if(Clk = '1') then
if(T = '1')then
buf <= (NOT buf);
end if;
end if;
end process;
Q <= buf;
end behavioral;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
entity TFFcounter16bit is
port ( enable, clk, rst : in std_logic;
Qpin : out unsigned(15 downto 0)
);
end TFFcounter16bit;
architecture wowee of TFFcounter16bit is
signal Qout : unsigned(15 downto 0);
begin
myTFF0 : entity work.myTFF port map( enable, clk, rst, Qout(0));
myTFF1 : entity work.myTFF port map( (enable AND Qout(0)), clk, rst,
Qout(1));
myTFF2 : entity work.myTFF port map( ((enable AND Qout(0)) AND
Qout(1) ), clk, rst, Qout(2));
etc... all the way town to myTFF15
Qpin <= Qout;
end wowee;
///////////////////////////////////////////
but it works terribly. Could someone give me an example of how to do
this? Just in case you're wondering, this is not schoolwork It's from
the Altera Labs. DE2 Lab4 part1 to be exact.
thanks
Malik
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
entity myTFF is
port( T, Clk, Reset : in std_logic;
Q : out std_logic
);
end myTFF;
architecture behavioral of myTFF is
signal buf : std_logic;
begin
process(T, Clk, Reset)
begin
if(reset = '1') then
buf <= '0';
end if;
if(Clk = '1') then
if(T = '1')then
buf <= (NOT buf);
end if;
end if;
end process;
Q <= buf;
end behavioral;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
entity TFFcounter16bit is
port ( enable, clk, rst : in std_logic;
Qpin : out unsigned(15 downto 0)
);
end TFFcounter16bit;
architecture wowee of TFFcounter16bit is
signal Qout : unsigned(15 downto 0);
begin
myTFF0 : entity work.myTFF port map( enable, clk, rst, Qout(0));
myTFF1 : entity work.myTFF port map( (enable AND Qout(0)), clk, rst,
Qout(1));
myTFF2 : entity work.myTFF port map( ((enable AND Qout(0)) AND
Qout(1) ), clk, rst, Qout(2));
etc... all the way town to myTFF15
Qpin <= Qout;
end wowee;
///////////////////////////////////////////
but it works terribly. Could someone give me an example of how to do
this? Just in case you're wondering, this is not schoolwork It's from
the Altera Labs. DE2 Lab4 part1 to be exact.
thanks
Malik