• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

shared_fooの不要ディレクトリ削除前のもの


Commit MetaInfo

Revision95e69d27192180fa210ad66112f9e898005731bd (tree)
Zeit2016-10-12 11:42:37
Autorsuikan <suikan@user...>
Commitersuikan

Log Message

Debug undergoing. Some problem in pipeline

Ändern Zusammenfassung

Diff

--- a/vhdl_my_lib/.metadata/.plugins/org.eclipse.cdt.core/.log
+++ b/vhdl_my_lib/.metadata/.plugins/org.eclipse.cdt.core/.log
@@ -37,3 +37,4 @@
3737 *** SESSION 10月 11, 2016 09:49:16.17 -------------------------------------------
3838 *** SESSION 10月 11, 2016 16:27:29.20 -------------------------------------------
3939 *** SESSION 10月 11, 2016 23:45:20.61 -------------------------------------------
40+*** SESSION 10月 12, 2016 10:36:46.53 -------------------------------------------
Binary files a/vhdl_my_lib/.metadata/.plugins/org.eclipse.cdt.core/cordic_sincos_testgen.1475319001122.pdom and b/vhdl_my_lib/.metadata/.plugins/org.eclipse.cdt.core/cordic_sincos_testgen.1475319001122.pdom differ
--- a/vhdl_my_lib/.metadata/.plugins/org.eclipse.cdt.core/language.settings.xml
+++ b/vhdl_my_lib/.metadata/.plugins/org.eclipse.cdt.core/language.settings.xml
@@ -1,7 +1,7 @@
11 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
22 <plugin>
33 <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 &quot;${INPUTS}&quot;">
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 &quot;${INPUTS}&quot;">
55 <language-scope id="org.eclipse.cdt.core.gcc"/>
66 <language-scope id="org.eclipse.cdt.core.g++"/>
77 <language id="org.eclipse.cdt.core.gcc">
--- a/vhdl_my_lib/.metadata/.plugins/org.eclipse.cdt.ui/cordic_sincos_testgen.build.log
+++ b/vhdl_my_lib/.metadata/.plugins/org.eclipse.cdt.ui/cordic_sincos_testgen.build.log
@@ -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 ****
22 make all
33 Building file: ../main.cpp
44 Invoking: GCC C++ Compiler
@@ -11,5 +11,5 @@ g++ -o "cordic_sincos_testgen" ./vhdl/sincosangledelta.o ./vhdl/sincoscordic.o
1111 Finished building target: cordic_sincos_testgen
1212
1313
14-08:53:33 Build Finished (took 990ms)
14+11:38:46 Build Finished (took 570ms)
1515
--- a/vhdl_my_lib/.metadata/.plugins/org.eclipse.cdt.ui/global-build.log
+++ b/vhdl_my_lib/.metadata/.plugins/org.eclipse.cdt.ui/global-build.log
@@ -5273,3 +5273,72 @@ Invoking: GCC C++ Linker
52735273 g++ -o "cordic_sincos_testgen" ./vhdl/sincosangledelta.o ./vhdl/sincoscordic.o ./vhdl/sincosscalingfactor.o ./vhdl/sincossub.o ./main.o
52745274 Finished building target: cordic_sincos_testgen
52755275
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+
--- a/vhdl_my_lib/.metadata/.plugins/org.eclipse.core.resources/.history/13/40ca40bce08e00161d9dc38de87e785a
+++ /dev/null
@@ -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-}
--- a/vhdl_my_lib/.metadata/.plugins/org.eclipse.core.resources/.history/18/5064b9a5ab8a001619b5f32be32c925e
+++ /dev/null
@@ -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
--- a/vhdl_my_lib/.metadata/.plugins/org.eclipse.core.resources/.history/13/40d1a055e08e00161d9dc38de87e785a
+++ b/vhdl_my_lib/.metadata/.plugins/org.eclipse.core.resources/.history/5b/b01538251e90001614edfeaed7a96a0b
@@ -22,27 +22,32 @@
2222 int main() {
2323
2424
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";
2727
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";
3030
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";
3333
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";
3636
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";
3939
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";
4142
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";
4345
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";
4651
4752 // positive x,
4853 test_0( filename_vector_0, filename_reference_0);
@@ -59,10 +64,16 @@ int main() {
5964 // positive x, async reset test
6065 test_4( filename_vector_4, filename_reference_4);
6166
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+
6372
73+ test_100( filename_vector_100, filename_reference_100, 20 );
6474
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 );
6677
6778
6879 }
@@ -98,99 +109,12 @@ void gen_table( const char * filename_angle_delta, const char * filename_scaling
98109 }
99110 }
100111
112+/*****************************************************************
113+ *
114+ * SINCOS SUB vector generation
115+ *
116+ *****************************************************************/
101117
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-}
194118
195119 void test_0( char *vec_name, char * ref_name) // positive rounding
196120 {
@@ -291,58 +215,113 @@ void test_4( char *vec_name, char * ref_name) // async reset
291215 test_async_11bit(vec, ref, 23, 32, 430, 75, 0, 1 ); // x, angle, p, q, reset, clk
292216 }
293217
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
304219 {
305-#ifdef BITWIDTH
306-#undef BITWIDTH
307-#endif
220+ std::ofstream vec; vec.open(vec_name);
221+ std::ofstream ref; ref.open(ref_name);
308222
309-#define BITWIDTH 32
223+ // reset
224+ test_async_13bit(vec, ref, 23, 0, 16, 64, 1, 0 ); // x, angle, p, q, reset, clk
310225
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
313266
314- static vhdl::sincos_angle_delta ad;
315- static vhdl::sincos_scaling_factor sf;
316- static vhdl::sincos_cordic cordic;
267+}
317268
318269
319- vec
320- << std::bitset<1>( reset ) << " " // reset
321- << std::bitset<1>( clk ) << " " // clock
322- << std::bitset<BITWIDTH>( x ) << std::endl;
323270
324- cordic.run( 20, clk, reset, x, p, q );
271+/*****************************************************************
272+ *
273+ * SINCOS vector generation
274+ *
275+ *****************************************************************/
325276
326- ref
327- << std::bitset<BITWIDTH>( last_p ) << " "
328- << std::bitset<BITWIDTH>( last_q ) << std::endl;
329277
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+ }
330298
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+ }
331308 }
332309
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)
334311 {
312+ std::ofstream vec; vec.open(vec_name);
313+ std::ofstream ref; ref.open(ref_name);
335314
336315 int x = 0;
337316
338317 // reset
339318 cordic_sincos_bw32( vec, ref, num_stages, x, 1, 0 );
340319
341- // scan [-0.5, 0.5)
342- for ( int i = -64; i < 63; i++ )
320+ //
321+ for ( int i = -3; i < 2; i++ )
343322 {
344323 cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 );
345- x = i << 24;
324+ x = i << 23;
346325 cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 );
347326 cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 );
348327 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 )
352331 for ( int i = 0; i < num_stages; i++ )
353332 {
354333 cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 );
355- x = i << 16;
334+ x = 0;
356335 cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 );
357336 cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 );
358337 cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 );
359338 }
360339 }
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+}
--- a/vhdl_my_lib/.metadata/.plugins/org.eclipse.core.resources/.history/76/a091f4efe08e00161d9dc38de87e785a
+++ b/vhdl_my_lib/.metadata/.plugins/org.eclipse.core.resources/.history/64/e04e4f971c90001614edfeaed7a96a0b
@@ -22,27 +22,32 @@
2222 int main() {
2323
2424
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";
2727
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";
3030
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";
3333
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";
3636
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";
3939
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";
4142
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";
4345
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";
4651
4752 // positive x,
4853 test_0( filename_vector_0, filename_reference_0);
@@ -59,10 +64,16 @@ int main() {
5964 // positive x, async reset test
6065 test_4( filename_vector_4, filename_reference_4);
6166
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+
6372
73+ test_100( filename_vector_100, filename_reference_100, 20 );
6474
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 );
6677
6778
6879 }
@@ -98,99 +109,12 @@ void gen_table( const char * filename_angle_delta, const char * filename_scaling
98109 }
99110 }
100111
112+/*****************************************************************
113+ *
114+ * SINCOS SUB vector generation
115+ *
116+ *****************************************************************/
101117
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-}
194118
195119 void test_0( char *vec_name, char * ref_name) // positive rounding
196120 {
@@ -291,57 +215,83 @@ void test_4( char *vec_name, char * ref_name) // async reset
291215 test_async_11bit(vec, ref, 23, 32, 430, 75, 0, 1 ); // x, angle, p, q, reset, clk
292216 }
293217
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
304219 {
305-#ifdef BITWIDTH
306-#undef BITWIDTH
307-#endif
220+ std::ofstream vec; vec.open(vec_name);
221+ std::ofstream ref; ref.open(ref_name);
308222
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+}
310237
311- int out_p, out_q;
312238
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+ *****************************************************************/
316245
317246
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);
322251
323- cordic.run( 20, clk, reset, x, out_p, out_q );
252+ int x = 0;
324253
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 );
328256
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+ }
329267
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+ }
330277 }
331278
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)
333280 {
281+ std::ofstream vec; vec.open(vec_name);
282+ std::ofstream ref; ref.open(ref_name);
334283
335284 int x = 0;
336285
337286 // reset
338287 cordic_sincos_bw32( vec, ref, num_stages, x, 1, 0 );
339288
289+ // scan [-0.5, 0.5)
340290 // scan [-0.5, 0.5)
341- for ( int i = -64; i < 63; i++ )
291+ for ( int i = -128; i < 127; i++ )
342292 {
343293 cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 );
344- x = i << 24;
294+ x = i << 23;
345295 cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 );
346296 cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 );
347297 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 )
357307 cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 );
358308 }
359309 }
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+}
--- /dev/null
+++ b/vhdl_my_lib/.metadata/.plugins/org.eclipse.core.resources/.history/8/60197f7e2490001614edfeaed7a96a0b
@@ -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+--! @}
--- /dev/null
+++ b/vhdl_my_lib/.metadata/.plugins/org.eclipse.core.resources/.history/82/e04ce4762290001614edfeaed7a96a0b
@@ -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+--! @}
--- /dev/null
+++ b/vhdl_my_lib/.metadata/.plugins/org.eclipse.core.resources/.history/83/80df4f652290001614edfeaed7a96a0b
@@ -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+--! @}
--- /dev/null
+++ b/vhdl_my_lib/.metadata/.plugins/org.eclipse.core.resources/.history/88/b043da3f2490001614edfeaed7a96a0b
@@ -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_ */
--- a/vhdl_my_lib/.metadata/.plugins/org.eclipse.core.resources/.history/97/e014b71cab8a001619b5f32be32c925e
+++ /dev/null
@@ -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-
--- /dev/null
+++ b/vhdl_my_lib/.metadata/.plugins/org.eclipse.core.resources/.history/a2/a035ccf91d90001614edfeaed7a96a0b
@@ -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+}
--- a/vhdl_my_lib/.metadata/.plugins/org.eclipse.core.resources/.history/a4/a07c0b12e08e00161d9dc38de87e785a
+++ /dev/null
@@ -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-}
--- a/vhdl_my_lib/.metadata/.plugins/org.eclipse.core.resources/.history/a8/408c1ca1e08e00161d9dc38de87e785a
+++ /dev/null
@@ -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-}
--- a/vhdl_my_lib/.metadata/.plugins/org.eclipse.core.resources/.history/a3/e01fd37fe08e00161d9dc38de87e785a
+++ b/vhdl_my_lib/.metadata/.plugins/org.eclipse.core.resources/.history/af/00a56f1c2490001614edfeaed7a96a0b
@@ -22,27 +22,32 @@
2222 int main() {
2323
2424
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";
2727
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";
3030
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";
3333
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";
3636
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";
3939
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";
4142
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";
4345
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";
4651
4752 // positive x,
4853 test_0( filename_vector_0, filename_reference_0);
@@ -59,10 +64,16 @@ int main() {
5964 // positive x, async reset test
6065 test_4( filename_vector_4, filename_reference_4);
6166
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+
6372
73+ test_100( filename_vector_100, filename_reference_100, 20 );
6474
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 );
6677
6778
6879 }
@@ -98,99 +109,12 @@ void gen_table( const char * filename_angle_delta, const char * filename_scaling
98109 }
99110 }
100111
112+/*****************************************************************
113+ *
114+ * SINCOS SUB vector generation
115+ *
116+ *****************************************************************/
101117
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-}
194118
195119 void test_0( char *vec_name, char * ref_name) // positive rounding
196120 {
@@ -291,70 +215,265 @@ void test_4( char *vec_name, char * ref_name) // async reset
291215 test_async_11bit(vec, ref, 23, 32, 430, 75, 0, 1 ); // x, angle, p, q, reset, clk
292216 }
293217
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
304219 {
305-#ifdef BITWIDTH
306-#undef BITWIDTH
307-#endif
220+ std::ofstream vec; vec.open(vec_name);
221+ std::ofstream ref; ref.open(ref_name);
308222
309-#define BITWIDTH 32
223+ // reset
224+ test_async_13bit(vec, ref, 23, 0, 16, 64, 1, 0 ); // x, angle, p, q, reset, clk
310225
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
313266
314- static vhdl::sincos_angle_delta ad;
315- static vhdl::sincos_scaling_factor sf;
316- static vhdl::sincos_cordic cordic;
267+}
317268
318269
319- vec
320- << std::bitset<1>( reset ) << " " // reset
321- << std::bitset<1>( clk ) << " " // clock
322- << std::bitset<BITWIDTH>( x ) << std::endl;
323270
324- cordic.run( 20, clk, reset, x, last_p, last_q );
271+/*****************************************************************
272+ *
273+ * SINCOS vector generation
274+ *
275+ *****************************************************************/
325276
326- ref
327- << std::bitset<BITWIDTH>( last_p ) << " "
328- << std::bitset<BITWIDTH>( last_q ) << std::endl;
329277
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+ }
330298
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+ }
331308 }
332309
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)
334311 {
312+ std::ofstream vec; vec.open(vec_name);
313+ std::ofstream ref; ref.open(ref_name);
335314
336315 int x = 0;
337316
338317 // reset
339318 cordic_sincos_bw32( vec, ref, num_stages, x, 1, 0 );
340319
341- // scan [-0.5, 0.5)
342- for ( int i = -64; i < 63; i++ )
320+ //
321+ for ( int i = -3; i < 2; i++ )
343322 {
344323 cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 );
345- x = i << 24;
324+ x = i << 23;
346325 cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 );
347326 cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 );
348327 cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 );
349328 }
350329
351330 // flush pipeline
352- for ( int i = 0; i < num_stages; i++ )
331+ for ( int i = 0; i < num_stages+2; i++ )
353332 {
354333 cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 );
355- x = i << 16;
334+ x = 0;
356335 cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 );
357336 cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 );
358337 cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 );
359338 }
360339 }
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+}
--- /dev/null
+++ b/vhdl_my_lib/.metadata/.plugins/org.eclipse.core.resources/.history/b2/80ad832f2490001614edfeaed7a96a0b
@@ -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+
--- a/vhdl_my_lib/.metadata/.plugins/org.eclipse.core.resources/.history/c4/a0b19a8ee08e00161d9dc38de87e785a
+++ /dev/null
@@ -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-}
--- a/vhdl_my_lib/.metadata/.plugins/org.eclipse.core.resources/.history/c6/d0794d8bab8a001619b5f32be32c925e
+++ /dev/null
@@ -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-
--- a/vhdl_my_lib/.metadata/.plugins/org.eclipse.core.resources/.history/d0/80070cc4e08e00161d9dc38de87e785a
+++ b/vhdl_my_lib/.metadata/.plugins/org.eclipse.core.resources/.history/d/50671bfe2490001614edfeaed7a96a0b
@@ -22,27 +22,32 @@
2222 int main() {
2323
2424
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";
2727
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";
3030
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";
3333
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";
3636
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";
3939
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";
4142
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";
4345
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";
4651
4752 // positive x,
4853 test_0( filename_vector_0, filename_reference_0);
@@ -59,10 +64,16 @@ int main() {
5964 // positive x, async reset test
6065 test_4( filename_vector_4, filename_reference_4);
6166
67+ // positive x, async reset test
68+ test_5( filename_vector_5, filename_reference_5);
69+
6270 gen_table( filename_angle_delta, filename_scaling_factor);
6371
6472
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 );
6677
6778
6879 }
@@ -98,99 +109,12 @@ void gen_table( const char * filename_angle_delta, const char * filename_scaling
98109 }
99110 }
100111
112+/*****************************************************************
113+ *
114+ * SINCOS SUB vector generation
115+ *
116+ *****************************************************************/
101117
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-}
194118
195119 void test_0( char *vec_name, char * ref_name) // positive rounding
196120 {
@@ -291,69 +215,271 @@ void test_4( char *vec_name, char * ref_name) // async reset
291215 test_async_11bit(vec, ref, 23, 32, 430, 75, 0, 1 ); // x, angle, p, q, reset, clk
292216 }
293217
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
304219 {
305-#ifdef BITWIDTH
306-#undef BITWIDTH
307-#endif
220+ std::ofstream vec; vec.open(vec_name);
221+ std::ofstream ref; ref.open(ref_name);
308222
309-#define BITWIDTH 32
223+ // reset
224+ test_async_13bit(vec, ref, 23, 0, 16, 64, 1, 0 ); // x, angle, p, q, reset, clk
310225
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+ *****************************************************************/
312276
313- static vhdl::sincos_angle_delta ad;
314- static vhdl::sincos_scaling_factor sf;
315- static vhdl::sincos_cordic cordic;
316277
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);
317282
318- vec
319- << std::bitset<1>( reset ) << " " // reset
320- << std::bitset<1>( clk ) << " " // clock
321- << std::bitset<BITWIDTH>( x ) << std::endl;
322283
323- cordic.run( 20, clk, reset, x, out_p, out_q );
284+ const int num_stages = 20;
285+ int x = 0;
324286
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 );
328289
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+ }
329300
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+ }
330310 }
331311
332-void test_100( std::ostream &vec, std::ostream &ref, int num_stages )
312+void test_101( char *vec_name, char * ref_name)
333313 {
314+ std::ofstream vec; vec.open(vec_name);
315+ std::ofstream ref; ref.open(ref_name);
334316
317+ const int num_stages = 3;
335318 int x = 0;
336319
337320 // reset
338321 cordic_sincos_bw32( vec, ref, num_stages, x, 1, 0 );
339322
340- // scan [-0.5, 0.5)
341- for ( int i = -64; i < 63; i++ )
323+ //
324+ for ( int i = -3; i < 2; i++ )
342325 {
343326 cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 );
344- x = i << 24;
327+ x = i << 23;
345328 cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 );
346329 cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 );
347330 cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 );
348331 }
349332
350333 // flush pipeline
351- for ( int i = 0; i < num_stages; i++ )
334+ for ( int i = 0; i < num_stages+2; i++ )
352335 {
353336 cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 );
354- x = i << 16;
337+ x = 0;
355338 cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 );
356339 cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 );
357340 cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 );
358341 }
359342 }
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+
--- /dev/null
+++ b/vhdl_my_lib/.metadata/.plugins/org.eclipse.core.resources/.history/dd/e05d76d31d90001614edfeaed7a96a0b
@@ -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+}
--- /dev/null
+++ b/vhdl_my_lib/.metadata/.plugins/org.eclipse.core.resources/.history/ff/f0f590282490001614edfeaed7a96a0b
@@ -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+
Binary files a/vhdl_my_lib/.metadata/.plugins/org.eclipse.core.resources/.projects/cordic_sincos/.indexes/30/history.index and b/vhdl_my_lib/.metadata/.plugins/org.eclipse.core.resources/.projects/cordic_sincos/.indexes/30/history.index differ
Binary files a/vhdl_my_lib/.metadata/.plugins/org.eclipse.core.resources/.projects/cordic_sincos/.indexes/e4/history.index and b/vhdl_my_lib/.metadata/.plugins/org.eclipse.core.resources/.projects/cordic_sincos/.indexes/e4/history.index differ
Binary files a/vhdl_my_lib/.metadata/.plugins/org.eclipse.core.resources/.projects/cordic_sincos/.indexes/history.index and b/vhdl_my_lib/.metadata/.plugins/org.eclipse.core.resources/.projects/cordic_sincos/.indexes/history.index differ
Binary files a/vhdl_my_lib/.metadata/.plugins/org.eclipse.core.resources/.projects/cordic_sincos_testgen/.indexes/history.index and b/vhdl_my_lib/.metadata/.plugins/org.eclipse.core.resources/.projects/cordic_sincos_testgen/.indexes/history.index differ
Binary files a/vhdl_my_lib/.metadata/.plugins/org.eclipse.core.resources/.projects/cordic_sincos_testgen/.markers and b/vhdl_my_lib/.metadata/.plugins/org.eclipse.core.resources/.projects/cordic_sincos_testgen/.markers differ
Binary files a/vhdl_my_lib/.metadata/.plugins/org.eclipse.core.resources/.root/39.tree and /dev/null differ
Binary files /dev/null and b/vhdl_my_lib/.metadata/.plugins/org.eclipse.core.resources/.root/40.tree differ
Binary files a/vhdl_my_lib/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources and b/vhdl_my_lib/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources differ
--- a/vhdl_my_lib/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.ide.prefs
+++ b/vhdl_my_lib/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.ide.prefs
@@ -5,6 +5,6 @@ IMPORT_FILES_AND_FOLDERS_VIRTUAL_FOLDER_MODE=prompt
55 PROBLEMS_FILTERS_MIGRATE=true
66 TASKS_FILTERS_MIGRATE=true
77 eclipse.preferences.version=1
8-platformState=1475306727637
8+platformState=1470363830848
99 quickStart=false
1010 tipsAndTricks=true
--- a/vhdl_my_lib/.metadata/.plugins/org.eclipse.ui.workbench/workbench.xml
+++ b/vhdl_my_lib/.metadata/.plugins/org.eclipse.ui.workbench/workbench.xml
@@ -19,14 +19,15 @@
1919 <coolItem id="org.eclipse.search.searchActionSet" itemType="typeToolBarContribution" x="88" y="30"/>
2020 <coolItem id="org.eclipse.ui.edit.text.actionSet.presentation" itemType="typeToolBarContribution" x="68" y="30"/>
2121 <coolItem id="group.nav" itemType="typeGroupMarker"/>
22-<coolItem id="org.eclipse.ui.workbench.navigate" itemType="typeToolBarContribution" x="232" y="30"/>
2322 <coolItem id="group.editor" itemType="typeGroupMarker"/>
2423 <coolItem id="org.eclipse.cdt.make.editor" itemType="typePlaceholder" x="-1" y="-1"/>
2524 <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"/>
2726 <coolItem id="org.eclipse.ui.DefaultTextEditor" itemType="typeToolBarContribution" x="-1" y="-1"/>
2827 <coolItem id="group.help" itemType="typeGroupMarker"/>
2928 <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"/>
3031 </coolbarLayout>
3132 <page aggregateWorkingSetId="Aggregate for window 1474028500277" focus="true" label="Workspace - C/C++">
3233 <editors>
@@ -36,6 +37,14 @@
3637 <presentation id="org.eclipse.ui.presentations.WorkbenchPresentationFactory">
3738 <part id="0"/>
3839 <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"/>
3948 </presentation>
4049 </folder>
4150 </info>
@@ -44,9 +53,37 @@
4453 <input factoryID="org.eclipse.ui.part.FileEditorInputFactory" path="/cordic_sincos/build"/>
4554 <editorState selectionHorizontalPixel="0" selectionLength="0" selectionOffset="425" selectionTopPixel="200"/>
4655 </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">
4857 <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"/>
5087 </editor>
5188 </editors>
5289 <views>
@@ -55,6 +92,7 @@
5592 <viewState PRIMARY_SORT_FIELD="org.eclipse.ui.ide.severityAndDescriptionField" categoryGroup="org.eclipse.ui.ide.severity" markerContentGenerator="org.eclipse.ui.ide.problemsGenerator" partName="Problems">
5693 <expanded>
5794 <category IMemento.internal.id="Errors"/>
95+<category IMemento.internal.id="Errors (1 item)"/>
5896 </expanded>
5997 <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"/>
6098 <visible IMemento.internal.id="org.eclipse.ui.ide.severityAndDescriptionField"/>
@@ -87,7 +125,7 @@
87125 <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"/>
88126 </view>
89127 </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">
91129 <perspective editorAreaTrimState="2" editorAreaVisible="1" fixed="0" version="0.016">
92130 <descriptor class="org.eclipse.ui.internal.ide.application.ResourcePerspective" id="org.eclipse.ui.resourcePerspective" label="Resource"/>
93131 <alwaysOnActionSet id="org.eclipse.ui.cheatsheets.actionSet"/>
@@ -259,174 +297,7 @@
259297 </perspective>
260298 </perspectives>
261299 <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/>
430301 <input factoryID="org.eclipse.ui.internal.model.ResourceFactory" path="/" type="8"/>
431302 </page>
432303 <workbenchWindowAdvisor/>
@@ -443,15 +314,42 @@
443314 </trimLayout>
444315 </window>
445316 <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"/>
448334 </file>
449335 <file factoryID="org.eclipse.ui.part.FileEditorInputFactory" id="org.eclipse.cdt.ui.editor.CEditor" name="main.h" tooltip="cordic_sincos_testgen/main.h">
450336 <persistable path="/cordic_sincos_testgen/main.h"/>
451337 </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>
452347 <file factoryID="org.eclipse.ui.part.FileEditorInputFactory" id="org.eclipse.cdt.ui.editor.CEditor" name="main.cpp" tooltip="cordic_sincos_testgen/main.cpp">
453348 <persistable path="/cordic_sincos_testgen/main.cpp"/>
454349 </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>
455353 <file factoryID="org.eclipse.ui.part.FileEditorInputFactory" id="net.sourceforge.veditor.editor.VhdlEditor" name="sincos_sub.vhd" tooltip="cordic_sincos/src/sincos_sub.vhd">
456354 <persistable path="/cordic_sincos/src/sincos_sub.vhd"/>
457355 </file>
@@ -461,32 +359,5 @@
461359 <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">
462360 <persistable path="/cordic_sincos/vectors/sincos_100.dut.txt"/>
463361 </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>
491362 </mruList>
492363 </workbench>
\ No newline at end of file
--- a/vhdl_my_lib/cordic_sincos/bench/sincos_cordic_bench_101.vhd
+++ b/vhdl_my_lib/cordic_sincos/bench/sincos_cordic_bench_101.vhd
@@ -30,7 +30,7 @@ architecture RTL of sincos_cordic_bench_101 is
3030 file fi: TEXT open read_mode is "vectors/sincos_101.vec.txt";
3131
3232 constant max_bit : integer := 31;
33- constant num_stage : integer := 20;
33+ constant num_stage : integer := 3;
3434
3535 signal clock_0 : std_logic := '0';
3636 signal reset_0 : std_logic := '0';
--- a/vhdl_my_lib/cordic_sincos/transcript
+++ b/vhdl_my_lib/cordic_sincos/transcript
@@ -1,6 +1,6 @@
11 # 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
33 # run 1ms
44 # 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
66 # Errors: 0, Warnings: 0
--- a/vhdl_my_lib/cordic_sincos/work/_info
+++ b/vhdl_my_lib/cordic_sincos/work/_info
@@ -9,7 +9,7 @@ z2
99 cModel Technology
1010 Z0 d/home/takemasa/shared_foo/vhdl_my_lib/cordic_sincos
1111 Esincos_cordic
12-Z1 w1476171384
12+Z1 w1476238837
1313 Z2 DPx4 ieee 16 std_logic_textio 0 22 V5TSK`;aJKC<l]CEg1>mz1
1414 Z3 DPx4 ieee 11 numeric_std 0 22 :ASDNFgHXf_ih3J@9F3Ze1
1515 Z4 DPx3 std 6 textio 0 22 zE1`LPoLg^DX3Oz^4Fj1K3
@@ -23,9 +23,9 @@ VDMSgO47IS[e[>cAb@OUT?0
2323 !s100 niN6AKIDm1lVeUPYD`Se[1
2424 Z8 OV;C;10.4d;61
2525 33
26-Z9 !s110 1476230224
26+Z9 !s110 1476239929
2727 !i10b 1
28-Z10 !s108 1476230224.000000
28+Z10 !s108 1476239929.000000
2929 Z11 !s90 -explicit|-work|work|-2008|-quiet|src/sincos_cordic.vhd|
3030 Z12 !s107 src/sincos_cordic.vhd|
3131 !i113 1
@@ -65,19 +65,19 @@ VSVLMLTUONO7cYcScWnR[]0
6565 !s100 Pza0h9Q01kMKR=CHane>=1
6666 R8
6767 33
68-R9
68+Z20 !s110 1476239930
6969 !i10b 1
7070 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|
7373 !i113 1
7474 R13
7575 R14
7676 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
7878 R2
7979 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
8181 R4
8282 R5
8383 DEx4 work 19 sincos_cordic_bench 0 22 SVLMLTUONO7cYcScWnR[]0
@@ -87,11 +87,11 @@ V@PiB8b?KCHoQaLLDzO8aR3
8787 !s100 Ld5InU`168e;0lD0S7o=b3
8888 R8
8989 33
90-R9
90+R20
9191 !i10b 1
9292 R10
93-R20
9493 R21
94+R22
9595 !i113 1
9696 R13
9797 R14
@@ -102,8 +102,8 @@ R3
102102 R4
103103 R5
104104 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
107107 l0
108108 L25
109109 V3@d=0?KzZ:YJS9OlVA4oD3
@@ -113,8 +113,8 @@ R8
113113 R9
114114 !i10b 1
115115 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|
118118 !i113 1
119119 R13
120120 R14
@@ -124,7 +124,7 @@ R2
124124 R3
125125 R4
126126 R5
127-R23
127+R24
128128 l41
129129 L28
130130 VGg25XRcT[j6j]CJQi[0?L0
@@ -134,20 +134,20 @@ R8
134134 R9
135135 !i10b 1
136136 R10
137-R26
138137 R27
138+R28
139139 !i113 1
140140 R13
141141 R14
142142 Esincos_cordic_bench_101
143-R17
143+Z29 w1476239709
144144 R2
145145 R3
146146 R4
147147 R5
148148 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
151151 l0
152152 L25
153153 VenR2@[JY??UXjMFKPfn6]1
@@ -157,8 +157,8 @@ R8
157157 R9
158158 !i10b 1
159159 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|
162162 !i113 1
163163 R13
164164 R14
@@ -168,18 +168,18 @@ R2
168168 R3
169169 R4
170170 R5
171-R22
171+R23
172172 l41
173173 L28
174-VW_]CZ:aVLX^gP:5H@fQ963
175-!s100 :S@_dEHPoI:lmE3P?569e0
174+V2m3]947hX3Ye;0AebNa?g3
175+!s100 @L5hW9MkHIIXklGR<;HLC1
176176 R8
177177 33
178178 R9
179179 !i10b 1
180180 R10
181-R30
182-R31
181+R32
182+R33
183183 !i113 1
184184 R13
185185 R14
@@ -189,8 +189,8 @@ R3
189189 R4
190190 R5
191191 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
194194 l0
195195 L40
196196 VPRDiF:EOYnbWUNjzV>j>92
@@ -200,8 +200,8 @@ R8
200200 R9
201201 !i10b 1
202202 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|
205205 !i113 1
206206 R13
207207 R14
@@ -219,8 +219,8 @@ R8
219219 R9
220220 !i10b 1
221221 R10
222-R34
223-R35
222+R36
223+R37
224224 !i113 1
225225 R13
226226 R14
@@ -231,8 +231,8 @@ R3
231231 R4
232232 R5
233233 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
236236 l0
237237 L21
238238 V8hE]@R;]4cBRk3DcbH:WG0
@@ -242,18 +242,18 @@ R8
242242 R9
243243 !i10b 1
244244 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|
247247 !i113 1
248248 R13
249249 R14
250250 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
257257 R2
258258 R3
259259 R4
@@ -268,20 +268,20 @@ R8
268268 R9
269269 !i10b 1
270270 R10
271-R38
272-R39
271+R40
272+R41
273273 !i113 1
274274 R13
275275 R14
276276 Esincos_sub_bench_0
277-Z46 w1476146790
277+Z48 w1476146790
278278 R2
279279 R3
280280 R4
281281 R5
282282 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
285285 l0
286286 L25
287287 V6>1=dP64^NzTLW><dcNHH1
@@ -291,8 +291,8 @@ R8
291291 R9
292292 !i10b 1
293293 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|
296296 !i113 1
297297 R13
298298 R14
@@ -302,7 +302,7 @@ R2
302302 R3
303303 R4
304304 R5
305-R45
305+R47
306306 l45
307307 L28
308308 VmQ1H3>`c1TF[A@EoHTeb81
@@ -312,20 +312,20 @@ R8
312312 R9
313313 !i10b 1
314314 R10
315-R49
316-R50
315+R51
316+R52
317317 !i113 1
318318 R13
319319 R14
320320 Esincos_sub_bench_1
321-R46
321+R48
322322 R2
323323 R3
324324 R4
325325 R5
326326 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
329329 l0
330330 L25
331331 VSnPiE?o5oHE65XLHTUm3S3
@@ -335,8 +335,8 @@ R8
335335 R9
336336 !i10b 1
337337 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|
340340 !i113 1
341341 R13
342342 R14
@@ -346,7 +346,7 @@ R2
346346 R3
347347 R4
348348 R5
349-R44
349+R46
350350 l45
351351 L28
352352 VTO6Wa8:YgL?04cSLW;0a:3
@@ -356,20 +356,20 @@ R8
356356 R9
357357 !i10b 1
358358 R10
359-R53
360-R54
359+R55
360+R56
361361 !i113 1
362362 R13
363363 R14
364364 Esincos_sub_bench_2
365-R46
365+R48
366366 R2
367367 R3
368368 R4
369369 R5
370370 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
373373 l0
374374 L25
375375 VXdaTVzUVGX3D1<b:^>9J=2
@@ -379,8 +379,8 @@ R8
379379 R9
380380 !i10b 1
381381 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|
384384 !i113 1
385385 R13
386386 R14
@@ -390,7 +390,7 @@ R2
390390 R3
391391 R4
392392 R5
393-R43
393+R45
394394 l45
395395 L28
396396 VGmg2B]XkMH2C9KUFg5dJM0
@@ -400,20 +400,20 @@ R8
400400 R9
401401 !i10b 1
402402 R10
403-R57
404-R58
403+R59
404+R60
405405 !i113 1
406406 R13
407407 R14
408408 Esincos_sub_bench_3
409-R46
409+R48
410410 R2
411411 R3
412412 R4
413413 R5
414414 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
417417 l0
418418 L25
419419 VGegYS0EVb1RP_TR@gQRGi1
@@ -423,8 +423,8 @@ R8
423423 R9
424424 !i10b 1
425425 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|
428428 !i113 1
429429 R13
430430 R14
@@ -434,7 +434,7 @@ R2
434434 R3
435435 R4
436436 R5
437-R42
437+R44
438438 l45
439439 L28
440440 V;>HN;M[mKm5hzZNaGShBE1
@@ -444,20 +444,20 @@ R8
444444 R9
445445 !i10b 1
446446 R10
447-R61
448-R62
447+R63
448+R64
449449 !i113 1
450450 R13
451451 R14
452452 Esincos_sub_bench_4
453-R46
453+R48
454454 R2
455455 R3
456456 R4
457457 R5
458458 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
461461 l0
462462 L25
463463 VA;`YdiTN7jF8GI5jY[EP_3
@@ -467,8 +467,8 @@ R8
467467 R9
468468 !i10b 1
469469 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|
472472 !i113 1
473473 R13
474474 R14
@@ -478,7 +478,7 @@ R2
478478 R3
479479 R4
480480 R5
481-R41
481+R43
482482 l45
483483 L28
484484 VhnKz7aS5eL=O;35K5<NIF2
@@ -488,8 +488,8 @@ R8
488488 R9
489489 !i10b 1
490490 R10
491-R65
492-R66
491+R67
492+R68
493493 !i113 1
494494 R13
495495 R14
@@ -500,8 +500,8 @@ R3
500500 R4
501501 R5
502502 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
505505 l0
506506 L25
507507 Vz1XPZlOlmVbNZb5V@JZg`3
@@ -511,8 +511,8 @@ R8
511511 R9
512512 !i10b 1
513513 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|
516516 !i113 1
517517 R13
518518 R14
@@ -522,7 +522,7 @@ R2
522522 R3
523523 R4
524524 R5
525-R40
525+R42
526526 l45
527527 L28
528528 Vg9geaHiXHiiCLGQFzNVNe1
@@ -532,8 +532,8 @@ R8
532532 R9
533533 !i10b 1
534534 R10
535-R69
536-R70
535+R71
536+R72
537537 !i113 1
538538 R13
539539 R14
Binary files a/vhdl_my_lib/cordic_sincos/work/_lib.qdb and b/vhdl_my_lib/cordic_sincos/work/_lib.qdb differ
Binary files a/vhdl_my_lib/cordic_sincos/work/_lib1_0.qpg and b/vhdl_my_lib/cordic_sincos/work/_lib1_0.qpg differ
Binary files a/vhdl_my_lib/cordic_sincos/work/_lib1_0.qtl and b/vhdl_my_lib/cordic_sincos/work/_lib1_0.qtl differ
Binary files a/vhdl_my_lib/cordic_sincos_testgen/Debug/cordic_sincos_testgen and b/vhdl_my_lib/cordic_sincos_testgen/Debug/cordic_sincos_testgen differ
--- a/vhdl_my_lib/cordic_sincos_testgen/main.cpp
+++ b/vhdl_my_lib/cordic_sincos_testgen/main.cpp
@@ -67,13 +67,13 @@ int main() {
6767 // positive x, async reset test
6868 test_5( filename_vector_5, filename_reference_5);
6969
70-gen_table( filename_angle_delta, filename_scaling_factor);
70+ gen_table( filename_angle_delta, filename_scaling_factor);
7171
7272
73- test_100( filename_vector_100, filename_reference_100, 20 );
73+ test_100( filename_vector_100, filename_reference_100 );
7474
7575 // 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 );
7777
7878
7979 }
@@ -224,15 +224,46 @@ void test_5( char *vec_name, char * ref_name) // test of completely same timing
224224 test_async_13bit(vec, ref, 23, 0, 16, 64, 1, 0 ); // x, angle, p, q, reset, clk
225225
226226 // 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
228228 test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk
229229 test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk
230230 test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 0 ); // x, angle, p, q, reset, clk
231231
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
233258 test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk
234259 test_async_13bit(vec, ref, 23, 0, 255, 127, 0, 1 ); // x, angle, p, q, reset, clk
235260 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+
236267 }
237268
238269
@@ -244,11 +275,13 @@ void test_5( char *vec_name, char * ref_name) // test of completely same timing
244275 *****************************************************************/
245276
246277
247-void test_100( char *vec_name, char * ref_name, int num_stages)
278+void test_100( char *vec_name, char * ref_name )
248279 {
249280 std::ofstream vec; vec.open(vec_name);
250281 std::ofstream ref; ref.open(ref_name);
251282
283+
284+ const int num_stages = 20;
252285 int x = 0;
253286
254287 // reset
@@ -276,32 +309,32 @@ void test_100( char *vec_name, char * ref_name, int num_stages)
276309 }
277310 }
278311
279-void test_101( char *vec_name, char * ref_name, int num_stages)
312+void test_101( char *vec_name, char * ref_name)
280313 {
281314 std::ofstream vec; vec.open(vec_name);
282315 std::ofstream ref; ref.open(ref_name);
283316
317+ const int num_stages = 3;
284318 int x = 0;
285319
286320 // reset
287321 cordic_sincos_bw32( vec, ref, num_stages, x, 1, 0 );
288322
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++ )
292325 {
293326 cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 );
294- x = i << 23;
327+ x = i << 28;
295328 cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 );
296329 cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 );
297330 cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 );
298331 }
299332
300333 // flush pipeline
301- for ( int i = 0; i < num_stages; i++ )
334+ for ( int i = 0; i < num_stages+2; i++ )
302335 {
303336 cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 );
304- x = i << 16;
337+ x = 0;
305338 cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 );
306339 cordic_sincos_bw32( vec, ref, num_stages, x, 0, 1 );
307340 cordic_sincos_bw32( vec, ref, num_stages, x, 0, 0 );
@@ -440,10 +473,13 @@ vec
440473 << std::bitset<1>( clk ) << " " // clock
441474 << std::bitset<BITWIDTH>( x ) << std::endl;
442475
443-cordic.run( 20, clk, reset, x, out_p, out_q );
476+cordic.run( num_stages, clk, reset, x, out_p, out_q );
444477
445478 ref
446479 << std::bitset<BITWIDTH>( out_p ) << " "
447480 << std::bitset<BITWIDTH>( out_q ) << std::endl;
448481
449482 }
483+
484+
485+
--- a/vhdl_my_lib/cordic_sincos_testgen/main.h
+++ b/vhdl_my_lib/cordic_sincos_testgen/main.h
@@ -141,8 +141,8 @@ void test_5( char *vec_name, char * ref_name);
141141
142142
143143
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 );
146146 void cordic_sincos_bw32( std::ostream &vec, std::ostream &ref, int num_stages, int x, int reset, int clk );
147147
148148