Jump to content

Recommended Posts

Posted

Hi,

I have came back to system c after 6 months, again.

I was trying to solve different basic examples of system c.

The code is getting compiled,but i am not able to view the desired output.

My output is not at all changing,i am not sure whether my function is getting hit or not.

Please have a look at the code below and any help would b appreciated.

 

In code,i have added stimulus first and then  monitor to check wheteher my function was getting invoked.Again ,in main file also i passed the input.

But from ,nowhere i am getting the output. Please help! 

https://www.edaplayground.com/x/5qEA

 

Ps:Not only this example,the other examples such as combinational circuits,encoders,decoders.

I am facing the same issue with respect to all of them.There must be a common mistake which i am repeating.

 

Thanks & regards,

shubham_v

Posted

You have registered d_operation() as a thread. Ideally a thread should have an infinite loop and a wait(). Adding that, you can see changes to your d_out.

Also, how about having another thread that does the reset job?

 

Posted (edited)

 

Hi deepti,

Thanks for your reply.

I have tried the other examples also,but tats the commmon issue iam facing of not getting output.

By infinite loop, you mean to say i need to put sc_start(-1) which in turn makes my thread to run forever.

As far as my problem is concerned,even for combinational circuits if iam using sc_method ,i am not getting the desired output.

 

Update:-Started writing the fresh code and  i am getting some ouput now.Some issues are there with respect to timing,but i think it can be resolved. 

 

 

Regards,

Shubham

Edited by shubham_v
Got the output
Posted

No, you need to have loop with the function registered as SC_THREAD. For your code, it will be:

  

  void d_operation()
    { while(1){
      
        if (reset.read()==1)
        {
        
        d_out = 0;
    //    std::cout << "reset= " << reset << "...din=  " << d_in << ".....d_out" << d_out << std::endl;
           }
        else
        {
            //d_out.write(d_in.read());
          d_out=d_in;
        //    wait(1, SC_NS);
        //    std::cout << "reset= " << reset << "...din=  " << d_in << ".....d_out" << d_out << std::endl;
            }
      wait();
    }
    }

 

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...