Motion FPGA
Motion FPGA for the MachX02-7000HE Breakout Board
sim_edge_count.vhd
Go to the documentation of this file.
1
-------------------------------------------------------------------------------
2
--! @file
3
--! @brief On percentage simulation 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 edges
16
ENTITY
sim_edge_count
IS
17
PORT
(
18
clk_in
:
IN
std_logic
;
--! Clock
19
rst_in
:
IN
std_logic
;
--! Asynchronous reset
20
signal
_in
:
IN
std_logic
;
--! Signal input
21
rise_out
:
OUT
integer
;
--! Count of rising edges
22
fall_out
:
OUT
integer
--! Count of falling edges
23
)
;
24
END
ENTITY
sim_edge_count
;
25
26
--! Architecture sim of entity sim_edge_count
27
ARCHITECTURE
sim
OF
sim_edge_count
IS
28
29
SIGNAL
prev_signal
:
std_logic
;
--! Previous signal
30
SIGNAL
prev_ok
:
std_logic
;
--! Previous signal ok flag
31
SIGNAL
rise
:
integer
;
--! Count of rising edges
32
SIGNAL
fall
:
integer
;
--! Count of falling edges
33
34
BEGIN
35
36
--! @brief Counting process
37
--!
38
--! This process counts the rising and falling edges
39
pr_count :
PROCESS
(
clk_in
,
rst_in
)
IS
40
BEGIN
41
42
IF
(
rst_in
=
'
1
'
)
THEN
43
-- Reset counts
44
prev_signal
<=
'
0
'
;
45
prev_ok
<=
'
0
'
;
46
rise
<=
0
;
47
fall
<=
0
;
48
ELSIF
(
rising_edge
(
clk_in
)
)
THEN
49
-- Detect edges
50
IF
(
prev_ok
=
'
1
'
)
THEN
51
-- Count rising edges
52
IF
(
prev_signal
=
'
0
'
AND
signal_in
=
'
1
'
)
THEN
53
rise
<=
rise
+
1
;
54
END
IF
;
55
56
-- Count falling edges
57
IF
(
prev_signal
=
'
1
'
AND
signal_in
=
'
0
'
)
THEN
58
fall
<=
fall
+
1
;
59
END
IF
;
60
END
IF
;
61
62
-- Update previous signal
63
prev_signal
<=
signal_in
;
64
prev_ok
<=
'
1
'
;
65
END
IF
;
66
67
END
PROCESS
pr_count
;
68
69
-- Output counts
70
rise_out
<=
rise
;
71
fall_out
<=
fall
;
72
73
END
ARCHITECTURE
sim
;
sim_edge_count
Entity to count edges.
Definition:
sim_edge_count.vhd:16
sim_edge_count.clk_in
in clk_instd_logic
Clock.
Definition:
sim_edge_count.vhd:18
sim_edge_count.rst_in
in rst_instd_logic
Asynchronous reset.
Definition:
sim_edge_count.vhd:19
sim_edge_count.rise_out
out rise_outinteger
Count of rising edges.
Definition:
sim_edge_count.vhd:21
sim_edge_count.sim.fall
integer fall
Count of falling edges.
Definition:
sim_edge_count.vhd:32
sim_edge_count.sim.prev_signal
std_logic prev_signal
Previous signal.
Definition:
sim_edge_count.vhd:29
sim_edge_count.signal_in
in signal_instd_logic
Signal input.
Definition:
sim_edge_count.vhd:20
sim_edge_count.fall_out
out fall_outinteger
Count of falling edges.
Definition:
sim_edge_count.vhd:23
sim_edge_count.sim.prev_ok
std_logic prev_ok
Previous signal ok flag.
Definition:
sim_edge_count.vhd:30
sdm_tb.ieee
_library_ ieeeieee
Using IEEE library.
Definition:
sdm_tb.vhd:7
sim_edge_count.sim.rise
integer rise
Count of rising edges.
Definition:
sim_edge_count.vhd:31
fpga
common
utility
sim
sim_edge_count.vhd
Generated by
1.8.12