Jump to content
Sign in to follow this  
carter

how can i bound port?

Recommended Posts

Deal all,

 

i just make systemc modeling. i just want to make module what have just sc_in, sc_out.

So when i trying to connect to sc_in by sc_clock's clock and i just want to see that reversed output.

 

this is code.

 #include <systemc.h>

int i=0;
 
int sc_main (int, char *[]) {
sc_signal<bool> popo_out;
pcg(popo_out);
sc_clock clk1("clock1",10,0.5,5,true);
pcg(popo_in); //??????????i'm not sure this line..
return 0;
    }
 
 
So What am i do to correct above code?

Share this post


Link to post
Share on other sites

I'm not sure exactly what you want to do - but I assume you want to connect the clock clk1 to the port popo_in.

 

So in sc_main you need

int sc_main (int argc, char *[] argv) {

   sc_signal<bool> popo_out;
   sc_clock clk1("clock1",10,0.5,5,true);

   popo_clk_gen pcg("pcg");
   pcg.popo_out(popo_out);
   pcg.popo_in(clk1);
   
   sc_start(50,SC_NS);
   return 0;
}

You also need to trigger your SC_METHOD by making it sensitive to the port popo_in,

 

For ease of understanding, I would rename the module "popo_clk_gen" to "popo_inverter" since it's just an inverter.

 

regards

Alan

Share this post


Link to post
Share on other sites

I've just realised your clock declaration looks wrong. It should be (I think)

sc_clock clk1("clk1", 10, SC_NS);

regards

Alan

 

P.S. I highly recommend that the label should be identical to the instance name, it makes debugging easier.

Share this post


Link to post
Share on other sites

I've just realised your clock declaration looks wrong. It should be (I think)

sc_clock clk1("clk1", 10, SC_NS);

regards

Alan

 

P.S. I highly recommend that the label should be identical to the instance name, it makes debugging easier.

Hello Sir,

The sc_core::sc_clock class has a set of constructors.

For example, the following compiles and runs fine :

 

sc_core::sc_clock clk_jk("clk_jk", 20.0, sc_core::SC_NS, 0.5);

 

There are some other options.

Share this post


Link to post
Share on other sites

I'm not sure exactly what you want to do - but I assume you want to connect the clock clk1 to the port popo_in.

 

So in sc_main you need

int sc_main (int argc, char *[] argv) {

   sc_signal<bool> popo_out;
   sc_clock clk1("clock1",10,0.5,5,true);

   popo_clk_gen pcg("pcg");
   pcg.popo_out(popo_out);
   pcg.popo_in(clk1);
   
   sc_start(50,SC_NS);
   return 0;
}

You also need to trigger your SC_METHOD by making it sensitive to the port popo_in,

 

For ease of understanding, I would rename the module "popo_clk_gen" to "popo_inverter" since it's just an inverter.

 

regards

Alan

Yes, you are right.

Actually i want make "invert block" like following figure.

 

 

so i think that i make input port but i'm not sure output.

so i need your advice.

 

i'm really thank you

Share this post


Link to post
Share on other sites

I'm not sure exactly what you want to do - but I assume you want to connect the clock clk1 to the port popo_in.

 

So in sc_main you need

int sc_main (int argc, char *[] argv) {

   sc_signal<bool> popo_out;
   sc_clock clk1("clock1",10,0.5,5,true);

   popo_clk_gen pcg("pcg");
   pcg.popo_out(popo_out);
   pcg.popo_in(clk1);
   
   sc_start(50,SC_NS);
   return 0;
}

You also need to trigger your SC_METHOD by making it sensitive to the port popo_in,

 

For ease of understanding, I would rename the module "popo_clk_gen" to "popo_inverter" since it's just an inverter.

 

regards

Alan

Dear Alan,

 

When i have modified code as your advice, it's seem passed. thank you.

 

 

 

here's modified code.

#include <systemc.h>
 
 
 
public:
sc_out<bool> popo_out;
 
}
void test()
{
int i=0;
{
popo_out = ~popo_in;
}
}
};
 
int sc_main (int, char *[]) {
 
sc_start(50,SC_NS);
return 0;
    }
Edited by carter

Share this post


Link to post
Share on other sites

I'm not sure exactly what you want to do - but I assume you want to connect the clock clk1 to the port popo_in.

 

So in sc_main you need

int sc_main (int argc, char *[] argv) {

   sc_signal<bool> popo_out;
   sc_clock clk1("clock1",10,0.5,5,true);

   popo_clk_gen pcg("pcg");
   pcg.popo_out(popo_out);
   pcg.popo_in(clk1);
   
   sc_start(50,SC_NS);
   return 0;
}

You also need to trigger your SC_METHOD by making it sensitive to the port popo_in,

 

For ease of understanding, I would rename the module "popo_clk_gen" to "popo_inverter" since it's just an inverter.

 

regards

Alan

 

 

Dear Alan,

If you can would you please let me know example about as your advice "You also need to trigger your SC_METHOD by making it sensitive to the port popo_in,"?

Actually, i don't know exactly how can i make trigger for sensitive.

 

One more thing,

 

When i captured VCD trace, popo_out, but i failed.

I used tarce like this.

 

 

 

I can trace  "clk1" and "popo_in"  But pcg.popo_out is not have transition.

Why pcg.popo_out has not transition in wave?

Share this post


Link to post
Share on other sites

Hi Carter,

   your two problems are connected - when you declare an SC_METHOD you need something to trigger it otherwise it will only run once at time zero. That's what I meant by "you need to make your SC_METHOD sensitive to popo_in". If you do that, when it runs it will then assign a new value to popo_out, and you will see the change on the waveforms.

 

There are examples of sensitivity here:

 

www.doulos.com/knowhow/systemc/tutorial

 

Look at the section "Modules and Processes".

 

Also I recommend you read section 5.2.9 of the IEEE 1666-2011 standard, which you can download free via the accellera website,

 

regards

Alan

Share this post


Link to post
Share on other sites

Hi Carter,

   your two problems are connected - when you declare an SC_METHOD you need something to trigger it otherwise it will only run once at time zero. That's what I meant by "you need to make your SC_METHOD sensitive to popo_in". If you do that, when it runs it will then assign a new value to popo_out, and you will see the change on the waveforms.

 

There are examples of sensitivity here:

 

www.doulos.com/knowhow/systemc/tutorial

 

Look at the section "Modules and Processes".

 

Also I recommend you read section 5.2.9 of the IEEE 1666-2011 standard, which you can download free via the accellera website,

 

regards

Alan

Share this post


Link to post
Share on other sites

Dear Alan,

i have modified

public:

sc_out<bool> popo_out;

(popo_clk_gen);

popo_clk_gen(sc_module_name name) : sc_module(name)

{

SC_METHOD(test);

sensitive(popo_in);

}

};

int (int, char *[]) {

sc_clock ("clk1",10,SC_NS);

return 0;

}

[/font][/color]

Share this post


Link to post
Share on other sites

All I meant was to change your sc_method to

SC_METHOD(test);
sensitive << popo_in;

That makes it run every time popo_In changes.

 

If you want to use an SC_THREAD, you'd need

SC_THREAD(test);
sensitive << popo_in;

void test ()
   while (1) {
       wait();
       popo_out = ~popo_in;
   }
}

regards

Alan

Share this post


Link to post
Share on other sites

It looks OK to me, perhaps someone else can see what's wrong?

Alan

It looks OK to me, perhaps someone else can see what's wrong?

Alan

Dear Alan,

Sir, Would you have checked

I will make inverter example.

But you can find popo_out is always high not transition.

Would you Please check?

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  

×