-
Notifications
You must be signed in to change notification settings - Fork 0
/
Counter30.vhd
34 lines (30 loc) · 876 Bytes
/
Counter30.vhd
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
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity Counter30 is
generic (N: integer range 0 to 30 := 30);
port (clk, Clr : in std_logic;
values : out std_logic_vector (7 downto 0));
end Counter30;
architecture behaviour of Counter30 is
component Experiment05PartA is
port (clkin : in std_logic;
clkout : out std_logic);
end component;
signal CNT : integer range 0 to 30;
signal clkout: std_logic;
begin
Clock : Experiment05PartA port map(clk, clkout);
process (clk, Clr)
begin
if (Clr = '1') then CNT <= 0;
elsif (clkout'event and clkout = '1') then
if (CNT = N-1) then CNT <= CNT + 1;
elsif (CNT = N) then CNT <= 0;
else CNT <= CNT + 1;
end if;
end if;
end process;
values <= conv_std_logic_vector(CNT,8);
end behaviour;