Motion FPGA
Motion FPGA for the MachX02-7000HE Breakout Board
sim_step_counter.vhd
Go to the documentation of this file.
1 -------------------------------------------------------------------------------
2 --! @file
3 --! @brief Step counter 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 --! Using IEE standard numeric components
13 USE ieee.numeric_std.ALL;
14 
15 --! @brief Entity to count steps
17  PORT (
18  rst_in : IN std_logic; --! Asynchronous reset
19  step_in : IN std_logic; --! Step input
20  dir_in : IN std_logic; --! Direction
21  size_in : IN integer; --! Size of steps
22  steps_out : OUT integer --! Current steps
23  );
24 END ENTITY sim_step_counter;
25 
26 --! Architecture sim of entity sim_step_counter
27 ARCHITECTURE sim OF sim_step_counter IS
28 
29  --! Current step count
30  SIGNAL steps : integer;
31 
32 BEGIN
33 
34  --! @brief Process to count steps
35  pr_count : PROCESS (rst_in, step_in) IS
36  BEGIN
37 
38  IF (rst_in = '1') THEN
39  -- Reset state
40  steps <= 0;
41  ELSIF (rising_edge(step_in)) THEN
42  -- Count steps
43  IF (dir_in = '0') THEN
44  steps <= steps + size_in;
45  ELSE
46  steps <= steps - size_in;
47  END IF;
48  END IF;
49 
50  END PROCESS pr_count;
51 
52  steps_out <= steps;
53 
54 END ARCHITECTURE sim;
in dir_instd_logic
Direction.
integer steps
Current step count.
in size_ininteger
Size of steps.
out steps_outinteger
Current steps.
Entity to count steps.
in rst_instd_logic
Asynchronous reset.
in step_instd_logic
Step input.
_library_ ieeeieee
Using IEEE library.