Jump to content
Sign in to follow this  
carter

how can i use sensitivity?

Recommended Posts

Hi.

i made simple inverter by clock.

I trying to trace "popo_in", "popo_out".  popo_in have normally transition and i checked from vcd.

But popo_out is not work(it's not having transition). what is wrong ?

 

Here's problems.

 

#include <systemc.h>
 
class popo_clk_gen : public sc_module
{
public:
sc_out<bool> popo_out;
sc_in<bool> popo_in;
SC_HAS_PROCESS(popo_clk_gen);
void test()
            {
            int i=0;
            {
            popo_out = ~popo_in;
            }
            }
 
 
 
popo_clk_gen(sc_module_name name) : sc_module(name)
{
SC_METHOD(test);
sensitive(popo_out);
}
 
 
 
 
 
 
 
};
 
int sc_main (int, char *[]) {
sc_signal<bool> popo_out;
sc_signal<bool> popo_in;
 
sc_clock clk1("clk1",10,SC_NS);
popo_clk_gen pcg("pcg");
pcg.popo_out(popo_out);
pcg.popo_in(clk1);
 
sc_trace_file *tf = sc_create_vcd_trace_file("wave");
sc_trace(tf,clk1, "clock");
sc_trace(tf,pcg.popo_in, "in_clk");
sc_trace(tf,pcg.popo_out, "out_clk");
sc_start(50,SC_NS);
sc_close_vcd_trace_file(tf);
return 0;
    }
 

Share this post


Link to post
Share on other sites

 

Hi.

i made simple inverter by clock.

I trying to trace "popo_in", "popo_out".  popo_in have normally transition and i checked from vcd.

But popo_out is not work(it's not having transition). what is wrong ?

 

Here's problems.

 

#include <systemc.h>
 
class popo_clk_gen : public sc_module
{
public:
sc_out<bool> popo_out;
sc_in<bool> popo_in;
SC_HAS_PROCESS(popo_clk_gen);
void test()
            {
            int i=0;
            {
            popo_out = ~popo_in;
            }
            }
 
 
 
popo_clk_gen(sc_module_name name) : sc_module(name)
{
SC_METHOD(test);
sensitive(popo_out);
}
 
 
 
 
 
 
 
};
 
int sc_main (int, char *[]) {
sc_signal<bool> popo_out;
sc_signal<bool> popo_in;
 
sc_clock clk1("clk1",10,SC_NS);
popo_clk_gen pcg("pcg");
pcg.popo_out(popo_out);
pcg.popo_in(clk1);
 
sc_trace_file *tf = sc_create_vcd_trace_file("wave");
sc_trace(tf,clk1, "clock");
sc_trace(tf,pcg.popo_in, "in_clk");
sc_trace(tf,pcg.popo_out, "out_clk");
sc_start(50,SC_NS);
sc_close_vcd_trace_file(tf);
return 0;
    }
 

 

Hello Sir,

It is highly recommended that you read up good references

on C++ and SystemC. To sensitize a thread to a clock use:

SC_CTHREAD(<thread_name>);

sensitive << clk.pos(); /* sensitive to positive clock edge */

OR

sensitive << clk.neg(); /* sensitive to negative clock edge */

 

To make a thread sensitive to ANY changes in a signal, use

SC_THREAD(<thread_name>);

sensitive << sig; /* Thread responds to ANY changes in sig */

 

Once again, read up the background material.

Share this post


Link to post
Share on other sites

Hello Sir,

It is highly recommended that you read up good references

on C++ and SystemC. To sensitize a thread to a clock use:

SC_CTHREAD(<thread_name>);

sensitive << clk.pos(); /* sensitive to positive clock edge */

OR

sensitive << clk.neg(); /* sensitive to negative clock edge */

 

To make a thread sensitive to ANY changes in a signal, use

SC_THREAD(<thread_name>);

sensitive << sig; /* Thread responds to ANY changes in sig */

 

Once again, read up the background material.

Thanks your advice.

I recently modified code like following

 

 

#include <systemc.h>
 
class popo_clk_gen : public sc_module
{
public:
sc_out<bool> popo_out;
sc_in<bool> popo_in;
 
void test()                          
               {
    while(1) {
                int i=0;
                {
                //popo_out = ~popo_in;
    wait();
                popo_out =  ~popo_in;
    //wait();
                }
    }
               }
 
SC_HAS_PROCESS(popo_clk_gen);
 
popo_clk_gen(sc_module_name name) : sc_module(name)
{
//SC_METHOD(test);
SC_THREAD(test);
//sensitive( popo_in);
//sensitive( popo_out);
sensitive << popo_in;
sensitive << popo_out;
}
 
 
 
 
 
 
 
 
 
 
 
 
 
};
 
int sc_main (int argc, char **argv)
{
sc_signal<bool> popo_out;
sc_signal<bool> popo_in;
 
sc_clock clk1("clk1",10,SC_NS);
popo_clk_gen pcg("pcg");
pcg.popo_out(popo_out);
pcg.popo_in(clk1);
 
sc_trace_file *tf = sc_create_vcd_trace_file("wave");
sc_trace(tf,clk1, "clock");
sc_trace(tf,pcg.popo_in, "in_clk");
sc_trace(tf,pcg.popo_out, "out_clk");
sc_start(500,SC_NS);
sc_close_vcd_trace_file(tf);
return 0;
    }
 

 

i solved it. thanks.

Share this post


Link to post
Share on other sites

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.

Sign in to follow this  

×
×
  • Create New...