Jump to content
Sign in to follow this  
chatbq

Error: (E519) wait() is only allowed in SC_THREADs and SC_CTHREADs

Recommended Posts

Hi everyone,

I have a runtime error when trying to simulate a sc_module

An example of my code architecture is presented hereunder, do you see any problem?

Here is my error:

Error: (E519) wait() is only allowed in SC_THREADs and SC_CTHREADs:
        in SC_METHODs use next_trigger() instead
In file: ../../../src/sysc/kernel/sc_wait.cpp:94

pe.h

#include "systemc.h"

template<typename IN_T, typename OUT_T>
SC_MODULE (pe) {
    sc_in<bool> clk;
    sc_in<bool> rst;
    sc_fifo_in<IN_T> Input;
    sc_fifo_out<OUT_T> Output;

    void pe_proc();

    SC_HAS_PROCESS(pe);
    pe(sc_module_name name_, int p_time_) :
            sc_module(name_), p_time(p_time_) {
        SC_CTHREAD(pe_proc, clk.pos());
        reset_signal_is(rst, true);
    }
private:
    int p_time;
};


template<typename IN_T, typename OUT_T>
void pe<IN_T, OUT_T>::pe_proc(void) {

    IN_T in_val;
    OUT_T out_val;
    // Reset code
    // Reset internal variables
    in_val = 0;
    out_val = 0;
    // Reset outputs
    wait();

    while (true) {
        // Read inputs
        in_val = Input.read();
        // Algorithm code
        for (int i = 0; i < p_time; i++) {
            wait();
        }
        // write outputs
        out_val = (OUT_T) in_val;
        Output.write(out_val);
    }

}

 

Share this post


Link to post
Share on other sites

Hello @chatbq,

There is not enough context, probably the exception is being thrown from another module.

Overall the code seems fine.

You can try and see from where the exception is being thrown from the debugger.

Regards,

Ameya Vikram Singh

Share this post


Link to post
Share on other sites

Hi @AmeyaVS

I have solved this problem. This runtime error shows up when I try to trace out the wave of sc_fifo.

Use the built-in trace() method of sc_fifo instate of sc_trace() solving this problem.
 

#include "system.h"

SYSTEM *top = NULL;

int sc_main (int argc, char* argv[])
{
    top = new SYSTEM("top");
    sc_trace_file *tr= sc_create_vcd_trace_file("pe");
    sc_trace(tr,top->clk_sig,"clock");
    top->Input.trace(tr);
    top->Output.trace(tr);
    sc_trace(tr,top->rst_sig,"rst");

    sc_core::sc_report_handler::set_actions( "/IEEE_Std_1666/deprecated",
                                               sc_core::SC_DO_NOTHING );
    sc_start();
    sc_close_vcd_trace_file(tr);
    return 0;
}

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×