ruwan2 Posted July 2, 2014 Report Share Posted July 2, 2014 Hi, I want to simulate a FIR filter, which reads a text file content as input data. I have tried with open a text file and call a function (entry) as a parameter, but it fails compilation. Because I cannot paste the code on this window, I attach the text .h file in the attachment. Please tell me how to access a text file in a method. Or you can tell me what is the best way to read text data file into the SystemC simulator. Thanks, stimulus.zip Quote Link to comment Share on other sites More sharing options...
ruwan2 Posted July 3, 2014 Author Report Share Posted July 3, 2014 Hi, I get a little progress. Before the read function, I want to implement a write text file (a log file) first. I want to close the file when a counter reaches the maximum number in module A. When the counter reaches the maximum number, it issues an sc_evnt. This sc_event will notify a method B. Is it possible first? Now, I do not know how to trigger the method B. I only have an example of the clock.pos() as event: SC_METHOD(exitfile); sensitive << clk. pos(); But, "sensitive << fileclose.pos();" does not work to substitute the second line. I have check the manual without finding how to notify a method example. Thanks, Quote Link to comment Share on other sites More sharing options...
dakupoto Posted July 3, 2014 Report Share Posted July 3, 2014 Hi, I want to simulate a FIR filter, which reads a text file content as input data. I have tried with open a text file and call a function (entry) as a parameter, but it fails compilation. Because I cannot paste the code on this window, I attach the text .h file in the attachment. Please tell me how to access a text file in a method. Or you can tell me what is the best way to read text data file into the SystemC simulator. Thanks, Hello, Have you considered the option of piped reads and writes, from stdin, stdout ? This works, and is very convenient for quick, easy testing. Quote Link to comment Share on other sites More sharing options...
apfitch Posted July 3, 2014 Report Share Posted July 3, 2014 If you notify an event called e, then just use sensitive << e; to trigger when the event is notified. regards Alan Quote Link to comment Share on other sites More sharing options...
David Black Posted July 5, 2014 Report Share Posted July 5, 2014 There are several things wrong with the code you provided and perhaps indicate a serious lack of appropriate C++ background: #include <iostream> #include <fstream> using namespace std; SC_MODULE(stimulus) { sc_out<bool> reset; sc_out<bool> input_valid; sc_out<int> sample; sc_in<bool> CLK; sc_int<8> send_value1; unsigned cycle; ofstream myfile; SC_CTOR(stimulus) { myfile.open ("example.txt"); myfile << "Writing this to a file.\n"; SC_METHOD(entry(ofstream)); dont_initialize(); sensitive << CLK.pos(); send_value1 = 0; cycle = 0; myfile.close(); } void entry(ofstream); }; You should check for success after opening a file If your process method requires an argument, you cannot use SC_METHOD to register it. It is unclear why you need ofstream as an argument to the entry() method. It is unclear what you are using the file for, and why you would write it inside the constructor. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.