karthiga05
Member level 2

Hi guys. I've posted a few threads before regarding counters. This is still regarding a counter. my 4-bit counter. But im not sure if the part in RED is right.
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity counter4 is
port(count
ut std_logic_vector(3 downto 0);
clk:in std_logic;
reset:in std_logic);
end counter4;
architecture behav_counter4 of counter4 is
component ha port (a: in std_logic;
b: in std_logic;
sum: out std_logic;
c_out: out std_logic);
end component;
component fa port (a, b, cin : in std_logic;
sum, c_out : out std_logic);
end component;
signal ain,s,c:std_logic_vector(3 downto 0) :="0000";
signal bin:std_logic_vector(3 downto 0):="0001";
--configuration specification
for all:ha use entity work.ha(rtl);
for all:fa use entity work.fa(fa_behav);
begin
u1:ha port map(a => ain(0), b => bin(0), sum => s(0), c_out => c(0));
u2:fa port map(a => ain(1), b => bin(1), sum => s(1), cin => c(0), c_out => c(0));
u3:fa port map(a => ain(2), b => bin(2), sum => s(2), cin => c(1), c_out => c(1));
u4:fa port map(a => ain(3), b => bin(3), sum => s(3), cin => c(2), c_out => c(2));
counter
rocess(clk, reset) --process(sensitivity list)
begin
if reset'event and (reset = '1') then
s <= (others => '0');
elsif clk'event and (clk='1') then
ain <= c or ain;
s <= ain or bin;
c <= s and c;
end if;
end process;
count <= s;
end behav_counter4;
---------- Post added at 14:34 ---------- Previous post was at 14:30 ----------
it doesnt loop.
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity counter4 is
port(count
clk:in std_logic;
reset:in std_logic);
end counter4;
architecture behav_counter4 of counter4 is
component ha port (a: in std_logic;
b: in std_logic;
sum: out std_logic;
c_out: out std_logic);
end component;
component fa port (a, b, cin : in std_logic;
sum, c_out : out std_logic);
end component;
signal ain,s,c:std_logic_vector(3 downto 0) :="0000";
signal bin:std_logic_vector(3 downto 0):="0001";
--configuration specification
for all:ha use entity work.ha(rtl);
for all:fa use entity work.fa(fa_behav);
begin
u1:ha port map(a => ain(0), b => bin(0), sum => s(0), c_out => c(0));
u2:fa port map(a => ain(1), b => bin(1), sum => s(1), cin => c(0), c_out => c(0));
u3:fa port map(a => ain(2), b => bin(2), sum => s(2), cin => c(1), c_out => c(1));
u4:fa port map(a => ain(3), b => bin(3), sum => s(3), cin => c(2), c_out => c(2));
counter
begin
if reset'event and (reset = '1') then
s <= (others => '0');
elsif clk'event and (clk='1') then
ain <= c or ain;
s <= ain or bin;
c <= s and c;
end if;
end process;
count <= s;
end behav_counter4;
---------- Post added at 14:34 ---------- Previous post was at 14:30 ----------
it doesnt loop.