Motion FPGA
Motion FPGA for the MachX02-7000HE Breakout Board
blink.vhd
Go to the documentation of this file.
1 -------------------------------------------------------------------------------
2 --! @file
3 --! @brief Blink module
4 -------------------------------------------------------------------------------
5 
6 --! Using IEEE library
7 LIBRARY ieee;
8 
9 --! Using IEEE standard logic components
10 USE ieee.std_logic_1164.ALL;
11 
12 --! @brief Blink entity
13 --!
14 --! This entity blinks an LED, toggling the output when max_count number of clocks
15 --! has been generated.
16 ENTITY blink IS
17  GENERIC (
18  max_count : integer := 10 --! Maximum Count value
19  );
20  PORT (
21  clk_in : IN std_logic; --! Clock
22  rst_in : IN std_logic; --! Asynchronous reset
23  led_out : OUT std_logic --! LED output
24  );
25 END ENTITY blink;
26 
27 --! Architecture rtl of blink entity
28 ARCHITECTURE rtl OF blink IS
29 
30  --! Internal counter
31  SIGNAL count : integer RANGE 0 TO max_count;
32 
33  --! Current led
34  SIGNAL led : std_logic;
35 
36 BEGIN
37 
38  --! @brief Process to count and toggle
39  --!
40  --! This process counts clocks and toggles the state when appropriate.
41  pr_count : PROCESS (clk_in, rst_in) IS
42  BEGIN
43 
44  IF (rst_in = '1') THEN
45  count <= 0;
46  led <= '0';
47  ELSIF (rising_edge(clk_in)) THEN
48  IF (count = max_count) THEN
49  count <= 0;
50  led <= NOT led;
51  ELSE
52  count <= count + 1;
53  END IF;
54  END IF;
55 
56  END PROCESS pr_count;
57 
58  led_out <= led;
59 
60 END ARCHITECTURE rtl;
_library_ ieeeieee
Using IEEE library.