1 -----------------------------------------------------------------------------
2 --! @file signal_generator_tb.vhd
3 --! @author Marc Kossmann
4 --! @author Michael Riedel
8 --! @brief Testbench for Signal Generator Component
9 --! @details Tests full functionality of component
11 --! @details v0.1.0 26.11.2014 Riedel
13 --! @details v1.0.0 05.12.2014 Riedel & Kossmann
14 --! - release milestone 3b
15 -----------------------------------------------------------------------------
17 --! Use Standard Library
19 --! Use Logic Elements
20 USE ieee.STD_LOGIC_1164.
all;
21 --! Use Arithmetic Functions
22 USE ieee.STD_LOGIC_arith.
all;
23 --! Use Conversion Functions
24 USE ieee.STD_LOGIC_SIGNED.
all;
26 --! @brief Entity of testbench for signal_generator
30 --! @brief Architecture of testbench for signal_generator
31 --! @details Test-procedure (1): reset_n
32 --! | signal | desired output |
33 --! | :------------- | :--------------|
34 --! | mode_state | `IDLE` |
35 --! | pwm_state | `ONE` |
36 --! | steps_counter | `0` |
37 --! | motor_pwm | `0000` |
38 --! | motor_en | `00` |
40 --! @details Test-procedure (2): Continuous Run with speed = 0, direction = left
41 --! | signal | desired output |
42 --! | :------------- | :--------------|
43 --! | mode_state | `CR` |
44 --! | pwm_state | `ONE` |
45 --! | steps_counter | `0` |
46 --! | motor_pwm | `0000` |
47 --! | motor_en | `00` |
49 --! @details Test-procedure (3): Continuous Run with speed = 1, direction = left
50 --! | signal | desired output |
51 --! | :------------- | :-------------------------------------|
52 --! | mode_state | `CR` |
53 --! | pwm_state | cycling `ONE`, `TWO`, `THREE`, `FOUR` |
54 --! | steps_counter | `0` |
55 --! | motor_pwm | `0000` |
56 --! | motor_en | `00` |
58 --! @details Test-procedure (4): Continuous Run with speed = 7, direction = left
59 --! | signal | desired output |
60 --! | :------------- | :-------------------------------------|
61 --! | mode_state | `CR` |
62 --! | pwm_state | cycling `ONE`, `TWO`, `THREE`, `FOUR` |
63 --! | steps_counter | `0` |
64 --! | motor_pwm | `0000` |
65 --! | motor_en | `00` |
67 --! @details Test-procedure (5): Continuous Run with speed = 7, direction = right
68 --! | signal | desired output |
69 --! | :------------- | :-------------------------------------|
70 --! | mode_state | `CR` |
71 --! | pwm_state | cycling `FOUR`, `THREE`, `TWO`, `ONE` |
72 --! | steps_counter | `0` |
73 --! | motor_pwm | `0000` |
74 --! | motor_en | `00` |
76 --! @details Test-procedure (6): Chain of Steps - 1/4 rotation with speed = 0, direction = left
77 --! | signal | desired output |
78 --! | :------------- | :-------------------------------------|
79 --! | mode_state | `COS_1_4` |
80 --! | pwm_state | cycling `ONE`, `TWO`, `THREE`, `FOUR` |
81 --! | steps_counter | `0` |
82 --! | motor_pwm | `0000` |
83 --! | motor_en | `00` |
85 --! @details Test-procedure (7): Chain of Steps - 1/2 rotation with speed = 0, direction = left
86 --! | signal | desired output |
87 --! | :------------- | :-------------------------------------|
88 --! | mode_state | `COS_1_2` |
89 --! | pwm_state | cycling `ONE`, `TWO`, `THREE`, `FOUR` |
90 --! | steps_counter | `0` |
91 --! | motor_pwm | `0000` |
92 --! | motor_en | `00` |
94 --! @details Test-procedure (8): Chain of Steps - 1 rotation with speed = 0, direction = left
95 --! | signal | desired output |
96 --! | :------------- | :-------------------------------------|
97 --! | mode_state | `COS_1` |
98 --! | pwm_state | cycling `ONE`, `TWO`, `THREE`, `FOUR` |
99 --! | steps_counter | `0` |
100 --! | motor_pwm | `0000` |
101 --! | motor_en | `00` |
103 --! @details Test-procedure (9): Chain of Steps - 2 rotations with speed = 0, direction = left
104 --! | signal | desired output |
105 --! | :------------- | :-------------------------------------|
106 --! | mode_state | `COS_2` |
107 --! | pwm_state | cycling `ONE`, `TWO`, `THREE`, `FOUR` |
108 --! | steps_counter | `0` |
109 --! | motor_pwm | `0000` |
110 --! | motor_en | `00` |
114 SIGNAL motor_pwm : (3 DOWNTO 0);
115 SIGNAL reset_n : := '1';
116 SIGNAL clock : := '0';
118 SIGNAL speed : (2 DOWNTO 0);
119 SIGNAL mode : (3 DOWNTO 0);
120 SIGNAL motor_en : (1 DOWNTO 0);
121 SIGNAL steps : (31 DOWNTO 0);
123 SIGNAL enable : := '0';
125 CONSTANT left : := '0';
126 CONSTANT right : := NOT left;
135 speed :
IN (
2 DOWNTO 0);
136 mode :
IN (
3 DOWNTO 0);
138 steps :
OUT (
31 DOWNTO 0);
160 clock <= not clock after 10 ns;
--! creates the clock
161 reset_n <= '0' after 40 ns, --! initial reset-trigger
163 mode <= "0001" after 60 ns;
--! CR
164 direction <= right after 60 ns;
165 enable <=
not enable
after 30 ns;
166 speed <= "111" after 60 ns;
168 finish_sim_time :
PROCESS
172 REPORT "simulation finished"
174 END PROCESS finish_sim_time;
in speedSTD_LOGIC_VECTOR(2 DOWNTO0)
speed to run moter with
in modeSTD_LOGIC_VECTOR(3 DOWNTO0)
mode to run motor with
in reset_nSTD_LOGIC
resets the component
out motor_enSTD_LOGIC_VECTOR(1 DOWNTO0)
both enable signals for the motor
out irSTD_LOGIC
IR signal set when motor stopped.
out motor_pwmSTD_LOGIC_VECTOR(3 DOWNTO0)
signal-bus for the motor pulse-width-modulation
in clockSTD_LOGIC
component clock
_library_ ieeeieee
Use Standard Library.
out stepsSTD_LOGIC_VECTOR(31 DOWNTO0)
number of steps motor did
in directionSTD_LOGIC
motor direction ('0' is LEFT)
Entity of testbench for signal_generator.