Motion FPGA
Motion FPGA for the MachX02-7000HE Breakout Board
sim_on_percent.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 measure on-percentage of signal
16
ENTITY
sim_on_percent
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
percent_out
:
OUT
integer
--! On percentage output
22
)
;
23
END
ENTITY
sim_on_percent
;
24
25
--! Architecture sim of entity sim_on_percent
26
ARCHITECTURE
sim
OF
sim_on_percent
IS
27
28
SIGNAL
count
:
integer
;
--! Clock count
29
SIGNAL
count_on
:
integer
;
--! On count
30
31
BEGIN
32
33
--! @brief Counting process
34
--!
35
--! This process counts the clocks and signal on-time to get the percentage
36
pr_count :
PROCESS
(
clk_in
,
rst_in
)
IS
37
BEGIN
38
39
IF
(
rst_in
=
'
1
'
)
THEN
40
-- Reset counts
41
count
<=
0
;
42
count_on
<=
0
;
43
percent_out
<=
0
;
44
ELSIF
(
rising_edge
(
clk_in
)
)
THEN
45
-- Update counts
46
count
<=
count
+
1
;
47
IF
(
signal_in
=
'
1
'
)
THEN
48
count_on
<=
count_on
+
1
;
49
END
IF
;
50
51
-- Calculate percentage
52
IF
(
count
>
0
)
THEN
53
percent_out
<=
(
count_on
*
100
)
/
count
;
54
END
IF
;
55
END
IF
;
56
57
END
PROCESS
pr_count
;
58
59
END
ARCHITECTURE
sim
;
sim_on_percent.signal_in
in signal_instd_logic
Signal input.
Definition:
sim_on_percent.vhd:20
sim_on_percent
Entity to measure on-percentage of signal.
Definition:
sim_on_percent.vhd:16
sim_on_percent.clk_in
in clk_instd_logic
Clock.
Definition:
sim_on_percent.vhd:18
sim_on_percent.sim.count
integer count
Clock count.
Definition:
sim_on_percent.vhd:28
sim_on_percent.sim.count_on
integer count_on
On count.
Definition:
sim_on_percent.vhd:29
sim_edge_count.ieee
_library_ ieeeieee
Using IEEE library.
Definition:
sim_edge_count.vhd:7
sim_on_percent.rst_in
in rst_instd_logic
Asynchronous reset.
Definition:
sim_on_percent.vhd:19
sim_on_percent.percent_out
out percent_outinteger
On percentage output.
Definition:
sim_on_percent.vhd:22
fpga
common
utility
sim
sim_on_percent.vhd
Generated by
1.8.12