sanjanavee
Newbie level 5
- Joined
- May 31, 2013
- Messages
- 9
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,377
Hey this is my vhdl program for a 3 bit counter with reset.. now i need to know how i can use another 3 bit counter simultaneously in such a way that while the 1st counter is resetting the 2nd counter counts and while the 2nd counter is resetting the 1st counter counts. This is done in such a manner that any bits received even during the reset time is counted by either of the counters.. without leaving out any bits.
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity BinCount3bit is
port(
clk : in std_logic;
reset : in std_logic;
sel : in std_logic;
q : out std_logic_vector(2 downto 0)
end BinCount3bit;
architecture behavioral of BinCount3bit is
begin
process(clk,reset)
begin
if reset = '1' then
q <= (others => '0');
elsif(rising_edge(clk))then
if sel = '0' then
q <= q+1;
else
q <= q+2;
end if;
end if;
end process;
end behavioral;
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity BinCount3bit is
port(
clk : in std_logic;
reset : in std_logic;
sel : in std_logic;
q : out std_logic_vector(2 downto 0)
end BinCount3bit;
architecture behavioral of BinCount3bit is
begin
process(clk,reset)
begin
if reset = '1' then
q <= (others => '0');
elsif(rising_edge(clk))then
if sel = '0' then
q <= q+1;
else
q <= q+2;
end if;
end if;
end process;
end behavioral;