Stepper-Motor-Control  v3.0.0
System on a Chip 2014 - Group 04
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros
counter_tb.vhd
Go to the documentation of this file.
1 -------------------------------------------------------------------------------
2 --! @file counter_tb.vhd
3 --! @author Marc Kossmann
4 --! @author Michael Riedel
5 --! @version v1.0.0
6 --! @date 05.12.2014
7 --! @brief Testbench for counter component
8 --! @par History:
9 --! @details v0.1.0 23.11.2014 Kossmann
10 --! - first draft
11 --! @details v0.1.2 28.11.2014 Kossmann
12 --! - improved documentation
13 --! @details v0.1.3 05.12.2014 Riedel
14 --! - corrected formatting and indention
15 --! @details v1.0.0 05.12.2014 Riedel & Kossmann
16 --! - release milestone 3b
17 -------------------------------------------------------------------------------
18 
19 --! Use Standard Library
20 LIBRARY ieee;
21 --! Use Logic Elements
22 USE ieee.std_logic_1164.all;
23 
24 --! @brief Testbench entity
25 ENTITY counter_tb IS
26  GENERIC
27  (
28  --! @brief Prescaler for PWM-signal.
29  --! @details For this purpose 2,5 ms are used as minimal pulse-width.
30  --! @details The prescaler is calculated with the given and desired frequency
31  --! via the following formula:
32  --! \f{equation*}{
33  --! \text{prescaler} = \frac{f_{\text{clock}} \text{Hz}}{f_{\text{prescaler}} \text{Hz}}
34  --! \f}
35  --! e.g.:
36  --! \f{equation*}{
37  --! \left.\begin{aligned}
38  --! f_{\text{prescaler}} &= \frac{5}{2}\,\text{ms} \newline
39  --! &= 400\,\text{Hz} \newline\newline
40  --! \text{prescaler} &= \frac{50\,\text{Mhz}}{400\,\text{Hz}} \newline
41  --! &= 125000 \newline
42  --! \end{aligned}
43  --! \right\}
44  --! \qquad \text{pulse-width: 2.5 ms}
45  --! \f}
46  --! @details For simulation-purpose the divider was set to 125 for faster wave generation.
47  divider : INTEGER := 125
48  );
49 END;
50 
51 --! @brief Architecture of testbench
52 --! @details Just to test if counter works like expected
53 ARCHITECTURE counter_tb_arch OF counter_tb IS
54 
55  SIGNAL reset_n : STD_LOGIC := '0';
56  SIGNAL clock : STD_LOGIC := '0';
57  SIGNAL clk_out : STD_LOGIC := '0';
58  SIGNAL enable : STD_LOGIC := '0';
59 
60  COMPONENT counter
61  GENERIC
62  (
63  divider : INTEGER
64  );
65  PORT (
66  reset_n : IN STD_LOGIC;
67  clock : IN STD_LOGIC;
68  clk_out : OUT STD_LOGIC;
69  enable : IN STD_LOGIC
70  );
71  END COMPONENT;
72 
73 BEGIN
74  DUT : counter
75  GENERIC MAP
76  (
77  divider => divider
78  )
79  PORT MAP
80  (
81  reset_n => reset_n,
82  clock => clock,
83  clk_out => clk_out,
84  enable => enable
85  );
86 
87  clock <= NOT clock AFTER 10 ns;
88  enable <= '1' AFTER 20 ns;
89  reset_n <= '1' AFTER 20 ns;
90 
91  finish_sim_time : PROCESS
92  BEGIN
93  WAIT FOR 50 ms;
94  ASSERT false
95  REPORT "simulation finished"
96  SEVERITY failure;
97  END PROCESS finish_sim_time;
98 END;
99 
in enableSTD_LOGIC
enables component
Definition: counter.vhd:57
in reset_nSTD_LOGIC
global reset
Definition: counter.vhd:56
out clk_outSTD_LOGIC
divided clock output
Definition: counter.vhd:59
dividerINTEGER:=125
Prescaler for PWM-signal.
Definition: counter_tb.vhd:48
_library_ ieeeieee
Use Standard Library.
Definition: counter.vhd:24
Testbench entity.
Definition: counter_tb.vhd:25
Counter-Component.
Definition: counter.vhd:29
in clockSTD_LOGIC
input clock
Definition: counter.vhd:55
dividerINTEGER
Prescaler for PWM-signal.
Definition: counter.vhd:52