Re: What difference of file write operation between MSVC and MINGW421?
On 7/3/2014 2:18 PM, fl wrote:
I am new to the difference between Microsoft and gcc. I think mingw4.2.1 is
from Linux world.
I have a code run SystemC, which a C++ library support Windows and Linxu, 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. I have check the SystemC
documentation without finding any clue. I guess this basic file operation is
different for the two compiler.
What requirement for SystemC 2.3.1 work with Modelsim?
How the hell should *we* know? This is not a SystemC newsgroup or a
Modelsim newsgroup. This is a C++ newsgroup. Do you have a C++
question? Then ask it. If you have difficulty with understanding what
comp.lang.c++ is about, try the FAQ: http://www.parashift.com/c++-faq/
and see section 5.
Could you help me on two compilers? Thanks,
Yes. But your code has no "file write operation." The only "write"
occurrences below are calls to member functions of 'sc_out' template
instantiations, one with bool the other with int.
You didn't supply the definition of that template. How do you propose
we should answer your question? Guess?
The code is attached below.
This code is incomplete. Refer to FAQ 5.8.
Thanks,
.h file:
#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:
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();
};
}
--
I do not respond to top-posted replies, please don't ask