Why this initialization generates exception warning?

F

fl

Hi,
The following code is from an example of SystemC, a C++ library for
simulation.
There is no isq constructor. The original author made a memory 'new'
call, then used the initilization by:

(*isqp)(reset, clk,
in_rdy, in_vld, it,
out_rdy, out_vld, is);

My question here is:
1. Why there is warning from the above code?
2. What are the better practice in this segment? One should write the
constructor explicitely? What detail should the constructor be for
connecting reset, clk, in_rdy etc. in this example?


Thanks.



.................
int
sc_main(int argc, char *argv[])
{
sc_clock clk;
sc_signal<bool> reset;
sc_signal<bool> in_rdy;
sc_signal<bool> in_vld;
sc_signal<bool> out_vld;
sc_signal<bool> out_rdy;
sc_signal<sc_uint<18> > it;
sc_signal<sc_uint<10> > is;
int errors;
isq *isqp;

isqp = new isq("isq0");
(*isqp)(reset, clk,
in_rdy, in_vld, it,
out_rdy, out_vld, is);

...............
SC_MODULE(isq)
{
sc_in<bool> RSTN;
sc_in_clk CLK;

sc_out<bool> DIN_rdy;
sc_in<bool> DIN_vld;
sc_in<sc_uint<18> > DIN_value;
sc_in<bool> DOUT_rdy;
sc_out<bool> DOUT_vld;
sc_out<sc_uint<10> > DOUT_value;

void thread();
sc_uint<10> isqrt5(sc_uint<18>);

SC_CTOR(isq){
SC_CTHREAD(thread, CLK.pos());
reset_signal_is(RSTN,false);
}
};

void
isq::thread()
{
if( !RSTN){
DIN_rdy = 1;
DOUT_vld = 0;
wait(1);
}

for(;;){
sc_uint<18> in_value;
sc_uint<10> out_value;

in_value = DIN_value.read();
while( !DIN_vld.read()){
wait(1);
in_value = DIN_value.read();
}
DIN_rdy = 0;
wait(1);

out_value = isqrt5(in_value);

while( !DOUT_rdy.read()){
wait(1);
}
DOUT_vld = 1;
DOUT_value.write(out_value);
DIN_rdy = 1;
wait(1);
DOUT_vld = 0;
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top