shared_fooの不要ディレクトリ削除前のもの
Revision | 95e69d27192180fa210ad66112f9e898005731bd (tree) |
---|---|
Zeit | 2016-10-12 11:42:37 |
Autor | suikan <suikan@user...> |
Commiter | suikan |
Debug undergoing. Some problem in pipeline
@@ -37,3 +37,4 @@ | ||
37 | 37 | *** SESSION 10月 11, 2016 09:49:16.17 ------------------------------------------- |
38 | 38 | *** SESSION 10月 11, 2016 16:27:29.20 ------------------------------------------- |
39 | 39 | *** SESSION 10月 11, 2016 23:45:20.61 ------------------------------------------- |
40 | +*** SESSION 10月 12, 2016 10:36:46.53 ------------------------------------------- |
@@ -1,7 +1,7 @@ | ||
1 | 1 | <?xml version="1.0" encoding="UTF-8" standalone="no"?> |
2 | 2 | <plugin> |
3 | 3 | <extension point="org.eclipse.cdt.core.LanguageSettingsProvider"> |
4 | - <provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="-559817851880621334" id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}""> | |
4 | + <provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="-1296126488323303667" id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}""> | |
5 | 5 | <language-scope id="org.eclipse.cdt.core.gcc"/> |
6 | 6 | <language-scope id="org.eclipse.cdt.core.g++"/> |
7 | 7 | <language id="org.eclipse.cdt.core.gcc"> |
@@ -1,4 +1,4 @@ | ||
1 | -08:53:32 **** Incremental Build of configuration Debug for project cordic_sincos_testgen **** | |
1 | +11:38:46 **** Incremental Build of configuration Debug for project cordic_sincos_testgen **** | |
2 | 2 | make all |
3 | 3 | Building file: ../main.cpp |
4 | 4 | Invoking: GCC C++ Compiler |
@@ -11,5 +11,5 @@ g++ -o "cordic_sincos_testgen" ./vhdl/sincosangledelta.o ./vhdl/sincoscordic.o | ||
11 | 11 | Finished building target: cordic_sincos_testgen |
12 | 12 | |
13 | 13 | |
14 | -08:53:33 Build Finished (took 990ms) | |
14 | +11:38:46 Build Finished (took 570ms) | |
15 | 15 |
@@ -5273,3 +5273,72 @@ Invoking: GCC C++ Linker | ||
5273 | 5273 | g++ -o "cordic_sincos_testgen" ./vhdl/sincosangledelta.o ./vhdl/sincoscordic.o ./vhdl/sincosscalingfactor.o ./vhdl/sincossub.o ./main.o |
5274 | 5274 | Finished building target: cordic_sincos_testgen |
5275 | 5275 | |
5276 | +10:38:37 **** Incremental Build of configuration Debug for project cordic_sincos_testgen **** | |
5277 | +make all | |
5278 | +Building file: ../main.cpp | |
5279 | +Invoking: GCC C++ Compiler | |
5280 | +g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"main.d" -MT"main.d" -o "main.o" "../main.cpp" | |
5281 | +Finished building: ../main.cpp | |
5282 | + | |
5283 | +Building target: cordic_sincos_testgen | |
5284 | +Invoking: GCC C++ Linker | |
5285 | +g++ -o "cordic_sincos_testgen" ./vhdl/sincosangledelta.o ./vhdl/sincoscordic.o ./vhdl/sincosscalingfactor.o ./vhdl/sincossub.o ./main.o | |
5286 | +Finished building target: cordic_sincos_testgen | |
5287 | + | |
5288 | +10:48:30 **** Incremental Build of configuration Debug for project cordic_sincos_testgen **** | |
5289 | +make all | |
5290 | +Building file: ../main.cpp | |
5291 | +Invoking: GCC C++ Compiler | |
5292 | +g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"main.d" -MT"main.d" -o "main.o" "../main.cpp" | |
5293 | +Finished building: ../main.cpp | |
5294 | + | |
5295 | +Building target: cordic_sincos_testgen | |
5296 | +Invoking: GCC C++ Linker | |
5297 | +g++ -o "cordic_sincos_testgen" ./vhdl/sincosangledelta.o ./vhdl/sincoscordic.o ./vhdl/sincosscalingfactor.o ./vhdl/sincossub.o ./main.o | |
5298 | +Finished building target: cordic_sincos_testgen | |
5299 | + | |
5300 | +10:48:33 **** Incremental Build of configuration Debug for project cordic_sincos_testgen **** | |
5301 | +make all | |
5302 | +make: 'all' に対して行うべき事はありません. | |
5303 | +10:49:43 **** Incremental Build of configuration Debug for project cordic_sincos_testgen **** | |
5304 | +make all | |
5305 | +Building file: ../main.cpp | |
5306 | +Invoking: GCC C++ Compiler | |
5307 | +g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"main.d" -MT"main.d" -o "main.o" "../main.cpp" | |
5308 | +Finished building: ../main.cpp | |
5309 | + | |
5310 | +Building target: cordic_sincos_testgen | |
5311 | +Invoking: GCC C++ Linker | |
5312 | +g++ -o "cordic_sincos_testgen" ./vhdl/sincosangledelta.o ./vhdl/sincoscordic.o ./vhdl/sincosscalingfactor.o ./vhdl/sincossub.o ./main.o | |
5313 | +Finished building target: cordic_sincos_testgen | |
5314 | + | |
5315 | +10:49:45 **** Incremental Build of configuration Debug for project cordic_sincos_testgen **** | |
5316 | +make all | |
5317 | +make: 'all' に対して行うべき事はありません. | |
5318 | +11:33:30 **** Incremental Build of configuration Debug for project cordic_sincos_testgen **** | |
5319 | +make all | |
5320 | +Building file: ../main.cpp | |
5321 | +Invoking: GCC C++ Compiler | |
5322 | +g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"main.d" -MT"main.d" -o "main.o" "../main.cpp" | |
5323 | +Finished building: ../main.cpp | |
5324 | + | |
5325 | +Building target: cordic_sincos_testgen | |
5326 | +Invoking: GCC C++ Linker | |
5327 | +g++ -o "cordic_sincos_testgen" ./vhdl/sincosangledelta.o ./vhdl/sincoscordic.o ./vhdl/sincosscalingfactor.o ./vhdl/sincossub.o ./main.o | |
5328 | +Finished building target: cordic_sincos_testgen | |
5329 | + | |
5330 | +11:36:12 **** Incremental Build of configuration Debug for project cordic_sincos_testgen **** | |
5331 | +make all | |
5332 | +make: 'all' に対して行うべき事はありません. | |
5333 | +11:38:46 **** Incremental Build of configuration Debug for project cordic_sincos_testgen **** | |
5334 | +make all | |
5335 | +Building file: ../main.cpp | |
5336 | +Invoking: GCC C++ Compiler | |
5337 | +g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"main.d" -MT"main.d" -o "main.o" "../main.cpp" | |
5338 | +Finished building: ../main.cpp | |
5339 | + | |
5340 | +Building target: cordic_sincos_testgen | |
5341 | +Invoking: GCC C++ Linker | |
5342 | +g++ -o "cordic_sincos_testgen" ./vhdl/sincosangledelta.o ./vhdl/sincoscordic.o ./vhdl/sincosscalingfactor.o ./vhdl/sincossub.o ./main.o | |
5343 | +Finished building target: cordic_sincos_testgen | |
5344 | + |
@@ -1,359 +0,0 @@ | ||
1 | -/** | |
2 | - * \file main.cpp | |
3 | - * | |
4 | - * \date 2016/10/01 | |
5 | - * \author: takemasa | |
6 | - * \brief Test vector Generator for cordic_sincos VHDL project | |
7 | - */ | |
8 | - | |
9 | -#include <iostream> | |
10 | -#include <bitset> | |
11 | -#include <string> | |
12 | -#include <cmath> | |
13 | - | |
14 | -#include <fstream> // ifstream, ofstream | |
15 | - | |
16 | -#include "main.h" | |
17 | - | |
18 | -/** | |
19 | - * \bfief main function | |
20 | - */ | |
21 | - | |
22 | -int main() { | |
23 | - | |
24 | - | |
25 | - char filename_vector_0[] = "sincossub_0.vec.txt"; | |
26 | - char filename_reference_0[] = "sincossub_0.ref.txt"; | |
27 | - | |
28 | - char filename_vector_1[] = "sincossub_1.vec.txt"; | |
29 | - char filename_reference_1[] = "sincossub_1.ref.txt"; | |
30 | - | |
31 | - char filename_vector_2[] = "sincossub_2.vec.txt"; | |
32 | - char filename_reference_2[] = "sincossub_2.ref.txt"; | |
33 | - | |
34 | - char filename_vector_3[] = "sincossub_3.vec.txt"; | |
35 | - char filename_reference_3[] = "sincossub_3.ref.txt"; | |
36 | - | |
37 | - char filename_vector_4[] = "sincossub_4.vec.txt"; | |
38 | - char filename_reference_4[] = "sincossub_4.ref.txt"; | |
39 | - | |
40 | - char filename_angle_delta[] = "sincos_angle_delta.txt"; | |
41 | - | |
42 | - char filename_scaling_factor[] = "sincos_scaling_factor.txt"; | |
43 | - | |
44 | - std::ofstream vector_5; vector_5.open("sincos_0.vec.txt"); | |
45 | - std::ofstream reference_5; reference_5.open("sincos_0.ref.txt"); | |
46 | - | |
47 | - // positive x, | |
48 | - test_0( filename_vector_0, filename_reference_0); | |
49 | - | |
50 | - // negative x | |
51 | - test_1( filename_vector_1, filename_reference_1); | |
52 | - | |
53 | - //positive x, rounding up | |
54 | - test_2( filename_vector_2, filename_reference_2); | |
55 | - | |
56 | - // negative x rouding up | |
57 | - test_3( filename_vector_3, filename_reference_3); | |
58 | - | |
59 | - // positive x, async reset test | |
60 | - test_4( filename_vector_4, filename_reference_4); | |
61 | - | |
62 | - gen_table( filename_angle_delta, filename_scaling_factor); | |
63 | - | |
64 | - | |
65 | - test_100( vector_5, reference_5, 24 ); | |
66 | - | |
67 | - | |
68 | -} | |
69 | - | |
70 | - /** | |
71 | - * \brief shift rith arithmetic with rounding. | |
72 | - */ | |
73 | -int round_shift( int operand, int shift) | |
74 | -{ | |
75 | - if (shift > 0) | |
76 | - return ( operand + (1<<(shift-1)) ) >> shift ; | |
77 | - else | |
78 | - return operand; | |
79 | -} | |
80 | - | |
81 | - | |
82 | -void gen_table( const char * filename_angle_delta, const char * filename_scaling_factor) | |
83 | -{ | |
84 | - std::ofstream angle_delta; angle_delta.open(filename_angle_delta); | |
85 | - std::ofstream scaling_factor; scaling_factor.open(filename_scaling_factor); | |
86 | - | |
87 | - vhdl::sincos_angle_delta ad; | |
88 | - vhdl::sincos_scaling_factor sf; | |
89 | - | |
90 | - // Initialize the scaling factor and angle delta table. | |
91 | - for ( int i = 0; i<vhdl::angle_delta_table_size; i++ ) | |
92 | - { | |
93 | - // output to the file | |
94 | - scaling_factor << std::bitset<32>( sf.table[i] ) << std::endl; | |
95 | - | |
96 | - // output to the file | |
97 | - angle_delta << std::bitset<32>( ad.table[i] ) << std::endl; | |
98 | - } | |
99 | -} | |
100 | - | |
101 | - | |
102 | -void test_async_9bit( std::ostream &vec, std::ostream &ref, int x, int angle, int p, int q, int reset, int clk) | |
103 | -{ | |
104 | -#ifdef BITWIDTH | |
105 | -#undef BITWIDTH | |
106 | -#undef SHIFT | |
107 | -#undef ANGLEDELTA | |
108 | -#endif | |
109 | - | |
110 | -#define BITWIDTH 9 | |
111 | -#define SHIFT 3 | |
112 | -#define ANGLEDELTA 31 | |
113 | - | |
114 | - static int last_angle = 0, last_q = 0, last_p = 0 , last_x = 0; | |
115 | - static vhdl::sincos_sub sincos_sub_module; | |
116 | - | |
117 | - vec << std::bitset<1>(reset) << " " | |
118 | - << std::bitset<1>(clk) << " " | |
119 | - << std::bitset<BITWIDTH>(x) << " " | |
120 | - << std::bitset<BITWIDTH>(angle) << " " | |
121 | - << std::bitset<BITWIDTH>(p) << " " | |
122 | - << std::bitset<BITWIDTH>(q) << std::endl; | |
123 | - | |
124 | - sincos_sub_module.run( SHIFT, ANGLEDELTA, clk, reset, x, last_x, angle, last_angle, p, last_p, q, last_q ); | |
125 | - | |
126 | - ref << std::bitset<BITWIDTH>( last_x ) << " " | |
127 | - << std::bitset<BITWIDTH>( last_angle ) << " " | |
128 | - << std::bitset<BITWIDTH>( last_p ) << " " | |
129 | - << std::bitset<BITWIDTH>( last_q ) << std::endl; | |
130 | - | |
131 | -} | |
132 | - | |
133 | -void test_async_13bit( std::ostream &vec, std::ostream &ref, int x, int angle, int p, int q, int reset, int clk) | |
134 | -{ | |
135 | -#ifdef BITWIDTH | |
136 | -#undef BITWIDTH | |
137 | -#undef SHIFT | |
138 | -#undef ANGLEDELTA | |
139 | -#endif | |
140 | - | |
141 | -#define BITWIDTH 13 | |
142 | -#define SHIFT 4 | |
143 | -#define ANGLEDELTA 65 | |
144 | - | |
145 | - static int last_angle = 0, last_q = 0, last_p = 0 , last_x = 0; | |
146 | - static vhdl::sincos_sub sincos_sub_module; | |
147 | - | |
148 | - vec << std::bitset<1>(reset) << " " | |
149 | - << std::bitset<1>(clk) << " " | |
150 | - << std::bitset<BITWIDTH>(x) << " " | |
151 | - << std::bitset<BITWIDTH>(angle) << " " | |
152 | - << std::bitset<BITWIDTH>(p) << " " | |
153 | - << std::bitset<BITWIDTH>(q) << std::endl; | |
154 | - | |
155 | - sincos_sub_module.run( SHIFT, ANGLEDELTA, clk, reset, x, last_x, angle, last_angle, p, last_p, q, last_q ); | |
156 | - | |
157 | - ref << std::bitset<BITWIDTH>( last_x ) << " " | |
158 | - << std::bitset<BITWIDTH>( last_angle ) << " " | |
159 | - << std::bitset<BITWIDTH>( last_p ) << " " | |
160 | - << std::bitset<BITWIDTH>( last_q ) << std::endl; | |
161 | - | |
162 | -} | |
163 | - | |
164 | -void test_async_11bit( std::ostream &vec, std::ostream &ref, int x, int angle, int p, int q, int reset, int clk) | |
165 | -{ | |
166 | -#ifdef BITWIDTH | |
167 | -#undef BITWIDTH | |
168 | -#undef SHIFT | |
169 | -#undef ANGLEDELTA | |
170 | -#endif | |
171 | - | |
172 | -#define BITWIDTH 11 | |
173 | -#define SHIFT 2 | |
174 | -#define ANGLEDELTA 65 | |
175 | - | |
176 | - int last_angle = 0, last_q = 0, last_p = 0 , last_x = 0; | |
177 | - static vhdl::sincos_sub sincos_sub_module; | |
178 | - | |
179 | - vec << std::bitset<1>(reset) << " " | |
180 | - << std::bitset<1>(clk) << " " | |
181 | - << std::bitset<BITWIDTH>(x) << " " | |
182 | - << std::bitset<BITWIDTH>(angle) << " " | |
183 | - << std::bitset<BITWIDTH>(p) << " " | |
184 | - << std::bitset<BITWIDTH>(q) << std::endl; | |
185 | - | |
186 | - sincos_sub_module.run( SHIFT, ANGLEDELTA, clk, reset, x, last_x, angle, last_angle, p, last_p, q, last_q ); | |
187 | - | |
188 | - ref << std::bitset<BITWIDTH>( last_x ) << " " | |
189 | - << std::bitset<BITWIDTH>( last_angle ) << " " | |
190 | - << std::bitset<BITWIDTH>( last_p ) << " " | |
191 | - << std::bitset<BITWIDTH>( last_q ) << std::endl; | |
192 | - | |
193 | -} | |
194 | - | |
195 | -void test_0( char *vec_name, char * ref_name) // positive rounding | |
196 | -{ | |
197 | - std::ofstream vec; vec.open(vec_name); | |
198 | - std::ofstream ref; ref.open(ref_name); | |
199 | - // reset | |
200 | - test_async_9bit(vec, ref, 23, 0, 60, 10, 1, 0); // x, angle, p, q, reset, clk // CCW | |
201 | - | |
202 | - // positive rounding | |
203 | - test_async_9bit(vec, ref, 23, 0, 60, 10, 0, 0); // x, angle, p, q, reset, clk // CCW | |
204 | - test_async_9bit(vec, ref, 23, 0, 60, 10, 0, 1); // x, angle, p, q, reset, clk // CCW | |
205 | - test_async_9bit(vec, ref, 23, 0, 60, 10, 0, 1); // x, angle, p, q, reset, clk // CCW | |
206 | - test_async_9bit(vec, ref, 23, 0, 60, 10, 0, 0); // x, angle, p, q, reset, clk // CCW | |
207 | - | |
208 | - test_async_9bit(vec, ref, 23, 24, 60, 10, 0, 0); // x, angle, p, q, reset, clk // CW | |
209 | - test_async_9bit(vec, ref, 23, 24, 60, 10, 0, 1); // x, angle, p, q, reset, clk // CW | |
210 | - test_async_9bit(vec, ref, 23, 24, 60, 10, 0, 1); // x, angle, p, q, reset, clk // CW | |
211 | - test_async_9bit(vec, ref, 23, 24, 60, 10, 0, 0); // x, angle, p, q, reset, clk // CW | |
212 | -} | |
213 | - | |
214 | -void test_1( char *vec_name, char * ref_name) // positive no rounding | |
215 | -{ | |
216 | - std::ofstream vec; vec.open(vec_name); | |
217 | - std::ofstream ref; ref.open(ref_name); | |
218 | - // reset | |
219 | - test_async_9bit(vec, ref, -23, 0, 60, -10, 1, 0); // x, angle, p, q, reset, clk // CW | |
220 | - | |
221 | - // positive no roundingb | |
222 | - test_async_9bit(vec, ref, -23, 0, 60, -10, 0, 0); // x, angle, p, q, reset, clk // CW | |
223 | - test_async_9bit(vec, ref, -23, 0, 60, -10, 0, 1); // x, angle, p, q, reset, clk // CW | |
224 | - test_async_9bit(vec, ref, -23, 0, 60, -10, 0, 1); // x, angle, p, q, reset, clk // CW | |
225 | - test_async_9bit(vec, ref, -23, 0, 60, -10, 0, 0); // x, angle, p, q, reset, clk // CW | |
226 | - | |
227 | - test_async_9bit(vec, ref, -23, -24, 60, -10, 0, 0); // x, angle, p, q, reset, clk // CCW | |
228 | - test_async_9bit(vec, ref, -23, -24, 60, -10, 0, 1); // x, angle, p, q, reset, clk // CCW | |
229 | - test_async_9bit(vec, ref, -23, -24, 60, -10, 0, 1); // x, angle, p, q, reset, clk // CCW | |
230 | - test_async_9bit(vec, ref, -23, -24, 60, -10, 0, 0); // x, angle, p, q, reset, clk // CCW | |
231 | - | |
232 | -} | |
233 | - | |
234 | -void test_2( char *vec_name, char * ref_name) // positive rounding | |
235 | -{ | |
236 | - std::ofstream vec; vec.open(vec_name); | |
237 | - std::ofstream ref; ref.open(ref_name); | |
238 | - // reset | |
239 | - test_async_13bit(vec, ref, 23, 0, 16, 64, 1, 0 ); // x, angle, p, q, reset, clk | |
240 | - | |
241 | - // positive rounding | |
242 | - test_async_13bit(vec, ref, 23, 0, 16, 64, 0, 0 ); // x, angle, p, q, reset, clk | |
243 | - test_async_13bit(vec, ref, 23, 0, 16, 64, 0, 1 ); // x, angle, p, q, reset, clk | |
244 | - test_async_13bit(vec, ref, 23, 0, 16, 64, 0, 1 ); // x, angle, p, q, reset, clk | |
245 | - test_async_13bit(vec, ref, 23, 0, 16, 64, 0, 0 ); // x, angle, p, q, reset, clk | |
246 | - | |
247 | - test_async_13bit(vec, ref, 23, 0, 31, 64, 0, 0 ); // x, angle, p, q, reset, clk // same with above when truncated, +1 when rounding | |
248 | - test_async_13bit(vec, ref, 23, 0, 31, 64, 0, 1 ); // x, angle, p, q, reset, clk | |
249 | - test_async_13bit(vec, ref, 23, 0, 31, 64, 0, 1 ); // x, angle, p, q, reset, clk | |
250 | - test_async_13bit(vec, ref, 23, 0, 31, 64, 0, 0 ); // x, angle, p, q, reset, clk | |
251 | -} | |
252 | - | |
253 | -void test_3( char *vec_name, char * ref_name) // negative rounding | |
254 | -{ | |
255 | - std::ofstream vec; vec.open(vec_name); | |
256 | - std::ofstream ref; ref.open(ref_name); | |
257 | - | |
258 | - // reset | |
259 | - test_async_13bit(vec, ref, -23, -24, 16, 64, 1, 0 ); // x, angle, p, q, reset, clk // | |
260 | - | |
261 | - // negative rounding | |
262 | - test_async_13bit(vec, ref, -23, -24, 16, 64, 0, 0 ); // x, angle, p, q, reset, clk // | |
263 | - test_async_13bit(vec, ref, -23, -24, 16, 64, 0, 1 ); // x, angle, p, q, reset, clk // | |
264 | - test_async_13bit(vec, ref, -23, -24, 16, 64, 0, 1 ); // x, angle, p, q, reset, clk // | |
265 | - test_async_13bit(vec, ref, -23, -24, 16, 64, 0, 0 ); // x, angle, p, q, reset, clk // | |
266 | - | |
267 | - test_async_13bit(vec, ref, -23, -24, 31, 64, 0, 0 ); // x, angle, p, q, reset, clk // same with above when truncated, +1 when rounding | |
268 | - test_async_13bit(vec, ref, -23, -24, 31, 64, 0, 1 ); // x, angle, p, q, reset, clk | |
269 | - test_async_13bit(vec, ref, -23, -24, 31, 64, 0, 1 ); // x, angle, p, q, reset, clk | |
270 | - test_async_13bit(vec, ref, -23, -24, 31, 64, 0, 0 ); // x, angle, p, q, reset, clk | |
271 | -} | |
272 | - | |
273 | - | |
274 | -void test_4( char *vec_name, char * ref_name) // async reset | |
275 | -{ | |
276 | - std::ofstream vec; vec.open(vec_name); | |
277 | - std::ofstream ref; ref.open(ref_name); | |
278 | - | |
279 | - test_async_11bit(vec, ref, 23, 0, 500, 230, 1, 0 ); // x, angle, p, q, reset, clk | |
280 | - test_async_11bit(vec, ref, 23, 0, 500, 20, 1, 1 ); // x, angle, p, q, reset, clk | |
281 | - test_async_11bit(vec, ref, 23, 25, 500, 20, 1, 0 ); // x, angle, p, q, reset, clk | |
282 | - test_async_11bit(vec, ref, 23, 0, 500, 230, 0, 0 ); // x, angle, p, q, reset, clk | |
283 | - test_async_11bit(vec, ref, 23, 0, 500, 230, 0, 1 ); // x, angle, p, q, reset, clk | |
284 | - test_async_11bit(vec, ref, 23, 0, 430, 75, 0, 0 ); // x, angle, p, q, reset, clk | |
285 | - test_async_11bit(vec, ref, 23, 0, 430, 75, 1, 0 ); // x, angle, p, q, reset, clk | |
286 | - test_async_11bit(vec, ref, 23, 0, 430, 75, 0, 0 ); // x, angle, p, q, reset, clk | |
287 | - test_async_11bit(vec, ref, 23, 0, 430, 75, 0, 1 ); // x, angle, p, q, reset, clk | |
288 | - test_async_11bit(vec, ref, 23, 0, 430, 75, 1, 1 ); // x, angle, p, q, reset, clk | |
289 | - test_async_11bit(vec, ref, 23, 0, 430, 75, 0, 1 ); // x, angle, p, q, reset, clk | |
290 | - test_async_11bit(vec, ref, 23, 32, 430, 75, 0, 0 ); // x, angle, p, q, reset, clk | |
291 | - test_async_11bit(vec, ref, 23, 32, 430, 75, 0, 1 ); // x, angle, p, q, reset, clk | |
292 | -} | |
293 | - | |
294 | - | |
295 | - /** | |
296 | - * \brief sincos CORDIC algorithm. | |
297 | - * \param x | |
298 | - * \param p | |
299 | - * \param q | |
300 | - * \param num_stages | |
301 | - * \param bit_width | |
302 | - */ | |
303 | -void cordic_sincos_bw32( std::ostream &vec, std::ostream &ref, int num_stages, int x, int reset, int clk ) | |
304 | -{ | |
305 | -#ifdef BITWIDTH | |
306 | -#undef BITWIDTH | |
307 | -#endif | |
308 | - | |
309 | -#define BITWIDTH 32 | |
310 | - | |
311 | - int out_p, out_q; | |
312 | - | |
313 | - static vhdl::sincos_angle_delta ad; | |
314 | - static vhdl::sincos_scaling_factor sf; | |
315 | - static vhdl::sincos_cordic cordic; | |
316 | - | |
317 | - | |
318 | - vec | |
319 | - << std::bitset<1>( reset ) << " " // reset | |
320 | - << std::bitset<1>( clk ) << " " // clock | |
321 | - << std::bitset<BITWIDTH>( x ) << std::endl; | |
322 | - | |
323 | - cordic.run( 20, clk, reset, x, out_p, out_q ); | |
324 | - | |
325 | - ref | |
326 | - << std::bitset<BITWIDTH>( out_p ) << " " | |
327 | - << std::bitset<BITWIDTH>( out_q ) << std::endl; | |
328 | - | |
329 | - | |
330 | -} | |
331 | - | |
332 | -void test_100( std::ostream &vec, std::ostream &ref, int num_stages ) | |
333 | -{ | |
334 | - | |
335 | - int x = 0; | |
336 | - | |
337 | - // reset | |
338 | - cordic_sincos_bw32( vec, ref, num_stages, x, 1, 0 ); | |
339 | - | |
340 | - // scan [-0.5, 0.5) | |
341 | - for ( int i = -64; i < 63; i++ ) | |
342 | - { | |
343 | - cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); | |
344 | - x = i << 24; | |
345 | - cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); | |
346 | - cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); | |
347 | - cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); | |
348 | - } | |
349 | - | |
350 | - // flush pipeline | |
351 | - for ( int i = 0; i < num_stages; i++ ) | |
352 | - { | |
353 | - cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); | |
354 | - x = i << 16; | |
355 | - cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); | |
356 | - cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); | |
357 | - cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); | |
358 | - } | |
359 | -} |
@@ -1,69 +0,0 @@ | ||
1 | -#! /bin/bash | |
2 | - | |
3 | -# subroutine for test | |
4 | -# The first parameter is the file body except extention | |
5 | -# the second parameter is description of test | |
6 | -function dotest() { | |
7 | -# file comparision | |
8 | - diff $1.dut.txt $1.ref.txt > $1.log.txt | |
9 | - | |
10 | -# Display message based on the result | |
11 | - if [ $? = "0" ] ; then | |
12 | -# if matched | |
13 | - echo -e "\e[32;1mGood!\e[m : $2 :" $1.log.txt | |
14 | - else | |
15 | -# if not matched | |
16 | - echo -e "\e[31;1mNG \e[m : $2 :" $1.log.txt | |
17 | - fi | |
18 | -} | |
19 | - | |
20 | - | |
21 | -echo | |
22 | -echo "############## BUILDING ##############" | |
23 | -echo | |
24 | - | |
25 | -# refresh the work directory | |
26 | -rm work -r -f | |
27 | - | |
28 | -# create a work directory | |
29 | -vlib work | |
30 | - | |
31 | -# copy test vector and reference data | |
32 | -cp ../cordic_sincos_testgen/*.vec.txt . | |
33 | -cp ../cordic_sincos_testgen/*.ref.txt . | |
34 | - | |
35 | -# compile the VHDL source and put the object into the work library. | |
36 | -# -2008 mean, based on the VHDL 2008 | |
37 | - | |
38 | -vcom -explicit -work work -2008 -quiet "src/sincos_sub.vhd" | |
39 | -vcom -explicit -work work -2008 -quiet "src/sincos_sub_bench_0.vhd" | |
40 | -vcom -explicit -work work -2008 -quiet "src/sincos_sub_bench_1.vhd" | |
41 | -vcom -explicit -work work -2008 -quiet "src/sincos_sub_bench_2.vhd" | |
42 | -vcom -explicit -work work -2008 -quiet "src/sincos_sub_bench_3.vhd" | |
43 | -vcom -explicit -work work -2008 -quiet "src/sincos_sub_bench.vhd" | |
44 | - | |
45 | -echo | |
46 | -echo "############# SIMULATING #############" | |
47 | -echo | |
48 | - | |
49 | -# vsim is modelsim simulator. This command runs the | |
50 | -# test_bech module of the work library. | |
51 | -# -c : command line only | |
52 | -# -do : execute given string as command. | |
53 | - | |
54 | -vsim work.sincos_sub_bench -c -quiet -do "run 10us; quit" | |
55 | - | |
56 | -# display the result | |
57 | - | |
58 | -echo | |
59 | -echo "######### SIMULATION RESULTS #########" | |
60 | -echo " If the result is good, log file is empty" | |
61 | -echo | |
62 | - | |
63 | -# invoke the suroutine defined at the top of file. | |
64 | -dotest sincossub_0 " 9bit test, positive x " | |
65 | -dotest sincossub_1 " 9bit test, negative x " | |
66 | -dotest sincossub_2 "13bit test, positive x, rounding" | |
67 | -dotest sincossub_3 "13bit test, negative x, rounding" | |
68 | - | |
69 | -echo |
@@ -22,27 +22,32 @@ | ||
22 | 22 | int main() { |
23 | 23 | |
24 | 24 | |
25 | - char filename_vector_0[] = "sincossub_0.vec.txt"; | |
26 | - char filename_reference_0[] = "sincossub_0.ref.txt"; | |
25 | + char filename_vector_0[] = "fileout/sincossub_0.vec.txt"; | |
26 | + char filename_reference_0[] = "fileout/sincossub_0.ref.txt"; | |
27 | 27 | |
28 | - char filename_vector_1[] = "sincossub_1.vec.txt"; | |
29 | - char filename_reference_1[] = "sincossub_1.ref.txt"; | |
28 | + char filename_vector_1[] = "fileout/sincossub_1.vec.txt"; | |
29 | + char filename_reference_1[] = "fileout/sincossub_1.ref.txt"; | |
30 | 30 | |
31 | - char filename_vector_2[] = "sincossub_2.vec.txt"; | |
32 | - char filename_reference_2[] = "sincossub_2.ref.txt"; | |
31 | + char filename_vector_2[] = "fileout/sincossub_2.vec.txt"; | |
32 | + char filename_reference_2[] = "fileout/sincossub_2.ref.txt"; | |
33 | 33 | |
34 | - char filename_vector_3[] = "sincossub_3.vec.txt"; | |
35 | - char filename_reference_3[] = "sincossub_3.ref.txt"; | |
34 | + char filename_vector_3[] = "fileout/sincossub_3.vec.txt"; | |
35 | + char filename_reference_3[] = "fileout/sincossub_3.ref.txt"; | |
36 | 36 | |
37 | - char filename_vector_4[] = "sincossub_4.vec.txt"; | |
38 | - char filename_reference_4[] = "sincossub_4.ref.txt"; | |
37 | + char filename_vector_4[] = "fileout/sincossub_4.vec.txt"; | |
38 | + char filename_reference_4[] = "fileout/sincossub_4.ref.txt"; | |
39 | 39 | |
40 | - char filename_angle_delta[] = "sincos_angle_delta.txt"; | |
40 | + char filename_vector_5[] = "fileout/sincossub_5.vec.txt"; | |
41 | + char filename_reference_5[] = "fileout/sincossub_5.ref.txt"; | |
41 | 42 | |
42 | - char filename_scaling_factor[] = "sincos_scaling_factor.txt"; | |
43 | + char filename_angle_delta[] = "fileout/sincos_angle_delta.txt"; | |
44 | + char filename_scaling_factor[] = "fileout/sincos_scaling_factor.txt"; | |
43 | 45 | |
44 | - std::ofstream vector_5; vector_5.open("sincos_0.vec.txt"); | |
45 | - std::ofstream reference_5; reference_5.open("sincos_0.ref.txt"); | |
46 | + char filename_vector_100[] = "fileout/sincos_100.vec.txt"; | |
47 | + char filename_reference_100[] = "fileout/sincos_100.ref.txt"; | |
48 | + | |
49 | + char filename_vector_101[] = "fileout/sincos_101.vec.txt"; | |
50 | + char filename_reference_101[] = "fileout/sincos_101.ref.txt"; | |
46 | 51 | |
47 | 52 | // positive x, |
48 | 53 | test_0( filename_vector_0, filename_reference_0); |
@@ -59,10 +64,16 @@ int main() { | ||
59 | 64 | // positive x, async reset test |
60 | 65 | test_4( filename_vector_4, filename_reference_4); |
61 | 66 | |
62 | - gen_table( filename_angle_delta, filename_scaling_factor); | |
67 | + // positive x, async reset test | |
68 | + test_5( filename_vector_5, filename_reference_5); | |
69 | + | |
70 | +gen_table( filename_angle_delta, filename_scaling_factor); | |
71 | + | |
63 | 72 | |
73 | + test_100( filename_vector_100, filename_reference_100, 20 ); | |
64 | 74 | |
65 | - test_100( vector_5, reference_5, 24 ); | |
75 | + // test signal and clock changes simul. | |
76 | + test_101( filename_vector_101, filename_reference_101, 20 ); | |
66 | 77 | |
67 | 78 | |
68 | 79 | } |
@@ -98,99 +109,12 @@ void gen_table( const char * filename_angle_delta, const char * filename_scaling | ||
98 | 109 | } |
99 | 110 | } |
100 | 111 | |
112 | +/***************************************************************** | |
113 | + * | |
114 | + * SINCOS SUB vector generation | |
115 | + * | |
116 | + *****************************************************************/ | |
101 | 117 | |
102 | -void test_async_9bit( std::ostream &vec, std::ostream &ref, int x, int angle, int p, int q, int reset, int clk) | |
103 | -{ | |
104 | -#ifdef BITWIDTH | |
105 | -#undef BITWIDTH | |
106 | -#undef SHIFT | |
107 | -#undef ANGLEDELTA | |
108 | -#endif | |
109 | - | |
110 | -#define BITWIDTH 9 | |
111 | -#define SHIFT 3 | |
112 | -#define ANGLEDELTA 31 | |
113 | - | |
114 | - static int last_angle = 0, last_q = 0, last_p = 0 , last_x = 0; | |
115 | - static vhdl::sincos_sub sincos_sub_module; | |
116 | - | |
117 | - vec << std::bitset<1>(reset) << " " | |
118 | - << std::bitset<1>(clk) << " " | |
119 | - << std::bitset<BITWIDTH>(x) << " " | |
120 | - << std::bitset<BITWIDTH>(angle) << " " | |
121 | - << std::bitset<BITWIDTH>(p) << " " | |
122 | - << std::bitset<BITWIDTH>(q) << std::endl; | |
123 | - | |
124 | - sincos_sub_module.run( SHIFT, ANGLEDELTA, clk, reset, x, last_x, angle, last_angle, p, last_p, q, last_q ); | |
125 | - | |
126 | - ref << std::bitset<BITWIDTH>( last_x ) << " " | |
127 | - << std::bitset<BITWIDTH>( last_angle ) << " " | |
128 | - << std::bitset<BITWIDTH>( last_p ) << " " | |
129 | - << std::bitset<BITWIDTH>( last_q ) << std::endl; | |
130 | - | |
131 | -} | |
132 | - | |
133 | -void test_async_13bit( std::ostream &vec, std::ostream &ref, int x, int angle, int p, int q, int reset, int clk) | |
134 | -{ | |
135 | -#ifdef BITWIDTH | |
136 | -#undef BITWIDTH | |
137 | -#undef SHIFT | |
138 | -#undef ANGLEDELTA | |
139 | -#endif | |
140 | - | |
141 | -#define BITWIDTH 13 | |
142 | -#define SHIFT 4 | |
143 | -#define ANGLEDELTA 65 | |
144 | - | |
145 | - static int last_angle = 0, last_q = 0, last_p = 0 , last_x = 0; | |
146 | - static vhdl::sincos_sub sincos_sub_module; | |
147 | - | |
148 | - vec << std::bitset<1>(reset) << " " | |
149 | - << std::bitset<1>(clk) << " " | |
150 | - << std::bitset<BITWIDTH>(x) << " " | |
151 | - << std::bitset<BITWIDTH>(angle) << " " | |
152 | - << std::bitset<BITWIDTH>(p) << " " | |
153 | - << std::bitset<BITWIDTH>(q) << std::endl; | |
154 | - | |
155 | - sincos_sub_module.run( SHIFT, ANGLEDELTA, clk, reset, x, last_x, angle, last_angle, p, last_p, q, last_q ); | |
156 | - | |
157 | - ref << std::bitset<BITWIDTH>( last_x ) << " " | |
158 | - << std::bitset<BITWIDTH>( last_angle ) << " " | |
159 | - << std::bitset<BITWIDTH>( last_p ) << " " | |
160 | - << std::bitset<BITWIDTH>( last_q ) << std::endl; | |
161 | - | |
162 | -} | |
163 | - | |
164 | -void test_async_11bit( std::ostream &vec, std::ostream &ref, int x, int angle, int p, int q, int reset, int clk) | |
165 | -{ | |
166 | -#ifdef BITWIDTH | |
167 | -#undef BITWIDTH | |
168 | -#undef SHIFT | |
169 | -#undef ANGLEDELTA | |
170 | -#endif | |
171 | - | |
172 | -#define BITWIDTH 11 | |
173 | -#define SHIFT 2 | |
174 | -#define ANGLEDELTA 65 | |
175 | - | |
176 | - int last_angle = 0, last_q = 0, last_p = 0 , last_x = 0; | |
177 | - static vhdl::sincos_sub sincos_sub_module; | |
178 | - | |
179 | - vec << std::bitset<1>(reset) << " " | |
180 | - << std::bitset<1>(clk) << " " | |
181 | - << std::bitset<BITWIDTH>(x) << " " | |
182 | - << std::bitset<BITWIDTH>(angle) << " " | |
183 | - << std::bitset<BITWIDTH>(p) << " " | |
184 | - << std::bitset<BITWIDTH>(q) << std::endl; | |
185 | - | |
186 | - sincos_sub_module.run( SHIFT, ANGLEDELTA, clk, reset, x, last_x, angle, last_angle, p, last_p, q, last_q ); | |
187 | - | |
188 | - ref << std::bitset<BITWIDTH>( last_x ) << " " | |
189 | - << std::bitset<BITWIDTH>( last_angle ) << " " | |
190 | - << std::bitset<BITWIDTH>( last_p ) << " " | |
191 | - << std::bitset<BITWIDTH>( last_q ) << std::endl; | |
192 | - | |
193 | -} | |
194 | 118 | |
195 | 119 | void test_0( char *vec_name, char * ref_name) // positive rounding |
196 | 120 | { |
@@ -291,58 +215,113 @@ void test_4( char *vec_name, char * ref_name) // async reset | ||
291 | 215 | test_async_11bit(vec, ref, 23, 32, 430, 75, 0, 1 ); // x, angle, p, q, reset, clk |
292 | 216 | } |
293 | 217 | |
294 | - | |
295 | - /** | |
296 | - * \brief sincos CORDIC algorithm. | |
297 | - * \param x | |
298 | - * \param p | |
299 | - * \param q | |
300 | - * \param num_stages | |
301 | - * \param bit_width | |
302 | - */ | |
303 | -void cordic_sincos_bw32( std::ostream &vec, std::ostream &ref, int num_stages, int x, int reset, int clk ) | |
218 | +void test_5( char *vec_name, char * ref_name) // test of completely same timing signal change with clock | |
304 | 219 | { |
305 | -#ifdef BITWIDTH | |
306 | -#undef BITWIDTH | |
307 | -#endif | |
220 | + std::ofstream vec; vec.open(vec_name); | |
221 | + std::ofstream ref; ref.open(ref_name); | |
308 | 222 | |
309 | -#define BITWIDTH 32 | |
223 | + // reset | |
224 | + test_async_13bit(vec, ref, 23, 0, 16, 64, 1, 0 ); // x, angle, p, q, reset, clk | |
310 | 225 | |
311 | - int p_next, q_next, angle; | |
312 | - static int last_p = 0, last_q = 0; | |
226 | + // positive rounding | |
227 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 0 ); // x, angle, p, q, reset, clk | |
228 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk | |
229 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk | |
230 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 0 ); // x, angle, p, q, reset, clk | |
231 | + | |
232 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 0 ); // x, angle, p, q, reset, clk | |
233 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 1 ); // x, angle, p, q, reset, clk | |
234 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 1 ); // x, angle, p, q, reset, clk | |
235 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 0 ); // x, angle, p, q, reset, clk | |
236 | + | |
237 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 0 ); // x, angle, p, q, reset, clk | |
238 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk | |
239 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk | |
240 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 0 ); // x, angle, p, q, reset, clk | |
241 | + | |
242 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 0 ); // x, angle, p, q, reset, clk | |
243 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 1 ); // x, angle, p, q, reset, clk | |
244 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 1 ); // x, angle, p, q, reset, clk | |
245 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 0 ); // x, angle, p, q, reset, clk | |
246 | + | |
247 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 0 ); // x, angle, p, q, reset, clk | |
248 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk | |
249 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk | |
250 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 0 ); // x, angle, p, q, reset, clk | |
251 | + | |
252 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 0 ); // x, angle, p, q, reset, clk | |
253 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 1 ); // x, angle, p, q, reset, clk | |
254 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 1 ); // x, angle, p, q, reset, clk | |
255 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 0 ); // x, angle, p, q, reset, clk | |
256 | + | |
257 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 0 ); // x, angle, p, q, reset, clk | |
258 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk | |
259 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk | |
260 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 0 ); // x, angle, p, q, reset, clk | |
261 | + | |
262 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 0 ); // x, angle, p, q, reset, clk | |
263 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 1 ); // x, angle, p, q, reset, clk | |
264 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 1 ); // x, angle, p, q, reset, clk | |
265 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 0 ); // x, angle, p, q, reset, clk | |
313 | 266 | |
314 | - static vhdl::sincos_angle_delta ad; | |
315 | - static vhdl::sincos_scaling_factor sf; | |
316 | - static vhdl::sincos_cordic cordic; | |
267 | +} | |
317 | 268 | |
318 | 269 | |
319 | - vec | |
320 | - << std::bitset<1>( reset ) << " " // reset | |
321 | - << std::bitset<1>( clk ) << " " // clock | |
322 | - << std::bitset<BITWIDTH>( x ) << std::endl; | |
323 | 270 | |
324 | - cordic.run( 20, clk, reset, x, p, q ); | |
271 | +/***************************************************************** | |
272 | + * | |
273 | + * SINCOS vector generation | |
274 | + * | |
275 | + *****************************************************************/ | |
325 | 276 | |
326 | - ref | |
327 | - << std::bitset<BITWIDTH>( last_p ) << " " | |
328 | - << std::bitset<BITWIDTH>( last_q ) << std::endl; | |
329 | 277 | |
278 | +void test_100( char *vec_name, char * ref_name, int num_stages) | |
279 | +{ | |
280 | + std::ofstream vec; vec.open(vec_name); | |
281 | + std::ofstream ref; ref.open(ref_name); | |
282 | + | |
283 | + int x = 0; | |
284 | + | |
285 | + // reset | |
286 | + cordic_sincos_bw32( vec, ref, num_stages, x, 1, 0 ); | |
287 | + | |
288 | + // scan [-0.5, 0.5) | |
289 | + // scan [-0.5, 0.5) | |
290 | + for ( int i = -128; i < 127; i++ ) | |
291 | + { | |
292 | + x = i << 23; | |
293 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); | |
294 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); | |
295 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); | |
296 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); | |
297 | + } | |
330 | 298 | |
299 | + // flush pipeline | |
300 | + for ( int i = 0; i < num_stages; i++ ) | |
301 | + { | |
302 | + x = i << 16; | |
303 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); | |
304 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); | |
305 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); | |
306 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); | |
307 | + } | |
331 | 308 | } |
332 | 309 | |
333 | -void test_100( std::ostream &vec, std::ostream &ref, int num_stages ) | |
310 | +void test_101( char *vec_name, char * ref_name, int num_stages) | |
334 | 311 | { |
312 | + std::ofstream vec; vec.open(vec_name); | |
313 | + std::ofstream ref; ref.open(ref_name); | |
335 | 314 | |
336 | 315 | int x = 0; |
337 | 316 | |
338 | 317 | // reset |
339 | 318 | cordic_sincos_bw32( vec, ref, num_stages, x, 1, 0 ); |
340 | 319 | |
341 | - // scan [-0.5, 0.5) | |
342 | - for ( int i = -64; i < 63; i++ ) | |
320 | + // | |
321 | + for ( int i = -3; i < 2; i++ ) | |
343 | 322 | { |
344 | 323 | cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); |
345 | - x = i << 24; | |
324 | + x = i << 23; | |
346 | 325 | cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); |
347 | 326 | cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); |
348 | 327 | cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); |
@@ -352,9 +331,149 @@ void test_100( std::ostream &vec, std::ostream &ref, int num_stages ) | ||
352 | 331 | for ( int i = 0; i < num_stages; i++ ) |
353 | 332 | { |
354 | 333 | cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); |
355 | - x = i << 16; | |
334 | + x = 0; | |
356 | 335 | cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); |
357 | 336 | cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); |
358 | 337 | cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); |
359 | 338 | } |
360 | 339 | } |
340 | + | |
341 | +/***************************************************************** | |
342 | + * | |
343 | + * SINCOS SUB Low level Test | |
344 | + * | |
345 | + *****************************************************************/ | |
346 | + | |
347 | + | |
348 | +void test_async_9bit( std::ostream &vec, std::ostream &ref, int x, int angle, int p, int q, int reset, int clk) | |
349 | +{ | |
350 | +#ifdef BITWIDTH | |
351 | +#undef BITWIDTH | |
352 | +#undef SHIFT | |
353 | +#undef ANGLEDELTA | |
354 | +#endif | |
355 | + | |
356 | +#define BITWIDTH 9 | |
357 | +#define SHIFT 3 | |
358 | +#define ANGLEDELTA 31 | |
359 | + | |
360 | + static int out_angle = 0, out_q = 0, last_p = 0 , last_x = 0; | |
361 | + static vhdl::sincos_sub sincos_sub_module; | |
362 | + | |
363 | + vec << std::bitset<1>(reset) << " " | |
364 | + << std::bitset<1>(clk) << " " | |
365 | + << std::bitset<BITWIDTH>(x) << " " | |
366 | + << std::bitset<BITWIDTH>(angle) << " " | |
367 | + << std::bitset<BITWIDTH>(p) << " " | |
368 | + << std::bitset<BITWIDTH>(q) << std::endl; | |
369 | + | |
370 | + sincos_sub_module.run( SHIFT, ANGLEDELTA, clk, reset, x, last_x, angle, out_angle, p, last_p, q, out_q ); | |
371 | + | |
372 | + ref << std::bitset<BITWIDTH>( last_x ) << " " | |
373 | + << std::bitset<BITWIDTH>( out_angle ) << " " | |
374 | + << std::bitset<BITWIDTH>( last_p ) << " " | |
375 | + << std::bitset<BITWIDTH>( out_q ) << std::endl; | |
376 | + | |
377 | +} | |
378 | + | |
379 | +void test_async_13bit( std::ostream &vec, std::ostream &ref, int x, int angle, int p, int q, int reset, int clk) | |
380 | +{ | |
381 | +#ifdef BITWIDTH | |
382 | +#undef BITWIDTH | |
383 | +#undef SHIFT | |
384 | +#undef ANGLEDELTA | |
385 | +#endif | |
386 | + | |
387 | +#define BITWIDTH 13 | |
388 | +#define SHIFT 4 | |
389 | +#define ANGLEDELTA 65 | |
390 | + | |
391 | + int out_angle = 0, out_q = 0, last_p = 0 , last_x = 0; | |
392 | + static vhdl::sincos_sub sincos_sub_module; | |
393 | + | |
394 | + vec << std::bitset<1>(reset) << " " | |
395 | + << std::bitset<1>(clk) << " " | |
396 | + << std::bitset<BITWIDTH>(x) << " " | |
397 | + << std::bitset<BITWIDTH>(angle) << " " | |
398 | + << std::bitset<BITWIDTH>(p) << " " | |
399 | + << std::bitset<BITWIDTH>(q) << std::endl; | |
400 | + | |
401 | + sincos_sub_module.run( SHIFT, ANGLEDELTA, clk, reset, x, last_x, angle, out_angle, p, last_p, q, out_q ); | |
402 | + | |
403 | + ref << std::bitset<BITWIDTH>( last_x ) << " " | |
404 | + << std::bitset<BITWIDTH>( out_angle ) << " " | |
405 | + << std::bitset<BITWIDTH>( last_p ) << " " | |
406 | + << std::bitset<BITWIDTH>( out_q ) << std::endl; | |
407 | + | |
408 | +} | |
409 | + | |
410 | +void test_async_11bit( std::ostream &vec, std::ostream &ref, int x, int angle, int p, int q, int reset, int clk) | |
411 | +{ | |
412 | +#ifdef BITWIDTH | |
413 | +#undef BITWIDTH | |
414 | +#undef SHIFT | |
415 | +#undef ANGLEDELTA | |
416 | +#endif | |
417 | + | |
418 | +#define BITWIDTH 11 | |
419 | +#define SHIFT 2 | |
420 | +#define ANGLEDELTA 65 | |
421 | + | |
422 | + int out_angle = 0, out_q = 0, out_p = 0 , out_x = 0; | |
423 | + static vhdl::sincos_sub sincos_sub_module; | |
424 | + | |
425 | + vec << std::bitset<1>(reset) << " " | |
426 | + << std::bitset<1>(clk) << " " | |
427 | + << std::bitset<BITWIDTH>(x) << " " | |
428 | + << std::bitset<BITWIDTH>(angle) << " " | |
429 | + << std::bitset<BITWIDTH>(p) << " " | |
430 | + << std::bitset<BITWIDTH>(q) << std::endl; | |
431 | + | |
432 | + sincos_sub_module.run( SHIFT, ANGLEDELTA, clk, reset, x, out_x, angle, out_angle, p, out_p, q, out_q ); | |
433 | + | |
434 | + ref << std::bitset<BITWIDTH>( out_x ) << " " | |
435 | + << std::bitset<BITWIDTH>( out_angle ) << " " | |
436 | + << std::bitset<BITWIDTH>( out_p ) << " " | |
437 | + << std::bitset<BITWIDTH>( out_q ) << std::endl; | |
438 | + | |
439 | +} | |
440 | + | |
441 | +/***************************************************************** | |
442 | + * | |
443 | + * SINCOS Low level Test | |
444 | + * | |
445 | + *****************************************************************/ | |
446 | + | |
447 | +/** | |
448 | + * \brief sincos CORDIC algorithm. | |
449 | + * \param x | |
450 | + * \param p | |
451 | + * \param q | |
452 | + * \param num_stages | |
453 | + * \param bit_width | |
454 | + */ | |
455 | +void cordic_sincos_bw32( std::ostream &vec, std::ostream &ref, int num_stages, int x, int reset, int clk ) | |
456 | +{ | |
457 | +#ifdef BITWIDTH | |
458 | +#undef BITWIDTH | |
459 | +#endif | |
460 | + | |
461 | +#define BITWIDTH 32 | |
462 | + | |
463 | +int out_p, out_q; | |
464 | + | |
465 | +static vhdl::sincos_cordic cordic; | |
466 | + | |
467 | + | |
468 | +vec | |
469 | + << std::bitset<1>( reset ) << " " // reset | |
470 | + << std::bitset<1>( clk ) << " " // clock | |
471 | + << std::bitset<BITWIDTH>( x ) << std::endl; | |
472 | + | |
473 | +cordic.run( 20, clk, reset, x, out_p, out_q ); | |
474 | + | |
475 | +ref | |
476 | + << std::bitset<BITWIDTH>( out_p ) << " " | |
477 | + << std::bitset<BITWIDTH>( out_q ) << std::endl; | |
478 | + | |
479 | +} |
@@ -22,27 +22,32 @@ | ||
22 | 22 | int main() { |
23 | 23 | |
24 | 24 | |
25 | - char filename_vector_0[] = "sincossub_0.vec.txt"; | |
26 | - char filename_reference_0[] = "sincossub_0.ref.txt"; | |
25 | + char filename_vector_0[] = "fileout/sincossub_0.vec.txt"; | |
26 | + char filename_reference_0[] = "fileout/sincossub_0.ref.txt"; | |
27 | 27 | |
28 | - char filename_vector_1[] = "sincossub_1.vec.txt"; | |
29 | - char filename_reference_1[] = "sincossub_1.ref.txt"; | |
28 | + char filename_vector_1[] = "fileout/sincossub_1.vec.txt"; | |
29 | + char filename_reference_1[] = "fileout/sincossub_1.ref.txt"; | |
30 | 30 | |
31 | - char filename_vector_2[] = "sincossub_2.vec.txt"; | |
32 | - char filename_reference_2[] = "sincossub_2.ref.txt"; | |
31 | + char filename_vector_2[] = "fileout/sincossub_2.vec.txt"; | |
32 | + char filename_reference_2[] = "fileout/sincossub_2.ref.txt"; | |
33 | 33 | |
34 | - char filename_vector_3[] = "sincossub_3.vec.txt"; | |
35 | - char filename_reference_3[] = "sincossub_3.ref.txt"; | |
34 | + char filename_vector_3[] = "fileout/sincossub_3.vec.txt"; | |
35 | + char filename_reference_3[] = "fileout/sincossub_3.ref.txt"; | |
36 | 36 | |
37 | - char filename_vector_4[] = "sincossub_4.vec.txt"; | |
38 | - char filename_reference_4[] = "sincossub_4.ref.txt"; | |
37 | + char filename_vector_4[] = "fileout/sincossub_4.vec.txt"; | |
38 | + char filename_reference_4[] = "fileout/sincossub_4.ref.txt"; | |
39 | 39 | |
40 | - char filename_angle_delta[] = "sincos_angle_delta.txt"; | |
40 | + char filename_vector_5[] = "fileout/sincossub_5.vec.txt"; | |
41 | + char filename_reference_5[] = "fileout/sincossub_5.ref.txt"; | |
41 | 42 | |
42 | - char filename_scaling_factor[] = "sincos_scaling_factor.txt"; | |
43 | + char filename_angle_delta[] = "fileout/sincos_angle_delta.txt"; | |
44 | + char filename_scaling_factor[] = "fileout/sincos_scaling_factor.txt"; | |
43 | 45 | |
44 | - std::ofstream vector_5; vector_5.open("sincos_0.vec.txt"); | |
45 | - std::ofstream reference_5; reference_5.open("sincos_0.ref.txt"); | |
46 | + char filename_vector_100[] = "fileout/sincos_100.vec.txt"; | |
47 | + char filename_reference_100[] = "fileout/sincos_100.ref.txt"; | |
48 | + | |
49 | + char filename_vector_101[] = "fileout/sincos_101.vec.txt"; | |
50 | + char filename_reference_101[] = "fileout/sincos_101.ref.txt"; | |
46 | 51 | |
47 | 52 | // positive x, |
48 | 53 | test_0( filename_vector_0, filename_reference_0); |
@@ -59,10 +64,16 @@ int main() { | ||
59 | 64 | // positive x, async reset test |
60 | 65 | test_4( filename_vector_4, filename_reference_4); |
61 | 66 | |
62 | - gen_table( filename_angle_delta, filename_scaling_factor); | |
67 | + // positive x, async reset test | |
68 | + test_5( filename_vector_5, filename_reference_5); | |
69 | + | |
70 | +gen_table( filename_angle_delta, filename_scaling_factor); | |
71 | + | |
63 | 72 | |
73 | + test_100( filename_vector_100, filename_reference_100, 20 ); | |
64 | 74 | |
65 | - test_100( vector_5, reference_5, 24 ); | |
75 | + // test signal and clock changes simul. | |
76 | + test_101( filename_vector_101, filename_reference_101, 20 ); | |
66 | 77 | |
67 | 78 | |
68 | 79 | } |
@@ -98,99 +109,12 @@ void gen_table( const char * filename_angle_delta, const char * filename_scaling | ||
98 | 109 | } |
99 | 110 | } |
100 | 111 | |
112 | +/***************************************************************** | |
113 | + * | |
114 | + * SINCOS SUB vector generation | |
115 | + * | |
116 | + *****************************************************************/ | |
101 | 117 | |
102 | -void test_async_9bit( std::ostream &vec, std::ostream &ref, int x, int angle, int p, int q, int reset, int clk) | |
103 | -{ | |
104 | -#ifdef BITWIDTH | |
105 | -#undef BITWIDTH | |
106 | -#undef SHIFT | |
107 | -#undef ANGLEDELTA | |
108 | -#endif | |
109 | - | |
110 | -#define BITWIDTH 9 | |
111 | -#define SHIFT 3 | |
112 | -#define ANGLEDELTA 31 | |
113 | - | |
114 | - static int out_angle = 0, out_q = 0, last_p = 0 , last_x = 0; | |
115 | - static vhdl::sincos_sub sincos_sub_module; | |
116 | - | |
117 | - vec << std::bitset<1>(reset) << " " | |
118 | - << std::bitset<1>(clk) << " " | |
119 | - << std::bitset<BITWIDTH>(x) << " " | |
120 | - << std::bitset<BITWIDTH>(angle) << " " | |
121 | - << std::bitset<BITWIDTH>(p) << " " | |
122 | - << std::bitset<BITWIDTH>(q) << std::endl; | |
123 | - | |
124 | - sincos_sub_module.run( SHIFT, ANGLEDELTA, clk, reset, x, last_x, angle, out_angle, p, last_p, q, out_q ); | |
125 | - | |
126 | - ref << std::bitset<BITWIDTH>( last_x ) << " " | |
127 | - << std::bitset<BITWIDTH>( out_angle ) << " " | |
128 | - << std::bitset<BITWIDTH>( last_p ) << " " | |
129 | - << std::bitset<BITWIDTH>( out_q ) << std::endl; | |
130 | - | |
131 | -} | |
132 | - | |
133 | -void test_async_13bit( std::ostream &vec, std::ostream &ref, int x, int angle, int p, int q, int reset, int clk) | |
134 | -{ | |
135 | -#ifdef BITWIDTH | |
136 | -#undef BITWIDTH | |
137 | -#undef SHIFT | |
138 | -#undef ANGLEDELTA | |
139 | -#endif | |
140 | - | |
141 | -#define BITWIDTH 13 | |
142 | -#define SHIFT 4 | |
143 | -#define ANGLEDELTA 65 | |
144 | - | |
145 | - static int last_angle = 0, last_q = 0, last_p = 0 , last_x = 0; | |
146 | - static vhdl::sincos_sub sincos_sub_module; | |
147 | - | |
148 | - vec << std::bitset<1>(reset) << " " | |
149 | - << std::bitset<1>(clk) << " " | |
150 | - << std::bitset<BITWIDTH>(x) << " " | |
151 | - << std::bitset<BITWIDTH>(angle) << " " | |
152 | - << std::bitset<BITWIDTH>(p) << " " | |
153 | - << std::bitset<BITWIDTH>(q) << std::endl; | |
154 | - | |
155 | - sincos_sub_module.run( SHIFT, ANGLEDELTA, clk, reset, x, last_x, angle, last_angle, p, last_p, q, last_q ); | |
156 | - | |
157 | - ref << std::bitset<BITWIDTH>( last_x ) << " " | |
158 | - << std::bitset<BITWIDTH>( last_angle ) << " " | |
159 | - << std::bitset<BITWIDTH>( last_p ) << " " | |
160 | - << std::bitset<BITWIDTH>( last_q ) << std::endl; | |
161 | - | |
162 | -} | |
163 | - | |
164 | -void test_async_11bit( std::ostream &vec, std::ostream &ref, int x, int angle, int p, int q, int reset, int clk) | |
165 | -{ | |
166 | -#ifdef BITWIDTH | |
167 | -#undef BITWIDTH | |
168 | -#undef SHIFT | |
169 | -#undef ANGLEDELTA | |
170 | -#endif | |
171 | - | |
172 | -#define BITWIDTH 11 | |
173 | -#define SHIFT 2 | |
174 | -#define ANGLEDELTA 65 | |
175 | - | |
176 | - int last_angle = 0, last_q = 0, last_p = 0 , last_x = 0; | |
177 | - static vhdl::sincos_sub sincos_sub_module; | |
178 | - | |
179 | - vec << std::bitset<1>(reset) << " " | |
180 | - << std::bitset<1>(clk) << " " | |
181 | - << std::bitset<BITWIDTH>(x) << " " | |
182 | - << std::bitset<BITWIDTH>(angle) << " " | |
183 | - << std::bitset<BITWIDTH>(p) << " " | |
184 | - << std::bitset<BITWIDTH>(q) << std::endl; | |
185 | - | |
186 | - sincos_sub_module.run( SHIFT, ANGLEDELTA, clk, reset, x, last_x, angle, last_angle, p, last_p, q, last_q ); | |
187 | - | |
188 | - ref << std::bitset<BITWIDTH>( last_x ) << " " | |
189 | - << std::bitset<BITWIDTH>( last_angle ) << " " | |
190 | - << std::bitset<BITWIDTH>( last_p ) << " " | |
191 | - << std::bitset<BITWIDTH>( last_q ) << std::endl; | |
192 | - | |
193 | -} | |
194 | 118 | |
195 | 119 | void test_0( char *vec_name, char * ref_name) // positive rounding |
196 | 120 | { |
@@ -291,57 +215,83 @@ void test_4( char *vec_name, char * ref_name) // async reset | ||
291 | 215 | test_async_11bit(vec, ref, 23, 32, 430, 75, 0, 1 ); // x, angle, p, q, reset, clk |
292 | 216 | } |
293 | 217 | |
294 | - | |
295 | - /** | |
296 | - * \brief sincos CORDIC algorithm. | |
297 | - * \param x | |
298 | - * \param p | |
299 | - * \param q | |
300 | - * \param num_stages | |
301 | - * \param bit_width | |
302 | - */ | |
303 | -void cordic_sincos_bw32( std::ostream &vec, std::ostream &ref, int num_stages, int x, int reset, int clk ) | |
218 | +void test_5( char *vec_name, char * ref_name) // test of completely same timing signal change with clock | |
304 | 219 | { |
305 | -#ifdef BITWIDTH | |
306 | -#undef BITWIDTH | |
307 | -#endif | |
220 | + std::ofstream vec; vec.open(vec_name); | |
221 | + std::ofstream ref; ref.open(ref_name); | |
308 | 222 | |
309 | -#define BITWIDTH 32 | |
223 | + // reset | |
224 | + test_async_13bit(vec, ref, 23, 0, 16, 64, 1, 0 ); // x, angle, p, q, reset, clk | |
225 | + | |
226 | + // positive rounding | |
227 | + test_async_13bit(vec, ref, 23, 0, 255, 0, 0, 0 ); // x, angle, p, q, reset, clk | |
228 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk | |
229 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk | |
230 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 0 ); // x, angle, p, q, reset, clk | |
231 | + | |
232 | + test_async_13bit(vec, ref, 23, 0, 255, 0, 0, 0 ); // x, angle, p, q, reset, clk // same with above when truncated, +1 when rounding | |
233 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk | |
234 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk | |
235 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 0 ); // x, angle, p, q, reset, clk | |
236 | +} | |
310 | 237 | |
311 | - int out_p, out_q; | |
312 | 238 | |
313 | - static vhdl::sincos_angle_delta ad; | |
314 | - static vhdl::sincos_scaling_factor sf; | |
315 | - static vhdl::sincos_cordic cordic; | |
239 | + | |
240 | +/***************************************************************** | |
241 | + * | |
242 | + * SINCOS vector generation | |
243 | + * | |
244 | + *****************************************************************/ | |
316 | 245 | |
317 | 246 | |
318 | - vec | |
319 | - << std::bitset<1>( reset ) << " " // reset | |
320 | - << std::bitset<1>( clk ) << " " // clock | |
321 | - << std::bitset<BITWIDTH>( x ) << std::endl; | |
247 | +void test_100( char *vec_name, char * ref_name, int num_stages) | |
248 | +{ | |
249 | + std::ofstream vec; vec.open(vec_name); | |
250 | + std::ofstream ref; ref.open(ref_name); | |
322 | 251 | |
323 | - cordic.run( 20, clk, reset, x, out_p, out_q ); | |
252 | + int x = 0; | |
324 | 253 | |
325 | - ref | |
326 | - << std::bitset<BITWIDTH>( out_p ) << " " | |
327 | - << std::bitset<BITWIDTH>( out_q ) << std::endl; | |
254 | + // reset | |
255 | + cordic_sincos_bw32( vec, ref, num_stages, x, 1, 0 ); | |
328 | 256 | |
257 | + // scan [-0.5, 0.5) | |
258 | + // scan [-0.5, 0.5) | |
259 | + for ( int i = -128; i < 127; i++ ) | |
260 | + { | |
261 | + x = i << 23; | |
262 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); | |
263 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); | |
264 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); | |
265 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); | |
266 | + } | |
329 | 267 | |
268 | + // flush pipeline | |
269 | + for ( int i = 0; i < num_stages; i++ ) | |
270 | + { | |
271 | + x = i << 16; | |
272 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); | |
273 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); | |
274 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); | |
275 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); | |
276 | + } | |
330 | 277 | } |
331 | 278 | |
332 | -void test_100( std::ostream &vec, std::ostream &ref, int num_stages ) | |
279 | +void test_101( char *vec_name, char * ref_name, int num_stages) | |
333 | 280 | { |
281 | + std::ofstream vec; vec.open(vec_name); | |
282 | + std::ofstream ref; ref.open(ref_name); | |
334 | 283 | |
335 | 284 | int x = 0; |
336 | 285 | |
337 | 286 | // reset |
338 | 287 | cordic_sincos_bw32( vec, ref, num_stages, x, 1, 0 ); |
339 | 288 | |
289 | + // scan [-0.5, 0.5) | |
340 | 290 | // scan [-0.5, 0.5) |
341 | - for ( int i = -64; i < 63; i++ ) | |
291 | + for ( int i = -128; i < 127; i++ ) | |
342 | 292 | { |
343 | 293 | cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); |
344 | - x = i << 24; | |
294 | + x = i << 23; | |
345 | 295 | cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); |
346 | 296 | cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); |
347 | 297 | cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); |
@@ -357,3 +307,143 @@ void test_100( std::ostream &vec, std::ostream &ref, int num_stages ) | ||
357 | 307 | cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); |
358 | 308 | } |
359 | 309 | } |
310 | + | |
311 | +/***************************************************************** | |
312 | + * | |
313 | + * SINCOS SUB Low level Test | |
314 | + * | |
315 | + *****************************************************************/ | |
316 | + | |
317 | + | |
318 | +void test_async_9bit( std::ostream &vec, std::ostream &ref, int x, int angle, int p, int q, int reset, int clk) | |
319 | +{ | |
320 | +#ifdef BITWIDTH | |
321 | +#undef BITWIDTH | |
322 | +#undef SHIFT | |
323 | +#undef ANGLEDELTA | |
324 | +#endif | |
325 | + | |
326 | +#define BITWIDTH 9 | |
327 | +#define SHIFT 3 | |
328 | +#define ANGLEDELTA 31 | |
329 | + | |
330 | + static int out_angle = 0, out_q = 0, last_p = 0 , last_x = 0; | |
331 | + static vhdl::sincos_sub sincos_sub_module; | |
332 | + | |
333 | + vec << std::bitset<1>(reset) << " " | |
334 | + << std::bitset<1>(clk) << " " | |
335 | + << std::bitset<BITWIDTH>(x) << " " | |
336 | + << std::bitset<BITWIDTH>(angle) << " " | |
337 | + << std::bitset<BITWIDTH>(p) << " " | |
338 | + << std::bitset<BITWIDTH>(q) << std::endl; | |
339 | + | |
340 | + sincos_sub_module.run( SHIFT, ANGLEDELTA, clk, reset, x, last_x, angle, out_angle, p, last_p, q, out_q ); | |
341 | + | |
342 | + ref << std::bitset<BITWIDTH>( last_x ) << " " | |
343 | + << std::bitset<BITWIDTH>( out_angle ) << " " | |
344 | + << std::bitset<BITWIDTH>( last_p ) << " " | |
345 | + << std::bitset<BITWIDTH>( out_q ) << std::endl; | |
346 | + | |
347 | +} | |
348 | + | |
349 | +void test_async_13bit( std::ostream &vec, std::ostream &ref, int x, int angle, int p, int q, int reset, int clk) | |
350 | +{ | |
351 | +#ifdef BITWIDTH | |
352 | +#undef BITWIDTH | |
353 | +#undef SHIFT | |
354 | +#undef ANGLEDELTA | |
355 | +#endif | |
356 | + | |
357 | +#define BITWIDTH 13 | |
358 | +#define SHIFT 4 | |
359 | +#define ANGLEDELTA 65 | |
360 | + | |
361 | + int out_angle = 0, out_q = 0, last_p = 0 , last_x = 0; | |
362 | + static vhdl::sincos_sub sincos_sub_module; | |
363 | + | |
364 | + vec << std::bitset<1>(reset) << " " | |
365 | + << std::bitset<1>(clk) << " " | |
366 | + << std::bitset<BITWIDTH>(x) << " " | |
367 | + << std::bitset<BITWIDTH>(angle) << " " | |
368 | + << std::bitset<BITWIDTH>(p) << " " | |
369 | + << std::bitset<BITWIDTH>(q) << std::endl; | |
370 | + | |
371 | + sincos_sub_module.run( SHIFT, ANGLEDELTA, clk, reset, x, last_x, angle, out_angle, p, last_p, q, out_q ); | |
372 | + | |
373 | + ref << std::bitset<BITWIDTH>( last_x ) << " " | |
374 | + << std::bitset<BITWIDTH>( out_angle ) << " " | |
375 | + << std::bitset<BITWIDTH>( last_p ) << " " | |
376 | + << std::bitset<BITWIDTH>( out_q ) << std::endl; | |
377 | + | |
378 | +} | |
379 | + | |
380 | +void test_async_11bit( std::ostream &vec, std::ostream &ref, int x, int angle, int p, int q, int reset, int clk) | |
381 | +{ | |
382 | +#ifdef BITWIDTH | |
383 | +#undef BITWIDTH | |
384 | +#undef SHIFT | |
385 | +#undef ANGLEDELTA | |
386 | +#endif | |
387 | + | |
388 | +#define BITWIDTH 11 | |
389 | +#define SHIFT 2 | |
390 | +#define ANGLEDELTA 65 | |
391 | + | |
392 | + int out_angle = 0, out_q = 0, out_p = 0 , out_x = 0; | |
393 | + static vhdl::sincos_sub sincos_sub_module; | |
394 | + | |
395 | + vec << std::bitset<1>(reset) << " " | |
396 | + << std::bitset<1>(clk) << " " | |
397 | + << std::bitset<BITWIDTH>(x) << " " | |
398 | + << std::bitset<BITWIDTH>(angle) << " " | |
399 | + << std::bitset<BITWIDTH>(p) << " " | |
400 | + << std::bitset<BITWIDTH>(q) << std::endl; | |
401 | + | |
402 | + sincos_sub_module.run( SHIFT, ANGLEDELTA, clk, reset, x, out_x, angle, out_angle, p, out_p, q, out_q ); | |
403 | + | |
404 | + ref << std::bitset<BITWIDTH>( out_x ) << " " | |
405 | + << std::bitset<BITWIDTH>( out_angle ) << " " | |
406 | + << std::bitset<BITWIDTH>( out_p ) << " " | |
407 | + << std::bitset<BITWIDTH>( out_q ) << std::endl; | |
408 | + | |
409 | +} | |
410 | + | |
411 | +/***************************************************************** | |
412 | + * | |
413 | + * SINCOS Low level Test | |
414 | + * | |
415 | + *****************************************************************/ | |
416 | + | |
417 | +/** | |
418 | + * \brief sincos CORDIC algorithm. | |
419 | + * \param x | |
420 | + * \param p | |
421 | + * \param q | |
422 | + * \param num_stages | |
423 | + * \param bit_width | |
424 | + */ | |
425 | +void cordic_sincos_bw32( std::ostream &vec, std::ostream &ref, int num_stages, int x, int reset, int clk ) | |
426 | +{ | |
427 | +#ifdef BITWIDTH | |
428 | +#undef BITWIDTH | |
429 | +#endif | |
430 | + | |
431 | +#define BITWIDTH 32 | |
432 | + | |
433 | +int out_p, out_q; | |
434 | + | |
435 | +static vhdl::sincos_cordic cordic; | |
436 | + | |
437 | + | |
438 | +vec | |
439 | + << std::bitset<1>( reset ) << " " // reset | |
440 | + << std::bitset<1>( clk ) << " " // clock | |
441 | + << std::bitset<BITWIDTH>( x ) << std::endl; | |
442 | + | |
443 | +cordic.run( 20, clk, reset, x, out_p, out_q ); | |
444 | + | |
445 | +ref | |
446 | + << std::bitset<BITWIDTH>( out_p ) << " " | |
447 | + << std::bitset<BITWIDTH>( out_q ) << std::endl; | |
448 | + | |
449 | +} |
@@ -0,0 +1,114 @@ | ||
1 | +-------------------------------------------------------------------------------- | |
2 | +-- Entity: sincos_cordic_bench_101 | |
3 | +--! @file sincos_cordic_bench_0.vhd | |
4 | +--! @date 2016-09-25 | |
5 | +--! @author takemasa | |
6 | +--! @brief Test bench for sincos_cordic. 32bit width, 20 stages. | |
7 | +--! | |
8 | +-------------------------------------------------------------------------------- | |
9 | +library ieee; | |
10 | +use ieee.std_logic_1164.all; | |
11 | +use ieee.numeric_std.all; | |
12 | +use std.textio.all; | |
13 | +use ieee.std_logic_textio.all; | |
14 | + | |
15 | +--! @addtogroup CORDIC_TEST | |
16 | +--! CORDIC algorithm test bench | |
17 | +--! @{ | |
18 | + | |
19 | +--! @brief This is test for cordic | |
20 | +--! @details | |
21 | +--! Read test vectors, process it and save to the dut file. The | |
22 | +--! The Vector format and Reference format are following : | |
23 | +--! @li Vector : reset, clk, x | |
24 | +--! @li Refrence : p, q | |
25 | +entity sincos_cordic_bench_101 is | |
26 | +end sincos_cordic_bench_101; | |
27 | + | |
28 | +architecture RTL of sincos_cordic_bench_101 is | |
29 | + file fo: TEXT open write_mode is "vectors/sincos_101.dut.txt"; | |
30 | + file fi: TEXT open read_mode is "vectors/sincos_101.vec.txt"; | |
31 | + | |
32 | + constant max_bit : integer := 31; | |
33 | + constant num_stage : integer := 20; | |
34 | + | |
35 | + signal clock_0 : std_logic := '0'; | |
36 | + signal reset_0 : std_logic := '0'; | |
37 | + signal x_0 : signed(max_bit downto 0); -- target angle. try to calc cos(x), sin(x) | |
38 | + signal p_1 : signed(max_bit downto 0); -- next holizontal posiion | |
39 | + signal q_1 : signed(max_bit downto 0); -- next holizontal position | |
40 | + | |
41 | +begin | |
42 | + dut : entity work.sincos_cordic -- instance of dut | |
43 | + generic map ( | |
44 | + num_stages => num_stage | |
45 | + ) | |
46 | + port map ( | |
47 | + clock => clock_0, | |
48 | + reset => reset_0, | |
49 | + x => x_0, | |
50 | + p => p_1, | |
51 | + q => q_1 | |
52 | + ); | |
53 | + | |
54 | + -- test 11 bit width operation | |
55 | + process | |
56 | + variable lo : line; | |
57 | + variable li : line; | |
58 | + | |
59 | + variable vreset_0 : std_logic := '0'; | |
60 | + variable vclock_0 : std_logic := '0'; | |
61 | + variable vx_0 : signed(max_bit downto 0) := (others=>'0'); | |
62 | + | |
63 | + begin | |
64 | + | |
65 | + -- format : reset, x, | |
66 | + -- first iteration to update the variable. | |
67 | + readline( fi, li ); | |
68 | + read( li, vreset_0 ); | |
69 | + read( li, vclock_0 ); | |
70 | + bread( li, vx_0 ); | |
71 | + | |
72 | + -- apply read value to signal. effective at next cycle. | |
73 | + reset_0 <= vreset_0; | |
74 | + clock_0 <= vclock_0; | |
75 | + x_0 <= vx_0; | |
76 | + | |
77 | + | |
78 | + -- repeat until test vector becomes empty. | |
79 | + while not endfile(fi) loop | |
80 | + -- read one test vector | |
81 | + wait for 100 nS; | |
82 | + -- write one test result | |
83 | + -- format: p, q | |
84 | + write( lo, p_1 ); write( lo, ' ' ); | |
85 | + write( lo, q_1 ); | |
86 | + writeline( fo, lo ); | |
87 | + | |
88 | + -- format : reset, x, | |
89 | + readline( fi, li ); | |
90 | + read( li, vreset_0 ); | |
91 | + read( li, vclock_0 ); | |
92 | + bread( li, vx_0 ); | |
93 | + | |
94 | + -- apply read value to signal. effective at next cycle. | |
95 | + reset_0 <= vreset_0; | |
96 | + clock_0 <= vclock_0; | |
97 | + x_0 <= vx_0; | |
98 | + | |
99 | + end loop; | |
100 | + | |
101 | + wait for 100 nS; | |
102 | + -- last iteration to flash the variable. | |
103 | + -- write one test result | |
104 | + -- format: p, q | |
105 | + write( lo, p_1 ); write( lo, ' ' ); | |
106 | + write( lo, q_1 ); | |
107 | + writeline( fo, lo ); | |
108 | + | |
109 | + wait; | |
110 | + end process; | |
111 | + | |
112 | +end RTL; | |
113 | + | |
114 | +--! @} |
@@ -0,0 +1,106 @@ | ||
1 | +-------------------------------------------------------------------------------- | |
2 | +--! @file sincos_sub_bench_0.vhd | |
3 | +--! @date 2016-10-8 | |
4 | +--! @author takemasa | |
5 | +--! @brief Main entity of the sincos cordic | |
6 | +--! | |
7 | +-------------------------------------------------------------------------------- | |
8 | +library ieee; | |
9 | +use ieee.std_logic_1164.all; | |
10 | +use ieee.numeric_std.all; | |
11 | + | |
12 | +use std.textio.all; | |
13 | +use ieee.std_logic_textio.all; | |
14 | + | |
15 | +--! @addtogroup CORDIC | |
16 | +--! CORDIC algorithm designes | |
17 | +--! @{ | |
18 | + | |
19 | + | |
20 | + --! Sine / Cosine CORDIC entity | |
21 | + --! @detials | |
22 | + --! Maximumn width of the x, p, q is 32. | |
23 | +entity sincos_cordic is | |
24 | + generic( | |
25 | + num_stages : natural --! Number of the CORDIC sub module stage. This value must be less or equal to 32 | |
26 | + ); | |
27 | + port ( | |
28 | + signal clock : in std_logic; --! Input clock. Transition on the rising edge. | |
29 | + signal reset : in std_logic; --! Synchronized reset. H to reset. | |
30 | + signal x : in signed; --! Target angle of cos(x). [-1,1) is mapped to [-pi,pi). Max width is 32 | |
31 | + signal p : out signed; --! cos output. | |
32 | + signal q : out signed --! sin output. | |
33 | + ); | |
34 | +end sincos_cordic; | |
35 | + | |
36 | +--! RTL implementation of CORDIC algorithm. | |
37 | +architecture RTL of sincos_cordic is | |
38 | + -- internal connection data type | |
39 | + type signal_type is array ( 1 to num_stages+1 ) of signed( 31 downto 0 ); | |
40 | + -- internal connection signals. | |
41 | + signal x_signals : signal_type; | |
42 | + signal angle_signals : signal_type; | |
43 | + signal p_signals : signal_type; | |
44 | + signal q_signals : signal_type; | |
45 | + | |
46 | + type coeff_type is array ( 1 to 32 ) of signed( 31 downto 0 ); | |
47 | + | |
48 | + --! Table initialization by external text file. | |
49 | + --! @parameter filename The name of the the external file | |
50 | + --! @returns Initialized table. | |
51 | + impure function init_table( filename : in string ) return coeff_type is | |
52 | + file fi: TEXT open read_mode is filename; | |
53 | + variable li : line; | |
54 | + variable table : coeff_type; | |
55 | + begin | |
56 | + for i in table'range loop | |
57 | + readline( fi, li ); | |
58 | + read( li, table(i) ); | |
59 | + end loop; | |
60 | + | |
61 | + return table; | |
62 | + end function; | |
63 | + | |
64 | + --! Scaling factor. Have to be given as p. For n stage processing, select table(n). | |
65 | + constant scale_factor_table : coeff_type := init_table("src/sincos_scaling_factor.txt" ); | |
66 | + --! A coefficient for angle_delta for each stage. Nth stage will receive table(n) | |
67 | + constant angle_delta_table : coeff_type := init_table("src/sincos_angle_delta.txt" ); | |
68 | + | |
69 | + | |
70 | +begin | |
71 | + stages : | |
72 | + for i in 1 to num_stages generate | |
73 | + stage : entity work.sincos_sub | |
74 | + generic map ( | |
75 | + shift => i-1, | |
76 | + angle_delta => angle_delta_table(i-1) | |
77 | + ) | |
78 | + port map ( | |
79 | + clock => clock, | |
80 | + reset => reset, | |
81 | + x => x_signals(i), | |
82 | + x_next => x_signals(i+1), | |
83 | + angle => angle_signals(i), | |
84 | + angle_next => angle_signals(i+1), | |
85 | + p => p_signals(i), | |
86 | + p_next => p_signals(i+1), | |
87 | + q => q_signals(i), | |
88 | + q_next => q_signals(i+1) | |
89 | + ); | |
90 | + end generate; | |
91 | + | |
92 | + -- Intput to the first stage | |
93 | + x_signals(1) <= x; -- x for cos( x ) | |
94 | + p_signals(1) <= scale_factor_table(num_stages); -- cos(x) initial value. | |
95 | + q_signals(1) <= ( others => '0' ); -- sin(x) is zero at first. | |
96 | + angle_signals(1) <= ( others => '0' ); -- always start from zero. | |
97 | + | |
98 | + -- Signal output | |
99 | + p <= p_signals( num_stages + 1 ); | |
100 | + q <= q_signals( num_stages + 1 ); | |
101 | + | |
102 | + -- Fix unsed signal | |
103 | + | |
104 | +end RTL; | |
105 | + | |
106 | +--! @} |
@@ -0,0 +1,106 @@ | ||
1 | +-------------------------------------------------------------------------------- | |
2 | +--! @file sincos_sub_bench_0.vhd | |
3 | +--! @date 2016-10-8 | |
4 | +--! @author takemasa | |
5 | +--! @brief Main entity of the sincos cordic | |
6 | +--! | |
7 | +-------------------------------------------------------------------------------- | |
8 | +library ieee; | |
9 | +use ieee.std_logic_1164.all; | |
10 | +use ieee.numeric_std.all; | |
11 | + | |
12 | +use std.textio.all; | |
13 | +use ieee.std_logic_textio.all; | |
14 | + | |
15 | +--! @addtogroup CORDIC | |
16 | +--! CORDIC algorithm designes | |
17 | +--! @{ | |
18 | + | |
19 | + | |
20 | + --! Sine / Cosine CORDIC entity | |
21 | + --! @detials | |
22 | + --! Maximumn width of the x, p, q is 32. | |
23 | +entity sincos_cordic is | |
24 | + generic( | |
25 | + num_stages : natural --! Number of the CORDIC sub module stage. This value must be less or equal to 32 | |
26 | + ); | |
27 | + port ( | |
28 | + signal clock : in std_logic; --! Input clock. Transition on the rising edge. | |
29 | + signal reset : in std_logic; --! Synchronized reset. H to reset. | |
30 | + signal x : in signed; --! Target angle of cos(x). [-1,1) is mapped to [-pi,pi). Max width is 32 | |
31 | + signal p : out signed; --! cos output. | |
32 | + signal q : out signed --! sin output. | |
33 | + ); | |
34 | +end sincos_cordic; | |
35 | + | |
36 | +--! RTL implementation of CORDIC algorithm. | |
37 | +architecture RTL of sincos_cordic is | |
38 | + -- internal connection data type | |
39 | + type signal_type is array ( 1 to num_stages+1 ) of signed( 31 downto 0 ); | |
40 | + -- internal connection signals. | |
41 | + signal x_signals : signal_type; | |
42 | + signal angle_signals : signal_type; | |
43 | + signal p_signals : signal_type; | |
44 | + signal q_signals : signal_type; | |
45 | + | |
46 | + type coeff_type is array ( 1 to 32 ) of signed( 31 downto 0 ); | |
47 | + | |
48 | + --! Table initialization by external text file. | |
49 | + --! @parameter filename The name of the the external file | |
50 | + --! @returns Initialized table. | |
51 | + impure function init_table( filename : in string ) return coeff_type is | |
52 | + file fi: TEXT open read_mode is filename; | |
53 | + variable li : line; | |
54 | + variable table : coeff_type; | |
55 | + begin | |
56 | + for i in table'range loop | |
57 | + readline( fi, li ); | |
58 | + read( li, table(i) ); | |
59 | + end loop; | |
60 | + | |
61 | + return table; | |
62 | + end function; | |
63 | + | |
64 | + --! Scaling factor. Have to be given as p. For n stage processing, select table(n). | |
65 | + constant scale_factor_table : coeff_type := init_table("src/sincos_scaling_factor.txt" ); | |
66 | + --! A coefficient for angle_delta for each stage. Nth stage will receive table(n) | |
67 | + constant angle_delta_table : coeff_type := init_table("src/sincos_angle_delta.txt" ); | |
68 | + | |
69 | + | |
70 | +begin | |
71 | + stages : | |
72 | + for i in 1 to num_stages generate | |
73 | + stage : entity work.sincos_sub | |
74 | + generic map ( | |
75 | + shift => i-1, | |
76 | + angle_delta => angle_delta_table(i) | |
77 | + ) | |
78 | + port map ( | |
79 | + clock => clock, | |
80 | + reset => reset, | |
81 | + x => x_signals(i), | |
82 | + x_next => x_signals(i+1), | |
83 | + angle => angle_signals(i), | |
84 | + angle_next => angle_signals(i+1), | |
85 | + p => p_signals(i), | |
86 | + p_next => p_signals(i+1), | |
87 | + q => q_signals(i), | |
88 | + q_next => q_signals(i+1) | |
89 | + ); | |
90 | + end generate; | |
91 | + | |
92 | + -- Intput to the first stage | |
93 | + x_signals(1) <= x; -- x for cos( x ) | |
94 | + p_signals(1) <= scale_factor_table(num_stages); -- cos(x) initial value. | |
95 | + q_signals(1) <= ( others => '0' ); -- sin(x) is zero at first. | |
96 | + angle_signals(1) <= ( others => '0' ); -- always start from zero. | |
97 | + | |
98 | + -- Signal output | |
99 | + p <= p_signals( num_stages + 1 ); | |
100 | + q <= q_signals( num_stages + 1 ); | |
101 | + | |
102 | + -- Fix unsed signal | |
103 | + | |
104 | +end RTL; | |
105 | + | |
106 | +--! @} |
@@ -0,0 +1,156 @@ | ||
1 | +/* | |
2 | + * main.h | |
3 | + * | |
4 | + * Created on: 2016/10/09 | |
5 | + * Author: takemasa | |
6 | + */ | |
7 | +/** | |
8 | + * \file main.h | |
9 | + * | |
10 | + * \date 2016/10/9 | |
11 | + * \author: takemasa | |
12 | + * \brief Test vector Generator for cordic_sincos VHDL project | |
13 | + */ | |
14 | + | |
15 | + | |
16 | +#ifndef MAIN_H_ | |
17 | +#define MAIN_H_ | |
18 | + | |
19 | +#include "vhdl/sincossub.h" | |
20 | +#include "vhdl/sincosangledelta.h" | |
21 | +#include "vhdl/sincosscalingfactor.h" | |
22 | +#include "vhdl/sincoscordic.h" | |
23 | + | |
24 | +/** | |
25 | + * \brief Test vector and Ref generator. No round up, Shift 3, with 9, angle delta 31. | |
26 | + * \param vec Output file stream for Vector. | |
27 | + * \param ref Output file stream for Reference | |
28 | + * \param x Target angle. | |
29 | + * \param angle Current angle | |
30 | + * \param p Cosine | |
31 | + * \param q Sine | |
32 | + * \param reset async reset. | |
33 | + * \param clk clock to toggle the operation. | |
34 | + * \details | |
35 | + * Add a one line vector data from the given parameter. And then, | |
36 | + * Add one line reference data. | |
37 | + * | |
38 | + * The Vector format and Reference format are following : | |
39 | + * \li Vector : 0(reset), x, angle, p, q | |
40 | + * \li Refrence : x_next, angle_next, p_next, q_next | |
41 | + * | |
42 | + * Following parameters are fixed : | |
43 | + * \li Width : 9 | |
44 | + * \li Shift : 3 | |
45 | + * \li Angle delta : 31 | |
46 | + */ | |
47 | +void test_async_9bit( std::ostream &vec, std::ostream &ref, int x, int angle, int p, int q, int reset, int clk); | |
48 | + | |
49 | +/** | |
50 | + * \brief Test vector and Ref generator. No round up, Shift 4, with 13, angle delta 65. | |
51 | + * \param vec Output file stream for Vector. | |
52 | + * \param ref Output file stream for Reference | |
53 | + * \param x Target angle. | |
54 | + * \param angle Current angle | |
55 | + * \param p Cosine | |
56 | + * \param q Sine | |
57 | + * \param reset async reset. | |
58 | + * \param clk clock to toggle the operation. | |
59 | + * \details | |
60 | + * Add a one line vector data from the given parameter. And then, | |
61 | + * Add one line reference data. | |
62 | + * | |
63 | + * The Vector format and Reference format are following : | |
64 | + * \li Vector : 0(reset), x, angle, p, q | |
65 | + * \li Refrence : x_next, angle_next, p_next, q_next | |
66 | + * | |
67 | + * Following parameters are fixed : | |
68 | + * \li Width : 13 | |
69 | + * \li Shift : 4 | |
70 | + * \li Angle delta : 65 | |
71 | + */ | |
72 | +void test_async_13bit( std::ostream &vec, std::ostream &ref, int x, int angle, int p, int q, int reset, int clk); | |
73 | + | |
74 | +/** | |
75 | + * \brief Test vector and Ref generator. No round up, Shift 2, width 11, angle delta 65. | |
76 | + * \param vec Output file stream for Vector. | |
77 | + * \param ref Output file stream for Reference | |
78 | + * \param x Target angle. | |
79 | + * \param angle Current angle | |
80 | + * \param p Cosine | |
81 | + * \param q Sine | |
82 | + * \param reset async reset. | |
83 | + * \param clk clock to toggle the operation. | |
84 | + * \details | |
85 | + * Add a one line vector data from the given parameter. And then, | |
86 | + * Add one line reference data. This routine is dedicated to check the | |
87 | + * async reset operation. | |
88 | + * | |
89 | + * The Vector format and Reference format are following : | |
90 | + * \li Vector : reset, clk, x, angle, p, q | |
91 | + * \li Refrence : x_next, angle_next, p_next, q_next | |
92 | + * | |
93 | + * Following parameters are fixed : | |
94 | + * \li Width : 11 | |
95 | + * \li Shift : 2 | |
96 | + * \li Angle delta : 65 | |
97 | + */ | |
98 | +void test_async_11bit( std::ostream &vec, std::ostream &ref, int x, int angle, int p, int q, int reset, int clk); | |
99 | + | |
100 | +/** | |
101 | + * \brief positive non rounding | |
102 | + * \param vec_name name of the output vector file | |
103 | + * \param ref_name name of the output reference file | |
104 | + */ | |
105 | +void test_0( char *vec_name, char * ref_name); | |
106 | + | |
107 | +/** | |
108 | + * \brief negative non rounding | |
109 | + * \param vec_name name of the output vector file | |
110 | + * \param ref_name name of the output reference file | |
111 | + */ | |
112 | +void test_1( char *vec_name, char * ref_name); | |
113 | + | |
114 | +/** | |
115 | + * \brief positive rounding | |
116 | + * \param vec_name name of the output vector file | |
117 | + * \param ref_name name of the output reference file | |
118 | + */ | |
119 | +void test_2( char *vec_name, char * ref_name); | |
120 | + | |
121 | +/** | |
122 | + * \brief negative rounding | |
123 | + * \param vec_name name of the output vector file | |
124 | + * \param ref_name name of the output reference file | |
125 | + */ | |
126 | +void test_3( char *vec_name, char * ref_name); | |
127 | + | |
128 | +/** | |
129 | + * \brief Async Reset Test | |
130 | + * \param vec_name name of the output vector file | |
131 | + * \param ref_name name of the output reference file | |
132 | + */ | |
133 | +void test_4( char *vec_name, char * ref_name); | |
134 | + | |
135 | +/** | |
136 | + * \brief Special case test. Test of the case when the signal and clock changes together | |
137 | + * \param vec_name name of the output vector file | |
138 | + * \param ref_name name of the output reference file | |
139 | + */ | |
140 | +void test_5( char *vec_name, char * ref_name); | |
141 | + | |
142 | + | |
143 | + | |
144 | +void test_100( char *vec_name, char * ref_name, int num_stages ); | |
145 | +void test_101( char *vec_name, char * ref_name, int num_stages ); | |
146 | +void cordic_sincos_bw32( std::ostream &vec, std::ostream &ref, int num_stages, int x, int reset, int clk ); | |
147 | + | |
148 | + | |
149 | +/** | |
150 | + * @brief Generate tables for delta angle and scaling factor | |
151 | + * @param filename_angle_delta output file name | |
152 | + * @param filename_scaling_factor output file name. | |
153 | + */ | |
154 | +void gen_table( const char * filename_angle_delta, const char * filename_scaling_factor); | |
155 | + | |
156 | +#endif /* MAIN_H_ */ |
@@ -1,102 +0,0 @@ | ||
1 | --------------------------------------------------------------------------------- | |
2 | --- Entity: sincos_sub_bench | |
3 | --- Date:2016-09-25 | |
4 | --- Author: takemasa | |
5 | --- | |
6 | --- Description: | |
7 | --------------------------------------------------------------------------------- | |
8 | -library ieee; | |
9 | -use ieee.std_logic_1164.all; | |
10 | -use ieee.numeric_std.all; | |
11 | -use std.textio.all; | |
12 | -use ieee.std_logic_textio.all; | |
13 | - | |
14 | -entity sincos_sub_bench_3 is | |
15 | -end sincos_sub_bench_3; | |
16 | - | |
17 | -architecture arch of sincos_sub_bench_3 is | |
18 | - constant max_bit : integer := 12; | |
19 | - | |
20 | - signal clock_0 : std_logic := '0'; | |
21 | - signal reset_0 : std_logic := '0'; | |
22 | - signal x_0 : signed(max_bit downto 0); -- target angle. try to calc cos(x), sin(x) | |
23 | - signal x_1 : signed(max_bit downto 0); -- target angle. try to calc cos(x), sin(x) | |
24 | - signal angle_0 : signed(max_bit downto 0); -- current angle converge to x | |
25 | - signal angle_1 : signed(max_bit downto 0); -- next angle converge to x | |
26 | - signal p_0 : signed(max_bit downto 0); -- current holizontal position | |
27 | - signal p_1 : signed(max_bit downto 0); -- next holizontal posiion | |
28 | - signal q_0 : signed(max_bit downto 0); -- current virtical position | |
29 | - signal q_1 : signed(max_bit downto 0); -- next holizontal position | |
30 | - | |
31 | - file fo: TEXT open write_mode is "sincossub_3.dut.txt"; | |
32 | - file fi: TEXT open read_mode is "sincossub_3.vec.txt"; | |
33 | - | |
34 | -begin | |
35 | - dut : entity work.sincos_sub -- instance of dut for 9bit width calc. | |
36 | - generic map ( | |
37 | - shift => 4, | |
38 | - angle_delta => "0000001000001" | |
39 | - ) | |
40 | - port map ( | |
41 | - clock => clock_0, | |
42 | - reset => reset_0, | |
43 | - x => x_0, | |
44 | - x_next => x_1, | |
45 | - angle => angle_0, | |
46 | - angle_next => angle_1, | |
47 | - p => p_0, | |
48 | - p_next => p_1, | |
49 | - q => q_0, | |
50 | - q_next => q_1 | |
51 | - ); | |
52 | - | |
53 | - -- test 9 bit width operation | |
54 | - process | |
55 | - variable lo : line; | |
56 | - variable li : line; | |
57 | - | |
58 | - variable vreset_0 : std_logic; | |
59 | - variable vx_0 : signed(max_bit downto 0); | |
60 | - variable vangle_0 : signed(max_bit downto 0); | |
61 | - variable vp_0 : signed(max_bit downto 0); | |
62 | - variable vq_0 : signed(max_bit downto 0); | |
63 | - | |
64 | - begin | |
65 | - -- repeat until test vector becomes empty. | |
66 | - while not endfile(fi) loop | |
67 | - -- read one test vector | |
68 | - wait for 100 nS; | |
69 | - clock_0 <= '1'; | |
70 | - | |
71 | - -- format : reset, x, angle, p, q | |
72 | - readline( fi, li ); | |
73 | - read( li, vreset_0 ); | |
74 | - bread( li, vx_0 ); | |
75 | - bread( li, vangle_0 ); | |
76 | - bread( li, vp_0 ); | |
77 | - bread( li, vq_0 ); | |
78 | - | |
79 | - -- apply read value to signal. effective at next cycle. | |
80 | - reset_0 <= vreset_0; | |
81 | - x_0 <= vx_0; | |
82 | - angle_0 <= vangle_0; | |
83 | - p_0 <= vp_0; | |
84 | - q_0 <= vq_0; | |
85 | - | |
86 | - -- wrinte one test result | |
87 | - wait for 100 nS; | |
88 | - clock_0 <= '0'; | |
89 | - | |
90 | - -- format: x, angle, p, q | |
91 | - write( lo, x_1 ); write( lo, ' ' ); | |
92 | - write( lo, angle_1 ); write( lo, ' ' ); | |
93 | - write( lo, p_1 ); write( lo, ' ' ); | |
94 | - write( lo, q_1 ); | |
95 | - writeline( fo, lo ); | |
96 | - | |
97 | - end loop; | |
98 | - wait; | |
99 | - end process; | |
100 | - | |
101 | -end arch; | |
102 | - |
@@ -0,0 +1,479 @@ | ||
1 | +/** | |
2 | + * \file main.cpp | |
3 | + * | |
4 | + * \date 2016/10/01 | |
5 | + * \author: takemasa | |
6 | + * \brief Test vector Generator for cordic_sincos VHDL project | |
7 | + */ | |
8 | + | |
9 | +#include <iostream> | |
10 | +#include <bitset> | |
11 | +#include <string> | |
12 | +#include <cmath> | |
13 | + | |
14 | +#include <fstream> // ifstream, ofstream | |
15 | + | |
16 | +#include "main.h" | |
17 | + | |
18 | +/** | |
19 | + * \bfief main function | |
20 | + */ | |
21 | + | |
22 | +int main() { | |
23 | + | |
24 | + | |
25 | + char filename_vector_0[] = "fileout/sincossub_0.vec.txt"; | |
26 | + char filename_reference_0[] = "fileout/sincossub_0.ref.txt"; | |
27 | + | |
28 | + char filename_vector_1[] = "fileout/sincossub_1.vec.txt"; | |
29 | + char filename_reference_1[] = "fileout/sincossub_1.ref.txt"; | |
30 | + | |
31 | + char filename_vector_2[] = "fileout/sincossub_2.vec.txt"; | |
32 | + char filename_reference_2[] = "fileout/sincossub_2.ref.txt"; | |
33 | + | |
34 | + char filename_vector_3[] = "fileout/sincossub_3.vec.txt"; | |
35 | + char filename_reference_3[] = "fileout/sincossub_3.ref.txt"; | |
36 | + | |
37 | + char filename_vector_4[] = "fileout/sincossub_4.vec.txt"; | |
38 | + char filename_reference_4[] = "fileout/sincossub_4.ref.txt"; | |
39 | + | |
40 | + char filename_vector_5[] = "fileout/sincossub_5.vec.txt"; | |
41 | + char filename_reference_5[] = "fileout/sincossub_5.ref.txt"; | |
42 | + | |
43 | + char filename_angle_delta[] = "fileout/sincos_angle_delta.txt"; | |
44 | + char filename_scaling_factor[] = "fileout/sincos_scaling_factor.txt"; | |
45 | + | |
46 | + char filename_vector_100[] = "fileout/sincos_100.vec.txt"; | |
47 | + char filename_reference_100[] = "fileout/sincos_100.ref.txt"; | |
48 | + | |
49 | + char filename_vector_101[] = "fileout/sincos_101.vec.txt"; | |
50 | + char filename_reference_101[] = "fileout/sincos_101.ref.txt"; | |
51 | + | |
52 | + // positive x, | |
53 | + test_0( filename_vector_0, filename_reference_0); | |
54 | + | |
55 | + // negative x | |
56 | + test_1( filename_vector_1, filename_reference_1); | |
57 | + | |
58 | + //positive x, rounding up | |
59 | + test_2( filename_vector_2, filename_reference_2); | |
60 | + | |
61 | + // negative x rouding up | |
62 | + test_3( filename_vector_3, filename_reference_3); | |
63 | + | |
64 | + // positive x, async reset test | |
65 | + test_4( filename_vector_4, filename_reference_4); | |
66 | + | |
67 | + // positive x, async reset test | |
68 | + test_5( filename_vector_5, filename_reference_5); | |
69 | + | |
70 | +gen_table( filename_angle_delta, filename_scaling_factor); | |
71 | + | |
72 | + | |
73 | + test_100( filename_vector_100, filename_reference_100, 20 ); | |
74 | + | |
75 | + // test signal and clock changes simul. | |
76 | + test_101( filename_vector_101, filename_reference_101, 20 ); | |
77 | + | |
78 | + | |
79 | +} | |
80 | + | |
81 | + /** | |
82 | + * \brief shift rith arithmetic with rounding. | |
83 | + */ | |
84 | +int round_shift( int operand, int shift) | |
85 | +{ | |
86 | + if (shift > 0) | |
87 | + return ( operand + (1<<(shift-1)) ) >> shift ; | |
88 | + else | |
89 | + return operand; | |
90 | +} | |
91 | + | |
92 | + | |
93 | +void gen_table( const char * filename_angle_delta, const char * filename_scaling_factor) | |
94 | +{ | |
95 | + std::ofstream angle_delta; angle_delta.open(filename_angle_delta); | |
96 | + std::ofstream scaling_factor; scaling_factor.open(filename_scaling_factor); | |
97 | + | |
98 | + vhdl::sincos_angle_delta ad; | |
99 | + vhdl::sincos_scaling_factor sf; | |
100 | + | |
101 | + // Initialize the scaling factor and angle delta table. | |
102 | + for ( int i = 0; i<vhdl::angle_delta_table_size; i++ ) | |
103 | + { | |
104 | + // output to the file | |
105 | + scaling_factor << std::bitset<32>( sf.table[i] ) << std::endl; | |
106 | + | |
107 | + // output to the file | |
108 | + angle_delta << std::bitset<32>( ad.table[i] ) << std::endl; | |
109 | + } | |
110 | +} | |
111 | + | |
112 | +/***************************************************************** | |
113 | + * | |
114 | + * SINCOS SUB vector generation | |
115 | + * | |
116 | + *****************************************************************/ | |
117 | + | |
118 | + | |
119 | +void test_0( char *vec_name, char * ref_name) // positive rounding | |
120 | +{ | |
121 | + std::ofstream vec; vec.open(vec_name); | |
122 | + std::ofstream ref; ref.open(ref_name); | |
123 | + // reset | |
124 | + test_async_9bit(vec, ref, 23, 0, 60, 10, 1, 0); // x, angle, p, q, reset, clk // CCW | |
125 | + | |
126 | + // positive rounding | |
127 | + test_async_9bit(vec, ref, 23, 0, 60, 10, 0, 0); // x, angle, p, q, reset, clk // CCW | |
128 | + test_async_9bit(vec, ref, 23, 0, 60, 10, 0, 1); // x, angle, p, q, reset, clk // CCW | |
129 | + test_async_9bit(vec, ref, 23, 0, 60, 10, 0, 1); // x, angle, p, q, reset, clk // CCW | |
130 | + test_async_9bit(vec, ref, 23, 0, 60, 10, 0, 0); // x, angle, p, q, reset, clk // CCW | |
131 | + | |
132 | + test_async_9bit(vec, ref, 23, 24, 60, 10, 0, 0); // x, angle, p, q, reset, clk // CW | |
133 | + test_async_9bit(vec, ref, 23, 24, 60, 10, 0, 1); // x, angle, p, q, reset, clk // CW | |
134 | + test_async_9bit(vec, ref, 23, 24, 60, 10, 0, 1); // x, angle, p, q, reset, clk // CW | |
135 | + test_async_9bit(vec, ref, 23, 24, 60, 10, 0, 0); // x, angle, p, q, reset, clk // CW | |
136 | +} | |
137 | + | |
138 | +void test_1( char *vec_name, char * ref_name) // positive no rounding | |
139 | +{ | |
140 | + std::ofstream vec; vec.open(vec_name); | |
141 | + std::ofstream ref; ref.open(ref_name); | |
142 | + // reset | |
143 | + test_async_9bit(vec, ref, -23, 0, 60, -10, 1, 0); // x, angle, p, q, reset, clk // CW | |
144 | + | |
145 | + // positive no roundingb | |
146 | + test_async_9bit(vec, ref, -23, 0, 60, -10, 0, 0); // x, angle, p, q, reset, clk // CW | |
147 | + test_async_9bit(vec, ref, -23, 0, 60, -10, 0, 1); // x, angle, p, q, reset, clk // CW | |
148 | + test_async_9bit(vec, ref, -23, 0, 60, -10, 0, 1); // x, angle, p, q, reset, clk // CW | |
149 | + test_async_9bit(vec, ref, -23, 0, 60, -10, 0, 0); // x, angle, p, q, reset, clk // CW | |
150 | + | |
151 | + test_async_9bit(vec, ref, -23, -24, 60, -10, 0, 0); // x, angle, p, q, reset, clk // CCW | |
152 | + test_async_9bit(vec, ref, -23, -24, 60, -10, 0, 1); // x, angle, p, q, reset, clk // CCW | |
153 | + test_async_9bit(vec, ref, -23, -24, 60, -10, 0, 1); // x, angle, p, q, reset, clk // CCW | |
154 | + test_async_9bit(vec, ref, -23, -24, 60, -10, 0, 0); // x, angle, p, q, reset, clk // CCW | |
155 | + | |
156 | +} | |
157 | + | |
158 | +void test_2( char *vec_name, char * ref_name) // positive rounding | |
159 | +{ | |
160 | + std::ofstream vec; vec.open(vec_name); | |
161 | + std::ofstream ref; ref.open(ref_name); | |
162 | + // reset | |
163 | + test_async_13bit(vec, ref, 23, 0, 16, 64, 1, 0 ); // x, angle, p, q, reset, clk | |
164 | + | |
165 | + // positive rounding | |
166 | + test_async_13bit(vec, ref, 23, 0, 16, 64, 0, 0 ); // x, angle, p, q, reset, clk | |
167 | + test_async_13bit(vec, ref, 23, 0, 16, 64, 0, 1 ); // x, angle, p, q, reset, clk | |
168 | + test_async_13bit(vec, ref, 23, 0, 16, 64, 0, 1 ); // x, angle, p, q, reset, clk | |
169 | + test_async_13bit(vec, ref, 23, 0, 16, 64, 0, 0 ); // x, angle, p, q, reset, clk | |
170 | + | |
171 | + test_async_13bit(vec, ref, 23, 0, 31, 64, 0, 0 ); // x, angle, p, q, reset, clk // same with above when truncated, +1 when rounding | |
172 | + test_async_13bit(vec, ref, 23, 0, 31, 64, 0, 1 ); // x, angle, p, q, reset, clk | |
173 | + test_async_13bit(vec, ref, 23, 0, 31, 64, 0, 1 ); // x, angle, p, q, reset, clk | |
174 | + test_async_13bit(vec, ref, 23, 0, 31, 64, 0, 0 ); // x, angle, p, q, reset, clk | |
175 | +} | |
176 | + | |
177 | +void test_3( char *vec_name, char * ref_name) // negative rounding | |
178 | +{ | |
179 | + std::ofstream vec; vec.open(vec_name); | |
180 | + std::ofstream ref; ref.open(ref_name); | |
181 | + | |
182 | + // reset | |
183 | + test_async_13bit(vec, ref, -23, -24, 16, 64, 1, 0 ); // x, angle, p, q, reset, clk // | |
184 | + | |
185 | + // negative rounding | |
186 | + test_async_13bit(vec, ref, -23, -24, 16, 64, 0, 0 ); // x, angle, p, q, reset, clk // | |
187 | + test_async_13bit(vec, ref, -23, -24, 16, 64, 0, 1 ); // x, angle, p, q, reset, clk // | |
188 | + test_async_13bit(vec, ref, -23, -24, 16, 64, 0, 1 ); // x, angle, p, q, reset, clk // | |
189 | + test_async_13bit(vec, ref, -23, -24, 16, 64, 0, 0 ); // x, angle, p, q, reset, clk // | |
190 | + | |
191 | + test_async_13bit(vec, ref, -23, -24, 31, 64, 0, 0 ); // x, angle, p, q, reset, clk // same with above when truncated, +1 when rounding | |
192 | + test_async_13bit(vec, ref, -23, -24, 31, 64, 0, 1 ); // x, angle, p, q, reset, clk | |
193 | + test_async_13bit(vec, ref, -23, -24, 31, 64, 0, 1 ); // x, angle, p, q, reset, clk | |
194 | + test_async_13bit(vec, ref, -23, -24, 31, 64, 0, 0 ); // x, angle, p, q, reset, clk | |
195 | +} | |
196 | + | |
197 | + | |
198 | +void test_4( char *vec_name, char * ref_name) // async reset | |
199 | +{ | |
200 | + std::ofstream vec; vec.open(vec_name); | |
201 | + std::ofstream ref; ref.open(ref_name); | |
202 | + | |
203 | + test_async_11bit(vec, ref, 23, 0, 500, 230, 1, 0 ); // x, angle, p, q, reset, clk | |
204 | + test_async_11bit(vec, ref, 23, 0, 500, 20, 1, 1 ); // x, angle, p, q, reset, clk | |
205 | + test_async_11bit(vec, ref, 23, 25, 500, 20, 1, 0 ); // x, angle, p, q, reset, clk | |
206 | + test_async_11bit(vec, ref, 23, 0, 500, 230, 0, 0 ); // x, angle, p, q, reset, clk | |
207 | + test_async_11bit(vec, ref, 23, 0, 500, 230, 0, 1 ); // x, angle, p, q, reset, clk | |
208 | + test_async_11bit(vec, ref, 23, 0, 430, 75, 0, 0 ); // x, angle, p, q, reset, clk | |
209 | + test_async_11bit(vec, ref, 23, 0, 430, 75, 1, 0 ); // x, angle, p, q, reset, clk | |
210 | + test_async_11bit(vec, ref, 23, 0, 430, 75, 0, 0 ); // x, angle, p, q, reset, clk | |
211 | + test_async_11bit(vec, ref, 23, 0, 430, 75, 0, 1 ); // x, angle, p, q, reset, clk | |
212 | + test_async_11bit(vec, ref, 23, 0, 430, 75, 1, 1 ); // x, angle, p, q, reset, clk | |
213 | + test_async_11bit(vec, ref, 23, 0, 430, 75, 0, 1 ); // x, angle, p, q, reset, clk | |
214 | + test_async_11bit(vec, ref, 23, 32, 430, 75, 0, 0 ); // x, angle, p, q, reset, clk | |
215 | + test_async_11bit(vec, ref, 23, 32, 430, 75, 0, 1 ); // x, angle, p, q, reset, clk | |
216 | +} | |
217 | + | |
218 | +void test_5( char *vec_name, char * ref_name) // test of completely same timing signal change with clock | |
219 | +{ | |
220 | + std::ofstream vec; vec.open(vec_name); | |
221 | + std::ofstream ref; ref.open(ref_name); | |
222 | + | |
223 | + // reset | |
224 | + test_async_13bit(vec, ref, 23, 0, 16, 64, 1, 0 ); // x, angle, p, q, reset, clk | |
225 | + | |
226 | + // positive rounding | |
227 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 0 ); // x, angle, p, q, reset, clk | |
228 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk | |
229 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk | |
230 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 0 ); // x, angle, p, q, reset, clk | |
231 | + | |
232 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 0 ); // x, angle, p, q, reset, clk | |
233 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 1 ); // x, angle, p, q, reset, clk | |
234 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 1 ); // x, angle, p, q, reset, clk | |
235 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 0 ); // x, angle, p, q, reset, clk | |
236 | + | |
237 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 0 ); // x, angle, p, q, reset, clk | |
238 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk | |
239 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk | |
240 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 0 ); // x, angle, p, q, reset, clk | |
241 | + | |
242 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 0 ); // x, angle, p, q, reset, clk | |
243 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 1 ); // x, angle, p, q, reset, clk | |
244 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 1 ); // x, angle, p, q, reset, clk | |
245 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 0 ); // x, angle, p, q, reset, clk | |
246 | + | |
247 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 0 ); // x, angle, p, q, reset, clk | |
248 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk | |
249 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk | |
250 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 0 ); // x, angle, p, q, reset, clk | |
251 | + | |
252 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 0 ); // x, angle, p, q, reset, clk | |
253 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 1 ); // x, angle, p, q, reset, clk | |
254 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 1 ); // x, angle, p, q, reset, clk | |
255 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 0 ); // x, angle, p, q, reset, clk | |
256 | + | |
257 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 0 ); // x, angle, p, q, reset, clk | |
258 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk | |
259 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk | |
260 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 0 ); // x, angle, p, q, reset, clk | |
261 | + | |
262 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 0 ); // x, angle, p, q, reset, clk | |
263 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 1 ); // x, angle, p, q, reset, clk | |
264 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 1 ); // x, angle, p, q, reset, clk | |
265 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 0 ); // x, angle, p, q, reset, clk | |
266 | + | |
267 | +} | |
268 | + | |
269 | + | |
270 | + | |
271 | +/***************************************************************** | |
272 | + * | |
273 | + * SINCOS vector generation | |
274 | + * | |
275 | + *****************************************************************/ | |
276 | + | |
277 | + | |
278 | +void test_100( char *vec_name, char * ref_name, int num_stages) | |
279 | +{ | |
280 | + std::ofstream vec; vec.open(vec_name); | |
281 | + std::ofstream ref; ref.open(ref_name); | |
282 | + | |
283 | + int x = 0; | |
284 | + | |
285 | + // reset | |
286 | + cordic_sincos_bw32( vec, ref, num_stages, x, 1, 0 ); | |
287 | + | |
288 | + // scan [-0.5, 0.5) | |
289 | + // scan [-0.5, 0.5) | |
290 | + for ( int i = -128; i < 127; i++ ) | |
291 | + { | |
292 | + x = i << 23; | |
293 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); | |
294 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); | |
295 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); | |
296 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); | |
297 | + } | |
298 | + | |
299 | + // flush pipeline | |
300 | + for ( int i = 0; i < num_stages; i++ ) | |
301 | + { | |
302 | + x = i << 16; | |
303 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); | |
304 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); | |
305 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); | |
306 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); | |
307 | + } | |
308 | +} | |
309 | + | |
310 | +void test_101( char *vec_name, char * ref_name, int num_stages) | |
311 | +{ | |
312 | + std::ofstream vec; vec.open(vec_name); | |
313 | + std::ofstream ref; ref.open(ref_name); | |
314 | + | |
315 | + int x = 0; | |
316 | + | |
317 | + // reset | |
318 | + cordic_sincos_bw32( vec, ref, num_stages, x, 1, 0 ); | |
319 | + | |
320 | + // | |
321 | + for ( int i = -3; i < 2; i++ ) | |
322 | + { | |
323 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); | |
324 | + x = i << 23; | |
325 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); | |
326 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); | |
327 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); | |
328 | + } | |
329 | + | |
330 | + // flush pipeline | |
331 | + for ( int i = 0; i < num_stages; i++ ) | |
332 | + { | |
333 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); | |
334 | + x = i << 16; | |
335 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); | |
336 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); | |
337 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); | |
338 | + } | |
339 | +} | |
340 | + | |
341 | +/***************************************************************** | |
342 | + * | |
343 | + * SINCOS SUB Low level Test | |
344 | + * | |
345 | + *****************************************************************/ | |
346 | + | |
347 | + | |
348 | +void test_async_9bit( std::ostream &vec, std::ostream &ref, int x, int angle, int p, int q, int reset, int clk) | |
349 | +{ | |
350 | +#ifdef BITWIDTH | |
351 | +#undef BITWIDTH | |
352 | +#undef SHIFT | |
353 | +#undef ANGLEDELTA | |
354 | +#endif | |
355 | + | |
356 | +#define BITWIDTH 9 | |
357 | +#define SHIFT 3 | |
358 | +#define ANGLEDELTA 31 | |
359 | + | |
360 | + static int out_angle = 0, out_q = 0, last_p = 0 , last_x = 0; | |
361 | + static vhdl::sincos_sub sincos_sub_module; | |
362 | + | |
363 | + vec << std::bitset<1>(reset) << " " | |
364 | + << std::bitset<1>(clk) << " " | |
365 | + << std::bitset<BITWIDTH>(x) << " " | |
366 | + << std::bitset<BITWIDTH>(angle) << " " | |
367 | + << std::bitset<BITWIDTH>(p) << " " | |
368 | + << std::bitset<BITWIDTH>(q) << std::endl; | |
369 | + | |
370 | + sincos_sub_module.run( SHIFT, ANGLEDELTA, clk, reset, x, last_x, angle, out_angle, p, last_p, q, out_q ); | |
371 | + | |
372 | + ref << std::bitset<BITWIDTH>( last_x ) << " " | |
373 | + << std::bitset<BITWIDTH>( out_angle ) << " " | |
374 | + << std::bitset<BITWIDTH>( last_p ) << " " | |
375 | + << std::bitset<BITWIDTH>( out_q ) << std::endl; | |
376 | + | |
377 | +} | |
378 | + | |
379 | +void test_async_13bit( std::ostream &vec, std::ostream &ref, int x, int angle, int p, int q, int reset, int clk) | |
380 | +{ | |
381 | +#ifdef BITWIDTH | |
382 | +#undef BITWIDTH | |
383 | +#undef SHIFT | |
384 | +#undef ANGLEDELTA | |
385 | +#endif | |
386 | + | |
387 | +#define BITWIDTH 13 | |
388 | +#define SHIFT 4 | |
389 | +#define ANGLEDELTA 65 | |
390 | + | |
391 | + int out_angle = 0, out_q = 0, last_p = 0 , last_x = 0; | |
392 | + static vhdl::sincos_sub sincos_sub_module; | |
393 | + | |
394 | + vec << std::bitset<1>(reset) << " " | |
395 | + << std::bitset<1>(clk) << " " | |
396 | + << std::bitset<BITWIDTH>(x) << " " | |
397 | + << std::bitset<BITWIDTH>(angle) << " " | |
398 | + << std::bitset<BITWIDTH>(p) << " " | |
399 | + << std::bitset<BITWIDTH>(q) << std::endl; | |
400 | + | |
401 | + sincos_sub_module.run( SHIFT, ANGLEDELTA, clk, reset, x, last_x, angle, out_angle, p, last_p, q, out_q ); | |
402 | + | |
403 | + ref << std::bitset<BITWIDTH>( last_x ) << " " | |
404 | + << std::bitset<BITWIDTH>( out_angle ) << " " | |
405 | + << std::bitset<BITWIDTH>( last_p ) << " " | |
406 | + << std::bitset<BITWIDTH>( out_q ) << std::endl; | |
407 | + | |
408 | +} | |
409 | + | |
410 | +void test_async_11bit( std::ostream &vec, std::ostream &ref, int x, int angle, int p, int q, int reset, int clk) | |
411 | +{ | |
412 | +#ifdef BITWIDTH | |
413 | +#undef BITWIDTH | |
414 | +#undef SHIFT | |
415 | +#undef ANGLEDELTA | |
416 | +#endif | |
417 | + | |
418 | +#define BITWIDTH 11 | |
419 | +#define SHIFT 2 | |
420 | +#define ANGLEDELTA 65 | |
421 | + | |
422 | + int out_angle = 0, out_q = 0, out_p = 0 , out_x = 0; | |
423 | + static vhdl::sincos_sub sincos_sub_module; | |
424 | + | |
425 | + vec << std::bitset<1>(reset) << " " | |
426 | + << std::bitset<1>(clk) << " " | |
427 | + << std::bitset<BITWIDTH>(x) << " " | |
428 | + << std::bitset<BITWIDTH>(angle) << " " | |
429 | + << std::bitset<BITWIDTH>(p) << " " | |
430 | + << std::bitset<BITWIDTH>(q) << std::endl; | |
431 | + | |
432 | + sincos_sub_module.run( SHIFT, ANGLEDELTA, clk, reset, x, out_x, angle, out_angle, p, out_p, q, out_q ); | |
433 | + | |
434 | + ref << std::bitset<BITWIDTH>( out_x ) << " " | |
435 | + << std::bitset<BITWIDTH>( out_angle ) << " " | |
436 | + << std::bitset<BITWIDTH>( out_p ) << " " | |
437 | + << std::bitset<BITWIDTH>( out_q ) << std::endl; | |
438 | + | |
439 | +} | |
440 | + | |
441 | +/***************************************************************** | |
442 | + * | |
443 | + * SINCOS Low level Test | |
444 | + * | |
445 | + *****************************************************************/ | |
446 | + | |
447 | +/** | |
448 | + * \brief sincos CORDIC algorithm. | |
449 | + * \param x | |
450 | + * \param p | |
451 | + * \param q | |
452 | + * \param num_stages | |
453 | + * \param bit_width | |
454 | + */ | |
455 | +void cordic_sincos_bw32( std::ostream &vec, std::ostream &ref, int num_stages, int x, int reset, int clk ) | |
456 | +{ | |
457 | +#ifdef BITWIDTH | |
458 | +#undef BITWIDTH | |
459 | +#endif | |
460 | + | |
461 | +#define BITWIDTH 32 | |
462 | + | |
463 | +int out_p, out_q; | |
464 | + | |
465 | +static vhdl::sincos_cordic cordic; | |
466 | + | |
467 | + | |
468 | +vec | |
469 | + << std::bitset<1>( reset ) << " " // reset | |
470 | + << std::bitset<1>( clk ) << " " // clock | |
471 | + << std::bitset<BITWIDTH>( x ) << std::endl; | |
472 | + | |
473 | +cordic.run( 20, clk, reset, x, out_p, out_q ); | |
474 | + | |
475 | +ref | |
476 | + << std::bitset<BITWIDTH>( out_p ) << " " | |
477 | + << std::bitset<BITWIDTH>( out_q ) << std::endl; | |
478 | + | |
479 | +} |
@@ -1,361 +0,0 @@ | ||
1 | -/** | |
2 | - * \file main.cpp | |
3 | - * | |
4 | - * \date 2016/10/01 | |
5 | - * \author: takemasa | |
6 | - * \brief Test vector Generator for cordic_sincos VHDL project | |
7 | - */ | |
8 | - | |
9 | -#include <iostream> | |
10 | -#include <bitset> | |
11 | -#include <string> | |
12 | -#include <cmath> | |
13 | - | |
14 | -#include <fstream> // ifstream, ofstream | |
15 | - | |
16 | -#include "main.h" | |
17 | - | |
18 | -/** | |
19 | - * \bfief main function | |
20 | - */ | |
21 | - | |
22 | -int main() { | |
23 | - | |
24 | - | |
25 | - char filename_vector_0[] = "sincossub_0.vec.txt"; | |
26 | - char filename_reference_0[] = "sincossub_0.ref.txt"; | |
27 | - | |
28 | - char filename_vector_1[] = "sincossub_1.vec.txt"; | |
29 | - char filename_reference_1[] = "sincossub_1.ref.txt"; | |
30 | - | |
31 | - char filename_vector_2[] = "sincossub_2.vec.txt"; | |
32 | - char filename_reference_2[] = "sincossub_2.ref.txt"; | |
33 | - | |
34 | - char filename_vector_3[] = "sincossub_3.vec.txt"; | |
35 | - char filename_reference_3[] = "sincossub_3.ref.txt"; | |
36 | - | |
37 | - char filename_vector_4[] = "sincossub_4.vec.txt"; | |
38 | - char filename_reference_4[] = "sincossub_4.ref.txt"; | |
39 | - | |
40 | - char filename_angle_delta[] = "sincos_angle_delta.txt"; | |
41 | - | |
42 | - char filename_scaling_factor[] = "sincos_scaling_factor.txt"; | |
43 | - | |
44 | - std::ofstream vector_5; vector_5.open("sincos_0.vec.txt"); | |
45 | - std::ofstream reference_5; reference_5.open("sincos_0.ref.txt"); | |
46 | - | |
47 | - // positive x, | |
48 | - test_0( filename_vector_0, filename_reference_0); | |
49 | - | |
50 | - // negative x | |
51 | - test_1( filename_vector_1, filename_reference_1); | |
52 | - | |
53 | - //positive x, rounding up | |
54 | - test_2( filename_vector_2, filename_reference_2); | |
55 | - | |
56 | - // negative x rouding up | |
57 | - test_3( filename_vector_3, filename_reference_3); | |
58 | - | |
59 | - // positive x, async reset test | |
60 | - test_4( filename_vector_4, filename_reference_4); | |
61 | - | |
62 | - gen_table( filename_angle_delta, filename_scaling_factor); | |
63 | - | |
64 | - | |
65 | - test_100( vector_5, reference_5, 24 ); | |
66 | - | |
67 | - | |
68 | -} | |
69 | - | |
70 | - /** | |
71 | - * \brief shift rith arithmetic with rounding. | |
72 | - */ | |
73 | -int round_shift( int operand, int shift) | |
74 | -{ | |
75 | - if (shift > 0) | |
76 | - return ( operand + (1<<(shift-1)) ) >> shift ; | |
77 | - else | |
78 | - return operand; | |
79 | -} | |
80 | - | |
81 | - | |
82 | -void gen_table( const char * filename_angle_delta, const char * filename_scaling_factor) | |
83 | -{ | |
84 | - std::ofstream angle_delta; angle_delta.open(filename_angle_delta); | |
85 | - std::ofstream scaling_factor; scaling_factor.open(filename_scaling_factor); | |
86 | - | |
87 | - vhdl::sincos_angle_delta ad; | |
88 | - vhdl::sincos_scaling_factor sf; | |
89 | - | |
90 | - // Initialize the scaling factor and angle delta table. | |
91 | - for ( int i = 0; i<vhdl::angle_delta_table_size; i++ ) | |
92 | - { | |
93 | - // output to the file | |
94 | - scaling_factor << std::bitset<32>( sf.table[i] ) << std::endl; | |
95 | - | |
96 | - // output to the file | |
97 | - angle_delta << std::bitset<32>( ad.table[i] ) << std::endl; | |
98 | - } | |
99 | -} | |
100 | - | |
101 | - | |
102 | -void test_async_9bit( std::ostream &vec, std::ostream &ref, int x, int angle, int p, int q, int reset, int clk) | |
103 | -{ | |
104 | -#ifdef BITWIDTH | |
105 | -#undef BITWIDTH | |
106 | -#undef SHIFT | |
107 | -#undef ANGLEDELTA | |
108 | -#endif | |
109 | - | |
110 | -#define BITWIDTH 9 | |
111 | -#define SHIFT 3 | |
112 | -#define ANGLEDELTA 31 | |
113 | - | |
114 | - static int last_angle = 0, last_q = 0, last_p = 0 , last_x = 0; | |
115 | - static vhdl::sincos_sub sincos_sub_module; | |
116 | - | |
117 | - vec << std::bitset<1>(reset) << " " | |
118 | - << std::bitset<1>(clk) << " " | |
119 | - << std::bitset<BITWIDTH>(x) << " " | |
120 | - << std::bitset<BITWIDTH>(angle) << " " | |
121 | - << std::bitset<BITWIDTH>(p) << " " | |
122 | - << std::bitset<BITWIDTH>(q) << std::endl; | |
123 | - | |
124 | - sincos_sub_module.run( SHIFT, ANGLEDELTA, clk, reset, x, last_x, angle, last_angle, p, last_p, q, last_q ); | |
125 | - | |
126 | - ref << std::bitset<BITWIDTH>( last_x ) << " " | |
127 | - << std::bitset<BITWIDTH>( last_angle ) << " " | |
128 | - << std::bitset<BITWIDTH>( last_p ) << " " | |
129 | - << std::bitset<BITWIDTH>( last_q ) << std::endl; | |
130 | - | |
131 | -} | |
132 | - | |
133 | -void test_async_13bit( std::ostream &vec, std::ostream &ref, int x, int angle, int p, int q, int reset, int clk) | |
134 | -{ | |
135 | -#ifdef BITWIDTH | |
136 | -#undef BITWIDTH | |
137 | -#undef SHIFT | |
138 | -#undef ANGLEDELTA | |
139 | -#endif | |
140 | - | |
141 | -#define BITWIDTH 13 | |
142 | -#define SHIFT 4 | |
143 | -#define ANGLEDELTA 65 | |
144 | - | |
145 | - static int last_angle = 0, last_q = 0, last_p = 0 , last_x = 0; | |
146 | - static vhdl::sincos_sub sincos_sub_module; | |
147 | - | |
148 | - vec << std::bitset<1>(reset) << " " | |
149 | - << std::bitset<1>(clk) << " " | |
150 | - << std::bitset<BITWIDTH>(x) << " " | |
151 | - << std::bitset<BITWIDTH>(angle) << " " | |
152 | - << std::bitset<BITWIDTH>(p) << " " | |
153 | - << std::bitset<BITWIDTH>(q) << std::endl; | |
154 | - | |
155 | - sincos_sub_module.run( SHIFT, ANGLEDELTA, clk, reset, x, last_x, angle, last_angle, p, last_p, q, last_q ); | |
156 | - | |
157 | - ref << std::bitset<BITWIDTH>( last_x ) << " " | |
158 | - << std::bitset<BITWIDTH>( last_angle ) << " " | |
159 | - << std::bitset<BITWIDTH>( last_p ) << " " | |
160 | - << std::bitset<BITWIDTH>( last_q ) << std::endl; | |
161 | - | |
162 | -} | |
163 | - | |
164 | -void test_async_11bit( std::ostream &vec, std::ostream &ref, int x, int angle, int p, int q, int reset, int clk) | |
165 | -{ | |
166 | -#ifdef BITWIDTH | |
167 | -#undef BITWIDTH | |
168 | -#undef SHIFT | |
169 | -#undef ANGLEDELTA | |
170 | -#endif | |
171 | - | |
172 | -#define BITWIDTH 11 | |
173 | -#define SHIFT 2 | |
174 | -#define ANGLEDELTA 65 | |
175 | - | |
176 | - int last_angle = 0, last_q = 0, last_p = 0 , last_x = 0; | |
177 | - static vhdl::sincos_sub sincos_sub_module; | |
178 | - | |
179 | - vec << std::bitset<1>(reset) << " " | |
180 | - << std::bitset<1>(clk) << " " | |
181 | - << std::bitset<BITWIDTH>(x) << " " | |
182 | - << std::bitset<BITWIDTH>(angle) << " " | |
183 | - << std::bitset<BITWIDTH>(p) << " " | |
184 | - << std::bitset<BITWIDTH>(q) << std::endl; | |
185 | - | |
186 | - sincos_sub_module.run( SHIFT, ANGLEDELTA, clk, reset, x, last_x, angle, last_angle, p, last_p, q, last_q ); | |
187 | - | |
188 | - ref << std::bitset<BITWIDTH>( last_x ) << " " | |
189 | - << std::bitset<BITWIDTH>( last_angle ) << " " | |
190 | - << std::bitset<BITWIDTH>( last_p ) << " " | |
191 | - << std::bitset<BITWIDTH>( last_q ) << std::endl; | |
192 | - | |
193 | -} | |
194 | - | |
195 | -void test_0( char *vec_name, char * ref_name) // positive rounding | |
196 | -{ | |
197 | - std::ofstream vec; vec.open(vec_name); | |
198 | - std::ofstream ref; ref.open(ref_name); | |
199 | - // reset | |
200 | - test_async_9bit(vec, ref, 23, 0, 60, 10, 1, 0); // x, angle, p, q, reset, clk // CCW | |
201 | - | |
202 | - // positive rounding | |
203 | - test_async_9bit(vec, ref, 23, 0, 60, 10, 0, 0); // x, angle, p, q, reset, clk // CCW | |
204 | - test_async_9bit(vec, ref, 23, 0, 60, 10, 0, 1); // x, angle, p, q, reset, clk // CCW | |
205 | - test_async_9bit(vec, ref, 23, 0, 60, 10, 0, 1); // x, angle, p, q, reset, clk // CCW | |
206 | - test_async_9bit(vec, ref, 23, 0, 60, 10, 0, 0); // x, angle, p, q, reset, clk // CCW | |
207 | - | |
208 | - test_async_9bit(vec, ref, 23, 24, 60, 10, 0, 0); // x, angle, p, q, reset, clk // CW | |
209 | - test_async_9bit(vec, ref, 23, 24, 60, 10, 0, 1); // x, angle, p, q, reset, clk // CW | |
210 | - test_async_9bit(vec, ref, 23, 24, 60, 10, 0, 1); // x, angle, p, q, reset, clk // CW | |
211 | - test_async_9bit(vec, ref, 23, 24, 60, 10, 0, 0); // x, angle, p, q, reset, clk // CW | |
212 | -} | |
213 | - | |
214 | -void test_1( char *vec_name, char * ref_name) // positive no rounding | |
215 | -{ | |
216 | - std::ofstream vec; vec.open(vec_name); | |
217 | - std::ofstream ref; ref.open(ref_name); | |
218 | - // reset | |
219 | - test_async_9bit(vec, ref, -23, 0, 60, -10, 1, 0); // x, angle, p, q, reset, clk // CW | |
220 | - | |
221 | - // positive no roundingb | |
222 | - test_async_9bit(vec, ref, -23, 0, 60, -10, 0, 0); // x, angle, p, q, reset, clk // CW | |
223 | - test_async_9bit(vec, ref, -23, 0, 60, -10, 0, 1); // x, angle, p, q, reset, clk // CW | |
224 | - test_async_9bit(vec, ref, -23, 0, 60, -10, 0, 1); // x, angle, p, q, reset, clk // CW | |
225 | - test_async_9bit(vec, ref, -23, 0, 60, -10, 0, 0); // x, angle, p, q, reset, clk // CW | |
226 | - | |
227 | - test_async_9bit(vec, ref, -23, -24, 60, -10, 0, 0); // x, angle, p, q, reset, clk // CCW | |
228 | - test_async_9bit(vec, ref, -23, -24, 60, -10, 0, 1); // x, angle, p, q, reset, clk // CCW | |
229 | - test_async_9bit(vec, ref, -23, -24, 60, -10, 0, 1); // x, angle, p, q, reset, clk // CCW | |
230 | - test_async_9bit(vec, ref, -23, -24, 60, -10, 0, 0); // x, angle, p, q, reset, clk // CCW | |
231 | - | |
232 | -} | |
233 | - | |
234 | -void test_2( char *vec_name, char * ref_name) // positive rounding | |
235 | -{ | |
236 | - std::ofstream vec; vec.open(vec_name); | |
237 | - std::ofstream ref; ref.open(ref_name); | |
238 | - // reset | |
239 | - test_async_13bit(vec, ref, 23, 0, 16, 64, 1, 0 ); // x, angle, p, q, reset, clk | |
240 | - | |
241 | - // positive rounding | |
242 | - test_async_13bit(vec, ref, 23, 0, 16, 64, 0, 0 ); // x, angle, p, q, reset, clk | |
243 | - test_async_13bit(vec, ref, 23, 0, 16, 64, 0, 1 ); // x, angle, p, q, reset, clk | |
244 | - test_async_13bit(vec, ref, 23, 0, 16, 64, 0, 1 ); // x, angle, p, q, reset, clk | |
245 | - test_async_13bit(vec, ref, 23, 0, 16, 64, 0, 0 ); // x, angle, p, q, reset, clk | |
246 | - | |
247 | - test_async_13bit(vec, ref, 23, 0, 31, 64, 0, 0 ); // x, angle, p, q, reset, clk // same with above when truncated, +1 when rounding | |
248 | - test_async_13bit(vec, ref, 23, 0, 31, 64, 0, 1 ); // x, angle, p, q, reset, clk | |
249 | - test_async_13bit(vec, ref, 23, 0, 31, 64, 0, 1 ); // x, angle, p, q, reset, clk | |
250 | - test_async_13bit(vec, ref, 23, 0, 31, 64, 0, 0 ); // x, angle, p, q, reset, clk | |
251 | -} | |
252 | - | |
253 | -void test_3( char *vec_name, char * ref_name) // negative rounding | |
254 | -{ | |
255 | - std::ofstream vec; vec.open(vec_name); | |
256 | - std::ofstream ref; ref.open(ref_name); | |
257 | - | |
258 | - // reset | |
259 | - test_async_13bit(vec, ref, -23, -24, 16, 64, 1, 0 ); // x, angle, p, q, reset, clk // | |
260 | - | |
261 | - // negative rounding | |
262 | - test_async_13bit(vec, ref, -23, -24, 16, 64, 0, 0 ); // x, angle, p, q, reset, clk // | |
263 | - test_async_13bit(vec, ref, -23, -24, 16, 64, 0, 1 ); // x, angle, p, q, reset, clk // | |
264 | - test_async_13bit(vec, ref, -23, -24, 16, 64, 0, 1 ); // x, angle, p, q, reset, clk // | |
265 | - test_async_13bit(vec, ref, -23, -24, 16, 64, 0, 0 ); // x, angle, p, q, reset, clk // | |
266 | - | |
267 | - test_async_13bit(vec, ref, -23, -24, 31, 64, 0, 0 ); // x, angle, p, q, reset, clk // same with above when truncated, +1 when rounding | |
268 | - test_async_13bit(vec, ref, -23, -24, 31, 64, 0, 1 ); // x, angle, p, q, reset, clk | |
269 | - test_async_13bit(vec, ref, -23, -24, 31, 64, 0, 1 ); // x, angle, p, q, reset, clk | |
270 | - test_async_13bit(vec, ref, -23, -24, 31, 64, 0, 0 ); // x, angle, p, q, reset, clk | |
271 | -} | |
272 | - | |
273 | - | |
274 | -void test_4( char *vec_name, char * ref_name) // async reset | |
275 | -{ | |
276 | - std::ofstream vec; vec.open(vec_name); | |
277 | - std::ofstream ref; ref.open(ref_name); | |
278 | - | |
279 | - test_async_11bit(vec, ref, 23, 0, 500, 230, 1, 0 ); // x, angle, p, q, reset, clk | |
280 | - test_async_11bit(vec, ref, 23, 0, 500, 20, 1, 1 ); // x, angle, p, q, reset, clk | |
281 | - test_async_11bit(vec, ref, 23, 25, 500, 20, 1, 0 ); // x, angle, p, q, reset, clk | |
282 | - test_async_11bit(vec, ref, 23, 0, 500, 230, 0, 0 ); // x, angle, p, q, reset, clk | |
283 | - test_async_11bit(vec, ref, 23, 0, 500, 230, 0, 1 ); // x, angle, p, q, reset, clk | |
284 | - test_async_11bit(vec, ref, 23, 0, 430, 75, 0, 0 ); // x, angle, p, q, reset, clk | |
285 | - test_async_11bit(vec, ref, 23, 0, 430, 75, 1, 0 ); // x, angle, p, q, reset, clk | |
286 | - test_async_11bit(vec, ref, 23, 0, 430, 75, 0, 0 ); // x, angle, p, q, reset, clk | |
287 | - test_async_11bit(vec, ref, 23, 0, 430, 75, 0, 1 ); // x, angle, p, q, reset, clk | |
288 | - test_async_11bit(vec, ref, 23, 0, 430, 75, 1, 1 ); // x, angle, p, q, reset, clk | |
289 | - test_async_11bit(vec, ref, 23, 0, 430, 75, 0, 1 ); // x, angle, p, q, reset, clk | |
290 | - test_async_11bit(vec, ref, 23, 32, 430, 75, 0, 0 ); // x, angle, p, q, reset, clk | |
291 | - test_async_11bit(vec, ref, 23, 32, 430, 75, 0, 1 ); // x, angle, p, q, reset, clk | |
292 | -} | |
293 | - | |
294 | - | |
295 | - /** | |
296 | - * \brief sincos CORDIC algorithm. | |
297 | - * \param x | |
298 | - * \param p | |
299 | - * \param q | |
300 | - * \param num_stages | |
301 | - * \param bit_width | |
302 | - */ | |
303 | -void cordic_sincos_bw32( std::ostream &vec, std::ostream &ref, int num_stages, int x, int reset, int clk ) | |
304 | -{ | |
305 | -#ifdef BITWIDTH | |
306 | -#undef BITWIDTH | |
307 | -#endif | |
308 | - | |
309 | -#define BITWIDTH 32 | |
310 | - | |
311 | - int p_next, q_next, angle; | |
312 | - int last_clk = 0; | |
313 | - static int last_p = 0, last_q = 0; | |
314 | - | |
315 | - static vhdl::sincos_angle_delta ad; | |
316 | - static vhdl::sincos_scaling_factor sf; | |
317 | - static vhdl::sincos_cordic cordic; | |
318 | - | |
319 | - | |
320 | - vec | |
321 | - << std::bitset<1>( reset ) << " " // reset | |
322 | - << std::bitset<1>( clk ) << " " // clock | |
323 | - << std::bitset<BITWIDTH>( x ) << std::endl; | |
324 | - | |
325 | - cordic.run( 20, clk, reset, x, p, q ); | |
326 | - | |
327 | - ref | |
328 | - << std::bitset<BITWIDTH>( last_p ) << " " | |
329 | - << std::bitset<BITWIDTH>( last_q ) << std::endl; | |
330 | - | |
331 | - | |
332 | -} | |
333 | - | |
334 | -void test_100( std::ostream &vec, std::ostream &ref, int num_stages ) | |
335 | -{ | |
336 | - | |
337 | - int x = 0; | |
338 | - | |
339 | - // reset | |
340 | - cordic_sincos_bw32( vec, ref, num_stages, x, 1, 0 ); | |
341 | - | |
342 | - // scan [-0.5, 0.5) | |
343 | - for ( int i = -64; i < 63; i++ ) | |
344 | - { | |
345 | - cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); | |
346 | - x = i << 24; | |
347 | - cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); | |
348 | - cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); | |
349 | - cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); | |
350 | - } | |
351 | - | |
352 | - // flush pipeline | |
353 | - for ( int i = 0; i < num_stages; i++ ) | |
354 | - { | |
355 | - cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); | |
356 | - x = i << 16; | |
357 | - cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); | |
358 | - cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); | |
359 | - cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); | |
360 | - } | |
361 | -} |
@@ -1,359 +0,0 @@ | ||
1 | -/** | |
2 | - * \file main.cpp | |
3 | - * | |
4 | - * \date 2016/10/01 | |
5 | - * \author: takemasa | |
6 | - * \brief Test vector Generator for cordic_sincos VHDL project | |
7 | - */ | |
8 | - | |
9 | -#include <iostream> | |
10 | -#include <bitset> | |
11 | -#include <string> | |
12 | -#include <cmath> | |
13 | - | |
14 | -#include <fstream> // ifstream, ofstream | |
15 | - | |
16 | -#include "main.h" | |
17 | - | |
18 | -/** | |
19 | - * \bfief main function | |
20 | - */ | |
21 | - | |
22 | -int main() { | |
23 | - | |
24 | - | |
25 | - char filename_vector_0[] = "sincossub_0.vec.txt"; | |
26 | - char filename_reference_0[] = "sincossub_0.ref.txt"; | |
27 | - | |
28 | - char filename_vector_1[] = "sincossub_1.vec.txt"; | |
29 | - char filename_reference_1[] = "sincossub_1.ref.txt"; | |
30 | - | |
31 | - char filename_vector_2[] = "sincossub_2.vec.txt"; | |
32 | - char filename_reference_2[] = "sincossub_2.ref.txt"; | |
33 | - | |
34 | - char filename_vector_3[] = "sincossub_3.vec.txt"; | |
35 | - char filename_reference_3[] = "sincossub_3.ref.txt"; | |
36 | - | |
37 | - char filename_vector_4[] = "sincossub_4.vec.txt"; | |
38 | - char filename_reference_4[] = "sincossub_4.ref.txt"; | |
39 | - | |
40 | - char filename_angle_delta[] = "sincos_angle_delta.txt"; | |
41 | - | |
42 | - char filename_scaling_factor[] = "sincos_scaling_factor.txt"; | |
43 | - | |
44 | - std::ofstream vector_5; vector_5.open("sincos_0.vec.txt"); | |
45 | - std::ofstream reference_5; reference_5.open("sincos_0.ref.txt"); | |
46 | - | |
47 | - // positive x, | |
48 | - test_0( filename_vector_0, filename_reference_0); | |
49 | - | |
50 | - // negative x | |
51 | - test_1( filename_vector_1, filename_reference_1); | |
52 | - | |
53 | - //positive x, rounding up | |
54 | - test_2( filename_vector_2, filename_reference_2); | |
55 | - | |
56 | - // negative x rouding up | |
57 | - test_3( filename_vector_3, filename_reference_3); | |
58 | - | |
59 | - // positive x, async reset test | |
60 | - test_4( filename_vector_4, filename_reference_4); | |
61 | - | |
62 | - gen_table( filename_angle_delta, filename_scaling_factor); | |
63 | - | |
64 | - | |
65 | - test_100( vector_5, reference_5, 24 ); | |
66 | - | |
67 | - | |
68 | -} | |
69 | - | |
70 | - /** | |
71 | - * \brief shift rith arithmetic with rounding. | |
72 | - */ | |
73 | -int round_shift( int operand, int shift) | |
74 | -{ | |
75 | - if (shift > 0) | |
76 | - return ( operand + (1<<(shift-1)) ) >> shift ; | |
77 | - else | |
78 | - return operand; | |
79 | -} | |
80 | - | |
81 | - | |
82 | -void gen_table( const char * filename_angle_delta, const char * filename_scaling_factor) | |
83 | -{ | |
84 | - std::ofstream angle_delta; angle_delta.open(filename_angle_delta); | |
85 | - std::ofstream scaling_factor; scaling_factor.open(filename_scaling_factor); | |
86 | - | |
87 | - vhdl::sincos_angle_delta ad; | |
88 | - vhdl::sincos_scaling_factor sf; | |
89 | - | |
90 | - // Initialize the scaling factor and angle delta table. | |
91 | - for ( int i = 0; i<vhdl::angle_delta_table_size; i++ ) | |
92 | - { | |
93 | - // output to the file | |
94 | - scaling_factor << std::bitset<32>( sf.table[i] ) << std::endl; | |
95 | - | |
96 | - // output to the file | |
97 | - angle_delta << std::bitset<32>( ad.table[i] ) << std::endl; | |
98 | - } | |
99 | -} | |
100 | - | |
101 | - | |
102 | -void test_async_9bit( std::ostream &vec, std::ostream &ref, int x, int angle, int p, int q, int reset, int clk) | |
103 | -{ | |
104 | -#ifdef BITWIDTH | |
105 | -#undef BITWIDTH | |
106 | -#undef SHIFT | |
107 | -#undef ANGLEDELTA | |
108 | -#endif | |
109 | - | |
110 | -#define BITWIDTH 9 | |
111 | -#define SHIFT 3 | |
112 | -#define ANGLEDELTA 31 | |
113 | - | |
114 | - static int last_angle = 0, last_q = 0, last_p = 0 , last_x = 0; | |
115 | - static vhdl::sincos_sub sincos_sub_module; | |
116 | - | |
117 | - vec << std::bitset<1>(reset) << " " | |
118 | - << std::bitset<1>(clk) << " " | |
119 | - << std::bitset<BITWIDTH>(x) << " " | |
120 | - << std::bitset<BITWIDTH>(angle) << " " | |
121 | - << std::bitset<BITWIDTH>(p) << " " | |
122 | - << std::bitset<BITWIDTH>(q) << std::endl; | |
123 | - | |
124 | - sincos_sub_module.run( SHIFT, ANGLEDELTA, clk, reset, x, last_x, angle, last_angle, p, last_p, q, last_q ); | |
125 | - | |
126 | - ref << std::bitset<BITWIDTH>( last_x ) << " " | |
127 | - << std::bitset<BITWIDTH>( last_angle ) << " " | |
128 | - << std::bitset<BITWIDTH>( last_p ) << " " | |
129 | - << std::bitset<BITWIDTH>( last_q ) << std::endl; | |
130 | - | |
131 | -} | |
132 | - | |
133 | -void test_async_13bit( std::ostream &vec, std::ostream &ref, int x, int angle, int p, int q, int reset, int clk) | |
134 | -{ | |
135 | -#ifdef BITWIDTH | |
136 | -#undef BITWIDTH | |
137 | -#undef SHIFT | |
138 | -#undef ANGLEDELTA | |
139 | -#endif | |
140 | - | |
141 | -#define BITWIDTH 13 | |
142 | -#define SHIFT 4 | |
143 | -#define ANGLEDELTA 65 | |
144 | - | |
145 | - static int last_angle = 0, last_q = 0, last_p = 0 , last_x = 0; | |
146 | - static vhdl::sincos_sub sincos_sub_module; | |
147 | - | |
148 | - vec << std::bitset<1>(reset) << " " | |
149 | - << std::bitset<1>(clk) << " " | |
150 | - << std::bitset<BITWIDTH>(x) << " " | |
151 | - << std::bitset<BITWIDTH>(angle) << " " | |
152 | - << std::bitset<BITWIDTH>(p) << " " | |
153 | - << std::bitset<BITWIDTH>(q) << std::endl; | |
154 | - | |
155 | - sincos_sub_module.run( SHIFT, ANGLEDELTA, clk, reset, x, last_x, angle, last_angle, p, last_p, q, last_q ); | |
156 | - | |
157 | - ref << std::bitset<BITWIDTH>( last_x ) << " " | |
158 | - << std::bitset<BITWIDTH>( last_angle ) << " " | |
159 | - << std::bitset<BITWIDTH>( last_p ) << " " | |
160 | - << std::bitset<BITWIDTH>( last_q ) << std::endl; | |
161 | - | |
162 | -} | |
163 | - | |
164 | -void test_async_11bit( std::ostream &vec, std::ostream &ref, int x, int angle, int p, int q, int reset, int clk) | |
165 | -{ | |
166 | -#ifdef BITWIDTH | |
167 | -#undef BITWIDTH | |
168 | -#undef SHIFT | |
169 | -#undef ANGLEDELTA | |
170 | -#endif | |
171 | - | |
172 | -#define BITWIDTH 11 | |
173 | -#define SHIFT 2 | |
174 | -#define ANGLEDELTA 65 | |
175 | - | |
176 | - int last_angle = 0, last_q = 0, last_p = 0 , last_x = 0; | |
177 | - static vhdl::sincos_sub sincos_sub_module; | |
178 | - | |
179 | - vec << std::bitset<1>(reset) << " " | |
180 | - << std::bitset<1>(clk) << " " | |
181 | - << std::bitset<BITWIDTH>(x) << " " | |
182 | - << std::bitset<BITWIDTH>(angle) << " " | |
183 | - << std::bitset<BITWIDTH>(p) << " " | |
184 | - << std::bitset<BITWIDTH>(q) << std::endl; | |
185 | - | |
186 | - sincos_sub_module.run( SHIFT, ANGLEDELTA, clk, reset, x, last_x, angle, last_angle, p, last_p, q, last_q ); | |
187 | - | |
188 | - ref << std::bitset<BITWIDTH>( last_x ) << " " | |
189 | - << std::bitset<BITWIDTH>( last_angle ) << " " | |
190 | - << std::bitset<BITWIDTH>( last_p ) << " " | |
191 | - << std::bitset<BITWIDTH>( last_q ) << std::endl; | |
192 | - | |
193 | -} | |
194 | - | |
195 | -void test_0( char *vec_name, char * ref_name) // positive rounding | |
196 | -{ | |
197 | - std::ofstream vec; vec.open(vec_name); | |
198 | - std::ofstream ref; ref.open(ref_name); | |
199 | - // reset | |
200 | - test_async_9bit(vec, ref, 23, 0, 60, 10, 1, 0); // x, angle, p, q, reset, clk // CCW | |
201 | - | |
202 | - // positive rounding | |
203 | - test_async_9bit(vec, ref, 23, 0, 60, 10, 0, 0); // x, angle, p, q, reset, clk // CCW | |
204 | - test_async_9bit(vec, ref, 23, 0, 60, 10, 0, 1); // x, angle, p, q, reset, clk // CCW | |
205 | - test_async_9bit(vec, ref, 23, 0, 60, 10, 0, 1); // x, angle, p, q, reset, clk // CCW | |
206 | - test_async_9bit(vec, ref, 23, 0, 60, 10, 0, 0); // x, angle, p, q, reset, clk // CCW | |
207 | - | |
208 | - test_async_9bit(vec, ref, 23, 24, 60, 10, 0, 0); // x, angle, p, q, reset, clk // CW | |
209 | - test_async_9bit(vec, ref, 23, 24, 60, 10, 0, 1); // x, angle, p, q, reset, clk // CW | |
210 | - test_async_9bit(vec, ref, 23, 24, 60, 10, 0, 1); // x, angle, p, q, reset, clk // CW | |
211 | - test_async_9bit(vec, ref, 23, 24, 60, 10, 0, 0); // x, angle, p, q, reset, clk // CW | |
212 | -} | |
213 | - | |
214 | -void test_1( char *vec_name, char * ref_name) // positive no rounding | |
215 | -{ | |
216 | - std::ofstream vec; vec.open(vec_name); | |
217 | - std::ofstream ref; ref.open(ref_name); | |
218 | - // reset | |
219 | - test_async_9bit(vec, ref, -23, 0, 60, -10, 1, 0); // x, angle, p, q, reset, clk // CW | |
220 | - | |
221 | - // positive no roundingb | |
222 | - test_async_9bit(vec, ref, -23, 0, 60, -10, 0, 0); // x, angle, p, q, reset, clk // CW | |
223 | - test_async_9bit(vec, ref, -23, 0, 60, -10, 0, 1); // x, angle, p, q, reset, clk // CW | |
224 | - test_async_9bit(vec, ref, -23, 0, 60, -10, 0, 1); // x, angle, p, q, reset, clk // CW | |
225 | - test_async_9bit(vec, ref, -23, 0, 60, -10, 0, 0); // x, angle, p, q, reset, clk // CW | |
226 | - | |
227 | - test_async_9bit(vec, ref, -23, -24, 60, -10, 0, 0); // x, angle, p, q, reset, clk // CCW | |
228 | - test_async_9bit(vec, ref, -23, -24, 60, -10, 0, 1); // x, angle, p, q, reset, clk // CCW | |
229 | - test_async_9bit(vec, ref, -23, -24, 60, -10, 0, 1); // x, angle, p, q, reset, clk // CCW | |
230 | - test_async_9bit(vec, ref, -23, -24, 60, -10, 0, 0); // x, angle, p, q, reset, clk // CCW | |
231 | - | |
232 | -} | |
233 | - | |
234 | -void test_2( char *vec_name, char * ref_name) // positive rounding | |
235 | -{ | |
236 | - std::ofstream vec; vec.open(vec_name); | |
237 | - std::ofstream ref; ref.open(ref_name); | |
238 | - // reset | |
239 | - test_async_13bit(vec, ref, 23, 0, 16, 64, 1, 0 ); // x, angle, p, q, reset, clk | |
240 | - | |
241 | - // positive rounding | |
242 | - test_async_13bit(vec, ref, 23, 0, 16, 64, 0, 0 ); // x, angle, p, q, reset, clk | |
243 | - test_async_13bit(vec, ref, 23, 0, 16, 64, 0, 1 ); // x, angle, p, q, reset, clk | |
244 | - test_async_13bit(vec, ref, 23, 0, 16, 64, 0, 1 ); // x, angle, p, q, reset, clk | |
245 | - test_async_13bit(vec, ref, 23, 0, 16, 64, 0, 0 ); // x, angle, p, q, reset, clk | |
246 | - | |
247 | - test_async_13bit(vec, ref, 23, 0, 31, 64, 0, 0 ); // x, angle, p, q, reset, clk // same with above when truncated, +1 when rounding | |
248 | - test_async_13bit(vec, ref, 23, 0, 31, 64, 0, 1 ); // x, angle, p, q, reset, clk | |
249 | - test_async_13bit(vec, ref, 23, 0, 31, 64, 0, 1 ); // x, angle, p, q, reset, clk | |
250 | - test_async_13bit(vec, ref, 23, 0, 31, 64, 0, 0 ); // x, angle, p, q, reset, clk | |
251 | -} | |
252 | - | |
253 | -void test_3( char *vec_name, char * ref_name) // negative rounding | |
254 | -{ | |
255 | - std::ofstream vec; vec.open(vec_name); | |
256 | - std::ofstream ref; ref.open(ref_name); | |
257 | - | |
258 | - // reset | |
259 | - test_async_13bit(vec, ref, -23, -24, 16, 64, 1, 0 ); // x, angle, p, q, reset, clk // | |
260 | - | |
261 | - // negative rounding | |
262 | - test_async_13bit(vec, ref, -23, -24, 16, 64, 0, 0 ); // x, angle, p, q, reset, clk // | |
263 | - test_async_13bit(vec, ref, -23, -24, 16, 64, 0, 1 ); // x, angle, p, q, reset, clk // | |
264 | - test_async_13bit(vec, ref, -23, -24, 16, 64, 0, 1 ); // x, angle, p, q, reset, clk // | |
265 | - test_async_13bit(vec, ref, -23, -24, 16, 64, 0, 0 ); // x, angle, p, q, reset, clk // | |
266 | - | |
267 | - test_async_13bit(vec, ref, -23, -24, 31, 64, 0, 0 ); // x, angle, p, q, reset, clk // same with above when truncated, +1 when rounding | |
268 | - test_async_13bit(vec, ref, -23, -24, 31, 64, 0, 1 ); // x, angle, p, q, reset, clk | |
269 | - test_async_13bit(vec, ref, -23, -24, 31, 64, 0, 1 ); // x, angle, p, q, reset, clk | |
270 | - test_async_13bit(vec, ref, -23, -24, 31, 64, 0, 0 ); // x, angle, p, q, reset, clk | |
271 | -} | |
272 | - | |
273 | - | |
274 | -void test_4( char *vec_name, char * ref_name) // async reset | |
275 | -{ | |
276 | - std::ofstream vec; vec.open(vec_name); | |
277 | - std::ofstream ref; ref.open(ref_name); | |
278 | - | |
279 | - test_async_11bit(vec, ref, 23, 0, 500, 230, 1, 0 ); // x, angle, p, q, reset, clk | |
280 | - test_async_11bit(vec, ref, 23, 0, 500, 20, 1, 1 ); // x, angle, p, q, reset, clk | |
281 | - test_async_11bit(vec, ref, 23, 25, 500, 20, 1, 0 ); // x, angle, p, q, reset, clk | |
282 | - test_async_11bit(vec, ref, 23, 0, 500, 230, 0, 0 ); // x, angle, p, q, reset, clk | |
283 | - test_async_11bit(vec, ref, 23, 0, 500, 230, 0, 1 ); // x, angle, p, q, reset, clk | |
284 | - test_async_11bit(vec, ref, 23, 0, 430, 75, 0, 0 ); // x, angle, p, q, reset, clk | |
285 | - test_async_11bit(vec, ref, 23, 0, 430, 75, 1, 0 ); // x, angle, p, q, reset, clk | |
286 | - test_async_11bit(vec, ref, 23, 0, 430, 75, 0, 0 ); // x, angle, p, q, reset, clk | |
287 | - test_async_11bit(vec, ref, 23, 0, 430, 75, 0, 1 ); // x, angle, p, q, reset, clk | |
288 | - test_async_11bit(vec, ref, 23, 0, 430, 75, 1, 1 ); // x, angle, p, q, reset, clk | |
289 | - test_async_11bit(vec, ref, 23, 0, 430, 75, 0, 1 ); // x, angle, p, q, reset, clk | |
290 | - test_async_11bit(vec, ref, 23, 32, 430, 75, 0, 0 ); // x, angle, p, q, reset, clk | |
291 | - test_async_11bit(vec, ref, 23, 32, 430, 75, 0, 1 ); // x, angle, p, q, reset, clk | |
292 | -} | |
293 | - | |
294 | - | |
295 | - /** | |
296 | - * \brief sincos CORDIC algorithm. | |
297 | - * \param x | |
298 | - * \param p | |
299 | - * \param q | |
300 | - * \param num_stages | |
301 | - * \param bit_width | |
302 | - */ | |
303 | -void cordic_sincos_bw32( std::ostream &vec, std::ostream &ref, int num_stages, int x, int reset, int clk ) | |
304 | -{ | |
305 | -#ifdef BITWIDTH | |
306 | -#undef BITWIDTH | |
307 | -#endif | |
308 | - | |
309 | -#define BITWIDTH 32 | |
310 | - | |
311 | - int last_p, last_q; | |
312 | - | |
313 | - static vhdl::sincos_angle_delta ad; | |
314 | - static vhdl::sincos_scaling_factor sf; | |
315 | - static vhdl::sincos_cordic cordic; | |
316 | - | |
317 | - | |
318 | - vec | |
319 | - << std::bitset<1>( reset ) << " " // reset | |
320 | - << std::bitset<1>( clk ) << " " // clock | |
321 | - << std::bitset<BITWIDTH>( x ) << std::endl; | |
322 | - | |
323 | - cordic.run( 20, clk, reset, x, last_p, last_q ); | |
324 | - | |
325 | - ref | |
326 | - << std::bitset<BITWIDTH>( last_p ) << " " | |
327 | - << std::bitset<BITWIDTH>( last_q ) << std::endl; | |
328 | - | |
329 | - | |
330 | -} | |
331 | - | |
332 | -void test_100( std::ostream &vec, std::ostream &ref, int num_stages ) | |
333 | -{ | |
334 | - | |
335 | - int x = 0; | |
336 | - | |
337 | - // reset | |
338 | - cordic_sincos_bw32( vec, ref, num_stages, x, 1, 0 ); | |
339 | - | |
340 | - // scan [-0.5, 0.5) | |
341 | - for ( int i = -64; i < 63; i++ ) | |
342 | - { | |
343 | - cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); | |
344 | - x = i << 24; | |
345 | - cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); | |
346 | - cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); | |
347 | - cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); | |
348 | - } | |
349 | - | |
350 | - // flush pipeline | |
351 | - for ( int i = 0; i < num_stages; i++ ) | |
352 | - { | |
353 | - cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); | |
354 | - x = i << 16; | |
355 | - cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); | |
356 | - cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); | |
357 | - cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); | |
358 | - } | |
359 | -} |
@@ -22,27 +22,32 @@ | ||
22 | 22 | int main() { |
23 | 23 | |
24 | 24 | |
25 | - char filename_vector_0[] = "sincossub_0.vec.txt"; | |
26 | - char filename_reference_0[] = "sincossub_0.ref.txt"; | |
25 | + char filename_vector_0[] = "fileout/sincossub_0.vec.txt"; | |
26 | + char filename_reference_0[] = "fileout/sincossub_0.ref.txt"; | |
27 | 27 | |
28 | - char filename_vector_1[] = "sincossub_1.vec.txt"; | |
29 | - char filename_reference_1[] = "sincossub_1.ref.txt"; | |
28 | + char filename_vector_1[] = "fileout/sincossub_1.vec.txt"; | |
29 | + char filename_reference_1[] = "fileout/sincossub_1.ref.txt"; | |
30 | 30 | |
31 | - char filename_vector_2[] = "sincossub_2.vec.txt"; | |
32 | - char filename_reference_2[] = "sincossub_2.ref.txt"; | |
31 | + char filename_vector_2[] = "fileout/sincossub_2.vec.txt"; | |
32 | + char filename_reference_2[] = "fileout/sincossub_2.ref.txt"; | |
33 | 33 | |
34 | - char filename_vector_3[] = "sincossub_3.vec.txt"; | |
35 | - char filename_reference_3[] = "sincossub_3.ref.txt"; | |
34 | + char filename_vector_3[] = "fileout/sincossub_3.vec.txt"; | |
35 | + char filename_reference_3[] = "fileout/sincossub_3.ref.txt"; | |
36 | 36 | |
37 | - char filename_vector_4[] = "sincossub_4.vec.txt"; | |
38 | - char filename_reference_4[] = "sincossub_4.ref.txt"; | |
37 | + char filename_vector_4[] = "fileout/sincossub_4.vec.txt"; | |
38 | + char filename_reference_4[] = "fileout/sincossub_4.ref.txt"; | |
39 | 39 | |
40 | - char filename_angle_delta[] = "sincos_angle_delta.txt"; | |
40 | + char filename_vector_5[] = "fileout/sincossub_5.vec.txt"; | |
41 | + char filename_reference_5[] = "fileout/sincossub_5.ref.txt"; | |
41 | 42 | |
42 | - char filename_scaling_factor[] = "sincos_scaling_factor.txt"; | |
43 | + char filename_angle_delta[] = "fileout/sincos_angle_delta.txt"; | |
44 | + char filename_scaling_factor[] = "fileout/sincos_scaling_factor.txt"; | |
43 | 45 | |
44 | - std::ofstream vector_5; vector_5.open("sincos_0.vec.txt"); | |
45 | - std::ofstream reference_5; reference_5.open("sincos_0.ref.txt"); | |
46 | + char filename_vector_100[] = "fileout/sincos_100.vec.txt"; | |
47 | + char filename_reference_100[] = "fileout/sincos_100.ref.txt"; | |
48 | + | |
49 | + char filename_vector_101[] = "fileout/sincos_101.vec.txt"; | |
50 | + char filename_reference_101[] = "fileout/sincos_101.ref.txt"; | |
46 | 51 | |
47 | 52 | // positive x, |
48 | 53 | test_0( filename_vector_0, filename_reference_0); |
@@ -59,10 +64,16 @@ int main() { | ||
59 | 64 | // positive x, async reset test |
60 | 65 | test_4( filename_vector_4, filename_reference_4); |
61 | 66 | |
62 | - gen_table( filename_angle_delta, filename_scaling_factor); | |
67 | + // positive x, async reset test | |
68 | + test_5( filename_vector_5, filename_reference_5); | |
69 | + | |
70 | +gen_table( filename_angle_delta, filename_scaling_factor); | |
71 | + | |
63 | 72 | |
73 | + test_100( filename_vector_100, filename_reference_100, 20 ); | |
64 | 74 | |
65 | - test_100( vector_5, reference_5, 24 ); | |
75 | + // test signal and clock changes simul. | |
76 | + test_101( filename_vector_101, filename_reference_101, 20 ); | |
66 | 77 | |
67 | 78 | |
68 | 79 | } |
@@ -98,99 +109,12 @@ void gen_table( const char * filename_angle_delta, const char * filename_scaling | ||
98 | 109 | } |
99 | 110 | } |
100 | 111 | |
112 | +/***************************************************************** | |
113 | + * | |
114 | + * SINCOS SUB vector generation | |
115 | + * | |
116 | + *****************************************************************/ | |
101 | 117 | |
102 | -void test_async_9bit( std::ostream &vec, std::ostream &ref, int x, int angle, int p, int q, int reset, int clk) | |
103 | -{ | |
104 | -#ifdef BITWIDTH | |
105 | -#undef BITWIDTH | |
106 | -#undef SHIFT | |
107 | -#undef ANGLEDELTA | |
108 | -#endif | |
109 | - | |
110 | -#define BITWIDTH 9 | |
111 | -#define SHIFT 3 | |
112 | -#define ANGLEDELTA 31 | |
113 | - | |
114 | - static int last_angle = 0, last_q = 0, last_p = 0 , last_x = 0; | |
115 | - static vhdl::sincos_sub sincos_sub_module; | |
116 | - | |
117 | - vec << std::bitset<1>(reset) << " " | |
118 | - << std::bitset<1>(clk) << " " | |
119 | - << std::bitset<BITWIDTH>(x) << " " | |
120 | - << std::bitset<BITWIDTH>(angle) << " " | |
121 | - << std::bitset<BITWIDTH>(p) << " " | |
122 | - << std::bitset<BITWIDTH>(q) << std::endl; | |
123 | - | |
124 | - sincos_sub_module.run( SHIFT, ANGLEDELTA, clk, reset, x, last_x, angle, last_angle, p, last_p, q, last_q ); | |
125 | - | |
126 | - ref << std::bitset<BITWIDTH>( last_x ) << " " | |
127 | - << std::bitset<BITWIDTH>( last_angle ) << " " | |
128 | - << std::bitset<BITWIDTH>( last_p ) << " " | |
129 | - << std::bitset<BITWIDTH>( last_q ) << std::endl; | |
130 | - | |
131 | -} | |
132 | - | |
133 | -void test_async_13bit( std::ostream &vec, std::ostream &ref, int x, int angle, int p, int q, int reset, int clk) | |
134 | -{ | |
135 | -#ifdef BITWIDTH | |
136 | -#undef BITWIDTH | |
137 | -#undef SHIFT | |
138 | -#undef ANGLEDELTA | |
139 | -#endif | |
140 | - | |
141 | -#define BITWIDTH 13 | |
142 | -#define SHIFT 4 | |
143 | -#define ANGLEDELTA 65 | |
144 | - | |
145 | - static int last_angle = 0, last_q = 0, last_p = 0 , last_x = 0; | |
146 | - static vhdl::sincos_sub sincos_sub_module; | |
147 | - | |
148 | - vec << std::bitset<1>(reset) << " " | |
149 | - << std::bitset<1>(clk) << " " | |
150 | - << std::bitset<BITWIDTH>(x) << " " | |
151 | - << std::bitset<BITWIDTH>(angle) << " " | |
152 | - << std::bitset<BITWIDTH>(p) << " " | |
153 | - << std::bitset<BITWIDTH>(q) << std::endl; | |
154 | - | |
155 | - sincos_sub_module.run( SHIFT, ANGLEDELTA, clk, reset, x, last_x, angle, last_angle, p, last_p, q, last_q ); | |
156 | - | |
157 | - ref << std::bitset<BITWIDTH>( last_x ) << " " | |
158 | - << std::bitset<BITWIDTH>( last_angle ) << " " | |
159 | - << std::bitset<BITWIDTH>( last_p ) << " " | |
160 | - << std::bitset<BITWIDTH>( last_q ) << std::endl; | |
161 | - | |
162 | -} | |
163 | - | |
164 | -void test_async_11bit( std::ostream &vec, std::ostream &ref, int x, int angle, int p, int q, int reset, int clk) | |
165 | -{ | |
166 | -#ifdef BITWIDTH | |
167 | -#undef BITWIDTH | |
168 | -#undef SHIFT | |
169 | -#undef ANGLEDELTA | |
170 | -#endif | |
171 | - | |
172 | -#define BITWIDTH 11 | |
173 | -#define SHIFT 2 | |
174 | -#define ANGLEDELTA 65 | |
175 | - | |
176 | - int last_angle = 0, last_q = 0, last_p = 0 , last_x = 0; | |
177 | - static vhdl::sincos_sub sincos_sub_module; | |
178 | - | |
179 | - vec << std::bitset<1>(reset) << " " | |
180 | - << std::bitset<1>(clk) << " " | |
181 | - << std::bitset<BITWIDTH>(x) << " " | |
182 | - << std::bitset<BITWIDTH>(angle) << " " | |
183 | - << std::bitset<BITWIDTH>(p) << " " | |
184 | - << std::bitset<BITWIDTH>(q) << std::endl; | |
185 | - | |
186 | - sincos_sub_module.run( SHIFT, ANGLEDELTA, clk, reset, x, last_x, angle, last_angle, p, last_p, q, last_q ); | |
187 | - | |
188 | - ref << std::bitset<BITWIDTH>( last_x ) << " " | |
189 | - << std::bitset<BITWIDTH>( last_angle ) << " " | |
190 | - << std::bitset<BITWIDTH>( last_p ) << " " | |
191 | - << std::bitset<BITWIDTH>( last_q ) << std::endl; | |
192 | - | |
193 | -} | |
194 | 118 | |
195 | 119 | void test_0( char *vec_name, char * ref_name) // positive rounding |
196 | 120 | { |
@@ -291,70 +215,265 @@ void test_4( char *vec_name, char * ref_name) // async reset | ||
291 | 215 | test_async_11bit(vec, ref, 23, 32, 430, 75, 0, 1 ); // x, angle, p, q, reset, clk |
292 | 216 | } |
293 | 217 | |
294 | - | |
295 | - /** | |
296 | - * \brief sincos CORDIC algorithm. | |
297 | - * \param x | |
298 | - * \param p | |
299 | - * \param q | |
300 | - * \param num_stages | |
301 | - * \param bit_width | |
302 | - */ | |
303 | -void cordic_sincos_bw32( std::ostream &vec, std::ostream &ref, int num_stages, int x, int reset, int clk ) | |
218 | +void test_5( char *vec_name, char * ref_name) // test of completely same timing signal change with clock | |
304 | 219 | { |
305 | -#ifdef BITWIDTH | |
306 | -#undef BITWIDTH | |
307 | -#endif | |
220 | + std::ofstream vec; vec.open(vec_name); | |
221 | + std::ofstream ref; ref.open(ref_name); | |
308 | 222 | |
309 | -#define BITWIDTH 32 | |
223 | + // reset | |
224 | + test_async_13bit(vec, ref, 23, 0, 16, 64, 1, 0 ); // x, angle, p, q, reset, clk | |
310 | 225 | |
311 | - int p_next, q_next, angle; | |
312 | - static int last_p = 0, last_q = 0; | |
226 | + // positive rounding | |
227 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 0 ); // x, angle, p, q, reset, clk | |
228 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk | |
229 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk | |
230 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 0 ); // x, angle, p, q, reset, clk | |
231 | + | |
232 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 0 ); // x, angle, p, q, reset, clk | |
233 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 1 ); // x, angle, p, q, reset, clk | |
234 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 1 ); // x, angle, p, q, reset, clk | |
235 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 0 ); // x, angle, p, q, reset, clk | |
236 | + | |
237 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 0 ); // x, angle, p, q, reset, clk | |
238 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk | |
239 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk | |
240 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 0 ); // x, angle, p, q, reset, clk | |
241 | + | |
242 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 0 ); // x, angle, p, q, reset, clk | |
243 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 1 ); // x, angle, p, q, reset, clk | |
244 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 1 ); // x, angle, p, q, reset, clk | |
245 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 0 ); // x, angle, p, q, reset, clk | |
246 | + | |
247 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 0 ); // x, angle, p, q, reset, clk | |
248 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk | |
249 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk | |
250 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 0 ); // x, angle, p, q, reset, clk | |
251 | + | |
252 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 0 ); // x, angle, p, q, reset, clk | |
253 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 1 ); // x, angle, p, q, reset, clk | |
254 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 1 ); // x, angle, p, q, reset, clk | |
255 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 0 ); // x, angle, p, q, reset, clk | |
256 | + | |
257 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 0 ); // x, angle, p, q, reset, clk | |
258 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk | |
259 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk | |
260 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 0 ); // x, angle, p, q, reset, clk | |
261 | + | |
262 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 0 ); // x, angle, p, q, reset, clk | |
263 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 1 ); // x, angle, p, q, reset, clk | |
264 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 1 ); // x, angle, p, q, reset, clk | |
265 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 0 ); // x, angle, p, q, reset, clk | |
313 | 266 | |
314 | - static vhdl::sincos_angle_delta ad; | |
315 | - static vhdl::sincos_scaling_factor sf; | |
316 | - static vhdl::sincos_cordic cordic; | |
267 | +} | |
317 | 268 | |
318 | 269 | |
319 | - vec | |
320 | - << std::bitset<1>( reset ) << " " // reset | |
321 | - << std::bitset<1>( clk ) << " " // clock | |
322 | - << std::bitset<BITWIDTH>( x ) << std::endl; | |
323 | 270 | |
324 | - cordic.run( 20, clk, reset, x, last_p, last_q ); | |
271 | +/***************************************************************** | |
272 | + * | |
273 | + * SINCOS vector generation | |
274 | + * | |
275 | + *****************************************************************/ | |
325 | 276 | |
326 | - ref | |
327 | - << std::bitset<BITWIDTH>( last_p ) << " " | |
328 | - << std::bitset<BITWIDTH>( last_q ) << std::endl; | |
329 | 277 | |
278 | +void test_100( char *vec_name, char * ref_name, int num_stages) | |
279 | +{ | |
280 | + std::ofstream vec; vec.open(vec_name); | |
281 | + std::ofstream ref; ref.open(ref_name); | |
282 | + | |
283 | + int x = 0; | |
284 | + | |
285 | + // reset | |
286 | + cordic_sincos_bw32( vec, ref, num_stages, x, 1, 0 ); | |
287 | + | |
288 | + // scan [-0.5, 0.5) | |
289 | + // scan [-0.5, 0.5) | |
290 | + for ( int i = -128; i < 127; i++ ) | |
291 | + { | |
292 | + x = i << 23; | |
293 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); | |
294 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); | |
295 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); | |
296 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); | |
297 | + } | |
330 | 298 | |
299 | + // flush pipeline | |
300 | + for ( int i = 0; i < num_stages; i++ ) | |
301 | + { | |
302 | + x = i << 16; | |
303 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); | |
304 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); | |
305 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); | |
306 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); | |
307 | + } | |
331 | 308 | } |
332 | 309 | |
333 | -void test_100( std::ostream &vec, std::ostream &ref, int num_stages ) | |
310 | +void test_101( char *vec_name, char * ref_name, int num_stages) | |
334 | 311 | { |
312 | + std::ofstream vec; vec.open(vec_name); | |
313 | + std::ofstream ref; ref.open(ref_name); | |
335 | 314 | |
336 | 315 | int x = 0; |
337 | 316 | |
338 | 317 | // reset |
339 | 318 | cordic_sincos_bw32( vec, ref, num_stages, x, 1, 0 ); |
340 | 319 | |
341 | - // scan [-0.5, 0.5) | |
342 | - for ( int i = -64; i < 63; i++ ) | |
320 | + // | |
321 | + for ( int i = -3; i < 2; i++ ) | |
343 | 322 | { |
344 | 323 | cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); |
345 | - x = i << 24; | |
324 | + x = i << 23; | |
346 | 325 | cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); |
347 | 326 | cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); |
348 | 327 | cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); |
349 | 328 | } |
350 | 329 | |
351 | 330 | // flush pipeline |
352 | - for ( int i = 0; i < num_stages; i++ ) | |
331 | + for ( int i = 0; i < num_stages+2; i++ ) | |
353 | 332 | { |
354 | 333 | cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); |
355 | - x = i << 16; | |
334 | + x = 0; | |
356 | 335 | cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); |
357 | 336 | cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); |
358 | 337 | cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); |
359 | 338 | } |
360 | 339 | } |
340 | + | |
341 | +/***************************************************************** | |
342 | + * | |
343 | + * SINCOS SUB Low level Test | |
344 | + * | |
345 | + *****************************************************************/ | |
346 | + | |
347 | + | |
348 | +void test_async_9bit( std::ostream &vec, std::ostream &ref, int x, int angle, int p, int q, int reset, int clk) | |
349 | +{ | |
350 | +#ifdef BITWIDTH | |
351 | +#undef BITWIDTH | |
352 | +#undef SHIFT | |
353 | +#undef ANGLEDELTA | |
354 | +#endif | |
355 | + | |
356 | +#define BITWIDTH 9 | |
357 | +#define SHIFT 3 | |
358 | +#define ANGLEDELTA 31 | |
359 | + | |
360 | + static int out_angle = 0, out_q = 0, last_p = 0 , last_x = 0; | |
361 | + static vhdl::sincos_sub sincos_sub_module; | |
362 | + | |
363 | + vec << std::bitset<1>(reset) << " " | |
364 | + << std::bitset<1>(clk) << " " | |
365 | + << std::bitset<BITWIDTH>(x) << " " | |
366 | + << std::bitset<BITWIDTH>(angle) << " " | |
367 | + << std::bitset<BITWIDTH>(p) << " " | |
368 | + << std::bitset<BITWIDTH>(q) << std::endl; | |
369 | + | |
370 | + sincos_sub_module.run( SHIFT, ANGLEDELTA, clk, reset, x, last_x, angle, out_angle, p, last_p, q, out_q ); | |
371 | + | |
372 | + ref << std::bitset<BITWIDTH>( last_x ) << " " | |
373 | + << std::bitset<BITWIDTH>( out_angle ) << " " | |
374 | + << std::bitset<BITWIDTH>( last_p ) << " " | |
375 | + << std::bitset<BITWIDTH>( out_q ) << std::endl; | |
376 | + | |
377 | +} | |
378 | + | |
379 | +void test_async_13bit( std::ostream &vec, std::ostream &ref, int x, int angle, int p, int q, int reset, int clk) | |
380 | +{ | |
381 | +#ifdef BITWIDTH | |
382 | +#undef BITWIDTH | |
383 | +#undef SHIFT | |
384 | +#undef ANGLEDELTA | |
385 | +#endif | |
386 | + | |
387 | +#define BITWIDTH 13 | |
388 | +#define SHIFT 4 | |
389 | +#define ANGLEDELTA 65 | |
390 | + | |
391 | + int out_angle = 0, out_q = 0, last_p = 0 , last_x = 0; | |
392 | + static vhdl::sincos_sub sincos_sub_module; | |
393 | + | |
394 | + vec << std::bitset<1>(reset) << " " | |
395 | + << std::bitset<1>(clk) << " " | |
396 | + << std::bitset<BITWIDTH>(x) << " " | |
397 | + << std::bitset<BITWIDTH>(angle) << " " | |
398 | + << std::bitset<BITWIDTH>(p) << " " | |
399 | + << std::bitset<BITWIDTH>(q) << std::endl; | |
400 | + | |
401 | + sincos_sub_module.run( SHIFT, ANGLEDELTA, clk, reset, x, last_x, angle, out_angle, p, last_p, q, out_q ); | |
402 | + | |
403 | + ref << std::bitset<BITWIDTH>( last_x ) << " " | |
404 | + << std::bitset<BITWIDTH>( out_angle ) << " " | |
405 | + << std::bitset<BITWIDTH>( last_p ) << " " | |
406 | + << std::bitset<BITWIDTH>( out_q ) << std::endl; | |
407 | + | |
408 | +} | |
409 | + | |
410 | +void test_async_11bit( std::ostream &vec, std::ostream &ref, int x, int angle, int p, int q, int reset, int clk) | |
411 | +{ | |
412 | +#ifdef BITWIDTH | |
413 | +#undef BITWIDTH | |
414 | +#undef SHIFT | |
415 | +#undef ANGLEDELTA | |
416 | +#endif | |
417 | + | |
418 | +#define BITWIDTH 11 | |
419 | +#define SHIFT 2 | |
420 | +#define ANGLEDELTA 65 | |
421 | + | |
422 | + int out_angle = 0, out_q = 0, out_p = 0 , out_x = 0; | |
423 | + static vhdl::sincos_sub sincos_sub_module; | |
424 | + | |
425 | + vec << std::bitset<1>(reset) << " " | |
426 | + << std::bitset<1>(clk) << " " | |
427 | + << std::bitset<BITWIDTH>(x) << " " | |
428 | + << std::bitset<BITWIDTH>(angle) << " " | |
429 | + << std::bitset<BITWIDTH>(p) << " " | |
430 | + << std::bitset<BITWIDTH>(q) << std::endl; | |
431 | + | |
432 | + sincos_sub_module.run( SHIFT, ANGLEDELTA, clk, reset, x, out_x, angle, out_angle, p, out_p, q, out_q ); | |
433 | + | |
434 | + ref << std::bitset<BITWIDTH>( out_x ) << " " | |
435 | + << std::bitset<BITWIDTH>( out_angle ) << " " | |
436 | + << std::bitset<BITWIDTH>( out_p ) << " " | |
437 | + << std::bitset<BITWIDTH>( out_q ) << std::endl; | |
438 | + | |
439 | +} | |
440 | + | |
441 | +/***************************************************************** | |
442 | + * | |
443 | + * SINCOS Low level Test | |
444 | + * | |
445 | + *****************************************************************/ | |
446 | + | |
447 | +/** | |
448 | + * \brief sincos CORDIC algorithm. | |
449 | + * \param x | |
450 | + * \param p | |
451 | + * \param q | |
452 | + * \param num_stages | |
453 | + * \param bit_width | |
454 | + */ | |
455 | +void cordic_sincos_bw32( std::ostream &vec, std::ostream &ref, int num_stages, int x, int reset, int clk ) | |
456 | +{ | |
457 | +#ifdef BITWIDTH | |
458 | +#undef BITWIDTH | |
459 | +#endif | |
460 | + | |
461 | +#define BITWIDTH 32 | |
462 | + | |
463 | +int out_p, out_q; | |
464 | + | |
465 | +static vhdl::sincos_cordic cordic; | |
466 | + | |
467 | + | |
468 | +vec | |
469 | + << std::bitset<1>( reset ) << " " // reset | |
470 | + << std::bitset<1>( clk ) << " " // clock | |
471 | + << std::bitset<BITWIDTH>( x ) << std::endl; | |
472 | + | |
473 | +cordic.run( 20, clk, reset, x, out_p, out_q ); | |
474 | + | |
475 | +ref | |
476 | + << std::bitset<BITWIDTH>( out_p ) << " " | |
477 | + << std::bitset<BITWIDTH>( out_q ) << std::endl; | |
478 | + | |
479 | +} |
@@ -0,0 +1,485 @@ | ||
1 | +/** | |
2 | + * \file main.cpp | |
3 | + * | |
4 | + * \date 2016/10/01 | |
5 | + * \author: takemasa | |
6 | + * \brief Test vector Generator for cordic_sincos VHDL project | |
7 | + */ | |
8 | + | |
9 | +#include <iostream> | |
10 | +#include <bitset> | |
11 | +#include <string> | |
12 | +#include <cmath> | |
13 | + | |
14 | +#include <fstream> // ifstream, ofstream | |
15 | + | |
16 | +#include "main.h" | |
17 | + | |
18 | +/** | |
19 | + * \bfief main function | |
20 | + */ | |
21 | + | |
22 | +int main() { | |
23 | + | |
24 | + | |
25 | + char filename_vector_0[] = "fileout/sincossub_0.vec.txt"; | |
26 | + char filename_reference_0[] = "fileout/sincossub_0.ref.txt"; | |
27 | + | |
28 | + char filename_vector_1[] = "fileout/sincossub_1.vec.txt"; | |
29 | + char filename_reference_1[] = "fileout/sincossub_1.ref.txt"; | |
30 | + | |
31 | + char filename_vector_2[] = "fileout/sincossub_2.vec.txt"; | |
32 | + char filename_reference_2[] = "fileout/sincossub_2.ref.txt"; | |
33 | + | |
34 | + char filename_vector_3[] = "fileout/sincossub_3.vec.txt"; | |
35 | + char filename_reference_3[] = "fileout/sincossub_3.ref.txt"; | |
36 | + | |
37 | + char filename_vector_4[] = "fileout/sincossub_4.vec.txt"; | |
38 | + char filename_reference_4[] = "fileout/sincossub_4.ref.txt"; | |
39 | + | |
40 | + char filename_vector_5[] = "fileout/sincossub_5.vec.txt"; | |
41 | + char filename_reference_5[] = "fileout/sincossub_5.ref.txt"; | |
42 | + | |
43 | + char filename_angle_delta[] = "fileout/sincos_angle_delta.txt"; | |
44 | + char filename_scaling_factor[] = "fileout/sincos_scaling_factor.txt"; | |
45 | + | |
46 | + char filename_vector_100[] = "fileout/sincos_100.vec.txt"; | |
47 | + char filename_reference_100[] = "fileout/sincos_100.ref.txt"; | |
48 | + | |
49 | + char filename_vector_101[] = "fileout/sincos_101.vec.txt"; | |
50 | + char filename_reference_101[] = "fileout/sincos_101.ref.txt"; | |
51 | + | |
52 | + // positive x, | |
53 | + test_0( filename_vector_0, filename_reference_0); | |
54 | + | |
55 | + // negative x | |
56 | + test_1( filename_vector_1, filename_reference_1); | |
57 | + | |
58 | + //positive x, rounding up | |
59 | + test_2( filename_vector_2, filename_reference_2); | |
60 | + | |
61 | + // negative x rouding up | |
62 | + test_3( filename_vector_3, filename_reference_3); | |
63 | + | |
64 | + // positive x, async reset test | |
65 | + test_4( filename_vector_4, filename_reference_4); | |
66 | + | |
67 | + // positive x, async reset test | |
68 | + test_5( filename_vector_5, filename_reference_5); | |
69 | + | |
70 | +gen_table( filename_angle_delta, filename_scaling_factor); | |
71 | + | |
72 | + | |
73 | + test_100( filename_vector_100, filename_reference_100, 20 ); | |
74 | + | |
75 | + // test signal and clock changes simul. | |
76 | + test_101( filename_vector_101, filename_reference_101, 20 ); | |
77 | + | |
78 | + | |
79 | +} | |
80 | + | |
81 | + /** | |
82 | + * \brief shift rith arithmetic with rounding. | |
83 | + */ | |
84 | +int round_shift( int operand, int shift) | |
85 | +{ | |
86 | + if (shift > 0) | |
87 | + return ( operand + (1<<(shift-1)) ) >> shift ; | |
88 | + else | |
89 | + return operand; | |
90 | +} | |
91 | + | |
92 | + | |
93 | +void gen_table( const char * filename_angle_delta, const char * filename_scaling_factor) | |
94 | +{ | |
95 | + std::ofstream angle_delta; angle_delta.open(filename_angle_delta); | |
96 | + std::ofstream scaling_factor; scaling_factor.open(filename_scaling_factor); | |
97 | + | |
98 | + vhdl::sincos_angle_delta ad; | |
99 | + vhdl::sincos_scaling_factor sf; | |
100 | + | |
101 | + // Initialize the scaling factor and angle delta table. | |
102 | + for ( int i = 0; i<vhdl::angle_delta_table_size; i++ ) | |
103 | + { | |
104 | + // output to the file | |
105 | + scaling_factor << std::bitset<32>( sf.table[i] ) << std::endl; | |
106 | + | |
107 | + // output to the file | |
108 | + angle_delta << std::bitset<32>( ad.table[i] ) << std::endl; | |
109 | + } | |
110 | +} | |
111 | + | |
112 | +/***************************************************************** | |
113 | + * | |
114 | + * SINCOS SUB vector generation | |
115 | + * | |
116 | + *****************************************************************/ | |
117 | + | |
118 | + | |
119 | +void test_0( char *vec_name, char * ref_name) // positive rounding | |
120 | +{ | |
121 | + std::ofstream vec; vec.open(vec_name); | |
122 | + std::ofstream ref; ref.open(ref_name); | |
123 | + // reset | |
124 | + test_async_9bit(vec, ref, 23, 0, 60, 10, 1, 0); // x, angle, p, q, reset, clk // CCW | |
125 | + | |
126 | + // positive rounding | |
127 | + test_async_9bit(vec, ref, 23, 0, 60, 10, 0, 0); // x, angle, p, q, reset, clk // CCW | |
128 | + test_async_9bit(vec, ref, 23, 0, 60, 10, 0, 1); // x, angle, p, q, reset, clk // CCW | |
129 | + test_async_9bit(vec, ref, 23, 0, 60, 10, 0, 1); // x, angle, p, q, reset, clk // CCW | |
130 | + test_async_9bit(vec, ref, 23, 0, 60, 10, 0, 0); // x, angle, p, q, reset, clk // CCW | |
131 | + | |
132 | + test_async_9bit(vec, ref, 23, 24, 60, 10, 0, 0); // x, angle, p, q, reset, clk // CW | |
133 | + test_async_9bit(vec, ref, 23, 24, 60, 10, 0, 1); // x, angle, p, q, reset, clk // CW | |
134 | + test_async_9bit(vec, ref, 23, 24, 60, 10, 0, 1); // x, angle, p, q, reset, clk // CW | |
135 | + test_async_9bit(vec, ref, 23, 24, 60, 10, 0, 0); // x, angle, p, q, reset, clk // CW | |
136 | +} | |
137 | + | |
138 | +void test_1( char *vec_name, char * ref_name) // positive no rounding | |
139 | +{ | |
140 | + std::ofstream vec; vec.open(vec_name); | |
141 | + std::ofstream ref; ref.open(ref_name); | |
142 | + // reset | |
143 | + test_async_9bit(vec, ref, -23, 0, 60, -10, 1, 0); // x, angle, p, q, reset, clk // CW | |
144 | + | |
145 | + // positive no roundingb | |
146 | + test_async_9bit(vec, ref, -23, 0, 60, -10, 0, 0); // x, angle, p, q, reset, clk // CW | |
147 | + test_async_9bit(vec, ref, -23, 0, 60, -10, 0, 1); // x, angle, p, q, reset, clk // CW | |
148 | + test_async_9bit(vec, ref, -23, 0, 60, -10, 0, 1); // x, angle, p, q, reset, clk // CW | |
149 | + test_async_9bit(vec, ref, -23, 0, 60, -10, 0, 0); // x, angle, p, q, reset, clk // CW | |
150 | + | |
151 | + test_async_9bit(vec, ref, -23, -24, 60, -10, 0, 0); // x, angle, p, q, reset, clk // CCW | |
152 | + test_async_9bit(vec, ref, -23, -24, 60, -10, 0, 1); // x, angle, p, q, reset, clk // CCW | |
153 | + test_async_9bit(vec, ref, -23, -24, 60, -10, 0, 1); // x, angle, p, q, reset, clk // CCW | |
154 | + test_async_9bit(vec, ref, -23, -24, 60, -10, 0, 0); // x, angle, p, q, reset, clk // CCW | |
155 | + | |
156 | +} | |
157 | + | |
158 | +void test_2( char *vec_name, char * ref_name) // positive rounding | |
159 | +{ | |
160 | + std::ofstream vec; vec.open(vec_name); | |
161 | + std::ofstream ref; ref.open(ref_name); | |
162 | + // reset | |
163 | + test_async_13bit(vec, ref, 23, 0, 16, 64, 1, 0 ); // x, angle, p, q, reset, clk | |
164 | + | |
165 | + // positive rounding | |
166 | + test_async_13bit(vec, ref, 23, 0, 16, 64, 0, 0 ); // x, angle, p, q, reset, clk | |
167 | + test_async_13bit(vec, ref, 23, 0, 16, 64, 0, 1 ); // x, angle, p, q, reset, clk | |
168 | + test_async_13bit(vec, ref, 23, 0, 16, 64, 0, 1 ); // x, angle, p, q, reset, clk | |
169 | + test_async_13bit(vec, ref, 23, 0, 16, 64, 0, 0 ); // x, angle, p, q, reset, clk | |
170 | + | |
171 | + test_async_13bit(vec, ref, 23, 0, 31, 64, 0, 0 ); // x, angle, p, q, reset, clk // same with above when truncated, +1 when rounding | |
172 | + test_async_13bit(vec, ref, 23, 0, 31, 64, 0, 1 ); // x, angle, p, q, reset, clk | |
173 | + test_async_13bit(vec, ref, 23, 0, 31, 64, 0, 1 ); // x, angle, p, q, reset, clk | |
174 | + test_async_13bit(vec, ref, 23, 0, 31, 64, 0, 0 ); // x, angle, p, q, reset, clk | |
175 | +} | |
176 | + | |
177 | +void test_3( char *vec_name, char * ref_name) // negative rounding | |
178 | +{ | |
179 | + std::ofstream vec; vec.open(vec_name); | |
180 | + std::ofstream ref; ref.open(ref_name); | |
181 | + | |
182 | + // reset | |
183 | + test_async_13bit(vec, ref, -23, -24, 16, 64, 1, 0 ); // x, angle, p, q, reset, clk // | |
184 | + | |
185 | + // negative rounding | |
186 | + test_async_13bit(vec, ref, -23, -24, 16, 64, 0, 0 ); // x, angle, p, q, reset, clk // | |
187 | + test_async_13bit(vec, ref, -23, -24, 16, 64, 0, 1 ); // x, angle, p, q, reset, clk // | |
188 | + test_async_13bit(vec, ref, -23, -24, 16, 64, 0, 1 ); // x, angle, p, q, reset, clk // | |
189 | + test_async_13bit(vec, ref, -23, -24, 16, 64, 0, 0 ); // x, angle, p, q, reset, clk // | |
190 | + | |
191 | + test_async_13bit(vec, ref, -23, -24, 31, 64, 0, 0 ); // x, angle, p, q, reset, clk // same with above when truncated, +1 when rounding | |
192 | + test_async_13bit(vec, ref, -23, -24, 31, 64, 0, 1 ); // x, angle, p, q, reset, clk | |
193 | + test_async_13bit(vec, ref, -23, -24, 31, 64, 0, 1 ); // x, angle, p, q, reset, clk | |
194 | + test_async_13bit(vec, ref, -23, -24, 31, 64, 0, 0 ); // x, angle, p, q, reset, clk | |
195 | +} | |
196 | + | |
197 | + | |
198 | +void test_4( char *vec_name, char * ref_name) // async reset | |
199 | +{ | |
200 | + std::ofstream vec; vec.open(vec_name); | |
201 | + std::ofstream ref; ref.open(ref_name); | |
202 | + | |
203 | + test_async_11bit(vec, ref, 23, 0, 500, 230, 1, 0 ); // x, angle, p, q, reset, clk | |
204 | + test_async_11bit(vec, ref, 23, 0, 500, 20, 1, 1 ); // x, angle, p, q, reset, clk | |
205 | + test_async_11bit(vec, ref, 23, 25, 500, 20, 1, 0 ); // x, angle, p, q, reset, clk | |
206 | + test_async_11bit(vec, ref, 23, 0, 500, 230, 0, 0 ); // x, angle, p, q, reset, clk | |
207 | + test_async_11bit(vec, ref, 23, 0, 500, 230, 0, 1 ); // x, angle, p, q, reset, clk | |
208 | + test_async_11bit(vec, ref, 23, 0, 430, 75, 0, 0 ); // x, angle, p, q, reset, clk | |
209 | + test_async_11bit(vec, ref, 23, 0, 430, 75, 1, 0 ); // x, angle, p, q, reset, clk | |
210 | + test_async_11bit(vec, ref, 23, 0, 430, 75, 0, 0 ); // x, angle, p, q, reset, clk | |
211 | + test_async_11bit(vec, ref, 23, 0, 430, 75, 0, 1 ); // x, angle, p, q, reset, clk | |
212 | + test_async_11bit(vec, ref, 23, 0, 430, 75, 1, 1 ); // x, angle, p, q, reset, clk | |
213 | + test_async_11bit(vec, ref, 23, 0, 430, 75, 0, 1 ); // x, angle, p, q, reset, clk | |
214 | + test_async_11bit(vec, ref, 23, 32, 430, 75, 0, 0 ); // x, angle, p, q, reset, clk | |
215 | + test_async_11bit(vec, ref, 23, 32, 430, 75, 0, 1 ); // x, angle, p, q, reset, clk | |
216 | +} | |
217 | + | |
218 | +void test_5( char *vec_name, char * ref_name) // test of completely same timing signal change with clock | |
219 | +{ | |
220 | + std::ofstream vec; vec.open(vec_name); | |
221 | + std::ofstream ref; ref.open(ref_name); | |
222 | + | |
223 | + // reset | |
224 | + test_async_13bit(vec, ref, 23, 0, 16, 64, 1, 0 ); // x, angle, p, q, reset, clk | |
225 | + | |
226 | + // positive rounding | |
227 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 0 ); // x, angle, p, q, reset, clk | |
228 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk | |
229 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk | |
230 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 0 ); // x, angle, p, q, reset, clk | |
231 | + | |
232 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 0 ); // x, angle, p, q, reset, clk | |
233 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 1 ); // x, angle, p, q, reset, clk | |
234 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 1 ); // x, angle, p, q, reset, clk | |
235 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 0 ); // x, angle, p, q, reset, clk | |
236 | + | |
237 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 0 ); // x, angle, p, q, reset, clk | |
238 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk | |
239 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk | |
240 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 0 ); // x, angle, p, q, reset, clk | |
241 | + | |
242 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 0 ); // x, angle, p, q, reset, clk | |
243 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 1 ); // x, angle, p, q, reset, clk | |
244 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 1 ); // x, angle, p, q, reset, clk | |
245 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 0 ); // x, angle, p, q, reset, clk | |
246 | + | |
247 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 0 ); // x, angle, p, q, reset, clk | |
248 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk | |
249 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk | |
250 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 0 ); // x, angle, p, q, reset, clk | |
251 | + | |
252 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 0 ); // x, angle, p, q, reset, clk | |
253 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 1 ); // x, angle, p, q, reset, clk | |
254 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 1 ); // x, angle, p, q, reset, clk | |
255 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 0 ); // x, angle, p, q, reset, clk | |
256 | + | |
257 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 0 ); // x, angle, p, q, reset, clk | |
258 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk | |
259 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk | |
260 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 0 ); // x, angle, p, q, reset, clk | |
261 | + | |
262 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 0 ); // x, angle, p, q, reset, clk | |
263 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 1 ); // x, angle, p, q, reset, clk | |
264 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 1 ); // x, angle, p, q, reset, clk | |
265 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 0 ); // x, angle, p, q, reset, clk | |
266 | + | |
267 | +} | |
268 | + | |
269 | + | |
270 | + | |
271 | +/***************************************************************** | |
272 | + * | |
273 | + * SINCOS vector generation | |
274 | + * | |
275 | + *****************************************************************/ | |
276 | + | |
277 | + | |
278 | +void test_100( char *vec_name, char * ref_name ) | |
279 | +{ | |
280 | + std::ofstream vec; vec.open(vec_name); | |
281 | + std::ofstream ref; ref.open(ref_name); | |
282 | + | |
283 | + | |
284 | + const int num_stages = 20; | |
285 | + int x = 0; | |
286 | + | |
287 | + // reset | |
288 | + cordic_sincos_bw32( vec, ref, num_stages, x, 1, 0 ); | |
289 | + | |
290 | + // scan [-0.5, 0.5) | |
291 | + // scan [-0.5, 0.5) | |
292 | + for ( int i = -128; i < 127; i++ ) | |
293 | + { | |
294 | + x = i << 23; | |
295 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); | |
296 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); | |
297 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); | |
298 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); | |
299 | + } | |
300 | + | |
301 | + // flush pipeline | |
302 | + for ( int i = 0; i < num_stages; i++ ) | |
303 | + { | |
304 | + x = i << 16; | |
305 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); | |
306 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); | |
307 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); | |
308 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); | |
309 | + } | |
310 | +} | |
311 | + | |
312 | +void test_101( char *vec_name, char * ref_name) | |
313 | +{ | |
314 | + std::ofstream vec; vec.open(vec_name); | |
315 | + std::ofstream ref; ref.open(ref_name); | |
316 | + | |
317 | + const int num_stages = 3; | |
318 | + int x = 0; | |
319 | + | |
320 | + // reset | |
321 | + cordic_sincos_bw32( vec, ref, num_stages, x, 1, 0 ); | |
322 | + | |
323 | + // | |
324 | + for ( int i = -3; i < 2; i++ ) | |
325 | + { | |
326 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); | |
327 | + x = i << 23; | |
328 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); | |
329 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); | |
330 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); | |
331 | + } | |
332 | + | |
333 | + // flush pipeline | |
334 | + for ( int i = 0; i < num_stages+2; i++ ) | |
335 | + { | |
336 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); | |
337 | + x = 0; | |
338 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); | |
339 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); | |
340 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); | |
341 | + } | |
342 | +} | |
343 | + | |
344 | +/***************************************************************** | |
345 | + * | |
346 | + * SINCOS SUB Low level Test | |
347 | + * | |
348 | + *****************************************************************/ | |
349 | + | |
350 | + | |
351 | +void test_async_9bit( std::ostream &vec, std::ostream &ref, int x, int angle, int p, int q, int reset, int clk) | |
352 | +{ | |
353 | +#ifdef BITWIDTH | |
354 | +#undef BITWIDTH | |
355 | +#undef SHIFT | |
356 | +#undef ANGLEDELTA | |
357 | +#endif | |
358 | + | |
359 | +#define BITWIDTH 9 | |
360 | +#define SHIFT 3 | |
361 | +#define ANGLEDELTA 31 | |
362 | + | |
363 | + static int out_angle = 0, out_q = 0, last_p = 0 , last_x = 0; | |
364 | + static vhdl::sincos_sub sincos_sub_module; | |
365 | + | |
366 | + vec << std::bitset<1>(reset) << " " | |
367 | + << std::bitset<1>(clk) << " " | |
368 | + << std::bitset<BITWIDTH>(x) << " " | |
369 | + << std::bitset<BITWIDTH>(angle) << " " | |
370 | + << std::bitset<BITWIDTH>(p) << " " | |
371 | + << std::bitset<BITWIDTH>(q) << std::endl; | |
372 | + | |
373 | + sincos_sub_module.run( SHIFT, ANGLEDELTA, clk, reset, x, last_x, angle, out_angle, p, last_p, q, out_q ); | |
374 | + | |
375 | + ref << std::bitset<BITWIDTH>( last_x ) << " " | |
376 | + << std::bitset<BITWIDTH>( out_angle ) << " " | |
377 | + << std::bitset<BITWIDTH>( last_p ) << " " | |
378 | + << std::bitset<BITWIDTH>( out_q ) << std::endl; | |
379 | + | |
380 | +} | |
381 | + | |
382 | +void test_async_13bit( std::ostream &vec, std::ostream &ref, int x, int angle, int p, int q, int reset, int clk) | |
383 | +{ | |
384 | +#ifdef BITWIDTH | |
385 | +#undef BITWIDTH | |
386 | +#undef SHIFT | |
387 | +#undef ANGLEDELTA | |
388 | +#endif | |
389 | + | |
390 | +#define BITWIDTH 13 | |
391 | +#define SHIFT 4 | |
392 | +#define ANGLEDELTA 65 | |
393 | + | |
394 | + int out_angle = 0, out_q = 0, last_p = 0 , last_x = 0; | |
395 | + static vhdl::sincos_sub sincos_sub_module; | |
396 | + | |
397 | + vec << std::bitset<1>(reset) << " " | |
398 | + << std::bitset<1>(clk) << " " | |
399 | + << std::bitset<BITWIDTH>(x) << " " | |
400 | + << std::bitset<BITWIDTH>(angle) << " " | |
401 | + << std::bitset<BITWIDTH>(p) << " " | |
402 | + << std::bitset<BITWIDTH>(q) << std::endl; | |
403 | + | |
404 | + sincos_sub_module.run( SHIFT, ANGLEDELTA, clk, reset, x, last_x, angle, out_angle, p, last_p, q, out_q ); | |
405 | + | |
406 | + ref << std::bitset<BITWIDTH>( last_x ) << " " | |
407 | + << std::bitset<BITWIDTH>( out_angle ) << " " | |
408 | + << std::bitset<BITWIDTH>( last_p ) << " " | |
409 | + << std::bitset<BITWIDTH>( out_q ) << std::endl; | |
410 | + | |
411 | +} | |
412 | + | |
413 | +void test_async_11bit( std::ostream &vec, std::ostream &ref, int x, int angle, int p, int q, int reset, int clk) | |
414 | +{ | |
415 | +#ifdef BITWIDTH | |
416 | +#undef BITWIDTH | |
417 | +#undef SHIFT | |
418 | +#undef ANGLEDELTA | |
419 | +#endif | |
420 | + | |
421 | +#define BITWIDTH 11 | |
422 | +#define SHIFT 2 | |
423 | +#define ANGLEDELTA 65 | |
424 | + | |
425 | + int out_angle = 0, out_q = 0, out_p = 0 , out_x = 0; | |
426 | + static vhdl::sincos_sub sincos_sub_module; | |
427 | + | |
428 | + vec << std::bitset<1>(reset) << " " | |
429 | + << std::bitset<1>(clk) << " " | |
430 | + << std::bitset<BITWIDTH>(x) << " " | |
431 | + << std::bitset<BITWIDTH>(angle) << " " | |
432 | + << std::bitset<BITWIDTH>(p) << " " | |
433 | + << std::bitset<BITWIDTH>(q) << std::endl; | |
434 | + | |
435 | + sincos_sub_module.run( SHIFT, ANGLEDELTA, clk, reset, x, out_x, angle, out_angle, p, out_p, q, out_q ); | |
436 | + | |
437 | + ref << std::bitset<BITWIDTH>( out_x ) << " " | |
438 | + << std::bitset<BITWIDTH>( out_angle ) << " " | |
439 | + << std::bitset<BITWIDTH>( out_p ) << " " | |
440 | + << std::bitset<BITWIDTH>( out_q ) << std::endl; | |
441 | + | |
442 | +} | |
443 | + | |
444 | +/***************************************************************** | |
445 | + * | |
446 | + * SINCOS Low level Test | |
447 | + * | |
448 | + *****************************************************************/ | |
449 | + | |
450 | +/** | |
451 | + * \brief sincos CORDIC algorithm. | |
452 | + * \param x | |
453 | + * \param p | |
454 | + * \param q | |
455 | + * \param num_stages | |
456 | + * \param bit_width | |
457 | + */ | |
458 | +void cordic_sincos_bw32( std::ostream &vec, std::ostream &ref, int num_stages, int x, int reset, int clk ) | |
459 | +{ | |
460 | +#ifdef BITWIDTH | |
461 | +#undef BITWIDTH | |
462 | +#endif | |
463 | + | |
464 | +#define BITWIDTH 32 | |
465 | + | |
466 | +int out_p, out_q; | |
467 | + | |
468 | +static vhdl::sincos_cordic cordic; | |
469 | + | |
470 | + | |
471 | +vec | |
472 | + << std::bitset<1>( reset ) << " " // reset | |
473 | + << std::bitset<1>( clk ) << " " // clock | |
474 | + << std::bitset<BITWIDTH>( x ) << std::endl; | |
475 | + | |
476 | +cordic.run( num_stages, clk, reset, x, out_p, out_q ); | |
477 | + | |
478 | +ref | |
479 | + << std::bitset<BITWIDTH>( out_p ) << " " | |
480 | + << std::bitset<BITWIDTH>( out_q ) << std::endl; | |
481 | + | |
482 | +} | |
483 | + | |
484 | + | |
485 | + |
@@ -1,359 +0,0 @@ | ||
1 | -/** | |
2 | - * \file main.cpp | |
3 | - * | |
4 | - * \date 2016/10/01 | |
5 | - * \author: takemasa | |
6 | - * \brief Test vector Generator for cordic_sincos VHDL project | |
7 | - */ | |
8 | - | |
9 | -#include <iostream> | |
10 | -#include <bitset> | |
11 | -#include <string> | |
12 | -#include <cmath> | |
13 | - | |
14 | -#include <fstream> // ifstream, ofstream | |
15 | - | |
16 | -#include "main.h" | |
17 | - | |
18 | -/** | |
19 | - * \bfief main function | |
20 | - */ | |
21 | - | |
22 | -int main() { | |
23 | - | |
24 | - | |
25 | - char filename_vector_0[] = "sincossub_0.vec.txt"; | |
26 | - char filename_reference_0[] = "sincossub_0.ref.txt"; | |
27 | - | |
28 | - char filename_vector_1[] = "sincossub_1.vec.txt"; | |
29 | - char filename_reference_1[] = "sincossub_1.ref.txt"; | |
30 | - | |
31 | - char filename_vector_2[] = "sincossub_2.vec.txt"; | |
32 | - char filename_reference_2[] = "sincossub_2.ref.txt"; | |
33 | - | |
34 | - char filename_vector_3[] = "sincossub_3.vec.txt"; | |
35 | - char filename_reference_3[] = "sincossub_3.ref.txt"; | |
36 | - | |
37 | - char filename_vector_4[] = "sincossub_4.vec.txt"; | |
38 | - char filename_reference_4[] = "sincossub_4.ref.txt"; | |
39 | - | |
40 | - char filename_angle_delta[] = "sincos_angle_delta.txt"; | |
41 | - | |
42 | - char filename_scaling_factor[] = "sincos_scaling_factor.txt"; | |
43 | - | |
44 | - std::ofstream vector_5; vector_5.open("sincos_0.vec.txt"); | |
45 | - std::ofstream reference_5; reference_5.open("sincos_0.ref.txt"); | |
46 | - | |
47 | - // positive x, | |
48 | - test_0( filename_vector_0, filename_reference_0); | |
49 | - | |
50 | - // negative x | |
51 | - test_1( filename_vector_1, filename_reference_1); | |
52 | - | |
53 | - //positive x, rounding up | |
54 | - test_2( filename_vector_2, filename_reference_2); | |
55 | - | |
56 | - // negative x rouding up | |
57 | - test_3( filename_vector_3, filename_reference_3); | |
58 | - | |
59 | - // positive x, async reset test | |
60 | - test_4( filename_vector_4, filename_reference_4); | |
61 | - | |
62 | - gen_table( filename_angle_delta, filename_scaling_factor); | |
63 | - | |
64 | - | |
65 | - test_100( vector_5, reference_5, 24 ); | |
66 | - | |
67 | - | |
68 | -} | |
69 | - | |
70 | - /** | |
71 | - * \brief shift rith arithmetic with rounding. | |
72 | - */ | |
73 | -int round_shift( int operand, int shift) | |
74 | -{ | |
75 | - if (shift > 0) | |
76 | - return ( operand + (1<<(shift-1)) ) >> shift ; | |
77 | - else | |
78 | - return operand; | |
79 | -} | |
80 | - | |
81 | - | |
82 | -void gen_table( const char * filename_angle_delta, const char * filename_scaling_factor) | |
83 | -{ | |
84 | - std::ofstream angle_delta; angle_delta.open(filename_angle_delta); | |
85 | - std::ofstream scaling_factor; scaling_factor.open(filename_scaling_factor); | |
86 | - | |
87 | - vhdl::sincos_angle_delta ad; | |
88 | - vhdl::sincos_scaling_factor sf; | |
89 | - | |
90 | - // Initialize the scaling factor and angle delta table. | |
91 | - for ( int i = 0; i<vhdl::angle_delta_table_size; i++ ) | |
92 | - { | |
93 | - // output to the file | |
94 | - scaling_factor << std::bitset<32>( sf.table[i] ) << std::endl; | |
95 | - | |
96 | - // output to the file | |
97 | - angle_delta << std::bitset<32>( ad.table[i] ) << std::endl; | |
98 | - } | |
99 | -} | |
100 | - | |
101 | - | |
102 | -void test_async_9bit( std::ostream &vec, std::ostream &ref, int x, int angle, int p, int q, int reset, int clk) | |
103 | -{ | |
104 | -#ifdef BITWIDTH | |
105 | -#undef BITWIDTH | |
106 | -#undef SHIFT | |
107 | -#undef ANGLEDELTA | |
108 | -#endif | |
109 | - | |
110 | -#define BITWIDTH 9 | |
111 | -#define SHIFT 3 | |
112 | -#define ANGLEDELTA 31 | |
113 | - | |
114 | - static int last_angle = 0, last_q = 0, last_p = 0 , last_x = 0; | |
115 | - static vhdl::sincos_sub sincos_sub_module; | |
116 | - | |
117 | - vec << std::bitset<1>(reset) << " " | |
118 | - << std::bitset<1>(clk) << " " | |
119 | - << std::bitset<BITWIDTH>(x) << " " | |
120 | - << std::bitset<BITWIDTH>(angle) << " " | |
121 | - << std::bitset<BITWIDTH>(p) << " " | |
122 | - << std::bitset<BITWIDTH>(q) << std::endl; | |
123 | - | |
124 | - sincos_sub_module.run( SHIFT, ANGLEDELTA, clk, reset, x, last_x, angle, last_angle, p, last_p, q, last_q ); | |
125 | - | |
126 | - ref << std::bitset<BITWIDTH>( last_x ) << " " | |
127 | - << std::bitset<BITWIDTH>( last_angle ) << " " | |
128 | - << std::bitset<BITWIDTH>( last_p ) << " " | |
129 | - << std::bitset<BITWIDTH>( last_q ) << std::endl; | |
130 | - | |
131 | -} | |
132 | - | |
133 | -void test_async_13bit( std::ostream &vec, std::ostream &ref, int x, int angle, int p, int q, int reset, int clk) | |
134 | -{ | |
135 | -#ifdef BITWIDTH | |
136 | -#undef BITWIDTH | |
137 | -#undef SHIFT | |
138 | -#undef ANGLEDELTA | |
139 | -#endif | |
140 | - | |
141 | -#define BITWIDTH 13 | |
142 | -#define SHIFT 4 | |
143 | -#define ANGLEDELTA 65 | |
144 | - | |
145 | - static int last_angle = 0, last_q = 0, last_p = 0 , last_x = 0; | |
146 | - static vhdl::sincos_sub sincos_sub_module; | |
147 | - | |
148 | - vec << std::bitset<1>(reset) << " " | |
149 | - << std::bitset<1>(clk) << " " | |
150 | - << std::bitset<BITWIDTH>(x) << " " | |
151 | - << std::bitset<BITWIDTH>(angle) << " " | |
152 | - << std::bitset<BITWIDTH>(p) << " " | |
153 | - << std::bitset<BITWIDTH>(q) << std::endl; | |
154 | - | |
155 | - sincos_sub_module.run( SHIFT, ANGLEDELTA, clk, reset, x, last_x, angle, last_angle, p, last_p, q, last_q ); | |
156 | - | |
157 | - ref << std::bitset<BITWIDTH>( last_x ) << " " | |
158 | - << std::bitset<BITWIDTH>( last_angle ) << " " | |
159 | - << std::bitset<BITWIDTH>( last_p ) << " " | |
160 | - << std::bitset<BITWIDTH>( last_q ) << std::endl; | |
161 | - | |
162 | -} | |
163 | - | |
164 | -void test_async_11bit( std::ostream &vec, std::ostream &ref, int x, int angle, int p, int q, int reset, int clk) | |
165 | -{ | |
166 | -#ifdef BITWIDTH | |
167 | -#undef BITWIDTH | |
168 | -#undef SHIFT | |
169 | -#undef ANGLEDELTA | |
170 | -#endif | |
171 | - | |
172 | -#define BITWIDTH 11 | |
173 | -#define SHIFT 2 | |
174 | -#define ANGLEDELTA 65 | |
175 | - | |
176 | - int last_angle = 0, last_q = 0, last_p = 0 , last_x = 0; | |
177 | - static vhdl::sincos_sub sincos_sub_module; | |
178 | - | |
179 | - vec << std::bitset<1>(reset) << " " | |
180 | - << std::bitset<1>(clk) << " " | |
181 | - << std::bitset<BITWIDTH>(x) << " " | |
182 | - << std::bitset<BITWIDTH>(angle) << " " | |
183 | - << std::bitset<BITWIDTH>(p) << " " | |
184 | - << std::bitset<BITWIDTH>(q) << std::endl; | |
185 | - | |
186 | - sincos_sub_module.run( SHIFT, ANGLEDELTA, clk, reset, x, last_x, angle, last_angle, p, last_p, q, last_q ); | |
187 | - | |
188 | - ref << std::bitset<BITWIDTH>( last_x ) << " " | |
189 | - << std::bitset<BITWIDTH>( last_angle ) << " " | |
190 | - << std::bitset<BITWIDTH>( last_p ) << " " | |
191 | - << std::bitset<BITWIDTH>( last_q ) << std::endl; | |
192 | - | |
193 | -} | |
194 | - | |
195 | -void test_0( char *vec_name, char * ref_name) // positive rounding | |
196 | -{ | |
197 | - std::ofstream vec; vec.open(vec_name); | |
198 | - std::ofstream ref; ref.open(ref_name); | |
199 | - // reset | |
200 | - test_async_9bit(vec, ref, 23, 0, 60, 10, 1, 0); // x, angle, p, q, reset, clk // CCW | |
201 | - | |
202 | - // positive rounding | |
203 | - test_async_9bit(vec, ref, 23, 0, 60, 10, 0, 0); // x, angle, p, q, reset, clk // CCW | |
204 | - test_async_9bit(vec, ref, 23, 0, 60, 10, 0, 1); // x, angle, p, q, reset, clk // CCW | |
205 | - test_async_9bit(vec, ref, 23, 0, 60, 10, 0, 1); // x, angle, p, q, reset, clk // CCW | |
206 | - test_async_9bit(vec, ref, 23, 0, 60, 10, 0, 0); // x, angle, p, q, reset, clk // CCW | |
207 | - | |
208 | - test_async_9bit(vec, ref, 23, 24, 60, 10, 0, 0); // x, angle, p, q, reset, clk // CW | |
209 | - test_async_9bit(vec, ref, 23, 24, 60, 10, 0, 1); // x, angle, p, q, reset, clk // CW | |
210 | - test_async_9bit(vec, ref, 23, 24, 60, 10, 0, 1); // x, angle, p, q, reset, clk // CW | |
211 | - test_async_9bit(vec, ref, 23, 24, 60, 10, 0, 0); // x, angle, p, q, reset, clk // CW | |
212 | -} | |
213 | - | |
214 | -void test_1( char *vec_name, char * ref_name) // positive no rounding | |
215 | -{ | |
216 | - std::ofstream vec; vec.open(vec_name); | |
217 | - std::ofstream ref; ref.open(ref_name); | |
218 | - // reset | |
219 | - test_async_9bit(vec, ref, -23, 0, 60, -10, 1, 0); // x, angle, p, q, reset, clk // CW | |
220 | - | |
221 | - // positive no roundingb | |
222 | - test_async_9bit(vec, ref, -23, 0, 60, -10, 0, 0); // x, angle, p, q, reset, clk // CW | |
223 | - test_async_9bit(vec, ref, -23, 0, 60, -10, 0, 1); // x, angle, p, q, reset, clk // CW | |
224 | - test_async_9bit(vec, ref, -23, 0, 60, -10, 0, 1); // x, angle, p, q, reset, clk // CW | |
225 | - test_async_9bit(vec, ref, -23, 0, 60, -10, 0, 0); // x, angle, p, q, reset, clk // CW | |
226 | - | |
227 | - test_async_9bit(vec, ref, -23, -24, 60, -10, 0, 0); // x, angle, p, q, reset, clk // CCW | |
228 | - test_async_9bit(vec, ref, -23, -24, 60, -10, 0, 1); // x, angle, p, q, reset, clk // CCW | |
229 | - test_async_9bit(vec, ref, -23, -24, 60, -10, 0, 1); // x, angle, p, q, reset, clk // CCW | |
230 | - test_async_9bit(vec, ref, -23, -24, 60, -10, 0, 0); // x, angle, p, q, reset, clk // CCW | |
231 | - | |
232 | -} | |
233 | - | |
234 | -void test_2( char *vec_name, char * ref_name) // positive rounding | |
235 | -{ | |
236 | - std::ofstream vec; vec.open(vec_name); | |
237 | - std::ofstream ref; ref.open(ref_name); | |
238 | - // reset | |
239 | - test_async_13bit(vec, ref, 23, 0, 16, 64, 1, 0 ); // x, angle, p, q, reset, clk | |
240 | - | |
241 | - // positive rounding | |
242 | - test_async_13bit(vec, ref, 23, 0, 16, 64, 0, 0 ); // x, angle, p, q, reset, clk | |
243 | - test_async_13bit(vec, ref, 23, 0, 16, 64, 0, 1 ); // x, angle, p, q, reset, clk | |
244 | - test_async_13bit(vec, ref, 23, 0, 16, 64, 0, 1 ); // x, angle, p, q, reset, clk | |
245 | - test_async_13bit(vec, ref, 23, 0, 16, 64, 0, 0 ); // x, angle, p, q, reset, clk | |
246 | - | |
247 | - test_async_13bit(vec, ref, 23, 0, 31, 64, 0, 0 ); // x, angle, p, q, reset, clk // same with above when truncated, +1 when rounding | |
248 | - test_async_13bit(vec, ref, 23, 0, 31, 64, 0, 1 ); // x, angle, p, q, reset, clk | |
249 | - test_async_13bit(vec, ref, 23, 0, 31, 64, 0, 1 ); // x, angle, p, q, reset, clk | |
250 | - test_async_13bit(vec, ref, 23, 0, 31, 64, 0, 0 ); // x, angle, p, q, reset, clk | |
251 | -} | |
252 | - | |
253 | -void test_3( char *vec_name, char * ref_name) // negative rounding | |
254 | -{ | |
255 | - std::ofstream vec; vec.open(vec_name); | |
256 | - std::ofstream ref; ref.open(ref_name); | |
257 | - | |
258 | - // reset | |
259 | - test_async_13bit(vec, ref, -23, -24, 16, 64, 1, 0 ); // x, angle, p, q, reset, clk // | |
260 | - | |
261 | - // negative rounding | |
262 | - test_async_13bit(vec, ref, -23, -24, 16, 64, 0, 0 ); // x, angle, p, q, reset, clk // | |
263 | - test_async_13bit(vec, ref, -23, -24, 16, 64, 0, 1 ); // x, angle, p, q, reset, clk // | |
264 | - test_async_13bit(vec, ref, -23, -24, 16, 64, 0, 1 ); // x, angle, p, q, reset, clk // | |
265 | - test_async_13bit(vec, ref, -23, -24, 16, 64, 0, 0 ); // x, angle, p, q, reset, clk // | |
266 | - | |
267 | - test_async_13bit(vec, ref, -23, -24, 31, 64, 0, 0 ); // x, angle, p, q, reset, clk // same with above when truncated, +1 when rounding | |
268 | - test_async_13bit(vec, ref, -23, -24, 31, 64, 0, 1 ); // x, angle, p, q, reset, clk | |
269 | - test_async_13bit(vec, ref, -23, -24, 31, 64, 0, 1 ); // x, angle, p, q, reset, clk | |
270 | - test_async_13bit(vec, ref, -23, -24, 31, 64, 0, 0 ); // x, angle, p, q, reset, clk | |
271 | -} | |
272 | - | |
273 | - | |
274 | -void test_4( char *vec_name, char * ref_name) // async reset | |
275 | -{ | |
276 | - std::ofstream vec; vec.open(vec_name); | |
277 | - std::ofstream ref; ref.open(ref_name); | |
278 | - | |
279 | - test_async_11bit(vec, ref, 23, 0, 500, 230, 1, 0 ); // x, angle, p, q, reset, clk | |
280 | - test_async_11bit(vec, ref, 23, 0, 500, 20, 1, 1 ); // x, angle, p, q, reset, clk | |
281 | - test_async_11bit(vec, ref, 23, 25, 500, 20, 1, 0 ); // x, angle, p, q, reset, clk | |
282 | - test_async_11bit(vec, ref, 23, 0, 500, 230, 0, 0 ); // x, angle, p, q, reset, clk | |
283 | - test_async_11bit(vec, ref, 23, 0, 500, 230, 0, 1 ); // x, angle, p, q, reset, clk | |
284 | - test_async_11bit(vec, ref, 23, 0, 430, 75, 0, 0 ); // x, angle, p, q, reset, clk | |
285 | - test_async_11bit(vec, ref, 23, 0, 430, 75, 1, 0 ); // x, angle, p, q, reset, clk | |
286 | - test_async_11bit(vec, ref, 23, 0, 430, 75, 0, 0 ); // x, angle, p, q, reset, clk | |
287 | - test_async_11bit(vec, ref, 23, 0, 430, 75, 0, 1 ); // x, angle, p, q, reset, clk | |
288 | - test_async_11bit(vec, ref, 23, 0, 430, 75, 1, 1 ); // x, angle, p, q, reset, clk | |
289 | - test_async_11bit(vec, ref, 23, 0, 430, 75, 0, 1 ); // x, angle, p, q, reset, clk | |
290 | - test_async_11bit(vec, ref, 23, 32, 430, 75, 0, 0 ); // x, angle, p, q, reset, clk | |
291 | - test_async_11bit(vec, ref, 23, 32, 430, 75, 0, 1 ); // x, angle, p, q, reset, clk | |
292 | -} | |
293 | - | |
294 | - | |
295 | - /** | |
296 | - * \brief sincos CORDIC algorithm. | |
297 | - * \param x | |
298 | - * \param p | |
299 | - * \param q | |
300 | - * \param num_stages | |
301 | - * \param bit_width | |
302 | - */ | |
303 | -void cordic_sincos_bw32( std::ostream &vec, std::ostream &ref, int num_stages, int x, int reset, int clk ) | |
304 | -{ | |
305 | -#ifdef BITWIDTH | |
306 | -#undef BITWIDTH | |
307 | -#endif | |
308 | - | |
309 | -#define BITWIDTH 32 | |
310 | - | |
311 | - static int last_p = 0, last_q = 0; | |
312 | - | |
313 | - static vhdl::sincos_angle_delta ad; | |
314 | - static vhdl::sincos_scaling_factor sf; | |
315 | - static vhdl::sincos_cordic cordic; | |
316 | - | |
317 | - | |
318 | - vec | |
319 | - << std::bitset<1>( reset ) << " " // reset | |
320 | - << std::bitset<1>( clk ) << " " // clock | |
321 | - << std::bitset<BITWIDTH>( x ) << std::endl; | |
322 | - | |
323 | - cordic.run( 20, clk, reset, x, last_p, last_q ); | |
324 | - | |
325 | - ref | |
326 | - << std::bitset<BITWIDTH>( last_p ) << " " | |
327 | - << std::bitset<BITWIDTH>( last_q ) << std::endl; | |
328 | - | |
329 | - | |
330 | -} | |
331 | - | |
332 | -void test_100( std::ostream &vec, std::ostream &ref, int num_stages ) | |
333 | -{ | |
334 | - | |
335 | - int x = 0; | |
336 | - | |
337 | - // reset | |
338 | - cordic_sincos_bw32( vec, ref, num_stages, x, 1, 0 ); | |
339 | - | |
340 | - // scan [-0.5, 0.5) | |
341 | - for ( int i = -64; i < 63; i++ ) | |
342 | - { | |
343 | - cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); | |
344 | - x = i << 24; | |
345 | - cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); | |
346 | - cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); | |
347 | - cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); | |
348 | - } | |
349 | - | |
350 | - // flush pipeline | |
351 | - for ( int i = 0; i < num_stages; i++ ) | |
352 | - { | |
353 | - cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); | |
354 | - x = i << 16; | |
355 | - cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); | |
356 | - cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); | |
357 | - cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); | |
358 | - } | |
359 | -} |
@@ -1,26 +0,0 @@ | ||
1 | --------------------------------------------------------------------------------- | |
2 | --- Entity: sincos_sub_bench | |
3 | --- Date:2016-09-25 | |
4 | --- Author: takemasa | |
5 | --- | |
6 | --- Description: | |
7 | --------------------------------------------------------------------------------- | |
8 | -library ieee; | |
9 | -use ieee.std_logic_1164.all; | |
10 | -use ieee.numeric_std.all; | |
11 | -use std.textio.all; | |
12 | -use ieee.std_logic_textio.all; | |
13 | - | |
14 | -entity sincos_sub_bench is | |
15 | -end sincos_sub_bench; | |
16 | - | |
17 | -architecture arch of sincos_sub_bench is | |
18 | - | |
19 | -begin | |
20 | - dut0 : entity work.sincos_sub_bench_0; -- instance of dut for 9bit, positive x. | |
21 | - dut1 : entity work.sincos_sub_bench_1; -- instance of dut for 9bit, negative x. | |
22 | - dut2 : entity work.sincos_sub_bench_2; -- instance of dut for 9bit, positive x. | |
23 | - dut3 : entity work.sincos_sub_bench_3; -- instance of dut for 9bit, negative x. | |
24 | - | |
25 | -end arch; | |
26 | - |
@@ -22,27 +22,32 @@ | ||
22 | 22 | int main() { |
23 | 23 | |
24 | 24 | |
25 | - char filename_vector_0[] = "sincossub_0.vec.txt"; | |
26 | - char filename_reference_0[] = "sincossub_0.ref.txt"; | |
25 | + char filename_vector_0[] = "fileout/sincossub_0.vec.txt"; | |
26 | + char filename_reference_0[] = "fileout/sincossub_0.ref.txt"; | |
27 | 27 | |
28 | - char filename_vector_1[] = "sincossub_1.vec.txt"; | |
29 | - char filename_reference_1[] = "sincossub_1.ref.txt"; | |
28 | + char filename_vector_1[] = "fileout/sincossub_1.vec.txt"; | |
29 | + char filename_reference_1[] = "fileout/sincossub_1.ref.txt"; | |
30 | 30 | |
31 | - char filename_vector_2[] = "sincossub_2.vec.txt"; | |
32 | - char filename_reference_2[] = "sincossub_2.ref.txt"; | |
31 | + char filename_vector_2[] = "fileout/sincossub_2.vec.txt"; | |
32 | + char filename_reference_2[] = "fileout/sincossub_2.ref.txt"; | |
33 | 33 | |
34 | - char filename_vector_3[] = "sincossub_3.vec.txt"; | |
35 | - char filename_reference_3[] = "sincossub_3.ref.txt"; | |
34 | + char filename_vector_3[] = "fileout/sincossub_3.vec.txt"; | |
35 | + char filename_reference_3[] = "fileout/sincossub_3.ref.txt"; | |
36 | 36 | |
37 | - char filename_vector_4[] = "sincossub_4.vec.txt"; | |
38 | - char filename_reference_4[] = "sincossub_4.ref.txt"; | |
37 | + char filename_vector_4[] = "fileout/sincossub_4.vec.txt"; | |
38 | + char filename_reference_4[] = "fileout/sincossub_4.ref.txt"; | |
39 | 39 | |
40 | - char filename_angle_delta[] = "sincos_angle_delta.txt"; | |
40 | + char filename_vector_5[] = "fileout/sincossub_5.vec.txt"; | |
41 | + char filename_reference_5[] = "fileout/sincossub_5.ref.txt"; | |
41 | 42 | |
42 | - char filename_scaling_factor[] = "sincos_scaling_factor.txt"; | |
43 | + char filename_angle_delta[] = "fileout/sincos_angle_delta.txt"; | |
44 | + char filename_scaling_factor[] = "fileout/sincos_scaling_factor.txt"; | |
43 | 45 | |
44 | - std::ofstream vector_5; vector_5.open("sincos_0.vec.txt"); | |
45 | - std::ofstream reference_5; reference_5.open("sincos_0.ref.txt"); | |
46 | + char filename_vector_100[] = "fileout/sincos_100.vec.txt"; | |
47 | + char filename_reference_100[] = "fileout/sincos_100.ref.txt"; | |
48 | + | |
49 | + char filename_vector_101[] = "fileout/sincos_101.vec.txt"; | |
50 | + char filename_reference_101[] = "fileout/sincos_101.ref.txt"; | |
46 | 51 | |
47 | 52 | // positive x, |
48 | 53 | test_0( filename_vector_0, filename_reference_0); |
@@ -59,10 +64,16 @@ int main() { | ||
59 | 64 | // positive x, async reset test |
60 | 65 | test_4( filename_vector_4, filename_reference_4); |
61 | 66 | |
67 | + // positive x, async reset test | |
68 | + test_5( filename_vector_5, filename_reference_5); | |
69 | + | |
62 | 70 | gen_table( filename_angle_delta, filename_scaling_factor); |
63 | 71 | |
64 | 72 | |
65 | - test_100( vector_5, reference_5, 24 ); | |
73 | + test_100( filename_vector_100, filename_reference_100 ); | |
74 | + | |
75 | + // test signal and clock changes simul. | |
76 | + test_101( filename_vector_101, filename_reference_101 ); | |
66 | 77 | |
67 | 78 | |
68 | 79 | } |
@@ -98,99 +109,12 @@ void gen_table( const char * filename_angle_delta, const char * filename_scaling | ||
98 | 109 | } |
99 | 110 | } |
100 | 111 | |
112 | +/***************************************************************** | |
113 | + * | |
114 | + * SINCOS SUB vector generation | |
115 | + * | |
116 | + *****************************************************************/ | |
101 | 117 | |
102 | -void test_async_9bit( std::ostream &vec, std::ostream &ref, int x, int angle, int p, int q, int reset, int clk) | |
103 | -{ | |
104 | -#ifdef BITWIDTH | |
105 | -#undef BITWIDTH | |
106 | -#undef SHIFT | |
107 | -#undef ANGLEDELTA | |
108 | -#endif | |
109 | - | |
110 | -#define BITWIDTH 9 | |
111 | -#define SHIFT 3 | |
112 | -#define ANGLEDELTA 31 | |
113 | - | |
114 | - static int out_angle = 0, last_q = 0, last_p = 0 , last_x = 0; | |
115 | - static vhdl::sincos_sub sincos_sub_module; | |
116 | - | |
117 | - vec << std::bitset<1>(reset) << " " | |
118 | - << std::bitset<1>(clk) << " " | |
119 | - << std::bitset<BITWIDTH>(x) << " " | |
120 | - << std::bitset<BITWIDTH>(angle) << " " | |
121 | - << std::bitset<BITWIDTH>(p) << " " | |
122 | - << std::bitset<BITWIDTH>(q) << std::endl; | |
123 | - | |
124 | - sincos_sub_module.run( SHIFT, ANGLEDELTA, clk, reset, x, last_x, angle, out_angle, p, last_p, q, last_q ); | |
125 | - | |
126 | - ref << std::bitset<BITWIDTH>( last_x ) << " " | |
127 | - << std::bitset<BITWIDTH>( out_angle ) << " " | |
128 | - << std::bitset<BITWIDTH>( last_p ) << " " | |
129 | - << std::bitset<BITWIDTH>( last_q ) << std::endl; | |
130 | - | |
131 | -} | |
132 | - | |
133 | -void test_async_13bit( std::ostream &vec, std::ostream &ref, int x, int angle, int p, int q, int reset, int clk) | |
134 | -{ | |
135 | -#ifdef BITWIDTH | |
136 | -#undef BITWIDTH | |
137 | -#undef SHIFT | |
138 | -#undef ANGLEDELTA | |
139 | -#endif | |
140 | - | |
141 | -#define BITWIDTH 13 | |
142 | -#define SHIFT 4 | |
143 | -#define ANGLEDELTA 65 | |
144 | - | |
145 | - static int last_angle = 0, last_q = 0, last_p = 0 , last_x = 0; | |
146 | - static vhdl::sincos_sub sincos_sub_module; | |
147 | - | |
148 | - vec << std::bitset<1>(reset) << " " | |
149 | - << std::bitset<1>(clk) << " " | |
150 | - << std::bitset<BITWIDTH>(x) << " " | |
151 | - << std::bitset<BITWIDTH>(angle) << " " | |
152 | - << std::bitset<BITWIDTH>(p) << " " | |
153 | - << std::bitset<BITWIDTH>(q) << std::endl; | |
154 | - | |
155 | - sincos_sub_module.run( SHIFT, ANGLEDELTA, clk, reset, x, last_x, angle, last_angle, p, last_p, q, last_q ); | |
156 | - | |
157 | - ref << std::bitset<BITWIDTH>( last_x ) << " " | |
158 | - << std::bitset<BITWIDTH>( last_angle ) << " " | |
159 | - << std::bitset<BITWIDTH>( last_p ) << " " | |
160 | - << std::bitset<BITWIDTH>( last_q ) << std::endl; | |
161 | - | |
162 | -} | |
163 | - | |
164 | -void test_async_11bit( std::ostream &vec, std::ostream &ref, int x, int angle, int p, int q, int reset, int clk) | |
165 | -{ | |
166 | -#ifdef BITWIDTH | |
167 | -#undef BITWIDTH | |
168 | -#undef SHIFT | |
169 | -#undef ANGLEDELTA | |
170 | -#endif | |
171 | - | |
172 | -#define BITWIDTH 11 | |
173 | -#define SHIFT 2 | |
174 | -#define ANGLEDELTA 65 | |
175 | - | |
176 | - int last_angle = 0, last_q = 0, last_p = 0 , last_x = 0; | |
177 | - static vhdl::sincos_sub sincos_sub_module; | |
178 | - | |
179 | - vec << std::bitset<1>(reset) << " " | |
180 | - << std::bitset<1>(clk) << " " | |
181 | - << std::bitset<BITWIDTH>(x) << " " | |
182 | - << std::bitset<BITWIDTH>(angle) << " " | |
183 | - << std::bitset<BITWIDTH>(p) << " " | |
184 | - << std::bitset<BITWIDTH>(q) << std::endl; | |
185 | - | |
186 | - sincos_sub_module.run( SHIFT, ANGLEDELTA, clk, reset, x, last_x, angle, last_angle, p, last_p, q, last_q ); | |
187 | - | |
188 | - ref << std::bitset<BITWIDTH>( last_x ) << " " | |
189 | - << std::bitset<BITWIDTH>( last_angle ) << " " | |
190 | - << std::bitset<BITWIDTH>( last_p ) << " " | |
191 | - << std::bitset<BITWIDTH>( last_q ) << std::endl; | |
192 | - | |
193 | -} | |
194 | 118 | |
195 | 119 | void test_0( char *vec_name, char * ref_name) // positive rounding |
196 | 120 | { |
@@ -291,69 +215,271 @@ void test_4( char *vec_name, char * ref_name) // async reset | ||
291 | 215 | test_async_11bit(vec, ref, 23, 32, 430, 75, 0, 1 ); // x, angle, p, q, reset, clk |
292 | 216 | } |
293 | 217 | |
294 | - | |
295 | - /** | |
296 | - * \brief sincos CORDIC algorithm. | |
297 | - * \param x | |
298 | - * \param p | |
299 | - * \param q | |
300 | - * \param num_stages | |
301 | - * \param bit_width | |
302 | - */ | |
303 | -void cordic_sincos_bw32( std::ostream &vec, std::ostream &ref, int num_stages, int x, int reset, int clk ) | |
218 | +void test_5( char *vec_name, char * ref_name) // test of completely same timing signal change with clock | |
304 | 219 | { |
305 | -#ifdef BITWIDTH | |
306 | -#undef BITWIDTH | |
307 | -#endif | |
220 | + std::ofstream vec; vec.open(vec_name); | |
221 | + std::ofstream ref; ref.open(ref_name); | |
308 | 222 | |
309 | -#define BITWIDTH 32 | |
223 | + // reset | |
224 | + test_async_13bit(vec, ref, 23, 0, 16, 64, 1, 0 ); // x, angle, p, q, reset, clk | |
310 | 225 | |
311 | - int out_p, out_q; | |
226 | + // positive rounding | |
227 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 0 ); // x, angle, p, q, reset, clk | |
228 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk | |
229 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk | |
230 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 0 ); // x, angle, p, q, reset, clk | |
231 | + | |
232 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 0 ); // x, angle, p, q, reset, clk | |
233 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 1 ); // x, angle, p, q, reset, clk | |
234 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 1 ); // x, angle, p, q, reset, clk | |
235 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 0 ); // x, angle, p, q, reset, clk | |
236 | + | |
237 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 0 ); // x, angle, p, q, reset, clk | |
238 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk | |
239 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk | |
240 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 0 ); // x, angle, p, q, reset, clk | |
241 | + | |
242 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 0 ); // x, angle, p, q, reset, clk | |
243 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 1 ); // x, angle, p, q, reset, clk | |
244 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 1 ); // x, angle, p, q, reset, clk | |
245 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 0 ); // x, angle, p, q, reset, clk | |
246 | + | |
247 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 0 ); // x, angle, p, q, reset, clk | |
248 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk | |
249 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk | |
250 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 0 ); // x, angle, p, q, reset, clk | |
251 | + | |
252 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 0 ); // x, angle, p, q, reset, clk | |
253 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 1 ); // x, angle, p, q, reset, clk | |
254 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 1 ); // x, angle, p, q, reset, clk | |
255 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 0 ); // x, angle, p, q, reset, clk | |
256 | + | |
257 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 0 ); // x, angle, p, q, reset, clk | |
258 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk | |
259 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk | |
260 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 0 ); // x, angle, p, q, reset, clk | |
261 | + | |
262 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 0 ); // x, angle, p, q, reset, clk | |
263 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 1 ); // x, angle, p, q, reset, clk | |
264 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 1 ); // x, angle, p, q, reset, clk | |
265 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 0 ); // x, angle, p, q, reset, clk | |
266 | + | |
267 | +} | |
268 | + | |
269 | + | |
270 | + | |
271 | +/***************************************************************** | |
272 | + * | |
273 | + * SINCOS vector generation | |
274 | + * | |
275 | + *****************************************************************/ | |
312 | 276 | |
313 | - static vhdl::sincos_angle_delta ad; | |
314 | - static vhdl::sincos_scaling_factor sf; | |
315 | - static vhdl::sincos_cordic cordic; | |
316 | 277 | |
278 | +void test_100( char *vec_name, char * ref_name ) | |
279 | +{ | |
280 | + std::ofstream vec; vec.open(vec_name); | |
281 | + std::ofstream ref; ref.open(ref_name); | |
317 | 282 | |
318 | - vec | |
319 | - << std::bitset<1>( reset ) << " " // reset | |
320 | - << std::bitset<1>( clk ) << " " // clock | |
321 | - << std::bitset<BITWIDTH>( x ) << std::endl; | |
322 | 283 | |
323 | - cordic.run( 20, clk, reset, x, out_p, out_q ); | |
284 | + const int num_stages = 20; | |
285 | + int x = 0; | |
324 | 286 | |
325 | - ref | |
326 | - << std::bitset<BITWIDTH>( out_p ) << " " | |
327 | - << std::bitset<BITWIDTH>( out_q ) << std::endl; | |
287 | + // reset | |
288 | + cordic_sincos_bw32( vec, ref, num_stages, x, 1, 0 ); | |
328 | 289 | |
290 | + // scan [-0.5, 0.5) | |
291 | + // scan [-0.5, 0.5) | |
292 | + for ( int i = -128; i < 127; i++ ) | |
293 | + { | |
294 | + x = i << 23; | |
295 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); | |
296 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); | |
297 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); | |
298 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); | |
299 | + } | |
329 | 300 | |
301 | + // flush pipeline | |
302 | + for ( int i = 0; i < num_stages; i++ ) | |
303 | + { | |
304 | + x = i << 16; | |
305 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); | |
306 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); | |
307 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); | |
308 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); | |
309 | + } | |
330 | 310 | } |
331 | 311 | |
332 | -void test_100( std::ostream &vec, std::ostream &ref, int num_stages ) | |
312 | +void test_101( char *vec_name, char * ref_name) | |
333 | 313 | { |
314 | + std::ofstream vec; vec.open(vec_name); | |
315 | + std::ofstream ref; ref.open(ref_name); | |
334 | 316 | |
317 | + const int num_stages = 3; | |
335 | 318 | int x = 0; |
336 | 319 | |
337 | 320 | // reset |
338 | 321 | cordic_sincos_bw32( vec, ref, num_stages, x, 1, 0 ); |
339 | 322 | |
340 | - // scan [-0.5, 0.5) | |
341 | - for ( int i = -64; i < 63; i++ ) | |
323 | + // | |
324 | + for ( int i = -3; i < 2; i++ ) | |
342 | 325 | { |
343 | 326 | cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); |
344 | - x = i << 24; | |
327 | + x = i << 23; | |
345 | 328 | cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); |
346 | 329 | cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); |
347 | 330 | cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); |
348 | 331 | } |
349 | 332 | |
350 | 333 | // flush pipeline |
351 | - for ( int i = 0; i < num_stages; i++ ) | |
334 | + for ( int i = 0; i < num_stages+2; i++ ) | |
352 | 335 | { |
353 | 336 | cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); |
354 | - x = i << 16; | |
337 | + x = 0; | |
355 | 338 | cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); |
356 | 339 | cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); |
357 | 340 | cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); |
358 | 341 | } |
359 | 342 | } |
343 | + | |
344 | +/***************************************************************** | |
345 | + * | |
346 | + * SINCOS SUB Low level Test | |
347 | + * | |
348 | + *****************************************************************/ | |
349 | + | |
350 | + | |
351 | +void test_async_9bit( std::ostream &vec, std::ostream &ref, int x, int angle, int p, int q, int reset, int clk) | |
352 | +{ | |
353 | +#ifdef BITWIDTH | |
354 | +#undef BITWIDTH | |
355 | +#undef SHIFT | |
356 | +#undef ANGLEDELTA | |
357 | +#endif | |
358 | + | |
359 | +#define BITWIDTH 9 | |
360 | +#define SHIFT 3 | |
361 | +#define ANGLEDELTA 31 | |
362 | + | |
363 | + static int out_angle = 0, out_q = 0, last_p = 0 , last_x = 0; | |
364 | + static vhdl::sincos_sub sincos_sub_module; | |
365 | + | |
366 | + vec << std::bitset<1>(reset) << " " | |
367 | + << std::bitset<1>(clk) << " " | |
368 | + << std::bitset<BITWIDTH>(x) << " " | |
369 | + << std::bitset<BITWIDTH>(angle) << " " | |
370 | + << std::bitset<BITWIDTH>(p) << " " | |
371 | + << std::bitset<BITWIDTH>(q) << std::endl; | |
372 | + | |
373 | + sincos_sub_module.run( SHIFT, ANGLEDELTA, clk, reset, x, last_x, angle, out_angle, p, last_p, q, out_q ); | |
374 | + | |
375 | + ref << std::bitset<BITWIDTH>( last_x ) << " " | |
376 | + << std::bitset<BITWIDTH>( out_angle ) << " " | |
377 | + << std::bitset<BITWIDTH>( last_p ) << " " | |
378 | + << std::bitset<BITWIDTH>( out_q ) << std::endl; | |
379 | + | |
380 | +} | |
381 | + | |
382 | +void test_async_13bit( std::ostream &vec, std::ostream &ref, int x, int angle, int p, int q, int reset, int clk) | |
383 | +{ | |
384 | +#ifdef BITWIDTH | |
385 | +#undef BITWIDTH | |
386 | +#undef SHIFT | |
387 | +#undef ANGLEDELTA | |
388 | +#endif | |
389 | + | |
390 | +#define BITWIDTH 13 | |
391 | +#define SHIFT 4 | |
392 | +#define ANGLEDELTA 65 | |
393 | + | |
394 | + int out_angle = 0, out_q = 0, last_p = 0 , last_x = 0; | |
395 | + static vhdl::sincos_sub sincos_sub_module; | |
396 | + | |
397 | + vec << std::bitset<1>(reset) << " " | |
398 | + << std::bitset<1>(clk) << " " | |
399 | + << std::bitset<BITWIDTH>(x) << " " | |
400 | + << std::bitset<BITWIDTH>(angle) << " " | |
401 | + << std::bitset<BITWIDTH>(p) << " " | |
402 | + << std::bitset<BITWIDTH>(q) << std::endl; | |
403 | + | |
404 | + sincos_sub_module.run( SHIFT, ANGLEDELTA, clk, reset, x, last_x, angle, out_angle, p, last_p, q, out_q ); | |
405 | + | |
406 | + ref << std::bitset<BITWIDTH>( last_x ) << " " | |
407 | + << std::bitset<BITWIDTH>( out_angle ) << " " | |
408 | + << std::bitset<BITWIDTH>( last_p ) << " " | |
409 | + << std::bitset<BITWIDTH>( out_q ) << std::endl; | |
410 | + | |
411 | +} | |
412 | + | |
413 | +void test_async_11bit( std::ostream &vec, std::ostream &ref, int x, int angle, int p, int q, int reset, int clk) | |
414 | +{ | |
415 | +#ifdef BITWIDTH | |
416 | +#undef BITWIDTH | |
417 | +#undef SHIFT | |
418 | +#undef ANGLEDELTA | |
419 | +#endif | |
420 | + | |
421 | +#define BITWIDTH 11 | |
422 | +#define SHIFT 2 | |
423 | +#define ANGLEDELTA 65 | |
424 | + | |
425 | + int out_angle = 0, out_q = 0, out_p = 0 , out_x = 0; | |
426 | + static vhdl::sincos_sub sincos_sub_module; | |
427 | + | |
428 | + vec << std::bitset<1>(reset) << " " | |
429 | + << std::bitset<1>(clk) << " " | |
430 | + << std::bitset<BITWIDTH>(x) << " " | |
431 | + << std::bitset<BITWIDTH>(angle) << " " | |
432 | + << std::bitset<BITWIDTH>(p) << " " | |
433 | + << std::bitset<BITWIDTH>(q) << std::endl; | |
434 | + | |
435 | + sincos_sub_module.run( SHIFT, ANGLEDELTA, clk, reset, x, out_x, angle, out_angle, p, out_p, q, out_q ); | |
436 | + | |
437 | + ref << std::bitset<BITWIDTH>( out_x ) << " " | |
438 | + << std::bitset<BITWIDTH>( out_angle ) << " " | |
439 | + << std::bitset<BITWIDTH>( out_p ) << " " | |
440 | + << std::bitset<BITWIDTH>( out_q ) << std::endl; | |
441 | + | |
442 | +} | |
443 | + | |
444 | +/***************************************************************** | |
445 | + * | |
446 | + * SINCOS Low level Test | |
447 | + * | |
448 | + *****************************************************************/ | |
449 | + | |
450 | +/** | |
451 | + * \brief sincos CORDIC algorithm. | |
452 | + * \param x | |
453 | + * \param p | |
454 | + * \param q | |
455 | + * \param num_stages | |
456 | + * \param bit_width | |
457 | + */ | |
458 | +void cordic_sincos_bw32( std::ostream &vec, std::ostream &ref, int num_stages, int x, int reset, int clk ) | |
459 | +{ | |
460 | +#ifdef BITWIDTH | |
461 | +#undef BITWIDTH | |
462 | +#endif | |
463 | + | |
464 | +#define BITWIDTH 32 | |
465 | + | |
466 | +int out_p, out_q; | |
467 | + | |
468 | +static vhdl::sincos_cordic cordic; | |
469 | + | |
470 | + | |
471 | +vec | |
472 | + << std::bitset<1>( reset ) << " " // reset | |
473 | + << std::bitset<1>( clk ) << " " // clock | |
474 | + << std::bitset<BITWIDTH>( x ) << std::endl; | |
475 | + | |
476 | +cordic.run( num_stages, clk, reset, x, out_p, out_q ); | |
477 | + | |
478 | +ref | |
479 | + << std::bitset<BITWIDTH>( out_p ) << " " | |
480 | + << std::bitset<BITWIDTH>( out_q ) << std::endl; | |
481 | + | |
482 | +} | |
483 | + | |
484 | + | |
485 | + |
@@ -0,0 +1,480 @@ | ||
1 | +/** | |
2 | + * \file main.cpp | |
3 | + * | |
4 | + * \date 2016/10/01 | |
5 | + * \author: takemasa | |
6 | + * \brief Test vector Generator for cordic_sincos VHDL project | |
7 | + */ | |
8 | + | |
9 | +#include <iostream> | |
10 | +#include <bitset> | |
11 | +#include <string> | |
12 | +#include <cmath> | |
13 | + | |
14 | +#include <fstream> // ifstream, ofstream | |
15 | + | |
16 | +#include "main.h" | |
17 | + | |
18 | +/** | |
19 | + * \bfief main function | |
20 | + */ | |
21 | + | |
22 | +int main() { | |
23 | + | |
24 | + | |
25 | + char filename_vector_0[] = "fileout/sincossub_0.vec.txt"; | |
26 | + char filename_reference_0[] = "fileout/sincossub_0.ref.txt"; | |
27 | + | |
28 | + char filename_vector_1[] = "fileout/sincossub_1.vec.txt"; | |
29 | + char filename_reference_1[] = "fileout/sincossub_1.ref.txt"; | |
30 | + | |
31 | + char filename_vector_2[] = "fileout/sincossub_2.vec.txt"; | |
32 | + char filename_reference_2[] = "fileout/sincossub_2.ref.txt"; | |
33 | + | |
34 | + char filename_vector_3[] = "fileout/sincossub_3.vec.txt"; | |
35 | + char filename_reference_3[] = "fileout/sincossub_3.ref.txt"; | |
36 | + | |
37 | + char filename_vector_4[] = "fileout/sincossub_4.vec.txt"; | |
38 | + char filename_reference_4[] = "fileout/sincossub_4.ref.txt"; | |
39 | + | |
40 | + char filename_vector_5[] = "fileout/sincossub_5.vec.txt"; | |
41 | + char filename_reference_5[] = "fileout/sincossub_5.ref.txt"; | |
42 | + | |
43 | + char filename_angle_delta[] = "fileout/sincos_angle_delta.txt"; | |
44 | + char filename_scaling_factor[] = "fileout/sincos_scaling_factor.txt"; | |
45 | + | |
46 | + char filename_vector_100[] = "fileout/sincos_100.vec.txt"; | |
47 | + char filename_reference_100[] = "fileout/sincos_100.ref.txt"; | |
48 | + | |
49 | + char filename_vector_101[] = "fileout/sincos_101.vec.txt"; | |
50 | + char filename_reference_101[] = "fileout/sincos_101.ref.txt"; | |
51 | + | |
52 | + // positive x, | |
53 | + test_0( filename_vector_0, filename_reference_0); | |
54 | + | |
55 | + // negative x | |
56 | + test_1( filename_vector_1, filename_reference_1); | |
57 | + | |
58 | + //positive x, rounding up | |
59 | + test_2( filename_vector_2, filename_reference_2); | |
60 | + | |
61 | + // negative x rouding up | |
62 | + test_3( filename_vector_3, filename_reference_3); | |
63 | + | |
64 | + // positive x, async reset test | |
65 | + test_4( filename_vector_4, filename_reference_4); | |
66 | + | |
67 | + // positive x, async reset test | |
68 | + test_5( filename_vector_5, filename_reference_5); | |
69 | + | |
70 | +gen_table( filename_angle_delta, filename_scaling_factor); | |
71 | + | |
72 | + | |
73 | + test_100( filename_vector_100, filename_reference_100, 20 ); | |
74 | + | |
75 | + // test signal and clock changes simul. | |
76 | + test_101( filename_vector_101, filename_reference_101, 20 ); | |
77 | + | |
78 | + | |
79 | +} | |
80 | + | |
81 | + /** | |
82 | + * \brief shift rith arithmetic with rounding. | |
83 | + */ | |
84 | +int round_shift( int operand, int shift) | |
85 | +{ | |
86 | + if (shift > 0) | |
87 | + return ( operand + (1<<(shift-1)) ) >> shift ; | |
88 | + else | |
89 | + return operand; | |
90 | +} | |
91 | + | |
92 | + | |
93 | +void gen_table( const char * filename_angle_delta, const char * filename_scaling_factor) | |
94 | +{ | |
95 | + std::ofstream angle_delta; angle_delta.open(filename_angle_delta); | |
96 | + std::ofstream scaling_factor; scaling_factor.open(filename_scaling_factor); | |
97 | + | |
98 | + vhdl::sincos_angle_delta ad; | |
99 | + vhdl::sincos_scaling_factor sf; | |
100 | + | |
101 | + // Initialize the scaling factor and angle delta table. | |
102 | + for ( int i = 0; i<vhdl::angle_delta_table_size; i++ ) | |
103 | + { | |
104 | + // output to the file | |
105 | + scaling_factor << std::bitset<32>( sf.table[i] ) << std::endl; | |
106 | + | |
107 | + // output to the file | |
108 | + angle_delta << std::bitset<32>( ad.table[i] ) << std::endl; | |
109 | + } | |
110 | +} | |
111 | + | |
112 | +/***************************************************************** | |
113 | + * | |
114 | + * SINCOS SUB vector generation | |
115 | + * | |
116 | + *****************************************************************/ | |
117 | + | |
118 | + | |
119 | +void test_0( char *vec_name, char * ref_name) // positive rounding | |
120 | +{ | |
121 | + std::ofstream vec; vec.open(vec_name); | |
122 | + std::ofstream ref; ref.open(ref_name); | |
123 | + // reset | |
124 | + test_async_9bit(vec, ref, 23, 0, 60, 10, 1, 0); // x, angle, p, q, reset, clk // CCW | |
125 | + | |
126 | + // positive rounding | |
127 | + test_async_9bit(vec, ref, 23, 0, 60, 10, 0, 0); // x, angle, p, q, reset, clk // CCW | |
128 | + test_async_9bit(vec, ref, 23, 0, 60, 10, 0, 1); // x, angle, p, q, reset, clk // CCW | |
129 | + test_async_9bit(vec, ref, 23, 0, 60, 10, 0, 1); // x, angle, p, q, reset, clk // CCW | |
130 | + test_async_9bit(vec, ref, 23, 0, 60, 10, 0, 0); // x, angle, p, q, reset, clk // CCW | |
131 | + | |
132 | + test_async_9bit(vec, ref, 23, 24, 60, 10, 0, 0); // x, angle, p, q, reset, clk // CW | |
133 | + test_async_9bit(vec, ref, 23, 24, 60, 10, 0, 1); // x, angle, p, q, reset, clk // CW | |
134 | + test_async_9bit(vec, ref, 23, 24, 60, 10, 0, 1); // x, angle, p, q, reset, clk // CW | |
135 | + test_async_9bit(vec, ref, 23, 24, 60, 10, 0, 0); // x, angle, p, q, reset, clk // CW | |
136 | +} | |
137 | + | |
138 | +void test_1( char *vec_name, char * ref_name) // positive no rounding | |
139 | +{ | |
140 | + std::ofstream vec; vec.open(vec_name); | |
141 | + std::ofstream ref; ref.open(ref_name); | |
142 | + // reset | |
143 | + test_async_9bit(vec, ref, -23, 0, 60, -10, 1, 0); // x, angle, p, q, reset, clk // CW | |
144 | + | |
145 | + // positive no roundingb | |
146 | + test_async_9bit(vec, ref, -23, 0, 60, -10, 0, 0); // x, angle, p, q, reset, clk // CW | |
147 | + test_async_9bit(vec, ref, -23, 0, 60, -10, 0, 1); // x, angle, p, q, reset, clk // CW | |
148 | + test_async_9bit(vec, ref, -23, 0, 60, -10, 0, 1); // x, angle, p, q, reset, clk // CW | |
149 | + test_async_9bit(vec, ref, -23, 0, 60, -10, 0, 0); // x, angle, p, q, reset, clk // CW | |
150 | + | |
151 | + test_async_9bit(vec, ref, -23, -24, 60, -10, 0, 0); // x, angle, p, q, reset, clk // CCW | |
152 | + test_async_9bit(vec, ref, -23, -24, 60, -10, 0, 1); // x, angle, p, q, reset, clk // CCW | |
153 | + test_async_9bit(vec, ref, -23, -24, 60, -10, 0, 1); // x, angle, p, q, reset, clk // CCW | |
154 | + test_async_9bit(vec, ref, -23, -24, 60, -10, 0, 0); // x, angle, p, q, reset, clk // CCW | |
155 | + | |
156 | +} | |
157 | + | |
158 | +void test_2( char *vec_name, char * ref_name) // positive rounding | |
159 | +{ | |
160 | + std::ofstream vec; vec.open(vec_name); | |
161 | + std::ofstream ref; ref.open(ref_name); | |
162 | + // reset | |
163 | + test_async_13bit(vec, ref, 23, 0, 16, 64, 1, 0 ); // x, angle, p, q, reset, clk | |
164 | + | |
165 | + // positive rounding | |
166 | + test_async_13bit(vec, ref, 23, 0, 16, 64, 0, 0 ); // x, angle, p, q, reset, clk | |
167 | + test_async_13bit(vec, ref, 23, 0, 16, 64, 0, 1 ); // x, angle, p, q, reset, clk | |
168 | + test_async_13bit(vec, ref, 23, 0, 16, 64, 0, 1 ); // x, angle, p, q, reset, clk | |
169 | + test_async_13bit(vec, ref, 23, 0, 16, 64, 0, 0 ); // x, angle, p, q, reset, clk | |
170 | + | |
171 | + test_async_13bit(vec, ref, 23, 0, 31, 64, 0, 0 ); // x, angle, p, q, reset, clk // same with above when truncated, +1 when rounding | |
172 | + test_async_13bit(vec, ref, 23, 0, 31, 64, 0, 1 ); // x, angle, p, q, reset, clk | |
173 | + test_async_13bit(vec, ref, 23, 0, 31, 64, 0, 1 ); // x, angle, p, q, reset, clk | |
174 | + test_async_13bit(vec, ref, 23, 0, 31, 64, 0, 0 ); // x, angle, p, q, reset, clk | |
175 | +} | |
176 | + | |
177 | +void test_3( char *vec_name, char * ref_name) // negative rounding | |
178 | +{ | |
179 | + std::ofstream vec; vec.open(vec_name); | |
180 | + std::ofstream ref; ref.open(ref_name); | |
181 | + | |
182 | + // reset | |
183 | + test_async_13bit(vec, ref, -23, -24, 16, 64, 1, 0 ); // x, angle, p, q, reset, clk // | |
184 | + | |
185 | + // negative rounding | |
186 | + test_async_13bit(vec, ref, -23, -24, 16, 64, 0, 0 ); // x, angle, p, q, reset, clk // | |
187 | + test_async_13bit(vec, ref, -23, -24, 16, 64, 0, 1 ); // x, angle, p, q, reset, clk // | |
188 | + test_async_13bit(vec, ref, -23, -24, 16, 64, 0, 1 ); // x, angle, p, q, reset, clk // | |
189 | + test_async_13bit(vec, ref, -23, -24, 16, 64, 0, 0 ); // x, angle, p, q, reset, clk // | |
190 | + | |
191 | + test_async_13bit(vec, ref, -23, -24, 31, 64, 0, 0 ); // x, angle, p, q, reset, clk // same with above when truncated, +1 when rounding | |
192 | + test_async_13bit(vec, ref, -23, -24, 31, 64, 0, 1 ); // x, angle, p, q, reset, clk | |
193 | + test_async_13bit(vec, ref, -23, -24, 31, 64, 0, 1 ); // x, angle, p, q, reset, clk | |
194 | + test_async_13bit(vec, ref, -23, -24, 31, 64, 0, 0 ); // x, angle, p, q, reset, clk | |
195 | +} | |
196 | + | |
197 | + | |
198 | +void test_4( char *vec_name, char * ref_name) // async reset | |
199 | +{ | |
200 | + std::ofstream vec; vec.open(vec_name); | |
201 | + std::ofstream ref; ref.open(ref_name); | |
202 | + | |
203 | + test_async_11bit(vec, ref, 23, 0, 500, 230, 1, 0 ); // x, angle, p, q, reset, clk | |
204 | + test_async_11bit(vec, ref, 23, 0, 500, 20, 1, 1 ); // x, angle, p, q, reset, clk | |
205 | + test_async_11bit(vec, ref, 23, 25, 500, 20, 1, 0 ); // x, angle, p, q, reset, clk | |
206 | + test_async_11bit(vec, ref, 23, 0, 500, 230, 0, 0 ); // x, angle, p, q, reset, clk | |
207 | + test_async_11bit(vec, ref, 23, 0, 500, 230, 0, 1 ); // x, angle, p, q, reset, clk | |
208 | + test_async_11bit(vec, ref, 23, 0, 430, 75, 0, 0 ); // x, angle, p, q, reset, clk | |
209 | + test_async_11bit(vec, ref, 23, 0, 430, 75, 1, 0 ); // x, angle, p, q, reset, clk | |
210 | + test_async_11bit(vec, ref, 23, 0, 430, 75, 0, 0 ); // x, angle, p, q, reset, clk | |
211 | + test_async_11bit(vec, ref, 23, 0, 430, 75, 0, 1 ); // x, angle, p, q, reset, clk | |
212 | + test_async_11bit(vec, ref, 23, 0, 430, 75, 1, 1 ); // x, angle, p, q, reset, clk | |
213 | + test_async_11bit(vec, ref, 23, 0, 430, 75, 0, 1 ); // x, angle, p, q, reset, clk | |
214 | + test_async_11bit(vec, ref, 23, 32, 430, 75, 0, 0 ); // x, angle, p, q, reset, clk | |
215 | + test_async_11bit(vec, ref, 23, 32, 430, 75, 0, 1 ); // x, angle, p, q, reset, clk | |
216 | +} | |
217 | + | |
218 | +void test_5( char *vec_name, char * ref_name) // test of completely same timing signal change with clock | |
219 | +{ | |
220 | + std::ofstream vec; vec.open(vec_name); | |
221 | + std::ofstream ref; ref.open(ref_name); | |
222 | + | |
223 | + // reset | |
224 | + test_async_13bit(vec, ref, 23, 0, 16, 64, 1, 0 ); // x, angle, p, q, reset, clk | |
225 | + | |
226 | + // positive rounding | |
227 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 0 ); // x, angle, p, q, reset, clk | |
228 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk | |
229 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk | |
230 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 0 ); // x, angle, p, q, reset, clk | |
231 | + | |
232 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 0 ); // x, angle, p, q, reset, clk | |
233 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 1 ); // x, angle, p, q, reset, clk | |
234 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 1 ); // x, angle, p, q, reset, clk | |
235 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 0 ); // x, angle, p, q, reset, clk | |
236 | + | |
237 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 0 ); // x, angle, p, q, reset, clk | |
238 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk | |
239 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk | |
240 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 0 ); // x, angle, p, q, reset, clk | |
241 | + | |
242 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 0 ); // x, angle, p, q, reset, clk | |
243 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 1 ); // x, angle, p, q, reset, clk | |
244 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 1 ); // x, angle, p, q, reset, clk | |
245 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 0 ); // x, angle, p, q, reset, clk | |
246 | + | |
247 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 0 ); // x, angle, p, q, reset, clk | |
248 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk | |
249 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk | |
250 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 0 ); // x, angle, p, q, reset, clk | |
251 | + | |
252 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 0 ); // x, angle, p, q, reset, clk | |
253 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 1 ); // x, angle, p, q, reset, clk | |
254 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 1 ); // x, angle, p, q, reset, clk | |
255 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 0 ); // x, angle, p, q, reset, clk | |
256 | + | |
257 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 0 ); // x, angle, p, q, reset, clk | |
258 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk | |
259 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk | |
260 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 0 ); // x, angle, p, q, reset, clk | |
261 | + | |
262 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 0 ); // x, angle, p, q, reset, clk | |
263 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 1 ); // x, angle, p, q, reset, clk | |
264 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 1 ); // x, angle, p, q, reset, clk | |
265 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 0 ); // x, angle, p, q, reset, clk | |
266 | + | |
267 | +} | |
268 | + | |
269 | + | |
270 | + | |
271 | +/***************************************************************** | |
272 | + * | |
273 | + * SINCOS vector generation | |
274 | + * | |
275 | + *****************************************************************/ | |
276 | + | |
277 | + | |
278 | +void test_100( char *vec_name, char * ref_name, int num_stages) | |
279 | +{ | |
280 | + std::ofstream vec; vec.open(vec_name); | |
281 | + std::ofstream ref; ref.open(ref_name); | |
282 | + | |
283 | + int x = 0; | |
284 | + | |
285 | + // reset | |
286 | + cordic_sincos_bw32( vec, ref, num_stages, x, 1, 0 ); | |
287 | + | |
288 | + // scan [-0.5, 0.5) | |
289 | + // scan [-0.5, 0.5) | |
290 | + for ( int i = -128; i < 127; i++ ) | |
291 | + { | |
292 | + x = i << 23; | |
293 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); | |
294 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); | |
295 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); | |
296 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); | |
297 | + } | |
298 | + | |
299 | + // flush pipeline | |
300 | + for ( int i = 0; i < num_stages; i++ ) | |
301 | + { | |
302 | + x = i << 16; | |
303 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); | |
304 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); | |
305 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); | |
306 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); | |
307 | + } | |
308 | +} | |
309 | + | |
310 | +void test_101( char *vec_name, char * ref_name, int num_stages) | |
311 | +{ | |
312 | + std::ofstream vec; vec.open(vec_name); | |
313 | + std::ofstream ref; ref.open(ref_name); | |
314 | + | |
315 | + int x = 0; | |
316 | + | |
317 | + // reset | |
318 | + cordic_sincos_bw32( vec, ref, num_stages, x, 1, 0 ); | |
319 | + | |
320 | + // scan [-0.5, 0.5) | |
321 | + // scan [-0.5, 0.5) | |
322 | + for ( int i = -128; i < 127; i++ ) | |
323 | + { | |
324 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); | |
325 | + x = i << 23; | |
326 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); | |
327 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); | |
328 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); | |
329 | + } | |
330 | + | |
331 | + // flush pipeline | |
332 | + for ( int i = 0; i < num_stages; i++ ) | |
333 | + { | |
334 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); | |
335 | + x = i << 16; | |
336 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); | |
337 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); | |
338 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); | |
339 | + } | |
340 | +} | |
341 | + | |
342 | +/***************************************************************** | |
343 | + * | |
344 | + * SINCOS SUB Low level Test | |
345 | + * | |
346 | + *****************************************************************/ | |
347 | + | |
348 | + | |
349 | +void test_async_9bit( std::ostream &vec, std::ostream &ref, int x, int angle, int p, int q, int reset, int clk) | |
350 | +{ | |
351 | +#ifdef BITWIDTH | |
352 | +#undef BITWIDTH | |
353 | +#undef SHIFT | |
354 | +#undef ANGLEDELTA | |
355 | +#endif | |
356 | + | |
357 | +#define BITWIDTH 9 | |
358 | +#define SHIFT 3 | |
359 | +#define ANGLEDELTA 31 | |
360 | + | |
361 | + static int out_angle = 0, out_q = 0, last_p = 0 , last_x = 0; | |
362 | + static vhdl::sincos_sub sincos_sub_module; | |
363 | + | |
364 | + vec << std::bitset<1>(reset) << " " | |
365 | + << std::bitset<1>(clk) << " " | |
366 | + << std::bitset<BITWIDTH>(x) << " " | |
367 | + << std::bitset<BITWIDTH>(angle) << " " | |
368 | + << std::bitset<BITWIDTH>(p) << " " | |
369 | + << std::bitset<BITWIDTH>(q) << std::endl; | |
370 | + | |
371 | + sincos_sub_module.run( SHIFT, ANGLEDELTA, clk, reset, x, last_x, angle, out_angle, p, last_p, q, out_q ); | |
372 | + | |
373 | + ref << std::bitset<BITWIDTH>( last_x ) << " " | |
374 | + << std::bitset<BITWIDTH>( out_angle ) << " " | |
375 | + << std::bitset<BITWIDTH>( last_p ) << " " | |
376 | + << std::bitset<BITWIDTH>( out_q ) << std::endl; | |
377 | + | |
378 | +} | |
379 | + | |
380 | +void test_async_13bit( std::ostream &vec, std::ostream &ref, int x, int angle, int p, int q, int reset, int clk) | |
381 | +{ | |
382 | +#ifdef BITWIDTH | |
383 | +#undef BITWIDTH | |
384 | +#undef SHIFT | |
385 | +#undef ANGLEDELTA | |
386 | +#endif | |
387 | + | |
388 | +#define BITWIDTH 13 | |
389 | +#define SHIFT 4 | |
390 | +#define ANGLEDELTA 65 | |
391 | + | |
392 | + int out_angle = 0, out_q = 0, last_p = 0 , last_x = 0; | |
393 | + static vhdl::sincos_sub sincos_sub_module; | |
394 | + | |
395 | + vec << std::bitset<1>(reset) << " " | |
396 | + << std::bitset<1>(clk) << " " | |
397 | + << std::bitset<BITWIDTH>(x) << " " | |
398 | + << std::bitset<BITWIDTH>(angle) << " " | |
399 | + << std::bitset<BITWIDTH>(p) << " " | |
400 | + << std::bitset<BITWIDTH>(q) << std::endl; | |
401 | + | |
402 | + sincos_sub_module.run( SHIFT, ANGLEDELTA, clk, reset, x, last_x, angle, out_angle, p, last_p, q, out_q ); | |
403 | + | |
404 | + ref << std::bitset<BITWIDTH>( last_x ) << " " | |
405 | + << std::bitset<BITWIDTH>( out_angle ) << " " | |
406 | + << std::bitset<BITWIDTH>( last_p ) << " " | |
407 | + << std::bitset<BITWIDTH>( out_q ) << std::endl; | |
408 | + | |
409 | +} | |
410 | + | |
411 | +void test_async_11bit( std::ostream &vec, std::ostream &ref, int x, int angle, int p, int q, int reset, int clk) | |
412 | +{ | |
413 | +#ifdef BITWIDTH | |
414 | +#undef BITWIDTH | |
415 | +#undef SHIFT | |
416 | +#undef ANGLEDELTA | |
417 | +#endif | |
418 | + | |
419 | +#define BITWIDTH 11 | |
420 | +#define SHIFT 2 | |
421 | +#define ANGLEDELTA 65 | |
422 | + | |
423 | + int out_angle = 0, out_q = 0, out_p = 0 , out_x = 0; | |
424 | + static vhdl::sincos_sub sincos_sub_module; | |
425 | + | |
426 | + vec << std::bitset<1>(reset) << " " | |
427 | + << std::bitset<1>(clk) << " " | |
428 | + << std::bitset<BITWIDTH>(x) << " " | |
429 | + << std::bitset<BITWIDTH>(angle) << " " | |
430 | + << std::bitset<BITWIDTH>(p) << " " | |
431 | + << std::bitset<BITWIDTH>(q) << std::endl; | |
432 | + | |
433 | + sincos_sub_module.run( SHIFT, ANGLEDELTA, clk, reset, x, out_x, angle, out_angle, p, out_p, q, out_q ); | |
434 | + | |
435 | + ref << std::bitset<BITWIDTH>( out_x ) << " " | |
436 | + << std::bitset<BITWIDTH>( out_angle ) << " " | |
437 | + << std::bitset<BITWIDTH>( out_p ) << " " | |
438 | + << std::bitset<BITWIDTH>( out_q ) << std::endl; | |
439 | + | |
440 | +} | |
441 | + | |
442 | +/***************************************************************** | |
443 | + * | |
444 | + * SINCOS Low level Test | |
445 | + * | |
446 | + *****************************************************************/ | |
447 | + | |
448 | +/** | |
449 | + * \brief sincos CORDIC algorithm. | |
450 | + * \param x | |
451 | + * \param p | |
452 | + * \param q | |
453 | + * \param num_stages | |
454 | + * \param bit_width | |
455 | + */ | |
456 | +void cordic_sincos_bw32( std::ostream &vec, std::ostream &ref, int num_stages, int x, int reset, int clk ) | |
457 | +{ | |
458 | +#ifdef BITWIDTH | |
459 | +#undef BITWIDTH | |
460 | +#endif | |
461 | + | |
462 | +#define BITWIDTH 32 | |
463 | + | |
464 | +int out_p, out_q; | |
465 | + | |
466 | +static vhdl::sincos_cordic cordic; | |
467 | + | |
468 | + | |
469 | +vec | |
470 | + << std::bitset<1>( reset ) << " " // reset | |
471 | + << std::bitset<1>( clk ) << " " // clock | |
472 | + << std::bitset<BITWIDTH>( x ) << std::endl; | |
473 | + | |
474 | +cordic.run( 20, clk, reset, x, out_p, out_q ); | |
475 | + | |
476 | +ref | |
477 | + << std::bitset<BITWIDTH>( out_p ) << " " | |
478 | + << std::bitset<BITWIDTH>( out_q ) << std::endl; | |
479 | + | |
480 | +} |
@@ -0,0 +1,484 @@ | ||
1 | +/** | |
2 | + * \file main.cpp | |
3 | + * | |
4 | + * \date 2016/10/01 | |
5 | + * \author: takemasa | |
6 | + * \brief Test vector Generator for cordic_sincos VHDL project | |
7 | + */ | |
8 | + | |
9 | +#include <iostream> | |
10 | +#include <bitset> | |
11 | +#include <string> | |
12 | +#include <cmath> | |
13 | + | |
14 | +#include <fstream> // ifstream, ofstream | |
15 | + | |
16 | +#include "main.h" | |
17 | + | |
18 | +/** | |
19 | + * \bfief main function | |
20 | + */ | |
21 | + | |
22 | +int main() { | |
23 | + | |
24 | + | |
25 | + char filename_vector_0[] = "fileout/sincossub_0.vec.txt"; | |
26 | + char filename_reference_0[] = "fileout/sincossub_0.ref.txt"; | |
27 | + | |
28 | + char filename_vector_1[] = "fileout/sincossub_1.vec.txt"; | |
29 | + char filename_reference_1[] = "fileout/sincossub_1.ref.txt"; | |
30 | + | |
31 | + char filename_vector_2[] = "fileout/sincossub_2.vec.txt"; | |
32 | + char filename_reference_2[] = "fileout/sincossub_2.ref.txt"; | |
33 | + | |
34 | + char filename_vector_3[] = "fileout/sincossub_3.vec.txt"; | |
35 | + char filename_reference_3[] = "fileout/sincossub_3.ref.txt"; | |
36 | + | |
37 | + char filename_vector_4[] = "fileout/sincossub_4.vec.txt"; | |
38 | + char filename_reference_4[] = "fileout/sincossub_4.ref.txt"; | |
39 | + | |
40 | + char filename_vector_5[] = "fileout/sincossub_5.vec.txt"; | |
41 | + char filename_reference_5[] = "fileout/sincossub_5.ref.txt"; | |
42 | + | |
43 | + char filename_angle_delta[] = "fileout/sincos_angle_delta.txt"; | |
44 | + char filename_scaling_factor[] = "fileout/sincos_scaling_factor.txt"; | |
45 | + | |
46 | + char filename_vector_100[] = "fileout/sincos_100.vec.txt"; | |
47 | + char filename_reference_100[] = "fileout/sincos_100.ref.txt"; | |
48 | + | |
49 | + char filename_vector_101[] = "fileout/sincos_101.vec.txt"; | |
50 | + char filename_reference_101[] = "fileout/sincos_101.ref.txt"; | |
51 | + | |
52 | + // positive x, | |
53 | + test_0( filename_vector_0, filename_reference_0); | |
54 | + | |
55 | + // negative x | |
56 | + test_1( filename_vector_1, filename_reference_1); | |
57 | + | |
58 | + //positive x, rounding up | |
59 | + test_2( filename_vector_2, filename_reference_2); | |
60 | + | |
61 | + // negative x rouding up | |
62 | + test_3( filename_vector_3, filename_reference_3); | |
63 | + | |
64 | + // positive x, async reset test | |
65 | + test_4( filename_vector_4, filename_reference_4); | |
66 | + | |
67 | + // positive x, async reset test | |
68 | + test_5( filename_vector_5, filename_reference_5); | |
69 | + | |
70 | +gen_table( filename_angle_delta, filename_scaling_factor); | |
71 | + | |
72 | + | |
73 | + test_100( filename_vector_100, filename_reference_100, 20 ); | |
74 | + | |
75 | + // test signal and clock changes simul. | |
76 | + test_101( filename_vector_101, filename_reference_101, 20 ); | |
77 | + | |
78 | + | |
79 | +} | |
80 | + | |
81 | + /** | |
82 | + * \brief shift rith arithmetic with rounding. | |
83 | + */ | |
84 | +int round_shift( int operand, int shift) | |
85 | +{ | |
86 | + if (shift > 0) | |
87 | + return ( operand + (1<<(shift-1)) ) >> shift ; | |
88 | + else | |
89 | + return operand; | |
90 | +} | |
91 | + | |
92 | + | |
93 | +void gen_table( const char * filename_angle_delta, const char * filename_scaling_factor) | |
94 | +{ | |
95 | + std::ofstream angle_delta; angle_delta.open(filename_angle_delta); | |
96 | + std::ofstream scaling_factor; scaling_factor.open(filename_scaling_factor); | |
97 | + | |
98 | + vhdl::sincos_angle_delta ad; | |
99 | + vhdl::sincos_scaling_factor sf; | |
100 | + | |
101 | + // Initialize the scaling factor and angle delta table. | |
102 | + for ( int i = 0; i<vhdl::angle_delta_table_size; i++ ) | |
103 | + { | |
104 | + // output to the file | |
105 | + scaling_factor << std::bitset<32>( sf.table[i] ) << std::endl; | |
106 | + | |
107 | + // output to the file | |
108 | + angle_delta << std::bitset<32>( ad.table[i] ) << std::endl; | |
109 | + } | |
110 | +} | |
111 | + | |
112 | +/***************************************************************** | |
113 | + * | |
114 | + * SINCOS SUB vector generation | |
115 | + * | |
116 | + *****************************************************************/ | |
117 | + | |
118 | + | |
119 | +void test_0( char *vec_name, char * ref_name) // positive rounding | |
120 | +{ | |
121 | + std::ofstream vec; vec.open(vec_name); | |
122 | + std::ofstream ref; ref.open(ref_name); | |
123 | + // reset | |
124 | + test_async_9bit(vec, ref, 23, 0, 60, 10, 1, 0); // x, angle, p, q, reset, clk // CCW | |
125 | + | |
126 | + // positive rounding | |
127 | + test_async_9bit(vec, ref, 23, 0, 60, 10, 0, 0); // x, angle, p, q, reset, clk // CCW | |
128 | + test_async_9bit(vec, ref, 23, 0, 60, 10, 0, 1); // x, angle, p, q, reset, clk // CCW | |
129 | + test_async_9bit(vec, ref, 23, 0, 60, 10, 0, 1); // x, angle, p, q, reset, clk // CCW | |
130 | + test_async_9bit(vec, ref, 23, 0, 60, 10, 0, 0); // x, angle, p, q, reset, clk // CCW | |
131 | + | |
132 | + test_async_9bit(vec, ref, 23, 24, 60, 10, 0, 0); // x, angle, p, q, reset, clk // CW | |
133 | + test_async_9bit(vec, ref, 23, 24, 60, 10, 0, 1); // x, angle, p, q, reset, clk // CW | |
134 | + test_async_9bit(vec, ref, 23, 24, 60, 10, 0, 1); // x, angle, p, q, reset, clk // CW | |
135 | + test_async_9bit(vec, ref, 23, 24, 60, 10, 0, 0); // x, angle, p, q, reset, clk // CW | |
136 | +} | |
137 | + | |
138 | +void test_1( char *vec_name, char * ref_name) // positive no rounding | |
139 | +{ | |
140 | + std::ofstream vec; vec.open(vec_name); | |
141 | + std::ofstream ref; ref.open(ref_name); | |
142 | + // reset | |
143 | + test_async_9bit(vec, ref, -23, 0, 60, -10, 1, 0); // x, angle, p, q, reset, clk // CW | |
144 | + | |
145 | + // positive no roundingb | |
146 | + test_async_9bit(vec, ref, -23, 0, 60, -10, 0, 0); // x, angle, p, q, reset, clk // CW | |
147 | + test_async_9bit(vec, ref, -23, 0, 60, -10, 0, 1); // x, angle, p, q, reset, clk // CW | |
148 | + test_async_9bit(vec, ref, -23, 0, 60, -10, 0, 1); // x, angle, p, q, reset, clk // CW | |
149 | + test_async_9bit(vec, ref, -23, 0, 60, -10, 0, 0); // x, angle, p, q, reset, clk // CW | |
150 | + | |
151 | + test_async_9bit(vec, ref, -23, -24, 60, -10, 0, 0); // x, angle, p, q, reset, clk // CCW | |
152 | + test_async_9bit(vec, ref, -23, -24, 60, -10, 0, 1); // x, angle, p, q, reset, clk // CCW | |
153 | + test_async_9bit(vec, ref, -23, -24, 60, -10, 0, 1); // x, angle, p, q, reset, clk // CCW | |
154 | + test_async_9bit(vec, ref, -23, -24, 60, -10, 0, 0); // x, angle, p, q, reset, clk // CCW | |
155 | + | |
156 | +} | |
157 | + | |
158 | +void test_2( char *vec_name, char * ref_name) // positive rounding | |
159 | +{ | |
160 | + std::ofstream vec; vec.open(vec_name); | |
161 | + std::ofstream ref; ref.open(ref_name); | |
162 | + // reset | |
163 | + test_async_13bit(vec, ref, 23, 0, 16, 64, 1, 0 ); // x, angle, p, q, reset, clk | |
164 | + | |
165 | + // positive rounding | |
166 | + test_async_13bit(vec, ref, 23, 0, 16, 64, 0, 0 ); // x, angle, p, q, reset, clk | |
167 | + test_async_13bit(vec, ref, 23, 0, 16, 64, 0, 1 ); // x, angle, p, q, reset, clk | |
168 | + test_async_13bit(vec, ref, 23, 0, 16, 64, 0, 1 ); // x, angle, p, q, reset, clk | |
169 | + test_async_13bit(vec, ref, 23, 0, 16, 64, 0, 0 ); // x, angle, p, q, reset, clk | |
170 | + | |
171 | + test_async_13bit(vec, ref, 23, 0, 31, 64, 0, 0 ); // x, angle, p, q, reset, clk // same with above when truncated, +1 when rounding | |
172 | + test_async_13bit(vec, ref, 23, 0, 31, 64, 0, 1 ); // x, angle, p, q, reset, clk | |
173 | + test_async_13bit(vec, ref, 23, 0, 31, 64, 0, 1 ); // x, angle, p, q, reset, clk | |
174 | + test_async_13bit(vec, ref, 23, 0, 31, 64, 0, 0 ); // x, angle, p, q, reset, clk | |
175 | +} | |
176 | + | |
177 | +void test_3( char *vec_name, char * ref_name) // negative rounding | |
178 | +{ | |
179 | + std::ofstream vec; vec.open(vec_name); | |
180 | + std::ofstream ref; ref.open(ref_name); | |
181 | + | |
182 | + // reset | |
183 | + test_async_13bit(vec, ref, -23, -24, 16, 64, 1, 0 ); // x, angle, p, q, reset, clk // | |
184 | + | |
185 | + // negative rounding | |
186 | + test_async_13bit(vec, ref, -23, -24, 16, 64, 0, 0 ); // x, angle, p, q, reset, clk // | |
187 | + test_async_13bit(vec, ref, -23, -24, 16, 64, 0, 1 ); // x, angle, p, q, reset, clk // | |
188 | + test_async_13bit(vec, ref, -23, -24, 16, 64, 0, 1 ); // x, angle, p, q, reset, clk // | |
189 | + test_async_13bit(vec, ref, -23, -24, 16, 64, 0, 0 ); // x, angle, p, q, reset, clk // | |
190 | + | |
191 | + test_async_13bit(vec, ref, -23, -24, 31, 64, 0, 0 ); // x, angle, p, q, reset, clk // same with above when truncated, +1 when rounding | |
192 | + test_async_13bit(vec, ref, -23, -24, 31, 64, 0, 1 ); // x, angle, p, q, reset, clk | |
193 | + test_async_13bit(vec, ref, -23, -24, 31, 64, 0, 1 ); // x, angle, p, q, reset, clk | |
194 | + test_async_13bit(vec, ref, -23, -24, 31, 64, 0, 0 ); // x, angle, p, q, reset, clk | |
195 | +} | |
196 | + | |
197 | + | |
198 | +void test_4( char *vec_name, char * ref_name) // async reset | |
199 | +{ | |
200 | + std::ofstream vec; vec.open(vec_name); | |
201 | + std::ofstream ref; ref.open(ref_name); | |
202 | + | |
203 | + test_async_11bit(vec, ref, 23, 0, 500, 230, 1, 0 ); // x, angle, p, q, reset, clk | |
204 | + test_async_11bit(vec, ref, 23, 0, 500, 20, 1, 1 ); // x, angle, p, q, reset, clk | |
205 | + test_async_11bit(vec, ref, 23, 25, 500, 20, 1, 0 ); // x, angle, p, q, reset, clk | |
206 | + test_async_11bit(vec, ref, 23, 0, 500, 230, 0, 0 ); // x, angle, p, q, reset, clk | |
207 | + test_async_11bit(vec, ref, 23, 0, 500, 230, 0, 1 ); // x, angle, p, q, reset, clk | |
208 | + test_async_11bit(vec, ref, 23, 0, 430, 75, 0, 0 ); // x, angle, p, q, reset, clk | |
209 | + test_async_11bit(vec, ref, 23, 0, 430, 75, 1, 0 ); // x, angle, p, q, reset, clk | |
210 | + test_async_11bit(vec, ref, 23, 0, 430, 75, 0, 0 ); // x, angle, p, q, reset, clk | |
211 | + test_async_11bit(vec, ref, 23, 0, 430, 75, 0, 1 ); // x, angle, p, q, reset, clk | |
212 | + test_async_11bit(vec, ref, 23, 0, 430, 75, 1, 1 ); // x, angle, p, q, reset, clk | |
213 | + test_async_11bit(vec, ref, 23, 0, 430, 75, 0, 1 ); // x, angle, p, q, reset, clk | |
214 | + test_async_11bit(vec, ref, 23, 32, 430, 75, 0, 0 ); // x, angle, p, q, reset, clk | |
215 | + test_async_11bit(vec, ref, 23, 32, 430, 75, 0, 1 ); // x, angle, p, q, reset, clk | |
216 | +} | |
217 | + | |
218 | +void test_5( char *vec_name, char * ref_name) // test of completely same timing signal change with clock | |
219 | +{ | |
220 | + std::ofstream vec; vec.open(vec_name); | |
221 | + std::ofstream ref; ref.open(ref_name); | |
222 | + | |
223 | + // reset | |
224 | + test_async_13bit(vec, ref, 23, 0, 16, 64, 1, 0 ); // x, angle, p, q, reset, clk | |
225 | + | |
226 | + // positive rounding | |
227 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 0 ); // x, angle, p, q, reset, clk | |
228 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk | |
229 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk | |
230 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 0 ); // x, angle, p, q, reset, clk | |
231 | + | |
232 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 0 ); // x, angle, p, q, reset, clk | |
233 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 1 ); // x, angle, p, q, reset, clk | |
234 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 1 ); // x, angle, p, q, reset, clk | |
235 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 0 ); // x, angle, p, q, reset, clk | |
236 | + | |
237 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 0 ); // x, angle, p, q, reset, clk | |
238 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk | |
239 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk | |
240 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 0 ); // x, angle, p, q, reset, clk | |
241 | + | |
242 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 0 ); // x, angle, p, q, reset, clk | |
243 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 1 ); // x, angle, p, q, reset, clk | |
244 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 1 ); // x, angle, p, q, reset, clk | |
245 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 0 ); // x, angle, p, q, reset, clk | |
246 | + | |
247 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 0 ); // x, angle, p, q, reset, clk | |
248 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk | |
249 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk | |
250 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 0 ); // x, angle, p, q, reset, clk | |
251 | + | |
252 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 0 ); // x, angle, p, q, reset, clk | |
253 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 1 ); // x, angle, p, q, reset, clk | |
254 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 1 ); // x, angle, p, q, reset, clk | |
255 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 0 ); // x, angle, p, q, reset, clk | |
256 | + | |
257 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 0 ); // x, angle, p, q, reset, clk | |
258 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk | |
259 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk | |
260 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 0 ); // x, angle, p, q, reset, clk | |
261 | + | |
262 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 0 ); // x, angle, p, q, reset, clk | |
263 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 1 ); // x, angle, p, q, reset, clk | |
264 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 1 ); // x, angle, p, q, reset, clk | |
265 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 0 ); // x, angle, p, q, reset, clk | |
266 | + | |
267 | +} | |
268 | + | |
269 | + | |
270 | + | |
271 | +/***************************************************************** | |
272 | + * | |
273 | + * SINCOS vector generation | |
274 | + * | |
275 | + *****************************************************************/ | |
276 | + | |
277 | + | |
278 | +void test_100( char *vec_name, char * ref_name ) | |
279 | +{ | |
280 | + std::ofstream vec; vec.open(vec_name); | |
281 | + std::ofstream ref; ref.open(ref_name); | |
282 | + | |
283 | + | |
284 | + const int num_stages = 20; | |
285 | + int x = 0; | |
286 | + | |
287 | + // reset | |
288 | + cordic_sincos_bw32( vec, ref, num_stages, x, 1, 0 ); | |
289 | + | |
290 | + // scan [-0.5, 0.5) | |
291 | + // scan [-0.5, 0.5) | |
292 | + for ( int i = -128; i < 127; i++ ) | |
293 | + { | |
294 | + x = i << 23; | |
295 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); | |
296 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); | |
297 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); | |
298 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); | |
299 | + } | |
300 | + | |
301 | + // flush pipeline | |
302 | + for ( int i = 0; i < num_stages; i++ ) | |
303 | + { | |
304 | + x = i << 16; | |
305 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); | |
306 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); | |
307 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); | |
308 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); | |
309 | + } | |
310 | +} | |
311 | + | |
312 | +void test_101( char *vec_name, char * ref_name, int num_stages) | |
313 | +{ | |
314 | + std::ofstream vec; vec.open(vec_name); | |
315 | + std::ofstream ref; ref.open(ref_name); | |
316 | + | |
317 | + int x = 0; | |
318 | + | |
319 | + // reset | |
320 | + cordic_sincos_bw32_3stages( vec, ref, num_stages, x, 1, 0 ); | |
321 | + | |
322 | + // | |
323 | + for ( int i = -3; i < 2; i++ ) | |
324 | + { | |
325 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); | |
326 | + x = i << 23; | |
327 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); | |
328 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); | |
329 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); | |
330 | + } | |
331 | + | |
332 | + // flush pipeline | |
333 | + for ( int i = 0; i < num_stages+2; i++ ) | |
334 | + { | |
335 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); | |
336 | + x = 0; | |
337 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); | |
338 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); | |
339 | + cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); | |
340 | + } | |
341 | +} | |
342 | + | |
343 | +/***************************************************************** | |
344 | + * | |
345 | + * SINCOS SUB Low level Test | |
346 | + * | |
347 | + *****************************************************************/ | |
348 | + | |
349 | + | |
350 | +void test_async_9bit( std::ostream &vec, std::ostream &ref, int x, int angle, int p, int q, int reset, int clk) | |
351 | +{ | |
352 | +#ifdef BITWIDTH | |
353 | +#undef BITWIDTH | |
354 | +#undef SHIFT | |
355 | +#undef ANGLEDELTA | |
356 | +#endif | |
357 | + | |
358 | +#define BITWIDTH 9 | |
359 | +#define SHIFT 3 | |
360 | +#define ANGLEDELTA 31 | |
361 | + | |
362 | + static int out_angle = 0, out_q = 0, last_p = 0 , last_x = 0; | |
363 | + static vhdl::sincos_sub sincos_sub_module; | |
364 | + | |
365 | + vec << std::bitset<1>(reset) << " " | |
366 | + << std::bitset<1>(clk) << " " | |
367 | + << std::bitset<BITWIDTH>(x) << " " | |
368 | + << std::bitset<BITWIDTH>(angle) << " " | |
369 | + << std::bitset<BITWIDTH>(p) << " " | |
370 | + << std::bitset<BITWIDTH>(q) << std::endl; | |
371 | + | |
372 | + sincos_sub_module.run( SHIFT, ANGLEDELTA, clk, reset, x, last_x, angle, out_angle, p, last_p, q, out_q ); | |
373 | + | |
374 | + ref << std::bitset<BITWIDTH>( last_x ) << " " | |
375 | + << std::bitset<BITWIDTH>( out_angle ) << " " | |
376 | + << std::bitset<BITWIDTH>( last_p ) << " " | |
377 | + << std::bitset<BITWIDTH>( out_q ) << std::endl; | |
378 | + | |
379 | +} | |
380 | + | |
381 | +void test_async_13bit( std::ostream &vec, std::ostream &ref, int x, int angle, int p, int q, int reset, int clk) | |
382 | +{ | |
383 | +#ifdef BITWIDTH | |
384 | +#undef BITWIDTH | |
385 | +#undef SHIFT | |
386 | +#undef ANGLEDELTA | |
387 | +#endif | |
388 | + | |
389 | +#define BITWIDTH 13 | |
390 | +#define SHIFT 4 | |
391 | +#define ANGLEDELTA 65 | |
392 | + | |
393 | + int out_angle = 0, out_q = 0, last_p = 0 , last_x = 0; | |
394 | + static vhdl::sincos_sub sincos_sub_module; | |
395 | + | |
396 | + vec << std::bitset<1>(reset) << " " | |
397 | + << std::bitset<1>(clk) << " " | |
398 | + << std::bitset<BITWIDTH>(x) << " " | |
399 | + << std::bitset<BITWIDTH>(angle) << " " | |
400 | + << std::bitset<BITWIDTH>(p) << " " | |
401 | + << std::bitset<BITWIDTH>(q) << std::endl; | |
402 | + | |
403 | + sincos_sub_module.run( SHIFT, ANGLEDELTA, clk, reset, x, last_x, angle, out_angle, p, last_p, q, out_q ); | |
404 | + | |
405 | + ref << std::bitset<BITWIDTH>( last_x ) << " " | |
406 | + << std::bitset<BITWIDTH>( out_angle ) << " " | |
407 | + << std::bitset<BITWIDTH>( last_p ) << " " | |
408 | + << std::bitset<BITWIDTH>( out_q ) << std::endl; | |
409 | + | |
410 | +} | |
411 | + | |
412 | +void test_async_11bit( std::ostream &vec, std::ostream &ref, int x, int angle, int p, int q, int reset, int clk) | |
413 | +{ | |
414 | +#ifdef BITWIDTH | |
415 | +#undef BITWIDTH | |
416 | +#undef SHIFT | |
417 | +#undef ANGLEDELTA | |
418 | +#endif | |
419 | + | |
420 | +#define BITWIDTH 11 | |
421 | +#define SHIFT 2 | |
422 | +#define ANGLEDELTA 65 | |
423 | + | |
424 | + int out_angle = 0, out_q = 0, out_p = 0 , out_x = 0; | |
425 | + static vhdl::sincos_sub sincos_sub_module; | |
426 | + | |
427 | + vec << std::bitset<1>(reset) << " " | |
428 | + << std::bitset<1>(clk) << " " | |
429 | + << std::bitset<BITWIDTH>(x) << " " | |
430 | + << std::bitset<BITWIDTH>(angle) << " " | |
431 | + << std::bitset<BITWIDTH>(p) << " " | |
432 | + << std::bitset<BITWIDTH>(q) << std::endl; | |
433 | + | |
434 | + sincos_sub_module.run( SHIFT, ANGLEDELTA, clk, reset, x, out_x, angle, out_angle, p, out_p, q, out_q ); | |
435 | + | |
436 | + ref << std::bitset<BITWIDTH>( out_x ) << " " | |
437 | + << std::bitset<BITWIDTH>( out_angle ) << " " | |
438 | + << std::bitset<BITWIDTH>( out_p ) << " " | |
439 | + << std::bitset<BITWIDTH>( out_q ) << std::endl; | |
440 | + | |
441 | +} | |
442 | + | |
443 | +/***************************************************************** | |
444 | + * | |
445 | + * SINCOS Low level Test | |
446 | + * | |
447 | + *****************************************************************/ | |
448 | + | |
449 | +/** | |
450 | + * \brief sincos CORDIC algorithm. | |
451 | + * \param x | |
452 | + * \param p | |
453 | + * \param q | |
454 | + * \param num_stages | |
455 | + * \param bit_width | |
456 | + */ | |
457 | +void cordic_sincos_bw32( std::ostream &vec, std::ostream &ref, int num_stages, int x, int reset, int clk ) | |
458 | +{ | |
459 | +#ifdef BITWIDTH | |
460 | +#undef BITWIDTH | |
461 | +#endif | |
462 | + | |
463 | +#define BITWIDTH 32 | |
464 | + | |
465 | +int out_p, out_q; | |
466 | + | |
467 | +static vhdl::sincos_cordic cordic; | |
468 | + | |
469 | + | |
470 | +vec | |
471 | + << std::bitset<1>( reset ) << " " // reset | |
472 | + << std::bitset<1>( clk ) << " " // clock | |
473 | + << std::bitset<BITWIDTH>( x ) << std::endl; | |
474 | + | |
475 | +cordic.run( num_stages, clk, reset, x, out_p, out_q ); | |
476 | + | |
477 | +ref | |
478 | + << std::bitset<BITWIDTH>( out_p ) << " " | |
479 | + << std::bitset<BITWIDTH>( out_q ) << std::endl; | |
480 | + | |
481 | +} | |
482 | + | |
483 | + | |
484 | + |
@@ -5,6 +5,6 @@ IMPORT_FILES_AND_FOLDERS_VIRTUAL_FOLDER_MODE=prompt | ||
5 | 5 | PROBLEMS_FILTERS_MIGRATE=true |
6 | 6 | TASKS_FILTERS_MIGRATE=true |
7 | 7 | eclipse.preferences.version=1 |
8 | -platformState=1475306727637 | |
8 | +platformState=1470363830848 | |
9 | 9 | quickStart=false |
10 | 10 | tipsAndTricks=true |
@@ -19,14 +19,15 @@ | ||
19 | 19 | <coolItem id="org.eclipse.search.searchActionSet" itemType="typeToolBarContribution" x="88" y="30"/> |
20 | 20 | <coolItem id="org.eclipse.ui.edit.text.actionSet.presentation" itemType="typeToolBarContribution" x="68" y="30"/> |
21 | 21 | <coolItem id="group.nav" itemType="typeGroupMarker"/> |
22 | -<coolItem id="org.eclipse.ui.workbench.navigate" itemType="typeToolBarContribution" x="232" y="30"/> | |
23 | 22 | <coolItem id="group.editor" itemType="typeGroupMarker"/> |
24 | 23 | <coolItem id="org.eclipse.cdt.make.editor" itemType="typePlaceholder" x="-1" y="-1"/> |
25 | 24 | <coolItem id="org.eclipse.compare.CompareEditor" itemType="typeToolBarContribution" x="96" y="30"/> |
26 | -<coolItem id="org.eclipse.cdt.ui.editor.CEditor" itemType="typePlaceholder" x="-1" y="-1"/> | |
25 | +<coolItem id="org.eclipse.cdt.ui.editor.CEditor" itemType="typeToolBarContribution" x="-1" y="-1"/> | |
27 | 26 | <coolItem id="org.eclipse.ui.DefaultTextEditor" itemType="typeToolBarContribution" x="-1" y="-1"/> |
28 | 27 | <coolItem id="group.help" itemType="typeGroupMarker"/> |
29 | 28 | <coolItem id="org.eclipse.ui.workbench.help" itemType="typeToolBarContribution" x="-1" y="-1"/> |
29 | +<coolItem id="UserSeparator" itemType="typeSeparator"/> | |
30 | +<coolItem id="org.eclipse.ui.workbench.navigate" itemType="typeToolBarContribution" x="232" y="30"/> | |
30 | 31 | </coolbarLayout> |
31 | 32 | <page aggregateWorkingSetId="Aggregate for window 1474028500277" focus="true" label="Workspace - C/C++"> |
32 | 33 | <editors> |
@@ -36,6 +37,14 @@ | ||
36 | 37 | <presentation id="org.eclipse.ui.presentations.WorkbenchPresentationFactory"> |
37 | 38 | <part id="0"/> |
38 | 39 | <part id="1"/> |
40 | +<part id="2"/> | |
41 | +<part id="3"/> | |
42 | +<part id="4"/> | |
43 | +<part id="5"/> | |
44 | +<part id="6"/> | |
45 | +<part id="7"/> | |
46 | +<part id="8"/> | |
47 | +<part id="9"/> | |
39 | 48 | </presentation> |
40 | 49 | </folder> |
41 | 50 | </info> |
@@ -44,9 +53,37 @@ | ||
44 | 53 | <input factoryID="org.eclipse.ui.part.FileEditorInputFactory" path="/cordic_sincos/build"/> |
45 | 54 | <editorState selectionHorizontalPixel="0" selectionLength="0" selectionOffset="425" selectionTopPixel="200"/> |
46 | 55 | </editor> |
47 | -<editor activePart="true" focus="true" id="net.sourceforge.veditor.editor.VhdlEditor" name="sincos_cordic.vhd" partName="sincos_cordic.vhd" path="/home/takemasa/shared_foo/vhdl_my_lib/cordic_sincos/src/sincos_cordic.vhd" title="sincos_cordic.vhd" tooltip="cordic_sincos/src/sincos_cordic.vhd" workbook="DefaultEditorWorkbook"> | |
56 | +<editor id="net.sourceforge.veditor.editor.VhdlEditor" name="sincos_cordic.vhd" partName="sincos_cordic.vhd" path="/home/takemasa/shared_foo/vhdl_my_lib/cordic_sincos/src/sincos_cordic.vhd" title="sincos_cordic.vhd" tooltip="cordic_sincos/src/sincos_cordic.vhd" workbook="DefaultEditorWorkbook"> | |
48 | 57 | <input factoryID="org.eclipse.ui.part.FileEditorInputFactory" path="/cordic_sincos/src/sincos_cordic.vhd"/> |
49 | -<editorState selectionHorizontalPixel="0" selectionLength="0" selectionOffset="3513" selectionTopPixel="884"/> | |
58 | +<editorState selectionHorizontalPixel="0" selectionLength="0" selectionOffset="2646" selectionTopPixel="537"/> | |
59 | +</editor> | |
60 | +<editor id="org.eclipse.cdt.ui.editor.CEditor" name="main.cpp" partName="main.cpp" path="/home/takemasa/shared_foo/vhdl_my_lib/cordic_sincos_testgen/main.cpp" title="main.cpp" tooltip="cordic_sincos_testgen/main.cpp" workbook="DefaultEditorWorkbook"> | |
61 | +<input factoryID="org.eclipse.ui.part.FileEditorInputFactory" path="/cordic_sincos_testgen/main.cpp"/> | |
62 | +<editorState selectionHorizontalPixel="0" selectionLength="0" selectionOffset="12639" selectionTopPixel="3911"/> | |
63 | +</editor> | |
64 | +<editor id="org.eclipse.ui.DefaultTextEditor" name="sincossub_5.vec.txt" partName="sincossub_5.vec.txt" path="/home/takemasa/shared_foo/vhdl_my_lib/cordic_sincos_testgen/fileout/sincossub_5.vec.txt" title="sincossub_5.vec.txt" tooltip="cordic_sincos_testgen/fileout/sincossub_5.vec.txt" workbook="DefaultEditorWorkbook"> | |
65 | +<input factoryID="org.eclipse.ui.part.FileEditorInputFactory" path="/cordic_sincos_testgen/fileout/sincossub_5.vec.txt"/> | |
66 | +<editorState selectionHorizontalPixel="0" selectionLength="0" selectionOffset="119" selectionTopPixel="0"/> | |
67 | +</editor> | |
68 | +<editor id="org.eclipse.ui.DefaultTextEditor" name="sincossub_5.ref.txt" partName="sincossub_5.ref.txt" path="/home/takemasa/shared_foo/vhdl_my_lib/cordic_sincos_testgen/fileout/sincossub_5.ref.txt" title="sincossub_5.ref.txt" tooltip="cordic_sincos_testgen/fileout/sincossub_5.ref.txt" workbook="DefaultEditorWorkbook"> | |
69 | +<input factoryID="org.eclipse.ui.part.FileEditorInputFactory" path="/cordic_sincos_testgen/fileout/sincossub_5.ref.txt"/> | |
70 | +<editorState selectionHorizontalPixel="0" selectionLength="0" selectionOffset="0" selectionTopPixel="0"/> | |
71 | +</editor> | |
72 | +<editor id="org.eclipse.ui.DefaultTextEditor" name="sincos_101.log.txt" partName="sincos_101.log.txt" path="/home/takemasa/shared_foo/vhdl_my_lib/cordic_sincos/vectors/sincos_101.log.txt" title="sincos_101.log.txt" tooltip="cordic_sincos/vectors/sincos_101.log.txt" workbook="DefaultEditorWorkbook"> | |
73 | +<input factoryID="org.eclipse.ui.part.FileEditorInputFactory" path="/cordic_sincos/vectors/sincos_101.log.txt"/> | |
74 | +<editorState selectionHorizontalPixel="0" selectionLength="0" selectionOffset="562" selectionTopPixel="0"/> | |
75 | +</editor> | |
76 | +<editor id="org.eclipse.cdt.ui.editor.CEditor" name="main.h" partName="main.h" path="/home/takemasa/shared_foo/vhdl_my_lib/cordic_sincos_testgen/main.h" title="main.h" tooltip="cordic_sincos_testgen/main.h" workbook="DefaultEditorWorkbook"> | |
77 | +<input factoryID="org.eclipse.ui.part.FileEditorInputFactory" path="/cordic_sincos_testgen/main.h"/> | |
78 | +<editorState selectionHorizontalPixel="0" selectionLength="0" selectionOffset="4222" selectionTopPixel="1304"/> | |
79 | +</editor> | |
80 | +<editor id="org.eclipse.ui.DefaultTextEditor" name="sincos_101.ref.txt" partName="sincos_101.ref.txt" path="/home/takemasa/shared_foo/vhdl_my_lib/cordic_sincos_testgen/fileout/sincos_101.ref.txt" title="sincos_101.ref.txt" tooltip="cordic_sincos_testgen/fileout/sincos_101.ref.txt" workbook="DefaultEditorWorkbook"> | |
81 | +<input factoryID="org.eclipse.ui.part.FileEditorInputFactory" path="/cordic_sincos_testgen/fileout/sincos_101.ref.txt"/> | |
82 | +<editorState selectionHorizontalPixel="0" selectionLength="0" selectionOffset="0" selectionTopPixel="0"/> | |
83 | +</editor> | |
84 | +<editor id="org.eclipse.ui.DefaultTextEditor" name="sincos_101.dut.txt" partName="sincos_101.dut.txt" path="/home/takemasa/shared_foo/vhdl_my_lib/cordic_sincos/vectors/sincos_101.dut.txt" title="sincos_101.dut.txt" tooltip="cordic_sincos/vectors/sincos_101.dut.txt" workbook="DefaultEditorWorkbook"> | |
85 | +<input factoryID="org.eclipse.ui.part.FileEditorInputFactory" path="/cordic_sincos/vectors/sincos_101.dut.txt"/> | |
86 | +<editorState selectionHorizontalPixel="0" selectionLength="0" selectionOffset="1055" selectionTopPixel="0"/> | |
50 | 87 | </editor> |
51 | 88 | </editors> |
52 | 89 | <views> |
@@ -55,6 +92,7 @@ | ||
55 | 92 | <viewState PRIMARY_SORT_FIELD="org.eclipse.ui.ide.severityAndDescriptionField" categoryGroup="org.eclipse.ui.ide.severity" markerContentGenerator="org.eclipse.ui.ide.problemsGenerator" partName="Problems"> |
56 | 93 | <expanded> |
57 | 94 | <category IMemento.internal.id="Errors"/> |
95 | +<category IMemento.internal.id="Errors (1 item)"/> | |
58 | 96 | </expanded> |
59 | 97 | <columnWidths org.eclipse.ui.ide.locationField="105" org.eclipse.ui.ide.markerType="353" org.eclipse.ui.ide.pathField="140" org.eclipse.ui.ide.resourceField="105" org.eclipse.ui.ide.severityAndDescriptionField="350"/> |
60 | 98 | <visible IMemento.internal.id="org.eclipse.ui.ide.severityAndDescriptionField"/> |
@@ -87,7 +125,7 @@ | ||
87 | 125 | <viewState CommonNavigator.LINKING_ENABLED="0" org.eclipse.cdt.ui.cview.groupincludes="false" org.eclipse.cdt.ui.cview.groupmacros="false" org.eclipse.cdt.ui.editor.CUChildren="true" org.eclipse.ui.navigator.resources.workingSets.showTopLevelWorkingSets="0"/> |
88 | 126 | </view> |
89 | 127 | </views> |
90 | -<perspectives activePart="net.sourceforge.veditor.editor.VhdlEditor" activePerspective="org.eclipse.cdt.ui.CPerspective"> | |
128 | +<perspectives activePart="org.eclipse.compare.CompareEditor" activePerspective="org.eclipse.cdt.ui.CPerspective"> | |
91 | 129 | <perspective editorAreaTrimState="2" editorAreaVisible="1" fixed="0" version="0.016"> |
92 | 130 | <descriptor class="org.eclipse.ui.internal.ide.application.ResourcePerspective" id="org.eclipse.ui.resourcePerspective" label="Resource"/> |
93 | 131 | <alwaysOnActionSet id="org.eclipse.ui.cheatsheets.actionSet"/> |
@@ -259,174 +297,7 @@ | ||
259 | 297 | </perspective> |
260 | 298 | </perspectives> |
261 | 299 | <workingSets/> |
262 | -<navigationHistory> | |
263 | -<editors> | |
264 | -<editor factoryID="org.eclipse.ui.part.FileEditorInputFactory" id="org.eclipse.ui.DefaultTextEditor" path="/cordic_sincos_testgen/fileout/sincos_100.ref.txt"/> | |
265 | -<editor factoryID="org.eclipse.ui.part.FileEditorInputFactory" id="net.sourceforge.veditor.editor.VhdlEditor" path="/cordic_sincos/src/sincos_cordic_bench_0.vhd"/> | |
266 | -<editor factoryID="org.eclipse.ui.part.FileEditorInputFactory" id="net.sourceforge.veditor.editor.VhdlEditor" path="/cordic_sincos/src/sincos_cordic_bench_100.vhd"/> | |
267 | -<editor factoryID="org.eclipse.ui.part.FileEditorInputFactory" id="org.eclipse.ui.DefaultTextEditor" path="/cordic_sincos/build"/> | |
268 | -<editor factoryID="org.eclipse.ui.part.FileEditorInputFactory" id="net.sourceforge.veditor.editor.VhdlEditor" path="/cordic_sincos/src/sincos_cordic_bench.vhd"/> | |
269 | -<editor factoryID="org.eclipse.ui.part.FileEditorInputFactory" id="org.eclipse.ui.DefaultTextEditor" path="/cordic_sincos/vectors/sincos_100.ref.txt"/> | |
270 | -<editor factoryID="org.eclipse.ui.part.FileEditorInputFactory" id="org.eclipse.ui.DefaultTextEditor" path="/cordic_sincos/vectors/sincos_100.log.txt"/> | |
271 | -<editor factoryID="org.eclipse.ui.part.FileEditorInputFactory" id="org.eclipse.ui.DefaultTextEditor" path="/cordic_sincos/vectors/sincos_100.dut.txt"/> | |
272 | -<editor factoryID="org.eclipse.ui.part.FileEditorInputFactory" id="net.sourceforge.veditor.editor.VhdlEditor" path="/cordic_sincos/src/sincos_cordic.vhd"/> | |
273 | -<editor factoryID="org.eclipse.ui.part.FileEditorInputFactory" id="net.sourceforge.veditor.editor.VhdlEditor" path="/cordic_sincos/src/sincos_sub.vhd"/> | |
274 | -<editor factoryID="org.eclipse.ui.part.FileEditorInputFactory" id="org.eclipse.ui.DefaultTextEditor" path="/cordic_sincos/build"/> | |
275 | -<editor factoryID="org.eclipse.ui.part.FileEditorInputFactory" id="org.eclipse.cdt.ui.editor.CEditor" path="/cordic_sincos_testgen/main.cpp"/> | |
276 | -<editor factoryID="org.eclipse.ui.part.FileEditorInputFactory" id="org.eclipse.cdt.ui.editor.CEditor" path="/cordic_sincos_testgen/main.h"/> | |
277 | -<editor factoryID="org.eclipse.ui.part.FileEditorInputFactory" id="net.sourceforge.veditor.editor.VhdlEditor" path="/cordic_sincos/src/sincos_cordic.vhd"/> | |
278 | -</editors> | |
279 | -<item historyLabel="sincos_100.ref.txt" index="0"> | |
280 | -<position info="not_deleted" x="71081" y="0"/> | |
281 | -</item> | |
282 | -<item historyLabel="sincos_cordic_bench_0.vhd" index="1"> | |
283 | -<position info="not_deleted" x="0" y="0"/> | |
284 | -</item> | |
285 | -<item historyLabel="sincos_cordic_bench_100.vhd" index="2"> | |
286 | -<position info="not_deleted" x="0" y="0"/> | |
287 | -</item> | |
288 | -<item historyLabel="build" index="3"> | |
289 | -<position info="not_deleted" x="2317" y="0"/> | |
290 | -</item> | |
291 | -<item historyLabel="build" index="3"> | |
292 | -<position info="not_deleted" x="2202" y="0"/> | |
293 | -</item> | |
294 | -<item historyLabel="sincos_cordic_bench.vhd" index="4"> | |
295 | -<position info="not_deleted" x="601" y="5"/> | |
296 | -</item> | |
297 | -<item historyLabel="sincos_100.ref.txt" index="5"> | |
298 | -<position info="not_deleted" x="0" y="0"/> | |
299 | -</item> | |
300 | -<item historyLabel="sincos_100.log.txt" index="6"> | |
301 | -<position/> | |
302 | -</item> | |
303 | -<item historyLabel="sincos_100.dut.txt" index="7"> | |
304 | -<position info="not_deleted" x="0" y="0"/> | |
305 | -</item> | |
306 | -<item historyLabel="sincos_100.ref.txt" index="5"> | |
307 | -<position info="not_deleted" x="0" y="0"/> | |
308 | -</item> | |
309 | -<item historyLabel="sincos_100.log.txt" index="6"> | |
310 | -<position/> | |
311 | -</item> | |
312 | -<item historyLabel="sincos_100.ref.txt" index="5"> | |
313 | -<position info="not_deleted" x="65" y="0"/> | |
314 | -</item> | |
315 | -<item historyLabel="sincos_100.dut.txt" index="7"> | |
316 | -<position info="not_deleted" x="6600" y="0"/> | |
317 | -</item> | |
318 | -<item historyLabel="sincos_100.ref.txt" index="5"> | |
319 | -<position info="not_deleted" x="4807" y="0"/> | |
320 | -</item> | |
321 | -<item historyLabel="sincos_100.dut.txt" index="7"> | |
322 | -<position info="not_deleted" x="6600" y="0"/> | |
323 | -</item> | |
324 | -<item historyLabel="sincos_100.ref.txt" index="5"> | |
325 | -<position info="not_deleted" x="4807" y="0"/> | |
326 | -</item> | |
327 | -<item historyLabel="sincos_100.dut.txt" index="7"> | |
328 | -<position info="not_deleted" x="6600" y="0"/> | |
329 | -</item> | |
330 | -<item historyLabel="build" index="3"> | |
331 | -<position info="not_deleted" x="1795" y="0"/> | |
332 | -</item> | |
333 | -<item historyLabel="sincos_100.log.txt" index="6"> | |
334 | -<position info="not_deleted" x="0" y="0"/> | |
335 | -</item> | |
336 | -<item historyLabel="sincos_100.log.txt" index="6"> | |
337 | -<position info="not_deleted" x="139148" y="0"/> | |
338 | -</item> | |
339 | -<item historyLabel="sincos_100.ref.txt" index="5"> | |
340 | -<position info="not_deleted" x="4807" y="0"/> | |
341 | -</item> | |
342 | -<item historyLabel="sincos_100.dut.txt" index="7"> | |
343 | -<position info="not_deleted" x="6600" y="0"/> | |
344 | -</item> | |
345 | -<item historyLabel="sincos_100.dut.txt" index="7"> | |
346 | -<position info="not_deleted" x="72666" y="0"/> | |
347 | -</item> | |
348 | -<item historyLabel="sincos_100.ref.txt" index="5"> | |
349 | -<position info="not_deleted" x="72666" y="0"/> | |
350 | -</item> | |
351 | -<item historyLabel="sincos_100.dut.txt" index="7"> | |
352 | -<position info="not_deleted" x="72666" y="0"/> | |
353 | -</item> | |
354 | -<item historyLabel="sincos_100.ref.txt" index="5"> | |
355 | -<position info="not_deleted" x="72666" y="0"/> | |
356 | -</item> | |
357 | -<item historyLabel="sincos_100.log.txt" index="6"> | |
358 | -<position info="not_deleted" x="139148" y="0"/> | |
359 | -</item> | |
360 | -<item historyLabel="build" index="3"> | |
361 | -<position info="not_deleted" x="1795" y="0"/> | |
362 | -</item> | |
363 | -<item historyLabel="sincos_cordic_bench.vhd" index="4"> | |
364 | -<position info="not_deleted" x="601" y="5"/> | |
365 | -</item> | |
366 | -<item historyLabel="build" index="3"> | |
367 | -<position info="not_deleted" x="1795" y="0"/> | |
368 | -</item> | |
369 | -<item historyLabel="sincos_cordic.vhd" index="8"> | |
370 | -<position info="not_deleted" x="3199" y="0"/> | |
371 | -</item> | |
372 | -<item historyLabel="sincos_100.log.txt" index="6"> | |
373 | -<position info="not_deleted" x="0" y="0"/> | |
374 | -</item> | |
375 | -<item historyLabel="sincos_100.log.txt" index="6"> | |
376 | -<position info="not_deleted" x="74741" y="0"/> | |
377 | -</item> | |
378 | -<item historyLabel="sincos_100.dut.txt" index="7"> | |
379 | -<position info="not_deleted" x="0" y="0"/> | |
380 | -</item> | |
381 | -<item historyLabel="sincos_100.ref.txt" index="5"> | |
382 | -<position info="not_deleted" x="0" y="0"/> | |
383 | -</item> | |
384 | -<item historyLabel="sincos_100.ref.txt" index="5"> | |
385 | -<position info="not_deleted" x="0" y="0"/> | |
386 | -</item> | |
387 | -<item historyLabel="sincos_100.dut.txt" index="7"> | |
388 | -<position info="not_deleted" x="0" y="0"/> | |
389 | -</item> | |
390 | -<item historyLabel="sincos_100.dut.txt" index="7"> | |
391 | -<position info="not_deleted" x="132" y="0"/> | |
392 | -</item> | |
393 | -<item historyLabel="sincos_100.log.txt" index="6"> | |
394 | -<position info="not_deleted" x="74400" y="0"/> | |
395 | -</item> | |
396 | -<item historyLabel="sincos_sub.vhd" index="9"> | |
397 | -<position info="not_deleted" x="2424" y="0"/> | |
398 | -</item> | |
399 | -<item historyLabel="build" index="10"> | |
400 | -<position info="not_deleted" x="2586" y="0"/> | |
401 | -</item> | |
402 | -<item historyLabel="build" index="10"> | |
403 | -<position info="not_deleted" x="0" y="0"/> | |
404 | -</item> | |
405 | -<item historyLabel="main.cpp" index="11"> | |
406 | -<position info="not_deleted" x="14936" y="0"/> | |
407 | -</item> | |
408 | -<item historyLabel="main.cpp" index="11"> | |
409 | -<position info="not_deleted" x="0" y="0"/> | |
410 | -</item> | |
411 | -<item historyLabel="main.h" index="12"> | |
412 | -<position info="not_deleted" x="353" y="0"/> | |
413 | -</item> | |
414 | -<item historyLabel="main.cpp" index="11"> | |
415 | -<position info="not_deleted" x="9041" y="0"/> | |
416 | -</item> | |
417 | -<item historyLabel="build" index="10"> | |
418 | -<position info="not_deleted" x="0" y="0"/> | |
419 | -</item> | |
420 | -<item historyLabel="sincos_cordic.vhd" index="13"> | |
421 | -<position info="not_deleted" x="3199" y="0"/> | |
422 | -</item> | |
423 | -<item historyLabel="build" index="10"> | |
424 | -<position info="not_deleted" x="425" y="0"/> | |
425 | -</item> | |
426 | -<item active="true" historyLabel="sincos_cordic.vhd" index="13"> | |
427 | -<position info="not_deleted" x="0" y="0"/> | |
428 | -</item> | |
429 | -</navigationHistory> | |
300 | +<navigationHistory/> | |
430 | 301 | <input factoryID="org.eclipse.ui.internal.model.ResourceFactory" path="/" type="8"/> |
431 | 302 | </page> |
432 | 303 | <workbenchWindowAdvisor/> |
@@ -443,15 +314,42 @@ | ||
443 | 314 | </trimLayout> |
444 | 315 | </window> |
445 | 316 | <mruList> |
446 | -<file factoryID="org.eclipse.ui.part.FileEditorInputFactory" id="net.sourceforge.veditor.editor.VhdlEditor" name="sincos_cordic.vhd" tooltip="cordic_sincos/src/sincos_cordic.vhd"> | |
447 | -<persistable path="/cordic_sincos/src/sincos_cordic.vhd"/> | |
317 | +<file factoryID="org.eclipse.ui.part.FileEditorInputFactory" id="org.eclipse.ui.DefaultTextEditor" name="sincos_101.dut.txt" tooltip="cordic_sincos/vectors/sincos_101.dut.txt"> | |
318 | +<persistable path="/cordic_sincos/vectors/sincos_101.dut.txt"/> | |
319 | +</file> | |
320 | +<file factoryID="org.eclipse.ui.part.FileEditorInputFactory" id="net.sourceforge.veditor.editor.VhdlEditor" name="sincos_cordic_bench_101.vhd" tooltip="cordic_sincos/bench/sincos_cordic_bench_101.vhd"> | |
321 | +<persistable path="/cordic_sincos/bench/sincos_cordic_bench_101.vhd"/> | |
322 | +</file> | |
323 | +<file factoryID="org.eclipse.ui.part.FileEditorInputFactory" id="org.eclipse.ui.DefaultTextEditor" name="sincos_101.vec.txt" tooltip="cordic_sincos_testgen/fileout/sincos_101.vec.txt"> | |
324 | +<persistable path="/cordic_sincos_testgen/fileout/sincos_101.vec.txt"/> | |
325 | +</file> | |
326 | +<file factoryID="org.eclipse.ui.part.FileEditorInputFactory" id="org.eclipse.ui.DefaultTextEditor" name="sincos_101.ref.txt" tooltip="cordic_sincos_testgen/fileout/sincos_101.ref.txt"> | |
327 | +<persistable path="/cordic_sincos_testgen/fileout/sincos_101.ref.txt"/> | |
328 | +</file> | |
329 | +<file factoryID="org.eclipse.ui.part.FileEditorInputFactory" id="org.eclipse.ui.DefaultTextEditor" name="sincos_100.vec.txt" tooltip="cordic_sincos_testgen/fileout/sincos_100.vec.txt"> | |
330 | +<persistable path="/cordic_sincos_testgen/fileout/sincos_100.vec.txt"/> | |
331 | +</file> | |
332 | +<file factoryID="org.eclipse.ui.part.FileEditorInputFactory" id="org.eclipse.ui.DefaultTextEditor" name="sincos_100.ref.txt" tooltip="cordic_sincos_testgen/fileout/sincos_100.ref.txt"> | |
333 | +<persistable path="/cordic_sincos_testgen/fileout/sincos_100.ref.txt"/> | |
448 | 334 | </file> |
449 | 335 | <file factoryID="org.eclipse.ui.part.FileEditorInputFactory" id="org.eclipse.cdt.ui.editor.CEditor" name="main.h" tooltip="cordic_sincos_testgen/main.h"> |
450 | 336 | <persistable path="/cordic_sincos_testgen/main.h"/> |
451 | 337 | </file> |
338 | +<file factoryID="org.eclipse.ui.part.FileEditorInputFactory" id="org.eclipse.ui.DefaultTextEditor" name="sincos_101.log.txt" tooltip="cordic_sincos/vectors/sincos_101.log.txt"> | |
339 | +<persistable path="/cordic_sincos/vectors/sincos_101.log.txt"/> | |
340 | +</file> | |
341 | +<file factoryID="org.eclipse.ui.part.FileEditorInputFactory" id="org.eclipse.ui.DefaultTextEditor" name="sincossub_5.ref.txt" tooltip="cordic_sincos_testgen/fileout/sincossub_5.ref.txt"> | |
342 | +<persistable path="/cordic_sincos_testgen/fileout/sincossub_5.ref.txt"/> | |
343 | +</file> | |
344 | +<file factoryID="org.eclipse.ui.part.FileEditorInputFactory" id="org.eclipse.ui.DefaultTextEditor" name="sincossub_5.vec.txt" tooltip="cordic_sincos_testgen/fileout/sincossub_5.vec.txt"> | |
345 | +<persistable path="/cordic_sincos_testgen/fileout/sincossub_5.vec.txt"/> | |
346 | +</file> | |
452 | 347 | <file factoryID="org.eclipse.ui.part.FileEditorInputFactory" id="org.eclipse.cdt.ui.editor.CEditor" name="main.cpp" tooltip="cordic_sincos_testgen/main.cpp"> |
453 | 348 | <persistable path="/cordic_sincos_testgen/main.cpp"/> |
454 | 349 | </file> |
350 | +<file factoryID="org.eclipse.ui.part.FileEditorInputFactory" id="net.sourceforge.veditor.editor.VhdlEditor" name="sincos_cordic.vhd" tooltip="cordic_sincos/src/sincos_cordic.vhd"> | |
351 | +<persistable path="/cordic_sincos/src/sincos_cordic.vhd"/> | |
352 | +</file> | |
455 | 353 | <file factoryID="org.eclipse.ui.part.FileEditorInputFactory" id="net.sourceforge.veditor.editor.VhdlEditor" name="sincos_sub.vhd" tooltip="cordic_sincos/src/sincos_sub.vhd"> |
456 | 354 | <persistable path="/cordic_sincos/src/sincos_sub.vhd"/> |
457 | 355 | </file> |
@@ -461,32 +359,5 @@ | ||
461 | 359 | <file factoryID="org.eclipse.ui.part.FileEditorInputFactory" id="org.eclipse.ui.DefaultTextEditor" name="sincos_100.dut.txt" tooltip="cordic_sincos/vectors/sincos_100.dut.txt"> |
462 | 360 | <persistable path="/cordic_sincos/vectors/sincos_100.dut.txt"/> |
463 | 361 | </file> |
464 | -<file factoryID="org.eclipse.ui.part.FileEditorInputFactory" id="org.eclipse.ui.DefaultTextEditor" name="sincos_100.log.txt" tooltip="cordic_sincos/vectors/sincos_100.log.txt"> | |
465 | -<persistable path="/cordic_sincos/vectors/sincos_100.log.txt"/> | |
466 | -</file> | |
467 | -<file factoryID="org.eclipse.ui.part.FileEditorInputFactory" id="net.sourceforge.veditor.editor.VhdlEditor" name="sincos_cordic_bench.vhd" tooltip="cordic_sincos/src/sincos_cordic_bench.vhd"> | |
468 | -<persistable path="/cordic_sincos/src/sincos_cordic_bench.vhd"/> | |
469 | -</file> | |
470 | -<file factoryID="org.eclipse.ui.part.FileEditorInputFactory" id="net.sourceforge.veditor.editor.VhdlEditor" name="sincos_cordic_bench_0.vhd" tooltip="cordic_sincos/src/sincos_cordic_bench_0.vhd"> | |
471 | -<persistable path="/cordic_sincos/src/sincos_cordic_bench_0.vhd"/> | |
472 | -</file> | |
473 | -<file factoryID="org.eclipse.ui.part.FileEditorInputFactory" id="org.eclipse.ui.DefaultTextEditor" name="sincos_100.ref.txt" tooltip="cordic_sincos_testgen/fileout/sincos_100.ref.txt"> | |
474 | -<persistable path="/cordic_sincos_testgen/fileout/sincos_100.ref.txt"/> | |
475 | -</file> | |
476 | -<file factoryID="org.eclipse.ui.part.FileEditorInputFactory" id="org.eclipse.cdt.ui.editor.CEditor" name="sincoscordic.cpp" tooltip="cordic_sincos_testgen/sincoscordic.cpp"> | |
477 | -<persistable path="/cordic_sincos_testgen/sincoscordic.cpp"/> | |
478 | -</file> | |
479 | -<file factoryID="org.eclipse.ui.part.FileEditorInputFactory" id="org.eclipse.cdt.ui.editor.CEditor" name="sincosscalingfactor.h" tooltip="cordic_sincos_testgen/sincosscalingfactor.h"> | |
480 | -<persistable path="/cordic_sincos_testgen/sincosscalingfactor.h"/> | |
481 | -</file> | |
482 | -<file factoryID="org.eclipse.ui.part.FileEditorInputFactory" id="org.eclipse.cdt.ui.editor.CEditor" name="sincosangledelta.cpp" tooltip="cordic_sincos_testgen/sincosangledelta.cpp"> | |
483 | -<persistable path="/cordic_sincos_testgen/sincosangledelta.cpp"/> | |
484 | -</file> | |
485 | -<file factoryID="org.eclipse.ui.part.FileEditorInputFactory" id="org.eclipse.cdt.ui.editor.CEditor" name="sincosscalingfactor.cpp" tooltip="cordic_sincos_testgen/sincosscalingfactor.cpp"> | |
486 | -<persistable path="/cordic_sincos_testgen/sincosscalingfactor.cpp"/> | |
487 | -</file> | |
488 | -<file factoryID="org.eclipse.ui.part.FileEditorInputFactory" id="org.eclipse.ui.DefaultTextEditor" name="sincos_scaling_factor.txt" tooltip="cordic_sincos_testgen/fileout/sincos_scaling_factor.txt"> | |
489 | -<persistable path="/cordic_sincos_testgen/fileout/sincos_scaling_factor.txt"/> | |
490 | -</file> | |
491 | 362 | </mruList> |
492 | 363 | </workbench> |
\ No newline at end of file |
@@ -30,7 +30,7 @@ architecture RTL of sincos_cordic_bench_101 is | ||
30 | 30 | file fi: TEXT open read_mode is "vectors/sincos_101.vec.txt"; |
31 | 31 | |
32 | 32 | constant max_bit : integer := 31; |
33 | - constant num_stage : integer := 20; | |
33 | + constant num_stage : integer := 3; | |
34 | 34 | |
35 | 35 | signal clock_0 : std_logic := '0'; |
36 | 36 | signal reset_0 : std_logic := '0'; |
@@ -1,6 +1,6 @@ | ||
1 | 1 | # vsim work.sincos_cordic_bench -c -quiet -do "run 1ms; quit" |
2 | -# Start time: 08:57:06 on Oct 12,2016 | |
2 | +# Start time: 11:38:51 on Oct 12,2016 | |
3 | 3 | # run 1ms |
4 | 4 | # quit |
5 | -# End time: 08:57:06 on Oct 12,2016, Elapsed time: 0:00:00 | |
5 | +# End time: 11:38:51 on Oct 12,2016, Elapsed time: 0:00:00 | |
6 | 6 | # Errors: 0, Warnings: 0 |
@@ -9,7 +9,7 @@ z2 | ||
9 | 9 | cModel Technology |
10 | 10 | Z0 d/home/takemasa/shared_foo/vhdl_my_lib/cordic_sincos |
11 | 11 | Esincos_cordic |
12 | -Z1 w1476171384 | |
12 | +Z1 w1476238837 | |
13 | 13 | Z2 DPx4 ieee 16 std_logic_textio 0 22 V5TSK`;aJKC<l]CEg1>mz1 |
14 | 14 | Z3 DPx4 ieee 11 numeric_std 0 22 :ASDNFgHXf_ih3J@9F3Ze1 |
15 | 15 | Z4 DPx3 std 6 textio 0 22 zE1`LPoLg^DX3Oz^4Fj1K3 |
@@ -23,9 +23,9 @@ VDMSgO47IS[e[>cAb@OUT?0 | ||
23 | 23 | !s100 niN6AKIDm1lVeUPYD`Se[1 |
24 | 24 | Z8 OV;C;10.4d;61 |
25 | 25 | 33 |
26 | -Z9 !s110 1476230224 | |
26 | +Z9 !s110 1476239929 | |
27 | 27 | !i10b 1 |
28 | -Z10 !s108 1476230224.000000 | |
28 | +Z10 !s108 1476239929.000000 | |
29 | 29 | Z11 !s90 -explicit|-work|work|-2008|-quiet|src/sincos_cordic.vhd| |
30 | 30 | Z12 !s107 src/sincos_cordic.vhd| |
31 | 31 | !i113 1 |
@@ -65,19 +65,19 @@ VSVLMLTUONO7cYcScWnR[]0 | ||
65 | 65 | !s100 Pza0h9Q01kMKR=CHane>=1 |
66 | 66 | R8 |
67 | 67 | 33 |
68 | -R9 | |
68 | +Z20 !s110 1476239930 | |
69 | 69 | !i10b 1 |
70 | 70 | R10 |
71 | -Z20 !s90 -explicit|-work|work|-2008|-quiet|bench/sincos_cordic_bench.vhd| | |
72 | -Z21 !s107 bench/sincos_cordic_bench.vhd| | |
71 | +Z21 !s90 -explicit|-work|work|-2008|-quiet|bench/sincos_cordic_bench.vhd| | |
72 | +Z22 !s107 bench/sincos_cordic_bench.vhd| | |
73 | 73 | !i113 1 |
74 | 74 | R13 |
75 | 75 | R14 |
76 | 76 | Artl |
77 | -Z22 DEx4 work 23 sincos_cordic_bench_101 0 22 enR2@[JY??UXjMFKPfn6]1 | |
77 | +Z23 DEx4 work 23 sincos_cordic_bench_101 0 22 enR2@[JY??UXjMFKPfn6]1 | |
78 | 78 | R2 |
79 | 79 | R3 |
80 | -Z23 DEx4 work 23 sincos_cordic_bench_100 0 22 3@d=0?KzZ:YJS9OlVA4oD3 | |
80 | +Z24 DEx4 work 23 sincos_cordic_bench_100 0 22 3@d=0?KzZ:YJS9OlVA4oD3 | |
81 | 81 | R4 |
82 | 82 | R5 |
83 | 83 | DEx4 work 19 sincos_cordic_bench 0 22 SVLMLTUONO7cYcScWnR[]0 |
@@ -87,11 +87,11 @@ V@PiB8b?KCHoQaLLDzO8aR3 | ||
87 | 87 | !s100 Ld5InU`168e;0lD0S7o=b3 |
88 | 88 | R8 |
89 | 89 | 33 |
90 | -R9 | |
90 | +R20 | |
91 | 91 | !i10b 1 |
92 | 92 | R10 |
93 | -R20 | |
94 | 93 | R21 |
94 | +R22 | |
95 | 95 | !i113 1 |
96 | 96 | R13 |
97 | 97 | R14 |
@@ -102,8 +102,8 @@ R3 | ||
102 | 102 | R4 |
103 | 103 | R5 |
104 | 104 | R0 |
105 | -Z24 8bench/sincos_cordic_bench_100.vhd | |
106 | -Z25 Fbench/sincos_cordic_bench_100.vhd | |
105 | +Z25 8bench/sincos_cordic_bench_100.vhd | |
106 | +Z26 Fbench/sincos_cordic_bench_100.vhd | |
107 | 107 | l0 |
108 | 108 | L25 |
109 | 109 | V3@d=0?KzZ:YJS9OlVA4oD3 |
@@ -113,8 +113,8 @@ R8 | ||
113 | 113 | R9 |
114 | 114 | !i10b 1 |
115 | 115 | R10 |
116 | -Z26 !s90 -explicit|-work|work|-2008|-quiet|bench/sincos_cordic_bench_100.vhd| | |
117 | -Z27 !s107 bench/sincos_cordic_bench_100.vhd| | |
116 | +Z27 !s90 -explicit|-work|work|-2008|-quiet|bench/sincos_cordic_bench_100.vhd| | |
117 | +Z28 !s107 bench/sincos_cordic_bench_100.vhd| | |
118 | 118 | !i113 1 |
119 | 119 | R13 |
120 | 120 | R14 |
@@ -124,7 +124,7 @@ R2 | ||
124 | 124 | R3 |
125 | 125 | R4 |
126 | 126 | R5 |
127 | -R23 | |
127 | +R24 | |
128 | 128 | l41 |
129 | 129 | L28 |
130 | 130 | VGg25XRcT[j6j]CJQi[0?L0 |
@@ -134,20 +134,20 @@ R8 | ||
134 | 134 | R9 |
135 | 135 | !i10b 1 |
136 | 136 | R10 |
137 | -R26 | |
138 | 137 | R27 |
138 | +R28 | |
139 | 139 | !i113 1 |
140 | 140 | R13 |
141 | 141 | R14 |
142 | 142 | Esincos_cordic_bench_101 |
143 | -R17 | |
143 | +Z29 w1476239709 | |
144 | 144 | R2 |
145 | 145 | R3 |
146 | 146 | R4 |
147 | 147 | R5 |
148 | 148 | R0 |
149 | -Z28 8bench/sincos_cordic_bench_101.vhd | |
150 | -Z29 Fbench/sincos_cordic_bench_101.vhd | |
149 | +Z30 8bench/sincos_cordic_bench_101.vhd | |
150 | +Z31 Fbench/sincos_cordic_bench_101.vhd | |
151 | 151 | l0 |
152 | 152 | L25 |
153 | 153 | VenR2@[JY??UXjMFKPfn6]1 |
@@ -157,8 +157,8 @@ R8 | ||
157 | 157 | R9 |
158 | 158 | !i10b 1 |
159 | 159 | R10 |
160 | -Z30 !s90 -explicit|-work|work|-2008|-quiet|bench/sincos_cordic_bench_101.vhd| | |
161 | -Z31 !s107 bench/sincos_cordic_bench_101.vhd| | |
160 | +Z32 !s90 -explicit|-work|work|-2008|-quiet|bench/sincos_cordic_bench_101.vhd| | |
161 | +Z33 !s107 bench/sincos_cordic_bench_101.vhd| | |
162 | 162 | !i113 1 |
163 | 163 | R13 |
164 | 164 | R14 |
@@ -168,18 +168,18 @@ R2 | ||
168 | 168 | R3 |
169 | 169 | R4 |
170 | 170 | R5 |
171 | -R22 | |
171 | +R23 | |
172 | 172 | l41 |
173 | 173 | L28 |
174 | -VW_]CZ:aVLX^gP:5H@fQ963 | |
175 | -!s100 :S@_dEHPoI:lmE3P?569e0 | |
174 | +V2m3]947hX3Ye;0AebNa?g3 | |
175 | +!s100 @L5hW9MkHIIXklGR<;HLC1 | |
176 | 176 | R8 |
177 | 177 | 33 |
178 | 178 | R9 |
179 | 179 | !i10b 1 |
180 | 180 | R10 |
181 | -R30 | |
182 | -R31 | |
181 | +R32 | |
182 | +R33 | |
183 | 183 | !i113 1 |
184 | 184 | R13 |
185 | 185 | R14 |
@@ -189,8 +189,8 @@ R3 | ||
189 | 189 | R4 |
190 | 190 | R5 |
191 | 191 | R0 |
192 | -Z32 8src/sincos_sub.vhd | |
193 | -Z33 Fsrc/sincos_sub.vhd | |
192 | +Z34 8src/sincos_sub.vhd | |
193 | +Z35 Fsrc/sincos_sub.vhd | |
194 | 194 | l0 |
195 | 195 | L40 |
196 | 196 | VPRDiF:EOYnbWUNjzV>j>92 |
@@ -200,8 +200,8 @@ R8 | ||
200 | 200 | R9 |
201 | 201 | !i10b 1 |
202 | 202 | R10 |
203 | -Z34 !s90 -explicit|-work|work|-2008|-quiet|src/sincos_sub.vhd| | |
204 | -Z35 !s107 src/sincos_sub.vhd| | |
203 | +Z36 !s90 -explicit|-work|work|-2008|-quiet|src/sincos_sub.vhd| | |
204 | +Z37 !s107 src/sincos_sub.vhd| | |
205 | 205 | !i113 1 |
206 | 206 | R13 |
207 | 207 | R14 |
@@ -219,8 +219,8 @@ R8 | ||
219 | 219 | R9 |
220 | 220 | !i10b 1 |
221 | 221 | R10 |
222 | -R34 | |
223 | -R35 | |
222 | +R36 | |
223 | +R37 | |
224 | 224 | !i113 1 |
225 | 225 | R13 |
226 | 226 | R14 |
@@ -231,8 +231,8 @@ R3 | ||
231 | 231 | R4 |
232 | 232 | R5 |
233 | 233 | R0 |
234 | -Z36 8bench/sincos_sub_bench.vhd | |
235 | -Z37 Fbench/sincos_sub_bench.vhd | |
234 | +Z38 8bench/sincos_sub_bench.vhd | |
235 | +Z39 Fbench/sincos_sub_bench.vhd | |
236 | 236 | l0 |
237 | 237 | L21 |
238 | 238 | V8hE]@R;]4cBRk3DcbH:WG0 |
@@ -242,18 +242,18 @@ R8 | ||
242 | 242 | R9 |
243 | 243 | !i10b 1 |
244 | 244 | R10 |
245 | -Z38 !s90 -explicit|-work|work|-2008|-quiet|bench/sincos_sub_bench.vhd| | |
246 | -Z39 !s107 bench/sincos_sub_bench.vhd| | |
245 | +Z40 !s90 -explicit|-work|work|-2008|-quiet|bench/sincos_sub_bench.vhd| | |
246 | +Z41 !s107 bench/sincos_sub_bench.vhd| | |
247 | 247 | !i113 1 |
248 | 248 | R13 |
249 | 249 | R14 |
250 | 250 | Artl |
251 | -Z40 DEx4 work 18 sincos_sub_bench_5 0 22 z1XPZlOlmVbNZb5V@JZg`3 | |
252 | -Z41 DEx4 work 18 sincos_sub_bench_4 0 22 A;`YdiTN7jF8GI5jY[EP_3 | |
253 | -Z42 DEx4 work 18 sincos_sub_bench_3 0 22 GegYS0EVb1RP_TR@gQRGi1 | |
254 | -Z43 DEx4 work 18 sincos_sub_bench_2 0 22 XdaTVzUVGX3D1<b:^>9J=2 | |
255 | -Z44 DEx4 work 18 sincos_sub_bench_1 0 22 SnPiE?o5oHE65XLHTUm3S3 | |
256 | -Z45 DEx4 work 18 sincos_sub_bench_0 0 22 6>1=dP64^NzTLW><dcNHH1 | |
251 | +Z42 DEx4 work 18 sincos_sub_bench_5 0 22 z1XPZlOlmVbNZb5V@JZg`3 | |
252 | +Z43 DEx4 work 18 sincos_sub_bench_4 0 22 A;`YdiTN7jF8GI5jY[EP_3 | |
253 | +Z44 DEx4 work 18 sincos_sub_bench_3 0 22 GegYS0EVb1RP_TR@gQRGi1 | |
254 | +Z45 DEx4 work 18 sincos_sub_bench_2 0 22 XdaTVzUVGX3D1<b:^>9J=2 | |
255 | +Z46 DEx4 work 18 sincos_sub_bench_1 0 22 SnPiE?o5oHE65XLHTUm3S3 | |
256 | +Z47 DEx4 work 18 sincos_sub_bench_0 0 22 6>1=dP64^NzTLW><dcNHH1 | |
257 | 257 | R2 |
258 | 258 | R3 |
259 | 259 | R4 |
@@ -268,20 +268,20 @@ R8 | ||
268 | 268 | R9 |
269 | 269 | !i10b 1 |
270 | 270 | R10 |
271 | -R38 | |
272 | -R39 | |
271 | +R40 | |
272 | +R41 | |
273 | 273 | !i113 1 |
274 | 274 | R13 |
275 | 275 | R14 |
276 | 276 | Esincos_sub_bench_0 |
277 | -Z46 w1476146790 | |
277 | +Z48 w1476146790 | |
278 | 278 | R2 |
279 | 279 | R3 |
280 | 280 | R4 |
281 | 281 | R5 |
282 | 282 | R0 |
283 | -Z47 8bench/sincos_sub_bench_0.vhd | |
284 | -Z48 Fbench/sincos_sub_bench_0.vhd | |
283 | +Z49 8bench/sincos_sub_bench_0.vhd | |
284 | +Z50 Fbench/sincos_sub_bench_0.vhd | |
285 | 285 | l0 |
286 | 286 | L25 |
287 | 287 | V6>1=dP64^NzTLW><dcNHH1 |
@@ -291,8 +291,8 @@ R8 | ||
291 | 291 | R9 |
292 | 292 | !i10b 1 |
293 | 293 | R10 |
294 | -Z49 !s90 -explicit|-work|work|-2008|-quiet|bench/sincos_sub_bench_0.vhd| | |
295 | -Z50 !s107 bench/sincos_sub_bench_0.vhd| | |
294 | +Z51 !s90 -explicit|-work|work|-2008|-quiet|bench/sincos_sub_bench_0.vhd| | |
295 | +Z52 !s107 bench/sincos_sub_bench_0.vhd| | |
296 | 296 | !i113 1 |
297 | 297 | R13 |
298 | 298 | R14 |
@@ -302,7 +302,7 @@ R2 | ||
302 | 302 | R3 |
303 | 303 | R4 |
304 | 304 | R5 |
305 | -R45 | |
305 | +R47 | |
306 | 306 | l45 |
307 | 307 | L28 |
308 | 308 | VmQ1H3>`c1TF[A@EoHTeb81 |
@@ -312,20 +312,20 @@ R8 | ||
312 | 312 | R9 |
313 | 313 | !i10b 1 |
314 | 314 | R10 |
315 | -R49 | |
316 | -R50 | |
315 | +R51 | |
316 | +R52 | |
317 | 317 | !i113 1 |
318 | 318 | R13 |
319 | 319 | R14 |
320 | 320 | Esincos_sub_bench_1 |
321 | -R46 | |
321 | +R48 | |
322 | 322 | R2 |
323 | 323 | R3 |
324 | 324 | R4 |
325 | 325 | R5 |
326 | 326 | R0 |
327 | -Z51 8bench/sincos_sub_bench_1.vhd | |
328 | -Z52 Fbench/sincos_sub_bench_1.vhd | |
327 | +Z53 8bench/sincos_sub_bench_1.vhd | |
328 | +Z54 Fbench/sincos_sub_bench_1.vhd | |
329 | 329 | l0 |
330 | 330 | L25 |
331 | 331 | VSnPiE?o5oHE65XLHTUm3S3 |
@@ -335,8 +335,8 @@ R8 | ||
335 | 335 | R9 |
336 | 336 | !i10b 1 |
337 | 337 | R10 |
338 | -Z53 !s90 -explicit|-work|work|-2008|-quiet|bench/sincos_sub_bench_1.vhd| | |
339 | -Z54 !s107 bench/sincos_sub_bench_1.vhd| | |
338 | +Z55 !s90 -explicit|-work|work|-2008|-quiet|bench/sincos_sub_bench_1.vhd| | |
339 | +Z56 !s107 bench/sincos_sub_bench_1.vhd| | |
340 | 340 | !i113 1 |
341 | 341 | R13 |
342 | 342 | R14 |
@@ -346,7 +346,7 @@ R2 | ||
346 | 346 | R3 |
347 | 347 | R4 |
348 | 348 | R5 |
349 | -R44 | |
349 | +R46 | |
350 | 350 | l45 |
351 | 351 | L28 |
352 | 352 | VTO6Wa8:YgL?04cSLW;0a:3 |
@@ -356,20 +356,20 @@ R8 | ||
356 | 356 | R9 |
357 | 357 | !i10b 1 |
358 | 358 | R10 |
359 | -R53 | |
360 | -R54 | |
359 | +R55 | |
360 | +R56 | |
361 | 361 | !i113 1 |
362 | 362 | R13 |
363 | 363 | R14 |
364 | 364 | Esincos_sub_bench_2 |
365 | -R46 | |
365 | +R48 | |
366 | 366 | R2 |
367 | 367 | R3 |
368 | 368 | R4 |
369 | 369 | R5 |
370 | 370 | R0 |
371 | -Z55 8bench/sincos_sub_bench_2.vhd | |
372 | -Z56 Fbench/sincos_sub_bench_2.vhd | |
371 | +Z57 8bench/sincos_sub_bench_2.vhd | |
372 | +Z58 Fbench/sincos_sub_bench_2.vhd | |
373 | 373 | l0 |
374 | 374 | L25 |
375 | 375 | VXdaTVzUVGX3D1<b:^>9J=2 |
@@ -379,8 +379,8 @@ R8 | ||
379 | 379 | R9 |
380 | 380 | !i10b 1 |
381 | 381 | R10 |
382 | -Z57 !s90 -explicit|-work|work|-2008|-quiet|bench/sincos_sub_bench_2.vhd| | |
383 | -Z58 !s107 bench/sincos_sub_bench_2.vhd| | |
382 | +Z59 !s90 -explicit|-work|work|-2008|-quiet|bench/sincos_sub_bench_2.vhd| | |
383 | +Z60 !s107 bench/sincos_sub_bench_2.vhd| | |
384 | 384 | !i113 1 |
385 | 385 | R13 |
386 | 386 | R14 |
@@ -390,7 +390,7 @@ R2 | ||
390 | 390 | R3 |
391 | 391 | R4 |
392 | 392 | R5 |
393 | -R43 | |
393 | +R45 | |
394 | 394 | l45 |
395 | 395 | L28 |
396 | 396 | VGmg2B]XkMH2C9KUFg5dJM0 |
@@ -400,20 +400,20 @@ R8 | ||
400 | 400 | R9 |
401 | 401 | !i10b 1 |
402 | 402 | R10 |
403 | -R57 | |
404 | -R58 | |
403 | +R59 | |
404 | +R60 | |
405 | 405 | !i113 1 |
406 | 406 | R13 |
407 | 407 | R14 |
408 | 408 | Esincos_sub_bench_3 |
409 | -R46 | |
409 | +R48 | |
410 | 410 | R2 |
411 | 411 | R3 |
412 | 412 | R4 |
413 | 413 | R5 |
414 | 414 | R0 |
415 | -Z59 8bench/sincos_sub_bench_3.vhd | |
416 | -Z60 Fbench/sincos_sub_bench_3.vhd | |
415 | +Z61 8bench/sincos_sub_bench_3.vhd | |
416 | +Z62 Fbench/sincos_sub_bench_3.vhd | |
417 | 417 | l0 |
418 | 418 | L25 |
419 | 419 | VGegYS0EVb1RP_TR@gQRGi1 |
@@ -423,8 +423,8 @@ R8 | ||
423 | 423 | R9 |
424 | 424 | !i10b 1 |
425 | 425 | R10 |
426 | -Z61 !s90 -explicit|-work|work|-2008|-quiet|bench/sincos_sub_bench_3.vhd| | |
427 | -Z62 !s107 bench/sincos_sub_bench_3.vhd| | |
426 | +Z63 !s90 -explicit|-work|work|-2008|-quiet|bench/sincos_sub_bench_3.vhd| | |
427 | +Z64 !s107 bench/sincos_sub_bench_3.vhd| | |
428 | 428 | !i113 1 |
429 | 429 | R13 |
430 | 430 | R14 |
@@ -434,7 +434,7 @@ R2 | ||
434 | 434 | R3 |
435 | 435 | R4 |
436 | 436 | R5 |
437 | -R42 | |
437 | +R44 | |
438 | 438 | l45 |
439 | 439 | L28 |
440 | 440 | V;>HN;M[mKm5hzZNaGShBE1 |
@@ -444,20 +444,20 @@ R8 | ||
444 | 444 | R9 |
445 | 445 | !i10b 1 |
446 | 446 | R10 |
447 | -R61 | |
448 | -R62 | |
447 | +R63 | |
448 | +R64 | |
449 | 449 | !i113 1 |
450 | 450 | R13 |
451 | 451 | R14 |
452 | 452 | Esincos_sub_bench_4 |
453 | -R46 | |
453 | +R48 | |
454 | 454 | R2 |
455 | 455 | R3 |
456 | 456 | R4 |
457 | 457 | R5 |
458 | 458 | R0 |
459 | -Z63 8bench/sincos_sub_bench_4.vhd | |
460 | -Z64 Fbench/sincos_sub_bench_4.vhd | |
459 | +Z65 8bench/sincos_sub_bench_4.vhd | |
460 | +Z66 Fbench/sincos_sub_bench_4.vhd | |
461 | 461 | l0 |
462 | 462 | L25 |
463 | 463 | VA;`YdiTN7jF8GI5jY[EP_3 |
@@ -467,8 +467,8 @@ R8 | ||
467 | 467 | R9 |
468 | 468 | !i10b 1 |
469 | 469 | R10 |
470 | -Z65 !s90 -explicit|-work|work|-2008|-quiet|bench/sincos_sub_bench_4.vhd| | |
471 | -Z66 !s107 bench/sincos_sub_bench_4.vhd| | |
470 | +Z67 !s90 -explicit|-work|work|-2008|-quiet|bench/sincos_sub_bench_4.vhd| | |
471 | +Z68 !s107 bench/sincos_sub_bench_4.vhd| | |
472 | 472 | !i113 1 |
473 | 473 | R13 |
474 | 474 | R14 |
@@ -478,7 +478,7 @@ R2 | ||
478 | 478 | R3 |
479 | 479 | R4 |
480 | 480 | R5 |
481 | -R41 | |
481 | +R43 | |
482 | 482 | l45 |
483 | 483 | L28 |
484 | 484 | VhnKz7aS5eL=O;35K5<NIF2 |
@@ -488,8 +488,8 @@ R8 | ||
488 | 488 | R9 |
489 | 489 | !i10b 1 |
490 | 490 | R10 |
491 | -R65 | |
492 | -R66 | |
491 | +R67 | |
492 | +R68 | |
493 | 493 | !i113 1 |
494 | 494 | R13 |
495 | 495 | R14 |
@@ -500,8 +500,8 @@ R3 | ||
500 | 500 | R4 |
501 | 501 | R5 |
502 | 502 | R0 |
503 | -Z67 8bench/sincos_sub_bench_5.vhd | |
504 | -Z68 Fbench/sincos_sub_bench_5.vhd | |
503 | +Z69 8bench/sincos_sub_bench_5.vhd | |
504 | +Z70 Fbench/sincos_sub_bench_5.vhd | |
505 | 505 | l0 |
506 | 506 | L25 |
507 | 507 | Vz1XPZlOlmVbNZb5V@JZg`3 |
@@ -511,8 +511,8 @@ R8 | ||
511 | 511 | R9 |
512 | 512 | !i10b 1 |
513 | 513 | R10 |
514 | -Z69 !s90 -explicit|-work|work|-2008|-quiet|bench/sincos_sub_bench_5.vhd| | |
515 | -Z70 !s107 bench/sincos_sub_bench_5.vhd| | |
514 | +Z71 !s90 -explicit|-work|work|-2008|-quiet|bench/sincos_sub_bench_5.vhd| | |
515 | +Z72 !s107 bench/sincos_sub_bench_5.vhd| | |
516 | 516 | !i113 1 |
517 | 517 | R13 |
518 | 518 | R14 |
@@ -522,7 +522,7 @@ R2 | ||
522 | 522 | R3 |
523 | 523 | R4 |
524 | 524 | R5 |
525 | -R40 | |
525 | +R42 | |
526 | 526 | l45 |
527 | 527 | L28 |
528 | 528 | Vg9geaHiXHiiCLGQFzNVNe1 |
@@ -532,8 +532,8 @@ R8 | ||
532 | 532 | R9 |
533 | 533 | !i10b 1 |
534 | 534 | R10 |
535 | -R69 | |
536 | -R70 | |
535 | +R71 | |
536 | +R72 | |
537 | 537 | !i113 1 |
538 | 538 | R13 |
539 | 539 | R14 |
@@ -67,13 +67,13 @@ int main() { | ||
67 | 67 | // positive x, async reset test |
68 | 68 | test_5( filename_vector_5, filename_reference_5); |
69 | 69 | |
70 | -gen_table( filename_angle_delta, filename_scaling_factor); | |
70 | + gen_table( filename_angle_delta, filename_scaling_factor); | |
71 | 71 | |
72 | 72 | |
73 | - test_100( filename_vector_100, filename_reference_100, 20 ); | |
73 | + test_100( filename_vector_100, filename_reference_100 ); | |
74 | 74 | |
75 | 75 | // test signal and clock changes simul. |
76 | - test_101( filename_vector_101, filename_reference_101, 20 ); | |
76 | + test_101( filename_vector_101, filename_reference_101 ); | |
77 | 77 | |
78 | 78 | |
79 | 79 | } |
@@ -224,15 +224,46 @@ void test_5( char *vec_name, char * ref_name) // test of completely same timing | ||
224 | 224 | test_async_13bit(vec, ref, 23, 0, 16, 64, 1, 0 ); // x, angle, p, q, reset, clk |
225 | 225 | |
226 | 226 | // positive rounding |
227 | - test_async_13bit(vec, ref, 23, 0, 255, 0, 0, 0 ); // x, angle, p, q, reset, clk | |
227 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 0 ); // x, angle, p, q, reset, clk | |
228 | 228 | test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk |
229 | 229 | test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk |
230 | 230 | test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 0 ); // x, angle, p, q, reset, clk |
231 | 231 | |
232 | - test_async_13bit(vec, ref, 23, 0, 255, 0, 0, 0 ); // x, angle, p, q, reset, clk // same with above when truncated, +1 when rounding | |
232 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 0 ); // x, angle, p, q, reset, clk | |
233 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 1 ); // x, angle, p, q, reset, clk | |
234 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 1 ); // x, angle, p, q, reset, clk | |
235 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 0 ); // x, angle, p, q, reset, clk | |
236 | + | |
237 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 0 ); // x, angle, p, q, reset, clk | |
238 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk | |
239 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk | |
240 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 0 ); // x, angle, p, q, reset, clk | |
241 | + | |
242 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 0 ); // x, angle, p, q, reset, clk | |
243 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 1 ); // x, angle, p, q, reset, clk | |
244 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 1 ); // x, angle, p, q, reset, clk | |
245 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 0 ); // x, angle, p, q, reset, clk | |
246 | + | |
247 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 0 ); // x, angle, p, q, reset, clk | |
248 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk | |
249 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk | |
250 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 0 ); // x, angle, p, q, reset, clk | |
251 | + | |
252 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 0 ); // x, angle, p, q, reset, clk | |
253 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 1 ); // x, angle, p, q, reset, clk | |
254 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 1 ); // x, angle, p, q, reset, clk | |
255 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 0 ); // x, angle, p, q, reset, clk | |
256 | + | |
257 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 0 ); // x, angle, p, q, reset, clk | |
233 | 258 | test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk |
234 | 259 | test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk |
235 | 260 | test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 0 ); // x, angle, p, q, reset, clk |
261 | + | |
262 | + test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 0 ); // x, angle, p, q, reset, clk | |
263 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 1 ); // x, angle, p, q, reset, clk | |
264 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 1 ); // x, angle, p, q, reset, clk | |
265 | + test_async_13bit(vec, ref, 23, 0, 255, 65, 0, 0 ); // x, angle, p, q, reset, clk | |
266 | + | |
236 | 267 | } |
237 | 268 | |
238 | 269 |
@@ -244,11 +275,13 @@ void test_5( char *vec_name, char * ref_name) // test of completely same timing | ||
244 | 275 | *****************************************************************/ |
245 | 276 | |
246 | 277 | |
247 | -void test_100( char *vec_name, char * ref_name, int num_stages) | |
278 | +void test_100( char *vec_name, char * ref_name ) | |
248 | 279 | { |
249 | 280 | std::ofstream vec; vec.open(vec_name); |
250 | 281 | std::ofstream ref; ref.open(ref_name); |
251 | 282 | |
283 | + | |
284 | + const int num_stages = 20; | |
252 | 285 | int x = 0; |
253 | 286 | |
254 | 287 | // reset |
@@ -276,32 +309,32 @@ void test_100( char *vec_name, char * ref_name, int num_stages) | ||
276 | 309 | } |
277 | 310 | } |
278 | 311 | |
279 | -void test_101( char *vec_name, char * ref_name, int num_stages) | |
312 | +void test_101( char *vec_name, char * ref_name) | |
280 | 313 | { |
281 | 314 | std::ofstream vec; vec.open(vec_name); |
282 | 315 | std::ofstream ref; ref.open(ref_name); |
283 | 316 | |
317 | + const int num_stages = 3; | |
284 | 318 | int x = 0; |
285 | 319 | |
286 | 320 | // reset |
287 | 321 | cordic_sincos_bw32( vec, ref, num_stages, x, 1, 0 ); |
288 | 322 | |
289 | - // scan [-0.5, 0.5) | |
290 | - // scan [-0.5, 0.5) | |
291 | - for ( int i = -128; i < 127; i++ ) | |
323 | + // | |
324 | + for ( int i = -4; i < 3; i++ ) | |
292 | 325 | { |
293 | 326 | cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); |
294 | - x = i << 23; | |
327 | + x = i << 28; | |
295 | 328 | cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); |
296 | 329 | cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); |
297 | 330 | cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); |
298 | 331 | } |
299 | 332 | |
300 | 333 | // flush pipeline |
301 | - for ( int i = 0; i < num_stages; i++ ) | |
334 | + for ( int i = 0; i < num_stages+2; i++ ) | |
302 | 335 | { |
303 | 336 | cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); |
304 | - x = i << 16; | |
337 | + x = 0; | |
305 | 338 | cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); |
306 | 339 | cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 ); |
307 | 340 | cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 ); |
@@ -440,10 +473,13 @@ vec | ||
440 | 473 | << std::bitset<1>( clk ) << " " // clock |
441 | 474 | << std::bitset<BITWIDTH>( x ) << std::endl; |
442 | 475 | |
443 | -cordic.run( 20, clk, reset, x, out_p, out_q ); | |
476 | +cordic.run( num_stages, clk, reset, x, out_p, out_q ); | |
444 | 477 | |
445 | 478 | ref |
446 | 479 | << std::bitset<BITWIDTH>( out_p ) << " " |
447 | 480 | << std::bitset<BITWIDTH>( out_q ) << std::endl; |
448 | 481 | |
449 | 482 | } |
483 | + | |
484 | + | |
485 | + |
@@ -141,8 +141,8 @@ void test_5( char *vec_name, char * ref_name); | ||
141 | 141 | |
142 | 142 | |
143 | 143 | |
144 | -void test_100( char *vec_name, char * ref_name, int num_stages ); | |
145 | -void test_101( char *vec_name, char * ref_name, int num_stages ); | |
144 | +void test_100( char *vec_name, char * ref_name ); | |
145 | +void test_101( char *vec_name, char * ref_name ); | |
146 | 146 | void cordic_sincos_bw32( std::ostream &vec, std::ostream &ref, int num_stages, int x, int reset, int clk ); |
147 | 147 | |
148 | 148 |