blob: 9fda0899709303f8369a801e1ee83e462a00fe71 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
-------------------------------------------------------------------------------
-- Module : t_falling_edge_detector
-------------------------------------------------------------------------------
-- Author : <haf@fh-augsburg.de>
-- Company : University of Applied Sciences Augsburg
-- Copyright (c) 2011 <haf@fh-augsburg.de>
-------------------------------------------------------------------------------
-- Description: Testbench for design "falling_edge_detector"
-------------------------------------------------------------------------------
-- Revisions : see end of file
-------------------------------------------------------------------------------
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
-------------------------------------------------------------------------------
ENTITY t_falling_edge_detector IS
END t_falling_edge_detector;
-------------------------------------------------------------------------------
ARCHITECTURE tbench OF t_falling_edge_detector IS
COMPONENT falling_edge_detector
PORT (
clk_i : IN std_ulogic;
rst_ni : IN std_ulogic;
x_i : IN std_ulogic;
fall_o : OUT std_ulogic);
END COMPONENT;
-- definition of a clock period
CONSTANT period : time := 10 ns;
-- switch for clock generator
SIGNAL clken_p : boolean := true;
-- component ports
SIGNAL clk_i : std_ulogic;
SIGNAL rst_ni : std_ulogic;
SIGNAL x_i : std_ulogic;
SIGNAL fall_o : std_ulogic;
BEGIN -- tbench
-- component instantiation
MUV : falling_edge_detector
PORT MAP (
clk_i => clk_i,
rst_ni => rst_ni,
x_i => x_i,
fall_o => fall_o);
-- clock generation
clock_p : PROCESS
BEGIN
WHILE clken_p LOOP
clk_i <= '0'; WAIT FOR period/2;
clk_i <= '1'; WAIT FOR period/2;
END LOOP;
WAIT;
END PROCESS;
-- initial reset, always necessary at the beginning of a simulation
reset : rst_ni <= '0', '1' AFTER period;
stimuli_p : PROCESS
BEGIN
WAIT UNTIL rst_ni = '1'; -- wait until asynchronous reset ...
-- ... is deactivated
---------------------------------------------------------------------------
-- create a low-active pulse over a no. of clock periods
---------------------------------------------------------------------------
x_i <= '1'; -- assign a '1' to x_i
WAIT FOR period;
x_i <= '0'; -- set input to '0' ...
WAIT UNTIL rising_edge(clk_i);
WAIT UNTIL falling_edge(clk_i);
-- Observer: check, if fall_o is assigned to '1' for one clock period
ASSERT fall_o = '1' REPORT "Error: Expected fall_o = '1' !" SEVERITY failure;
WAIT UNTIL falling_edge(clk_i);
ASSERT fall_o = '0' REPORT "Error: Expected fall_o = '0' !" SEVERITY failure;
WAIT FOR 6 * period; -- ... for a no. of periods
x_i <= '1'; -- assign a '1' to form a
WAIT FOR 3 * period; -- low active input pulse
---------------------------------------------------------------------------
-- add another low-active input pulse here ...
clken_p <= false; -- switch clock generator off
WAIT; -- suspend proces
END PROCESS;
END tbench;
-------------------------------------------------------------------------------
-- Revisions:
-- ----------
-- $Id:$
-------------------------------------------------------------------------------
|