Stepper-Motor-Control
v3.0.0
System on a Chip 2014 - Group 04
Main Page
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
counter.vhd
Go to the documentation of this file.
1
-------------------------------------------------------------------------------
2
--! @file counter.vhd
3
--! @author Marc Kossmann
4
--! @author Michael Riedel
5
--! @version v1.0.0
6
--! @date 05.12.2014
7
--!
8
--! @brief Counter which divides the clock according to the divider
9
--! @details Provide 5 ms time base when divider = 250000.
10
--! @par History:
11
--! @details v0.1.0 23.11.2014 Kossmann
12
--! - first draft
13
--! @details v0.1.1 25.11.2014 Riedel
14
--! - corrected formatting
15
--! - renamed component to counter
16
--! - re-implemented counter according to digital ciruit design
17
--! @details v0.1.2 28.11.2014 Kossmann
18
--! - improved documentation
19
--! @details v1.0.0 05.12.2014 Riedel & Kossmann
20
--! - release milestone 3b
21
-------------------------------------------------------------------------------
22
23
--! Use Standard Library
24
LIBRARY
ieee
;
25
--! Use Logic Elements
26
USE
ieee.std_logic_1164.
all
;
27
28
--! @brief Counter-Component
29
ENTITY
counter
is
30
GENERIC
31
(
32
--! @brief Prescaler for PWM-signal.
33
--! @details For this purpose 2,5 ms are used as minimal pulse-width.
34
--! @details The prescaler is calculated with the given and desired frequency
35
--! via the following formula:
36
--! \f{equation*}{
37
--! \text{prescaler} = \frac{f_{\text{clock}} \text{Hz}}{f_{\text{prescaler}} \text{Hz}}
38
--! \f}
39
--! e.g.:
40
--! \f{equation*}{
41
--! \left.\begin{aligned}
42
--! f_{\text{prescaler}} &= \frac{5}{2}\,\text{ms} \newline
43
--! &= 400\,\text{Hz} \newline\newline
44
--! \text{prescaler} &= \frac{50\,\text{Mhz}}{400\,\text{Hz}} \newline
45
--! &= 125000 \newline
46
--! \end{aligned}
47
--! \right\}
48
--! \qquad \text{pulse-width: 2.5 ms}
49
--! \f}
50
--! @details For simulation-purpose the divider was set to 125 for faster wave generation.
51
divider
:
INTEGER
52
)
;
53
PORT
54
(
55
clock
:
IN
STD_LOGIC
;
--! input clock
56
reset_n
:
IN
STD_LOGIC
;
--! global reset
57
enable :
IN
STD_LOGIC
; --! enables
component
58
clk_out
:
OUT
STD_LOGIC
--! divided clock output
59
)
;
60
END
counter
;
61
62
--! @brief Architecture of counter
63
--! @details realized functionality:
64
--! - divides clock with generic clock divider
65
architecture
counter_arch
of
counter
is
66
SIGNAL
counter
:
INTEGER
:=
0
;
67
BEGIN
68
--! @brief counting process incrementing internal signal value
69
count:
PROCESS
(
reset_n
,
clock
,
enable
)
70
BEGIN
71
IF
(
reset_n
=
'
0
'
)
THEN
72
counter
<=
0
;
73
ELSIF
(
rising_edge
(
clock
)
AND
enable
=
'
1
'
)
THEN
74
IF
(
counter
=
divider
-
1
)
THEN
75
counter
<=
0
;
76
ELSE
counter
<=
counter
+
1
;
77
END
IF
;
78
END
IF
;
79
END
PROCESS
;
80
--! @brief process to output the divided clock
81
output:
PROCESS
(counter)
82
BEGIN
83
IF
(
counter
=
0
)
THEN
84
clk_out
<=
'
1
'
;
85
ELSE
86
clk_out
<=
'
0
'
;
87
END
IF
;
88
END
PROCESS
;
89
END
counter_arch
;
counter.enable
in enableSTD_LOGIC
enables component
Definition:
counter.vhd:57
counter.reset_n
in reset_nSTD_LOGIC
global reset
Definition:
counter.vhd:56
counter.clk_out
out clk_outSTD_LOGIC
divided clock output
Definition:
counter.vhd:59
counter
Counter-Component.
Definition:
counter.vhd:29
counter.clock
in clockSTD_LOGIC
input clock
Definition:
counter.vhd:55
counter.divider
dividerINTEGER
Prescaler for PWM-signal.
Definition:
counter.vhd:52
quartus
IP
counter
counter.vhd
Generated on Fri Dec 12 2014 00:03:05 for Stepper-Motor-Control by
1.8.8