Jump to content

Aaron Yang

  • Content Count

  • Joined

  • Last visited

Everything posted by Aaron Yang

  1. Hey Guys, I am kinda new to this language so bear with me if question sounds naive. I am building cycle accurate system C model. When I run performance profiler, some process triggered by clk consume a lot resources(clk is always running). So I am looking for tricks to improve the performance: Original code: SC_METHOD(process_output); sensitive << reset; sensitive << clk.pos(); ... void fir::process_output() { if (reset.read() == 0) { //reset sequence } else { if(enable.read()) { //normal operation } } } One way to avoid triggered the process every time clk toggles is that create a event: void fir::enable_event() { if (enable.read()) { enable_rise.notify(); } } ... void fir::process_output() { if (reset.read() == 0) { //reset seq } else { if (enable.read() == 0) { next_trigger(enable_rise);//Correct me if I am wrong, based on my understanding, next_trigger() overrides the static sensitivity list. } else { next_trigger(); //normal op } } } The other way is to use .suspend() and .resume(); SC_THREAD(monitor_trig_event); sensitive << reset << enable; ... void fir::monitor_trig_event() { sc_spawn_options opt; opt.set_sensitivity(&clk.pos()); sc_process_handle handle = sc_spawn(sc_bind(&fir::process_output, this), "run_fir", &opt); handle.suspend(); while (1) { wait(); if (!reset) reset(); else { if (enable.read()) { handle.resume(); break; } else if (enable.read() == 0) { handle.suspend(); } } } In this case, process output won't have next_trigger() statement anymore. For those two methods above, which one is more recommended? Or is there any clean and straightforward way to implement the improvement? Thank you all in advance.
  2. Hey guys, Need help about this: Exception thrown at 0x00007FFC1FCE1CAF (ntdll.dll) in mytest.exe: 0xC0000005: Access violation reading location 0x0000000000000000. I traced the call stack to where it stopped in my code, found it's this line in header file: sc_vector<sc_signal<float>> output_connect_wire{"output_connect_wire",1}; It's been used like this in cpp file, not sure if it's relevant though: .... submodule->O_data(output_connect_wire); .... if(...){...} else { data_out.write(output_conncet_wire[0].read()); } .... where the submodule output declared as sc_vector<sc_out<float>> O_data{"O_data",1}; Thank you in advance and tell me if you need any more info to identify the issue.
  3. Aaron Yang

    Sensitive List

    Hey, question about the sensitive list, I got this error: fir.h:79:23: error: no match for 'operator<<' (operand types are 'sc_core::sc_sensitive' and 'sc_core::sc_vector<sc_dt::sc_fixed<16, 2> >::element_type {aka sc_dt::sc_fixed<16, 2>}') sensitive << in_val; Here is the fir.h sc_vector<sc_fixed<din_size, din_int>> in_val{"in_val", din_num_samples}; void fir_comb(); SC_HAS_PROCESS(fir); // The combination of SC_HAS_PROCESS and a normal constructor replaces the use of SC_CTOR fir(sc_module_name name_, bool debug_ = false): sc_module(name_), debug(debug_) { SC_THREAD(fir_comb); for( unsigned i= 0; i<in_val.size(); ++i ) sensitive << in_val[i]; Anything wrong with it? Thank you in advance.
  4. Aaron Yang

    Sensitive List

    Thank you for the explanation, where should I put this overload? In the systemc.h?
  5. Aaron Yang

    Sensitive List

    To be more concrete, I have another thread called fir_main and in_val = din.read(); In this example, I want to trigger fir_comb by adding the in_val(updated in the fir_main) to its sensitive list.
  6. Aaron Yang

    How to connect array of ports?

    Thanks Roman, that works!
  7. Hey I am kinda new to system C, I met this error when connecting ports declared as array: sc_main.cpp: In function 'int sc_main(int, char**)': sc_main.cpp:16:21: error: expression cannot be used as a function tb0.in(sample_in); This is sc_main.cpp #include <systemc.h> #include "fir.h" #include "tb.h" int sc_main (int, char *[]){ sc_clock clock("clock", 10, SC_NS); sc_signal<bool> reset; sc_signal<sc_fixed<16,2>> sample_in[2]; sc_signal<sc_fixed<16,2>> sample_out[4]; tb tb0("tb0_name"); tb0.rstn(reset); tb0.clk(clock); tb0.in(sample_in); tb0.out(sample_out); fir1("fir1_name", true); fir1.din(sample_in); fir1.dout(sample_out); This is the tb.h file #include <systemc.h> SC_MODULE(tb) { sc_in<bool> clk; sc_out<bool> rstn; sc_out<sc_fixed<16,2>> in[2]; sc_in<sc_fixed<16,2>> out[4]; This is the fir.h #include <systemc.h> SC_MODULE(fir) { sc_in<bool> rst_n; sc_in<bool> clk; sc_in<sc_fixed<16,2>> din[2]; sc_out<sc_fixed<16,2>> dout[4]; What should I do in this case?