-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcounterN2.vhd.bak
40 lines (30 loc) · 1.01 KB
/
counterN2.vhd.bak
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity counterN is
generic(N: positive := 8);
port(
--entradas de controle
clock, reset: in std_logic;
--d: in std_logic_vector(N-1 downto 0);
q: out std_logic_vector(N-1 downto 0)
);
end;
architecture canonical of counterN is
--type State is std_logic_vector(N-1 downto 0); --mudar apenas o que esta dentro do is
signal nextState, actualState: unsigned(N-1 downto 0); --State;
begin
-- -- Next-State Logic -- --
nextState <= actualState + 1;
-- Memory Element (State Element) -- sera SEMPRE igual
process(clock, reset) is -- sequencial
begin
if reset='1' then
actualState <= (others=>'0'); -- MUDAR apenas o que o actualState recebe
elsif rising_edge(clock) then -- clock'event and clock='1' NAO USAR. MELHOR rising_edge()
actualState <= nextState;
end if;
end process; -- utilizar process para setar apenas um valor, caso outro fazer outro process
-- -- Output Logic -- --
q <= std_logic_vector(actualState);
end;