Hi,
I have a code run well with Microsoft Visio Studio Express 10.0, but I would like to run with Modelsim which has MINGW4.2.1. I find that the file write operation fails. If I comment out the file operation part, it works.
What requirement for SystemC 2.3.1 work with Modelsim?
BTW, how to know the SytemsC library version in Modelsim? I can see that when run MSVC, Windows, but no such info in mingw4.2.1 under Modelsim.
The code is attached below.
Thanks a lot,
.h file:
Code C++ - [expand ] 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#define FILE_WRITE 1
/*
#undef FILE_WRITE
*/
struct fir: sc_module{
sc_in< bool > reset;
sc_in< bool > input_valid;
sc_in< int > sample;
sc_out< bool > output_data_ready;
sc_out< int > result;
sc_in_clk CLK;
int index;
#ifdef FILE_WRITE
FILE * fp_real; // ofstream myfile;
#endif
sc_int< 9 > coefs[ 16 ] ;
SC_CTOR( fir)
{
SC_CTHREAD( entry, CLK.pos ( ) ) ;
reset_signal_is( reset,true ) ;
#include "fir_const.h"
}
void entry( ) ;
#ifdef FILE_WRITE
~fir( )
{
fclose ( fp_real ) ;
}
#endif
} ;
.c file:
Code C++ - [expand ] 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
void fir:: entry ( ) {
sc_int< 8 > sample_tmp;
sc_int< 17 > pro;
sc_int< 19 > acc;
sc_int< 8 > shift[ 16 ] ;
sc_uint< 16 > val; //variable to hold data
int tmp_out;
// reset watching
/* this would be an unrolled loop */
#ifdef FILE_WRITE
fp_real = fopen ( "out_example.txt" ,"w" ) ;
#endif
for ( int i= 0 ; i<= 15 ; i++ )
shift[ i] = 0 ;
result.write ( 0 ) ;
output_data_ready.write ( false ) ;
wait( ) ;
// main functionality
index= 0 ;
while ( 1 ) {
output_data_ready.write ( false ) ;
do
{
wait( ) ;
} while ( ! ( input_valid == true ) ) ;
sample_tmp = sample.read ( ) ;
acc = sample_tmp* coefs[ 0 ] ;
for ( int i= 14 ; i>= 0 ; i-- ) {
/* this would be an unrolled loop */
pro = shift[ i] * coefs[ i+ 1 ] ;
acc + = pro;
} ;
for ( int i= 14 ; i>= 0 ; i-- ) {
/* this would be an unrolled loop */
shift[ i+ 1 ] = shift[ i] ;
} ;
shift[ 0 ] = sample_tmp;
// write output values
result.write ( ( int ) acc) ;
output_data_ready.write ( true ) ; /*
myfile << "shift[xxxxxx]";
myfile << "index=" << index << endl;
cout << "index=" << index << endl;*/
#ifdef FILE_WRITE
// fprintf(fp_real,"%d \n", tmp_out);
#endif
index++ ;
wait( ) ;
} ;
}
Last edited by a moderator: Jul 4, 2014